///TEST CODE : BEG///
var g_bTst                  = false;
var c_iTstMsgsAllMsgs       = 0;
var c_iTstMsgsObjReports    = 50;
var c_iTstMsgsJustMine      = 100;
var c_iTstMsgsNone          = 1000;

if(g_bTst)
{
    Tst("TEST MODE HARD-CODE ENABLED IN global.js!!!",null,c_iTstMsgsAllMsgs);
}

function Tst(sMsg,iTp,iTstLvl)
{
    //RETURN if not in test mode
    if(!g_bTst) return;

    //SET iTp to default value if null.
    if(iTp == null) iTp = -1;

    //RETURN if message level below threshold
    //CHANGE iTstLvlThresholdMin to vary level of test messaging.
    var iTstLvlThresholdMin     = c_iTstMsgsAllMsgs;
    if(iTstLvl == null) iTstLvl = c_iTstMsgsAllMsgs;
    if(iTstLvl < iTstLvlThresholdMin) return;

    //ADD name of calling function to message IF available.
    var sFxnName;
    if(Tst.caller != null)  sFxnName = Tst.caller.toString().slice(0,Tst.caller.toString().indexOf(")")+1);
    else                    sFxnName = "no calling function";

    var sTxt    = '[CALLING FUNCTION]\n'
                + sFxnName
                + '\n\n[MESSAGE LEVEL/THRESHOLD]\n'
                + iTstLvl + " / " + iTstLvlThresholdMin
                + '\n\n--------------------------------------------------\t'
                + '\n\n[TEXT]\n'
                + sMsg;
    try
    {
        switch(iTp)
        {
            case 0: //SHOW partial msg, EXPOSE manual copy
            prompt(sTxt,sTxt);
            break;
            case 1: //SHOW full msg, COPY full msg to clipboard
                clipboardData.setData("text",sMsg);
                sTxt = "[*MSG CONTENTS COPIED TO CLIPBOARD*]\n\n" + sTxt;
                alert(sTxt);
            break;
            case 2: //SHOW full msg, COPY first 2000 chars of msg to clipboard
                var sMaxCBSz = 2000;
                var sCBD = clipboardData.getData("TEXT");
                sCBD = sCBD.slice(0,sMaxCBSz);

                clipboardData.setData("text",sCBD+sMsg);
                sTxt = "[*MSG CONTENTS COPIED TO CLIPBOARD*]\n\n" + sTxt;
                alert(sTxt);
            break;
            default: //SHOW full msg
            alert(sTxt);
            break;
        }
    }
    catch(e){};

}
///TEST CODE : END///
var bMac= (navigator.platform.indexOf("Mac") != -1);
var bSafari = (navigator.appVersion.indexOf("Safari") > 0);
var bNS	= (navigator.appName.indexOf("Netscape")!= -1);
var bIE = !bNS;
var gaMonName,gaDayName;
gaMonName=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
gaDayName=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];

function init(iCaller)
{
var iOmnitureSemaphoreDelay = 10,iO;
	iO=iOmnitureSemaphoreDelay;

	switch(iCaller)
	{
		case 1 :	//aircode.aspx
			ShowControl();
		break;
		default :
		var sImmediateExec	= '';
		var aDelayedExec	= new Array();
			cc(true);

			for(var i=0; i< gaBodyLoadScript.length; i+=2)
			{
				if(gaBodyLoadScript[i+1] == 0) sImmediateExec+=gaBodyLoadScript[i] + ';';
				else
				{
					aDelayedExec[aDelayedExec.length] = gaBodyLoadScript[i];
					aDelayedExec[aDelayedExec.length] = gaBodyLoadScript[i+1];
				}
			}
			sImmediateExec = sImmediateExec.replace(/;+/g,';');

			eval(sImmediateExec);

			for(var i=0; i<aDelayedExec.length;i+=2)
			{
				if(iO < aDelayedExec[i+1]) iO = aDelayedExec[i+1];
				setTimeout(aDelayedExec[i],aDelayedExec[i+1]);
			}
		break;
	}

	iO *= 2;

	FSB(iO);

}

