﻿startList=function(){
	if (document.all&&document.getElementById){
		var navRoot=document.getElementById("nav");
		if(navRoot!=null){
			for(i=0;i<navRoot.childNodes.length;i++){
				var node=navRoot.childNodes[i];
				if(node.nodeName=="LI"){
					node.onmouseover=function(){this.className+=" over";}
					node.onmouseout=function(){this.className=this.className.replace(" over","");}
				}
			}
		}
	}
}
window.onload = startList; setCookie("ctest", "1");
function findPosX(obj) {
var curleft = 0;
if (obj.offsetParent) {
    while (obj.offsetParent) {
        curleft += obj.offsetLeft
        obj = obj.offsetParent;
    }
}
else if (obj.x)
    curleft += obj.x;
return curleft;
}
function findPosY(obj) {
var curtop = 0;
if (obj.offsetParent) {
    while (obj.offsetParent) {
        curtop += obj.offsetTop
        obj = obj.offsetParent;
    }
}
else if (obj.y)
    curtop += obj.y;
return curtop;
}

function setCookie(c_name, value, expiredays) {
    document.cookie = c_name + "=" + escape(value);
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function Expert(version) {
    ExpertQuestion(version, '');
}
function ExpertQuestion(version, question) {
    var urlprotocol = "https:";
    if (window.location.host.toLowerCase().indexOf("localhost") > -1 || window.location.host.toLowerCase().indexOf("10.") > -1) urlprotocol = "http:";

    var url = urlprotocol + "//" + window.location.host;
    if (version) { url = url + '/alex/Agent.aspx'; }
    else { url = url + '/superalex/Agent.aspx'; }
    if (question != '') url = url + "?Question=" + question;
    if (version) {
        LaunchExternalAgent(url);
    }
    else {
        LaunchInternalAgent(url);
    }
    if (location.protocol.toLowerCase() == 'http:' & urlprotocol == 'https:') {
        location.href = location.href.replace('http:', urlprotocol);
    }
}
function ShowDiv(id,hideIds){
	var arrShowIds=id.split(",");
	var arrHideIds=hideIds.split(",");
	var objElement;
	for(var i=0;i<arrShowIds.length;i++){
		if(arrShowIds[i]!=""){
			objElement=document.getElementById(arrShowIds[i]);
			if(objElement!=null)objElement.style.display="";
			objElement=document.getElementById(arrShowIds[i]+"Text");
			if(objElement!=null)objElement.className="active";
		}
	}
	for(var i=0;i<arrHideIds.length;i++){
		if(arrHideIds[i]!=""){
			objElement=document.getElementById(arrHideIds[i]);
			if(objElement!=null)objElement.style.display="none";
			objElement=document.getElementById(arrHideIds[i]+"Text");
			if(objElement!=null)objElement.className="inactive";
		}
	}
}
function ShowDivToggle(id,hideIds){
	var arrShowIds=id.split(",");
	var arrHideIds=hideIds.split(",");
	var objElement;
	var showIds="";
	var newHideIds="";
	for(var i=0;i<arrShowIds.length;i++){
		if(arrShowIds[i]!=""){
			objElement=document.getElementById(arrShowIds[i]);
			if(objElement!=null)
			    if(objElement.style.display=="")newHideIds+=arrShowIds[i]+",";else showIds+=arrShowIds[i]+",";
		}
	}
//	for(var i=0;i<arrHideIds.length;i++){
//		if(arrHideIds[i]!=""){
//			objElement=document.getElementById(arrHideIds[i]);
//			if(objElement!=null)
//			    if(objElement.style.display=="")newHideIds+=arrHideIds[i]+",";else showIds+=arrHideIds[i]+",";
//		}
//	}
    ShowDiv(showIds,newHideIds);
}

function surveyWindow(langCode){
	if(langCode=="es"){
		window.open('http://survey.novatris.com/cit/airtrack/fev06/invite_CO_sp.html','daughter','height=300,width=500,resizeable=no,scrollbars=no');
	}
	else{
		window.open('http://survey.novatris.com/cit/airtrack/fev06/invite_CO.html','daughter','height=300,width=500,resizeable=no,scrollbars=no');
	}
}
function launchSurvey(type, url) {
    var rnd = Math.random();
    if (rnd * 10 < 4) {
        var cookieValue = readCookie(type);
        var count = 0;
        if (cookieValue != null) {
            if (!isNaN(cookieValue)) count = eval(cookieValue) + 1;
            if (count < 3) {
                window.open(url, 'daughter', 'width=500,resizeable=no,scrollbars=no');
                count = 3;
            }
        }
        setCookie(type, count, '');
    }
}
function test(){
    alert(window.location.href);
    alert('host ' + window.location.host);
    alert('test ' + document.url);
}

function DetectFlashVer(intReqMajorVer){
	var strVersion, strMajorVer, strError, objFlash
	var blnIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var blnWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
	var blnOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
	if (blnIE && blnWin && !blnOpera) {
		try {
			objFlash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+intReqMajorVer);
			objFlash.AllowScriptAccess = "always";
			strVersion = objFlash.GetVariable("$version");
			}
		catch (strError) {
			strVersion="0";
			}
		if (strVersion != "0") strMajorVer = strVersion.split(" ")[1].split(",")[0];
		else strMajorVer = strVersion;
		}
	else if ((navigator.plugins != null && navigator.plugins.length > 0) && navigator.plugins["Shockwave Flash"]){
		strMajorVer = navigator.plugins["Shockwave Flash"].description.split(" ")[2].split(".")[0];
		}
	else return false;
	if (parseInt(strMajorVer) >= intReqMajorVer) return true;
	else return false ;
}

