wmtt = null;
var openadvert = true;
var activeTabName = null;
var activeTabNameInitialized = false;
document.onmousemove = update;
function update(e) {
    if (document.body == null) return;
    x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
    y = (document.all) ? window.event.y + document.body.scrollTop : e.pageY;
    if (wmtt != null) {
        wmtt.style.left = (x + 20) + "px";
        wmtt.style.top = (y + 10) + "px";
    }

}

function show(id) {
    wmtt = document.getElementById(id);
    wmtt.style.display = "block";
    //wmtt.className = "showME";
}
function hideId(id) {
    wmtt = document.getElementById(id);
    wmtt.style.display = "none";
    //wmtt.className = "showME";
}

function hide() {
    wmtt.style.display = "none";
    //wmtt.className="dontshowME"
}

function showWaitingPopup() {
    //window.alert("showWaitingPopup");
    window.open('warning.htm', 'tesco', 'width=400,height=400,scrollbars=0, status=0');
    //event.cancelBubble = true;  
    return false;
}
function showPrintResults() {
    /*@cc_on
    @if (@_jscript_version <= 5.6)
    window.open('Print-Results.aspx', 'tesco', 'width=750,height=600,scrollbars=1, status=0');
    @else @*/
  window.open('Print-Results.aspx','tesco','width=1030,height=600,scrollbars=1, status=0');
/*@end
    @*/

    //event.cancelBubble = true;  
    return false;
}

function showSpecialOffer() {
    //600 x 600
    window.open('SpecialOffer.aspx', 'thebikeinsurer', 'width=795,height=900,scrollbars=1, status=0, linkbar=0, menubar=0');
    return false;
}

function printResultsClicked() {
    var isN = document.getElementById(document.isNotifiedId);
    if (isN) {
        if (isN.value == "1") {
            showPrintResults();
        } else {
            showWaitingPopup();
        }
    }
    return false;
}
function PDFClicked() {
    var isN = document.getElementById(document.isNotifiedId);
    if (isN) {
        if (isN.value == "0") {
            showWaitingPopup();
            return false;
        }
    }
}
function emailClicked() {
    var isN = document.getElementById(document.isNotifiedId);
    if (isN) {
        if (isN.value == "0") {
            showWaitingPopup();
            return false;
        }
    }
}

function specialOfferClicked() {
    var isN = document.getElementById(document.isNotifiedId);
    if (isN) {
        if (isN.value == "1") {
            showSpecialOffer();
        } else {
            showWaitingPopup();
        }
    }
    return false;
}

function dirtyKitchen(isNotifiedId, print, email, pdf, so) {
    document.isNotifiedId = isNotifiedId;
    var p = document.getElementById(print);
    if (p != null) {
        p.onclick = printResultsClicked;
    }
    var e = document.getElementById(email);
    if (e != null) {
        e.onclick = emailClicked;
    }
    var Pa = document.getElementById(pdf);
    if (Pa != null) {
        Pa.onclick = PDFClicked;
    }
    var s = document.getElementById(so);
    if (s != null) {
        s.onclick = specialOfferClicked;
    }
}

function openPopUpAdvert() {
    if (openadvert == true) {
        openadvert = false;
        popupunder = window.open('Advert/Motorbike-Marketplace.aspx', 'Advert', 'width=1024,height=1000,scrollbars=1, status=0');
        popupunder.blur();
        return true;
    }
}