// Flip_Semaphore_Bit(iScriptDelay)
function FSB(iD){setTimeout("document.body.s_semaphore=0",iD);}

function GO(sI)
{
	if(GE(sI).value==-1)
	return false;

	SubRegPageNav(GE(sI).value);
	return false;
}

function OpacIt(oT,i1,i2,iI,sS)
{
	SetOpac(oT,i1);
	i1+=iI;
	if((i1 <= i2 && iI > 0) || (i1 >= i2 && iI < 0)) setTimeout("OpacIt("+oT.id+","+i1+","+i2+","+iI+")",10);
	else if(sS != null) eval(sS);
}

function SetOpac(oT,iO)
{
var ie5=(document.getElementById && document.all);
var ns6=(document.getElementById && !document.all);
	if(ie5){
		oT.style.filter="alpha(opacity="+iO+")";
	}
	if(ns6){
	oT.style.MozOpacity = 0 + '%';
	oT.style.MozOpacity = iO + '%';
	}
}

//Build_Previous_Button
function BPB(iT)
{
	if (history.length > ((bNS)?1:0))
	{
		if(iT == null) document.write("<A HREF='Javascript:history.go(-1);' CLASS=BOX2><B>Return to Previous</B></A>");
		else document.write("<b><a style='color:#669966;font-family:TAHOMA;font-size:11px;' href='javascript:history.back();'>Return to Previous</a></b>");
	}
}

//Build_Floating_Element2(iBalloonIndex,sLinkText,sBGColor,sBalloonHTML)
var g_iFltElmtNum = 0;
function BFE(iBI,sLnkTxt,sBGColor,sBllnHTML)
{
var rgBllnCont	= new Array();
var sLnkCont		= "";
var sDefTxt		= "Details";
var sDefHTM		= "We\'re sorry, the help text you requested is currently unavailable.";
var sDefBGColor	= "#FFFFCD";

	rgBllnCont=	[
						[sDefBGColor,sDefTxt,"<B>All-Inclusive</B> resorts make travel simple and stress-free by including most meals and beverages in the price of the accommodations. Most all-inclusive resorts also include recreational activities, entertainment, and gratuities in their rate. Spa services generally are an additional charge. If you have questions or would like more details about what's offered at this or any of the properties we offer, <B>please call a Classic personal travel specialist at " + g_sPNum + "</B>."],
						[sDefBGColor,"View full details for this offer",""]
					];

	if(iBI != null)
	{
		if(sBGColor == null)	sBGColor	= rgBllnCont[iBI][0];
		if(sLnkTxt == null)		sLnkTxt		= rgBllnCont[iBI][1];
		if(sBllnHTML == null)	sBllnHTML	= rgBllnCont[iBI][2];
	}

	if(sBGColor == null		|| sBGColor== "")	sBGColor	= sDefBGColor;
	if(sLnkTxt == null		|| sLnkTxt == "")	sLnkTxt		= sDefTxt;
	if(sBllnHTML == null	|| sBllnHTML == "")	sBllnHTML	= sDefHTM;

	sBllnHTML = CJSS(sBllnHTML);

	sLnkCont	= "<div id=\"divFloatTxtFOR" + g_iFltElmtNum +"\" style=\"display:inline;position:absolute;line-height:1px; height:1px;\"><img src=\"/s.gif\" height=1 width=1></div>"
				+ "<span style=\"height:0px;margin-left:2px;margin-right:8px;cursor:hand;\" onclick=\"ShowHideBalloon(1,divFloatTxtFOR" + g_iFltElmtNum + ",'" + sBllnHTML + "','"+ sBGColor +"');\">"
				+ "<img src=\"/images/details_icon.gif\" style=\"position:relative;top:3px;\" height=12 width=12 alt=\"\">"
				+ "<span style=\"padding-left:2px;padding-bottom:2px;line-height:10px;font-family:tahoma;font-size:10px;font-weight:bold;color:#669966;text-decoration:underline;\">" + sLnkTxt + "</span>"
				+ "</span>";

	if(sLnkCont != null && sLnkCont .length > 0) document.write(sLnkCont);

	g_iFltElmtNum++;

}