function RunFlashVer(intReqMajorVer, strObjCode) {
if (DetectFlashVer(intReqMajorVer)) {
	document.write(strObjCode);
	return true;
	}
else return false;
}
function ShowDivItemSelected(objItem,id,hideIds){
    if(objItem.checked){
        ShowDiv(id,"");
    }
    else{
        ShowDiv("",hideIds);
    }
}
function ShowDivSetItemSelected(id, hideIds, id1, id2) {
    var objElement1 = document.getElementById(ChangeValue(id1, "$", "_"));
    if (objElement1 != null) { objElement1.checked = true; }
    var objElement2 = document.getElementById(ChangeValue(id2, "$", "_"));
    if (objElement2 != null) { objElement2.checked = false; }
    ShowDiv(id, hideIds);
}
//get value selected in dropdown list - lyn manimtim
function GetItemSelected(objItem)
{
    var opt = "";
    var idx = objItem.selectedIndex;
    opt = objItem.options[idx].value;
    return opt;
}

function SetText(id,text){
   var objElement = document.getElementById(ChangeValue(id,"$","_"));
   if(objElement!=null){objElement.innerHTML=text;}
}
function SetClass(id,className){
   var objElement = document.getElementById(ChangeValue(id,"$","_"));
   if(objElement!=null){objElement.className=className;}
}
function SetFocus(id) {
    var objElement = document.getElementById(id);
    if (objElement != null) { objElement.focus(); }
}
function ShowDivAdd(id,hideIds){
    var arrShowIds=id.split(",");
    var objElement;
	var blnPrevShown=false;
	var blnLastShown=false;
	for(var i=0;i<arrShowIds.length;i++){
		if(arrShowIds[i]!=""){
			objElement=document.getElementById(arrShowIds[i]);
			if(objElement!=null){
			    if(objElement.style.display==""){
			        blnPrevShown=true;
			    }
			    else if(blnPrevShown){
			        objElement.style.display="";
			        if(i==arrShowIds.length-1){blnLastShown=true;}
			        break;
			    }
			}
		}
	}
	if(blnLastShown){   //only hide if the last item has been shown
	    ShowDiv("",hideIds);
	}
}

var gblnAbandonPopUp = true;
var gblnInvokeAbandon=false;
var gstrConfNum= "";
var gstrLangCode="";

function PurchaseAbandon(){
//alert(gblnAbandonPopUp + " | " + window.location.href);
if(gblnAbandonPopUp & gblnInvokeAbandon){
    var strSID="";
    if(document.forms[0].hdnSID){
        strSID = document.forms[0].hdnSID.value;
    }
    if (gstrLangCode != "es" && gstrLangCode != "de-DE" && gstrLangCode != "ja-JP" && gstrLangCode != "zh-CN" && gstrLangCode != "fr" && gstrLangCode != "pt" && gstrLangCode != "en-US") { gstrLangCode = "en-US"; }
	var strURL = "/web/"+gstrLangCode+"/apps/booking/flight/call.aspx?SID="+strSID+"&ConfNum="+gstrConfNum+"&LangCode="+gstrLangCode;
	window.open(strURL, "CallCO", "toolbar=0,status=0,menubar=0,location=0,scrollbars=0,resizable=1,width=500,height=300,top=50,left=50");
	}
}

function DisableAbandonPopUp(objActiveItem){
    if (objActiveItem != null && !(/(Safari)/.test(navigator.userAgent))) {
			//alert(objActiveItem.tagName);
			//alert(objActiveItem.attributes);
			if(objActiveItem.tagName=='A'){
				var strItemID=objActiveItem.getAttribute("id");
				if(strItemID.indexOf("Header") > 0 || strItemID.indexOf("Footer") > 0){
					gblnAbandonPopUp = true;
				}
				else{
					gblnAbandonPopUp = false;
				}
			}
			else if(objActiveItem.tagName=='INPUT'){
			    var strItemID = objActiveItem.getAttribute("id");
			    //TD#17072 added check for "strItemID.indexOf("Btn") > 0" with a capital "B"
			    if ((strItemID.indexOf("button") > 0 || strItemID.indexOf("btn") > 0 || strItemID.indexOf("Btn") > 0 || strItemID.indexOf("Button") > 0)) {
					gblnAbandonPopUp = false;					
				}
				else{
					gblnAbandonPopUp = true;					
				}
			}
			else{
				gblnAbandonPopUp=false;
			}
	}
	else
	{
	    //alert("check for firefox any version and disable popup.");
	    //TD#14478
	    if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) { //test for Firefox
	        var ffversion = new Number(RegExp.$1)  //grab version
	        if (ffversion >= 1) //disable all firefox versions
	        {
	            gblnAbandonPopUp = false;
	        }
	        else {
	            gblnAbandonPopUp = true;
	        }
	    } else {
	    gblnAbandonPopUp = false; //mainly to disable popup in safari browser.
	    }
    }
}