function txtActiveTabChanged(e) {
    var activeTexts = new Array("SHOWING\nCOMPREHENSIVE\nRESULTS", "SHOWING THIRD\nPARTY FIRE & THEFT\nRESULTS", "SHOWING\nTHIRD PARTY ONLY\nRESULTS");
    var inactiveTexts = new Array("VIEW\nCOMPREHENSIVE\nRESULTS", "VIEW THIRD PARTY\nFIRE & THEFT RESULTS", "VIEW THIRD PARTY\nONLY RESULTS");
    //alert(inactiveTexts.length);
    var _tabs = e._tabs;
    var _activeTabIndex = e._activeTabIndex;
    for (var i = 0; i < 3; ++i) {
        var tab = _tabs[i];
        var txt = inactiveTexts[i];
        if (i == _activeTabIndex) {
            txt = activeTexts[i];
        }
        var headerSpan = tab._header;
        var inputs = headerSpan.getElementsByTagName("input");
        var headerInput = inputs[0]
        headerInput.value = txt;

    }
}
function changeActiveTab() {
    if (activeTabName == 'comp') {
        var tabComp = document.getElementById('ctl00_CP_TabContainer_TabPanelComp_tabComp');
        tabComp.style.visibility = "visible";
        tabComp.style.display = "block";
        document.getElementById('__tab_ctl00_CP_TabContainer_TabPanelComp').setAttribute("class", "ajax__tab_active");
        document.getElementById('__tab_ctl00_CP_TabContainer_TabPanelComp').className = "ajax__tab_active";
        var buttonComp = document.getElementById('ctl00_CP_TabContainer_TabPanelComp_btnTabPanelComp');
        buttonComp.defaultValue = "You are looking at\nComprehensive Results";
        buttonComp.Value = "You are looking at\nComprehensive Results";
        var buttonTPO = document.getElementById('ctl00_CP_TabContainer_TabPanelTPO_btnTabPanelTPO');
        buttonTPO.defaultValue = "Third Party Only";
        buttonTPO.setAttribute("value", "Third Party Only");
        var buttonTPFT = document.getElementById('ctl00_CP_TabContainer_TabPanelTPFT_btnTabPanelTPFT');
        buttonTPFT.defaultValue = "Third Party, Fire and Theft";
        buttonTPFT.setAttribute("value" , "Third Party, Fire and Theft");
    }
    if (activeTabName == 'tpo') {
        var tabTpo = document.getElementById('ctl00_CP_TabContainer_TabPanelTPO');
        tabTpo.style.visibility = "visible";
        tabTpo.style.display = "block";
        document.getElementById('__tab_ctl00_CP_TabContainer_TabPanelTPO').setAttribute("class", "ajax__tab_active");
        document.getElementById('__tab_ctl00_CP_TabContainer_TabPanelTPO').className = "ajax__tab_active";
        var buttonTPO = document.getElementById('ctl00_CP_TabContainer_TabPanelTPO_btnTabPanelTPO');
        buttonTPO.defaultValue = "You are looking at\nThird Party Only Results ";
        buttonTPO.setAttribute("value" , "You are looking at\nThird Party Only Results ");
        var buttonTPFT = document.getElementById('ctl00_CP_TabContainer_TabPanelTPFT_btnTabPanelTPFT');
        buttonTPFT.defaultValue = "Third Party, Fire and Theft";
        buttonTPFT.setAttribute("value", "Third Party, Fire and Theft");
        var buttonComp = document.getElementById('ctl00_CP_TabContainer_TabPanelComp_btnTabPanelComp');
        buttonComp.defaultValue = "Comprehensive";
        buttonComp.setAttribute("value","Comprehensive");
    }
    if (activeTabName == 'tpft') {
        var tabTpft = document.getElementById('ctl00_CP_TabContainer_TabPanelTPFT_tabTPFT');
        tabTpft.style.visibility = "visible";
        tabTpft.style.display = "block";
        document.getElementById('__tab_ctl00_CP_TabContainer_TabPanelTPFT').setAttribute("class", "ajax__tab_active");
        document.getElementById('__tab_ctl00_CP_TabContainer_TabPanelTPFT').className = "ajax__tab_active";
        var buttonTPFT = document.getElementById('ctl00_CP_TabContainer_TabPanelTPFT_btnTabPanelTPFT');
        buttonTPFT.defaultValue = "You are looking at\nThird Party, Fire and Theft Results ";
        buttonTPFT.setAttribute("value", "You are looking at\nThird Party, Fire and Theft Results");
        var buttonTPO = document.getElementById('ctl00_CP_TabContainer_TabPanelTPO_btnTabPanelTPO');
        buttonTPO.defaultValue = "Third Party Only";
        buttonTPO.setAttribute("value", "Third Party Only");
        var buttonComp = document.getElementById('ctl00_CP_TabContainer_TabPanelComp_btnTabPanelComp');
        buttonComp.defaultValue = "Comprehensive";
        buttonComp.setAttribute("value", "Comprehensive");
    }
}

function setActiveTab(activetab) {
    activeTabName = activetab;
}

