

/***********************************************************************
TAB ZONE FUNCTIONS ADDED BY SAMAN KODITHUWAKKU
SEPTEMBER 2009
(Contract developer for Alaska Cruise Experts - saman@programmer.net)
************************************************************************/



var xmlReq; // = false;

/***********************************************************************
Handle tab button clicked event to for tab buttons on index pages to show 
tab content appropriately and highlight selected tab. 
PARAMETERS : Tab button id calling this function, 
             cruise line id represented by the button,              
             currenly selected cruise line id
************************************************************************/
function ClickCruiseLineTab(btnid){

    var numOfTabs = 6;
    var tabButton;
    var btnImagePath = new String();
    var tabContent;


    try {
        for (var indx = 1; indx <= numOfTabs; indx++) {

            tabButton = document.getElementById("TABBTN" + indx);
            tabContent = document.getElementById("DIV" + tabButton.id);

            btnImagePath = tabButton.src;

            if (tabButton.id == btnid) {
                btnImagePath = btnImagePath.replace("cltbw", "cltbb");
                tabContent.style.display = "block";
            }
            else {
                tabContent.style.display = "none";
                btnImagePath = btnImagePath.replace("cltbb", "cltbw");
            }
            tabButton.src = btnImagePath;
        }
    } catch (e) {
    }
}


/***********************************************************************
Handle tab button clicked event to show tab content appropriately
2nd and 3rd parameters are for future use.
************************************************************************/
function tzf_ClickTab(tabNumber, ctlIdSfx, qryID) {

    tzf_ShowTabContent(tabNumber);
}

/***********************************************************************
Highlight selected tab only and show tab content for the selected tab. 
Then hide content for other tabs. 
************************************************************************/
function tzf_ShowTabContent(tabNumber) {

    var tabButtons = new Array();
    var tabContents = new Array();
    var numOfTabs = 5;


    try {
        tabButtons[1] = document.getElementById("itinerary-details-");
        tabButtons[2] = document.getElementById("rooom-deck-plans-");
        tabButtons[3] = document.getElementById("port-information-");
        tabButtons[4] = document.getElementById("ship-information-");
        tabButtons[5] = document.getElementById("cruiseline-details-");

        for (var ix = 1; ix <= numOfTabs; ix++)
            tabContents[ix] = document.getElementById("tab" + ix);
        
        for (var indx = 1; indx <= numOfTabs; indx++) {
            if (tabNumber == indx)
                tabButtons[indx].src = "/imgs/buttons/" + tabButtons[indx].id + "blue.gif";
            else
                tabButtons[indx].src = "/imgs/buttons/" + tabButtons[indx].id + "white.gif";
            
            var tabid = "tab" + tabNumber;

            if (tabContents[indx].id == tabid) 
                tabContents[indx].style.display = "block";
            else 
                tabContents[indx].style.display = "none";            
        }
    } catch (Error) {
        alert(Error);
    }


    tabButtons = null;
    tabContents = null;

   
      
    return true;
}


/***********************************************************************
Open window to show port information - used in tab 3
************************************************************************/
function tzf_OpenVideoWindow(linkToVideo) {

    //open a new sized window with only scrollbars
    var roomWin = window.open(linkToVideo, "WatchVideoPopup", "width=750, height=600, scrollbars=yes, location=no, toolbar=no, menubar=no, resizable=yes");

    //bring window to top
    roomWin.focus();
}


/***********************************************************************
Open window to show port information - used in tab 3
************************************************************************/
function tzf_OpenPortWindow(portID) {

    var pageURL = "tzpg_portdisplay.asp?portid=" + portID ;
    
    //open a new sized window with only scrollbars
    var roomWin = window.open(pageURL, "portInfoPopup", "width=750, height=600, scrollbars=yes, location=no, toolbar=no, menubar=no, resizable=no");

    //bring window to top
    roomWin.focus();
}

/***********************************************************************
Change tab content of tab 2 and 4 when user selects a ship from drop down 
ships list 
************************************************************************/
function tzf_ChangeTabShip(tabId, selectedShipId, outToCtrlId) 
{
    switch (tabId) {

        case 'tab2':
            RefreshTabTwo(selectedShipId, outToCtrlId)
            break;

        case 'tab4':
            RefreshTabFour(selectedShipId, outToCtrlId)
            break;
    }
}
/********************************************************************************************************
Get content for tab 4 from server using ajax 
********************************************************************************************************/
function RefreshTabFour(selectedShipId, outToCtrlId) {
    var url = "tzpg_ajx_Tab4.asp?shipid=" + selectedShipId;

    try {

        try {
            xmlReq = new XMLHttpRequest();
        } catch (tryMS) {
            try {
                xmlReq = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (tryOtherMS) {
                try {
                    xmlReq = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (failed) { }
            }
        }

        // Open a connection to the server
        xmlReq.open("GET", url, true);

        // Setup a function for the server to run when it's done
        xmlReq.onreadystatechange = UpdateTabFour;

        // Send the request
        xmlReq.send(null);
    }
    catch (ferr) {
    }
}

/********************************************************************************************************
Get content for tab 2 from server using ajax 
********************************************************************************************************/
function RefreshTabTwo(selectedShipId, outToCtrlId)
{
    var url = "tzpg_ajx_Tab2.asp?shipid=" + selectedShipId;

    try {

        try {
            xmlReq = new XMLHttpRequest();
        } catch (tryMS) {
            try {
                xmlReq = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (tryOtherMS) {
                try {
                    xmlReq = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (failed) { }
           }
       }

        // Open a connection to the server
        xmlReq.open("GET", url, true);

        // Setup a function for the server to run when it's done
        xmlReq.onreadystatechange = UpdateTabTwo;

        // Send the request
        xmlReq.send(null);
    }
    catch (ferr) {
    }    
}

/********************************************************************************************************
Update tab 2 with content got from server by ajax
********************************************************************************************************/
function UpdateTabTwo() {

    if (xmlReq.readyState == 4) {

        if (xmlReq.status == 200) {

            var response = xmlReq.responseText;

            document.getElementById("tab2Content").innerHTML = response;
        }
    }
}

/********************************************************************************************************
Update tab 4 with content got from server by ajax
********************************************************************************************************/
function UpdateTabFour() {

    if (xmlReq.readyState == 4) {

        if (xmlReq.status == 200) {

            var response = xmlReq.responseText;

            document.getElementById("tab4Content").innerHTML = response;
        }
    }
}