function AllowAbandonScript(strConfNum,strLangCode){
	gblnInvokeAbandon=true;
	gstrConfNum=strConfNum;
	gstrLangCode=strLangCode;
	//TD13945 - don't do the eStara pop up for languages where we don't have this translated
	if(strLangCode=="ja-JP"){
	    gblnInvokeAbandon=false;
	}
}

function ShowAccountHistoryDetail(strCountrLogId, strLogID, strSrcTable, strDiv, sessionId){
	if (window.document.all['div' + strDiv + strCountrLogId].style.display == "inline"){
		window.document.all['div' + strDiv + strCountrLogId].style.display = "none";
	}
	else{
		//if (window.document.all['txt' + strDiv + strLogID].value != "loaded"){	// if the IFrame has already been loaded then don't reset it's src property
			var strSrc = 'accountHistoryDetail.aspx?SrcTable=' + strSrcTable + '&LogID=' + strLogID + '&SID=' + sessionId;
			window.document.all['iframe' + strDiv + strCountrLogId].src = strSrc;
			//window.document.all['txt' + strDiv + strLogID].value="loaded";
		//}
		window.document.all['div' + strDiv + strCountrLogId].style.display="inline";
	}
}

function ShowPreviewSiteMembersDetail(strCustomerID, strDiv, strSID){
	if (window.document.all['div' + strDiv + strCustomerID].style.display == "inline")
	{
		window.document.all['div' + strDiv + strCustomerID].style.display = "none";
	}
	else
	{
		var strSrc = 'previewMembersDetail.aspx?CustomerID=' + strCustomerID + '&SID=' + strSID;
		window.document.all['iframe' + strDiv + strCustomerID].src = strSrc;
			
		window.document.all['div' + strDiv + strCustomerID].style.display="inline";
	}
}

function ShowDivByValue(objItem,arrValues,arrShowIds,arrHideIds){
    for(var i=0;i<arrValues.length;i++){
        if(objItem.value==arrValues[i]){
            ShowDiv(arrShowIds[i],arrHideIds[i]);
        }
    }
}
function SetValue(objItem,id,startIndex,endIndex,value){
    startIndex=startIndex-0+1;
    for(var i=startIndex;i < endIndex;i++){
        if(document.getElementById(ChangeValue(id,'#',i))!=null){
            document.getElementById(ChangeValue(id,'#',i)).value=value;
        }
    }
}

function SetDestValueWithSourceValue(sourceElementId, destElementId) {
    var sourceElement = document.getElementById(sourceElementId);
    var destElement = document.getElementById(destElementId);
    if (sourceElement != null && destElement != null && sourceElement.value.length > 0 && (destElement.value.length == 0 || !IsDatePattern(destElement.value)))
        destElement.value = sourceElement.value;
}

function GetData(){
    document.forms[0].hdnInfo.value='NO DATA COLLECTED';
    session_util.validate('hdnInfo');
}

//function to toggle display of Reward Travel item in the dropdown list.
var marrListItems = new Array();
function SetItemByValue(objItem,arrValues,listId,arrIdValues,removeItem){
    
    var checkList = false;
    var arrItemExists = false;
    if(arrValues == ''){
        checkList = true;
    }
    else{
        arrValues = arrValues.split(",");
        for(var i=0;i<arrValues.length;i++){
            if(objItem.value==arrValues[i]){
                checkList = true;
            }
        }
    }
    arrIdValues = arrIdValues.split(",");
    
    if(checkList){
        var objElement = document.getElementById(listId);
        if(objElement!=null){
            if(removeItem){
                for(var x=0;x<objElement.options.length;x++){
                    for(var y=0;y<arrIdValues.length;y++){
                        arrItemExists = false
                        if(objElement.options[x].value==arrIdValues[y]){
                            for(var z=0;z<marrListItems.length;z++){
                                if(marrListItems[z].value == objElement.options[x].value){
                                    arrItemExists = true;
                                }
                            }
                            if(!arrItemExists)marrListItems[marrListItems.length] = objElement.options[x];
                            objElement.options[x]=null;
                            x=0;//list has been modified so you have to start at the beginning again
                            objElement.options.selectedIndex=0;
                        }
                    }
                }
            }
            else{
                for(var x=0;x<marrListItems.length;x++){
                    for(var y=0;y<arrIdValues.length;y++){
                        if(arrIdValues[y]==marrListItems[x].value){
                            objElement.options.add(marrListItems[x]);
                        }
                    }
                }
            }
        }
    }
}