//Clean_JS_String(sJS2Clean)
function CJSS(sJS)
{
sJS = sJS.replace(/\n/g,"");
sJS = sJS.replace(/'/g,"\\\'");
sJS = sJS.replace(/"/g,"&quot;");
return sJS;
}

function SubRegPageNav(sT)
{
var url;

	switch (sT.length)
	{
		case 2:			
			//rnguyen011207 - 'southpacific' is the location of South Pacific content pages
			if (sT == "cs")
				url = "/southpacific";
			else
				url = '/' + sT + '/';
		break;
		case 6:			
			aLoc = sT.split("|")
			url = '/' + aLoc[0] + '/sr_' + aLoc[1] + '.aspx';
		break;
		case 10:
			aLoc = sT.split("|");
			//rnguyen011207 - 'so' the first 2 characters of 'South Pacific' 
			//Thus, direct the link to its South Pacific sub-region pages accordingly
			if (aLoc[0] == "so")
			{
				if (aLoc[2] == "SYD")
					url = '/southpacific/' + 'australia' + '/default.aspx';
				else if (aLoc[2] == "AKL")
					url = '/southpacific/' + 'newzealand' + '/default.aspx';
				else if (aLoc[2] == "NAN")
					url = '/southpacific/' + 'fiji' + '/default.aspx';				
				else if (aLoc[2] == "BOB")
					url = '/southpacific/' + 'tahiti' + '/default.aspx';
				else if (aLoc[2] == "TAH")
					url = '/southpacific/' + 'tahiti' + '/default.aspx';
			}
			else
				url = '/' + aLoc[0] + '/sr_' + aLoc[1] + '.aspx?AirCode=' + aLoc[2];				
		break;
		default:
			url = '/ha/';
		break;		
	}

	document.location.href=(url);

return false;
}

function SubRegPageMapNav(sT)
{
	var url;
	if( sT.length >0 )
	{
		aLoc = sT.split("|");
		url = '/' + aLoc[0] + '/' + aLoc[1] + '-hotels.aspx';
		//rnguyen101007 - link map to South Pacific sub-region accordingly
		if (aLoc[0] == "southpacific")
			url = '/' + aLoc[0] + '/' + aLoc[1] + '/' + 'default.aspx';
		else if ( (aLoc[0] == "australia") || (aLoc[0] == "newzealand") || (aLoc[0] == "fiji") )
			url = '/southpacific/' + aLoc[0] + '/' + aLoc[1] + '-hotels.aspx';
	}
	else
	{
		url = '/hawaii/';
	}
	document.location.href=(url);

	return false;
}

function cc(bR)
{
	if(IsBot()) return true;						//DO NOT impose cookie requirement on crawlers or bots.

    var beforeWriteAttempt,afterWriteAttempt;
    beforeWriteAttempt  = document.cookie + "";
    document.cookie     = "test=" + (new Date());
    afterWriteAttempt   = document.cookie + "";

    if(beforeWriteAttempt == afterWriteAttempt)
	{
		if(bR) document.location.href='/error/nocookies.aspx';
		else
		{
			return false;
		}
	}
	else return true;
}

function IsBot()
{
var bSE,aSE;
	bSE = false;
	aSE = ["Scooter","teoma","fast","slurp","ZyBorg","googlebot"];
	for(var i=0;i<=aSE.length;i++)
	{
		if(navigator.userAgent.indexOf(aSE[i])!=-1)
		{
			bSE = true;
			break;
		}
	}
	return bSE;
}

function tt(iTT)
{
	var oTT=GE("tt_statusbox"),oTT1=GE("tt_title"),oTT2=GE("tt_text"),s1,s2;
	if(iTT != null)
	{
		switch (iTT)
		{
			case 1:
				s1="Step 1: Choose a Destination";
				s2="Discover a world of luxury with our interactive maps and destination guides designed to pinpoint your perfect vacation.";
			break;
			case 2:
				s1="Step 2: Create Your Vacation";
				s2="Customize your vacation experience with premier hotels, flights, and activities that meet your needs. View resort photos, virtual tours, and select your VIP amenities.";
			break;
			case 3:
                s1="Step 3: Call " + g_sPNum + " to book your vacation";
                s2="Finalize your Classic Vacation by calling " + g_sPNum + ". A personal travel specialist is available to answer questions, make recommendations, and finalize your purchase.";
			break;
		}
		oTT1.innerHTML=s1;
		oTT2.innerHTML=s2;
 		oTT.style.display='inline';
	}
	else oTT.style.display='none';
}

function ShowSubReg(sTLA,bStick)
{
	
var sRegion = "eu_";
var sRegionSouthPacific = "cs_";

if(sTLA.length == 6)
{
	var temp = sTLA;
	sTLA = sTLA.substring(3,6);
	sRegion = temp.substring(0,3);
	
}
var oImgMain=GE("imgMapMain");
var oImgAB=GE("imgMap"+sTLA+"AB");
var oBtn=GE("divButton"+sTLA);
var oMapCon=GE("ABMapContainer");

	if(g_sLastABImgMap!=null)
	{
		GE(g_sLastABButton).className = "BOX2";
		GE(g_sLastABImgMap).style.display='none';
	}

	if ( (sTLA == "akl") || (sTLA == "rot") )
		oImgMain.src="/images/maps/" + sRegionSouthPacific + sTLA + "_mainmap.gif";
	else
		oImgMain.src="/images/maps/" + sRegion + sTLA + "_mainmap.gif";

	oBtn.className = "BOX10";
	oImgAB.style.display='inline';

	if(bStick==null){setTimeout("document.location.href='#ABMap'",400);}

	g_sLastABButton = "divButton" + sTLA;
	g_sLastABImgMap = "imgMap" + sTLA + "AB";

}

//MouserOverNavButton(iButtonNum,sCSSClassModifier
function MONBOT(iBtn,iCM)
{
var aE = ["OT_NB1_"];
    for(var i=0; i < aE.length; i++)
    {
        GE(aE[i] + iBtn).className = aE[i] + iCM;
    }
}

//MouserOverNavButton(iButtonNum,sCSSClassModifier
function MONB(iBtn,iCM)
{
//var aE = ["NB1_","NB2_","NB3_","NB4B_","NB4T_","NB5B_","NB5T_","NBANC_","NBGRAD_"];
var aE = ["NBGRAD_"];
    for(var i=0; i < aE.length; i++)
    {
        GE(aE[i] + iBtn).className = aE[i] + iCM;
    }
}

//MouseOverRoomDescription
function MORD(sRD,oE)
{
	var o_TT = GE("divToolTip");
	if(sRD == null || sRD == '') o_TT.style.visibility='hidden';
	else
	{
		o_TT.innerHTML = sRD;

		if(bNS)
		{
			 iY = oE.pageY - 22;
			 iX = oE.pageX - 10;
		}
		else
		{
			 iY = oE.y + document.body.scrollTop - 22;
			 iX = oE.x + document.body.scrollLeft - 10;
		}

		o_TT.style.top	= iY;
		o_TT.style.left = iX;

		o_TT.style.visibility='visible';
	}
}

//UpdateOrigDropDown
function UODD(sCty,sTLA)
{
var o_S = GE("INPDEST1A");
o_S[0].value=sTLA;
o_S[0].text=sCty;
o_S[0].selected=true;
CI2('DEST1A',1,181);
try{setTimeout("GE('INPDEST1A').focus()",10);}
catch(e){}
}

// function SetPickerTop
// iO = total parents offset heights.
// iFH = height of picker frame
// iPT = adjustment to picker's position.
// oCD = picker container div.
// oFOR = frame of reference div.
// iTBH = total body offset, height of body + scroll position

function SPT()
{
if(bNS){return null;}

var oDB=document.body;
var oDA=document.all;
var oFOR=oDA.divAirPickerFOR;
var oCD=oDA.divAirPickerContainer;
var oPE=oFOR;
var iOT=oFOR.offsetTop;
var iOL=oFOR.offsetLeft;
var iBH=oDB.clientHeight;
var iBW=oDB.clientWidth;
var iBST=oDB.scrollTop;
var iBSW=oDB.scrollLeft;
var iFORT=parseInt(oFOR.style.top);
var iFORL=parseInt(oFOR.style.left);
var iPT=0;
var iPL=0;
var iTBH=iBH+iBST;
var iTBW=iBW+iBSW;
var iFH=oDA.frmAirPicker.style.pixelHeight;
var iFW=oDA.frmAirPicker.style.pixelWidth;

	while(oPE.tagName != "BODY")
	{
		iOT+=oPE.offsetTop;
		iOL+=oPE.offsetLeft;
		oPE = oPE.offsetParent;
	}

	if(iBH > (iFH + 2))
	{
		if(iOT+iFH > iTBH)iPT = iTBH - (iOT + (iFH+2));
 		else if(iBST > (iOT+iFORT)) iPT = iBST - iOT;
	}
 	else iPT = iBST - iOT;

	if(iBW > (iFW + 2))
	{
		if(iOL+iFW > iTBW) iPL = iTBW - (iOL + (iFW+2));
 		else if(iBSW > (iOL+iFORL)) iPL = iBSW - iOL;
	}
 	else iPL = iBSW - iOL;

	oCD.style.top = iPT;
	oCD.style.left = iPL;
}

function PCA(sCty,sTLA){window.parent.CA(sCty,sTLA);}
function CA(sCty,sTLA,bOpen)
{
var oAirFrm=GE("frmAirPicker");
	if(
	!bNS
	&& bOpen
	&& document.frames.frmLoadMsg.g_bLLM != null
	&& document.frames.frmLoadMsg.g_bLLM == true
	)
	{document.frames.frmLoadMsg.LLM();}

	var oCon=GE("divAirPickerContainer");
	var sStyle=(bOpen==true)?'inline':'none';

	if(bOpen)
	{
		SPT();
		if(oAirFrm.src.toLowerCase().indexOf("aircode") == -1){setTimeout("GE('frmAirPicker').src='../include/aircode.aspx'",200)}
		if(sCty != null && sTLA != null) UODD(sCty,sTLA);
	}

	oCon.style.display	= sStyle;
	oAirFrm.style.display = sStyle;

	if(sCty != null && sTLA != null) UODD(sCty,sTLA);
	if(!bNS && event != null) event.cancelBubble=true;

	FXWZ();

	if(!bNS && bOpen)
	{
		var oAP = document.frames.frmAirPicker;
		var sC = "A"
		if(oAP.g_sLCity != null)
		{
			sC = oAP.g_sLCity;
		}
		try{setTimeout("SetFocusGlobal('document.frames.frmAirPicker.document.all.div" + sC + "0Sel',10,400)",400);}
		catch(e){}
	}

}

function SetFocusGlobal(sObj,i,iD)
{
	try
	{
		var oObj = eval(sObj)
		oObj.focus();
		return true;
	}
	catch(e)
	{
		if(i > 0)
		{
			try{setTimeout("SetFocusGlobal('" + sObj + "'," + --i + "," + iD + ")");}
			catch(e){};
		}
	}
}

function GetOffSet(oPE,fTop)
{
var nOT =0;
var nOL =0;

	while(oPE.tagName != "BODY")
	{
		if(fTop)nOT+=oPE.offsetTop;
		else nOL+=oPE.offsetLeft;
		oPE = oPE.offsetParent;
	}

	if(fTop) return nOT;
	else return nOL;

}

function ShowHideBalloon(fShow,oSrc,sHTM,sBGC)
{
	try
	{
	if(sHTM == null) sHTM = "";

	var objTxt	= document.all.frmTxtBalloon;
	var objShdw	= document.all.frmTxtBalloonShadow;
	var strStyle	= (fShow) ? 'visible':'hidden';
	var objDF = document.frames("frmTxtBalloon");

	objDF.document.all.divBC.innerHTML = sHTM;
	objDF.document.all.TxtBalloon.style.backgroundColor = sBGC;

	objDF.SetFrameDims();

	objShdw.style.visibility = strStyle;
	objTxt.style.visibility = strStyle;

		if(oSrc != null)
		{
			var nX = GetOffSet(oSrc,0) - 10;
			var nY = GetOffSet(oSrc,1) - 10;


			objShdw.style.left	= nX;
			objShdw.style.top		= nY;

			objTxt.style.left		= nX;
			objTxt.style.top		= nY;
		}

	}
	catch(e){};
}

function ShowControl()
{
	var o1 = window.parent.GE("frmLoadMsg");
	var o2 = window.parent.GE("frmAirPicker")

	o1.style.display='none';
	o2.style.display='inline';
}



//Main & Right Column Email Check
//also see Global next function below

function CheckForm()
{
        if(document.MainForm.email.value == "")
        {
                    alert("Email address is required. Please try again.");
                    document.MainForm.email.focus();
                    return(false);
        }

	var atsign = document.MainForm.email.value.indexOf ('@');
	var dot = document.MainForm.email.value.indexOf ('.');
 
 		if (atsign == -1 || dot == -1)
 		{
			 alert ("The format of your email entry may be wrong. \nExample: jane@domain.com. Please try again.");
			 document.MainForm.email.focus();    
			 return (false);
 		}
		


       document.MainForm.action = 'http://www.whatcounts.com/bin/listctrl';
       document.MainForm.slid.value = '6930' + '0011' + '0297' + '285' + '8258';
       document.MainForm.submit();
       return false;
}


//Global Footer Email Check
//also see Main & Right Column above

function GlobalCheckForm()
{
        if(document.GlobalForm.email.value == "")
        {
                    alert("Email address is required. Please try again.");
                    document.GlobalForm.email.focus();
                    return(false);
        }

	var atsign = document.GlobalForm.email.value.indexOf ('@');
	var dot = document.GlobalForm.email.value.indexOf ('.');
 
 		if (atsign == -1 || dot == -1)
 		{
			 alert ("The format of your email entry may be wrong. \nExample: jane@domain.com. Please try again.");
			 document.GlobalForm.email.focus();    
			 return (false);
 		}
		


       document.GlobalForm.action = 'http://www.whatcounts.com/bin/listctrl';
       document.GlobalForm.slid.value = '6930' + '0011' + '0297' + '285' + '8258';
       document.GlobalForm.submit();
       return false;
}






// NavButtonClick
function NBC(sNB){document.location.href=((sNB=="ho")? "/": "/"+sNB);}

// SetClipBoard
function SCB(sVal){try{clipboardData.setData("text",sVal)}catch(e){Tst("unable to write to clipboard")}}
// AddMdData
function AMD(sLabel,sVal,bClip){try{if(bClip){sLabel+=" (<FONT COLOR=\"green\">clip</FONT>)";SCB(sVal);}divTestHookMode1.innerHTML+="<BR/><BR/><SPAN CLASS=\"BODY1OR1\"><B>" + sLabel + ":</B></SPAN>"+"<BR/><SPAN CLASS=\"BODY1GY2\">" + sVal + "</SPAN>";}catch(e){Tst("unable to add data")}}
function GE(sE){return document.getElementById(sE);}
function mAdd(){for(c=0;c<mAdd.arguments.length;c+=2) this[mAdd.arguments[c]] = mAdd.arguments[c+1];}
function mDict(){this.add=mAdd;this.get=mGet;}
function mGet(key){return(this[key]);}
//1.0.4.1