DOM = (document.getElementById) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0;
// We need to explicitly detect Konqueror
// because Konqueror 3 sets IE = 1 ... AAAAAAAAAARGHHH!!!
Konqueror = (navigator.userAgent.indexOf('Konqueror') > -1) ? 1 : 0;
// We need to detect Konqueror 2.2 as it does not handle the window.onresize event
Konqueror22 = (navigator.userAgent.indexOf('Konqueror 2.2') > -1 || navigator.userAgent.indexOf('Konqueror/2.2') > -1) ? 1 : 0;
Konqueror30 =
	(
		navigator.userAgent.indexOf('Konqueror 3.0') > -1
		|| navigator.userAgent.indexOf('Konqueror/3.0') > -1
		|| navigator.userAgent.indexOf('Konqueror 3;') > -1
		|| navigator.userAgent.indexOf('Konqueror/3;') > -1
		|| navigator.userAgent.indexOf('Konqueror 3)') > -1
		|| navigator.userAgent.indexOf('Konqueror/3)') > -1
	)
	? 1 : 0;
Konqueror31 = (navigator.userAgent.indexOf('Konqueror 3.1') > -1 || navigator.userAgent.indexOf('Konqueror/3.1') > -1) ? 1 : 0;
// We need to detect Konqueror 3.2 as it is affected by the see-through effect only for 2 form elements
Konqueror32 = (navigator.userAgent.indexOf('Konqueror 3.2') > -1 || navigator.userAgent.indexOf('Konqueror/3.2') > -1) ? 1 : 0;
Opera = (navigator.userAgent.indexOf('Opera') > -1) ? 1 : 0;
Opera5 = (navigator.userAgent.indexOf('Opera 5') > -1 || navigator.userAgent.indexOf('Opera/5') > -1) ? 1 : 0;
Opera6 = (navigator.userAgent.indexOf('Opera 6') > -1 || navigator.userAgent.indexOf('Opera/6') > -1) ? 1 : 0;
Opera56 = Opera5 || Opera6;
IE = (navigator.userAgent.indexOf('MSIE') > -1) ? 1 : 0;
IE = IE && !Opera;
IE5 = IE && DOM;
IE4 = (document.all) ? 1 : 0;
IE4 = IE4 && IE && !DOM;

// GC New Card printing
function NewCardPopUp(){
	newWindow = window.open("/gc/joinnow/en/card.aspx","","width=320,height=230,toolbar=no,scrollbars=no,left=90,top=90");	
}

// for adding an item in drop down list
function addOption(dropDownObj, pos, newValue, newText) {
	dropDownObj.options[pos] = new Option();
	dropDownObj.options[pos].value = newValue;
	dropDownObj.options[pos].text = newText;
}
	
// for removing all items in drop down list
function clearOption(dropDownObj) {
	for (i=dropDownObj.length;i>=0; i--) {
		dropDownObj.options[i] = null
	}
//	dropDownObj.length = 1;
//	dropDownObj.options[0] = new Option();
//	dropDownObj.options[0].value = "";
//	dropDownObj.options[0].text = "";
}


function trim(a){
	return a.replace(/^\s+/,'').replace(/\s+$/,'')
}

function isHotelSelect(formobj) {
}

// the javascript function move to CheckInOutDate WebControls
/*
function checkRate_bak(formobj) {  
		formobj.rate_id.value = trim(formobj.rate_id.value) ;
		formobj.agency_code.value = trim(formobj.agency_code.value);
		inMonth = formobj.inMonthList.selectedIndex;
		outMonth = formobj.outMonthList.selectedIndex;
		inDay  = formobj.inDayList.selectedIndex;
		outDay  = formobj.outDayList.selectedIndex;
		if (inMonth > outMonth) {
			alert("DateMessage");
			return false;
		} else if (inMonth == outMonth){
			if (inDay >= outDay) {
				alert("DateMessage");
				return false;
			}
		}
		if (inMonth == 0) {
			today = new Date();
			if(formobj.inDayList[inDay].value < today.getDate()) {
				alert("DateMessage");
				return false;
			}
		}
		if (formobj.rate_id.value != "" && formobj.agency_code.value != "") {
			alert("CTAMessage");
			return false;
		}
		formobj.checkRate.value = 1;
		formobj.submit();
}
*/

function CheckRateBoxCheckMonthChange(formobj, type, addDay) {


	MonthObj = eval("formobj." + type + "MonthList");
	dayObj = eval("formobj." + type + "DayList");
	monthSelected = MonthObj.selectedIndex;
	daySelected = dayObj.selectedIndex;
	if (type == "out") {
		InMonthObj = eval("formobj.inMonthList");
		InDayObj = eval("formobj.inDayList");
		//availMonth = monthSelected;
		/*
		if ((InDayObj.selectedIndex+1) == InDayObj.length) {
			monthSelected++;
			//availMonth++;
		}
		*/
		clearOption(dayObj);
		if (hotelType == "") {
			addOption(dayObj, dayObj.length, "", "--");
		}
		for (i=1;i<=thisDayArray[monthSelected];i++) {
			addOption(dayObj, dayObj.length, i, i);
		}
		if (hotelType == "") {
			// corp home
			dayObj.selectedIndex = 1;
		} else {
			dayObj.selectedIndex = 0;
		}
		//prefill the day
		if (daySelected < dayObj.length) {
			dayObj.selectedIndex = daySelected;
		}

	}

	if (type == "in") {

		clearOption(dayObj);
		if (hotelType == "") {
			addOption(dayObj, dayObj.length, "", "--");
		}
		for (i=1;i<=thisDayArray[monthSelected];i++) {
			addOption(dayObj, dayObj.length, i, i);
		}
		if (hotelType == "") {
			// corp home
			dayObj.selectedIndex = 1;
		} else {
			dayObj.selectedIndex = 0;
		}

		//prefill the day
		if (daySelected < dayObj.length) {
			dayObj.selectedIndex = daySelected;
		}
		
		CheckRateBoxCheckInDayChange(formobj, addDay);
		/*
		OutMonthObj = eval("formobj.outMonthList");
		OutDayObj = eval("formobj.outDayList");
		OutMonthObj.selectedIndex = monthSelected;
		clearOption(OutDayObj);
		if (hotelType == "") {
			addOption(OutDayObj, OutDayObj.length, "", "--");
		}
		for (i=1;i<=thisDayArray[monthSelected];i++) {
			addOption(OutDayObj, OutDayObj.length, i, i);
		}
		OutDayObj.selectedIndex = dayObj.selectedIndex + addDay;
		*/
	}

	if (type == "single") {
		//availMonth = monthSelected;
		clearOption(dayObj);

		if (hotelType == "") {
			addOption(dayObj, dayObj.length, "", "--");
		}
		for (i=1;i<=thisDayArray[monthSelected];i++) {
			addOption(dayObj, dayObj.length, i, i);
		}
		//prefill the day
		if (daySelected < dayObj.length) {
			dayObj.selectedIndex = daySelected;
		}
	}
}

function UpdateInOutDate(InMonthObj, InDayObj, OutMonthObj, OutDayObj, addDay) {
	monthSelected = InMonthObj.selectedIndex;
	
	OutMonthObj.selectedIndex = InMonthObj.selectedIndex;
	if (hotelType == "") {
		DAY_ARRAY = parseInt(thisDayArray[monthSelected]) + 1;
	} else {
		DAY_ARRAY = parseInt(thisDayArray[monthSelected]);
	}
	/*
	alert("in=" + InDayObj.selectedIndex);
	alert("out=" + (InDayObj.selectedIndex+addDay));
	alert("array=" + DAY_ARRAY);
	*/
	if( (InDayObj.selectedIndex+addDay) <  DAY_ARRAY) {
		// the return day not go to next month. only updat the return day value.
		clearOption(OutDayObj);
		if (hotelType == "") {
			addOption(OutDayObj, OutDayObj.length, "", "--");
		}
		for (i=1;i<=thisDayArray[InMonthObj.selectedIndex];i++) {
			addOption(OutDayObj, OutDayObj.length, i, i);
		}
		// avoid user select "--" at inDay in corp calendar
		if (InDayObj[InDayObj.selectedIndex].value != "") {
			OutDayObj.selectedIndex = InDayObj.selectedIndex + addDay;
		}
	} else {
		if (InMonthObj.selectedIndex == (InMonthObj.length-1) && (InDayObj.selectedIndex+addDay) >= InDayObj.length-1) {
			// Out of range
			OutMonthObj.selectedIndex = InMonthObj.selectedIndex;
			OutDayObj.selectedIndex = InDayObj.length-1;
		} else {
			OutMonthObj.selectedIndex = InMonthObj.selectedIndex + 1;	// Next Month
			clearOption(OutDayObj);
			if (hotelType == "") {
				addOption(OutDayObj, OutDayObj.length, "", "--");
			}
			for (i=1;i<=thisDayArray[OutMonthObj.selectedIndex];i++) {
				addOption(OutDayObj, OutDayObj.length, i, i);
			}
			OutDayObj.selectedIndex = (InDayObj.selectedIndex + addDay) -   DAY_ARRAY;
			if (hotelType == "") {
				OutDayObj.selectedIndex = (InDayObj.selectedIndex + addDay) -   DAY_ARRAY;
				if (OutDayObj.selectedIndex == 0) {
					OutDayObj.selectedIndex = 1;
				}
			}
		}
	}
}

function CheckRateBoxCheckInDayChange(formobj, addDay) {

	OutMonthObj = eval("formobj.outMonthList");
	OutDayObj = eval("formobj.outDayList");
	InMonthObj = eval("formobj.inMonthList");
	InDayObj = eval("formobj.inDayList");
	UpdateInOutDate(InMonthObj, InDayObj, OutMonthObj, OutDayObj, addDay);	
}

function CheckRateBoxCheckOutDayChange(formobj) {

	OutMonthObj = eval("formobj.outMonthList");
	OutDayObj = eval("formobj.outDayList");
	InMonthObj = eval("formobj.inMonthList");
	InDayObj = eval("formobj.inDayList");
	if (InMonthObj.selectedIndex == OutMonthObj.selectedIndex) {
		if (InDayObj.selectedIndex >= OutDayObj.selectedIndex) {
			//alert("Error");
			changeCheckInDay(formobj);
		}
	}
}

function FindOtherHotelCountryChange(formobj, section) {
	cityCounter = 0;
	countryObj = eval("formobj.countryList");
	cityObj = eval("formobj.cityList");
	hotelObj = eval("formobj.hotelList");
	countrySelected = countryObj.selectedIndex;
	lastCityName = "";
	clearOption(cityObj);
	if (section == 'corpHome') {
		hotelCounter = 0;
		clearOption(hotelObj);
		hotelObj = eval("formobj.hotelList");
		lastHotelID = -1;
	}	
	
	if (countrySelected>0)  {
		if (section == 'corpHome') {
			addOption(hotelObj, 0, "", "Please select");
			hotelObj.selectedIndex = 0;
		}
		//addOption(cityObj, 0, "", "Please select");
		cityObj.selectedIndex = 0;
		for (i=0;i<thisCityArray[countrySelected].length;i++) {
			if (section == 'specialRequest') {
				addOption(cityObj, cityObj.length, thisCityArray[countrySelected][i], thisCityValueArray[countrySelected][i]);
			} else {			
				addOption(cityObj, cityObj.length, thisCityArray[countrySelected][i], thisCityArray[countrySelected][i]);
			}
			if(thisCityArray[countrySelected][i] != lastCityName) {
				cityCounter++;
				lastCityName = thisCityArray[countrySelected][i];
			}
			if (section == 'corpHome') {
				// Please select item
				for (j=1;j<thisHotelArray[countrySelected][i].length;j++) {
		//			addOption(hotelObj, hotelObj.length, thisHotelArray[countrySelected][i][j], thisHotelArray[countrySelected][i][j]);
					addOption(hotelObj, hotelObj.length, hid[countrySelected][i][j], thisHotelArray[countrySelected][i][j]);
					if (hid[countrySelected][i][j] != lastHotelID) {
						hotelCounter++;
						lastHotelID = hid[countrySelected][i][j];
					}
				}
			}
		}
		if (cityCounter == 2) {
			cityObj.selectedIndex = 1;
			cityObj.options[0] = null;
		}
		if (section == 'corpHome') {
			if (hotelCounter == 1) {
				hotelObj.selectedIndex = 1;
				hotelObj.options[0] = null;
			}
		}
	}
}

function FindOtherHotelCityChange(formobj, section) {
	countryObj = eval("formobj.countryList");
	cityObj = eval("formobj.cityList");	
	countrySelected = countryObj.selectedIndex;
	citySelected = cityObj.selectedIndex;
	if (section == 'corpHome') {
		hotelCounter = 0;
		hotelObj = eval("formobj.hotelList");
		lastHotelID = -1;
	}	

	if (cityObj.length > 1) {
		if (section == 'corpHome') {
			clearOption(hotelObj);
		}
	
		addOption(hotelObj, 0, "Please select", "Please select");

		if (citySelected == 0) {
			for (i=1;i<thisCityArray[countrySelected].length;i++) {
				for (j=1;j<thisHotelArray[countrySelected][i].length;j++) {
					addOption(hotelObj, hotelObj.length, hid[countrySelected][i][j], thisHotelArray[countrySelected][i][j]);
					if (hid[countrySelected][i][j] != lastHotelID) {
						hotelCounter++;
						lastHotelID = hid[countrySelected][i][j];
					}
				}
			}
		} else {
			if (section == 'corpHome') {
				for (i=1;i<thisHotelArray[countrySelected][citySelected].length;i++) {
					addOption(hotelObj, hotelObj.length, hid[countrySelected][citySelected][i], thisHotelArray[countrySelected][citySelected][i]);
					//alert("hid[" + countrySelected + "][" + i + "][" + j  + "]");
					if (hid[countrySelected][citySelected][i] != lastHotelID) {
						hotelCounter++;
						lastHotelID = hid[countrySelected][citySelected][i];
					}
				}
			}
		}
		if (section == 'corpHome') {
			if (hotelCounter == 1) {
				hotelObj.selectedIndex = 1;
				hotelObj.options[0] = null;
			}
		}
	}
}

function WeddingEnquiryMonthChange(formobj) {

	MonthObj = eval("formobj.monthList");
	dayObj = eval("formobj.dayList");
	monthSelected = MonthObj.selectedIndex;
	
	clearOption(dayObj);

	for (i=1;i<=thisDayArray[monthSelected];i++) {
		addOption(dayObj, dayObj.length, i, i);
	}

}

// PT imageClick 
function PTImgClick(lang, hotelCode, hotelType, id, Nam, target) {
	currentSelectedPT = Nam;
	tempWeb = eval("parent.frames['" + target + "'].location");
	tempWeb.href = "/common/phototour/" + lang + "/index.aspx?hoteltype=" + hotelType + "&hotelShortCode=" + hotelCode + "&selectedID=" + id;
	document.images["PT"].src = PTLeft_off.src;
			
	
}
// PT imageON
function PTImgOn(Nam) {
	if (document.images) {
		document.images["PT"].src = eval(Nam + ".src");
		document.images[currentSelectedPT].src = PTLeft_off.src; 
		document.images[Nam].src = PTLeft_on.src;
	}
}

// PT imageON 
function PTImgOff(Nam) {
	if (document.images) {
		document.images["PT"].src = PTLeft_off.src;
		document.images[Nam].src = PTLeft_off.src; 
		document.images[currentSelectedPT].src = PTLeft_on.src; 
		//document.images["PT"].src = eval(currentSelectedPT + ".src");
	}
}

// Show Image
function ImgOn(Nam) {
	if (document.images) {
		document.images[Nam].src = eval(Nam+ "_on.src");
    }
}

// Hide Image
function ImgOff(Nam) {
	if (document.images) {
		document.images[Nam].src = eval(Nam+ "_off.src");
    }
}

// Show Image of header Nav
function ImgOnHead(Nam) {
	if (document.images) {
		document.images[Nam].src = eval(Nam+ "_on.src");
    }
}

// Hide Image of header Nav
function ImgOffHead(Nam) {
	if (document.images) {
		document.images[Nam].src = eval(Nam+ "_off.src");
    }
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function changeCheckButton(status) {
	if (hotelType == "") {
		if (IE) {
			if (status == 1) {
				document.all["CheckButtonDiv"].innerHTML = '<a href="javascript:validation(document.forms[0]);void(0);"><img src="/images/corp/button/en/but_checkavil_on.gif" border="0"></a>';
			} else {
				document.all["CheckButtonDiv"].innerHTML = '<img src="/images/corp/button/en/but_checkavil.gif" border="0">';
			}
		} else {
			if (status == 1) {
				document.getElementById("CheckButtonDiv").innerHTML = '<a href="javascript:validation(document.forms[0]);void(0);"><img src="/images/corp/button/en/but_checkavil_on.gif" border="0"></a>';
			} else {
				document.getElementById("CheckButtonDiv").innerHTML = '<img src="/images/corp/button/en/but_checkavil.gif" border="0">';
			}
		}
	}
}

function ChangeCareersApplyButton(status) {
	if (IE) {
		if (status == 1) {
			document.all["ApplyButtonDiv"].innerHTML = '<a href="javascript:ClearForm(document.forms[0]);"><img src="/images/corp/button/en/but_resetyl.gif" alt="Reset" border="0" /></a><img height="1" src="/images/blank.gif" width="28"><a href="javascript:validation(document.forms[0]);void(0);"><img src="/images/corp/button/en/but_subappyl_on.gif" border="0"></a>';
		} else {
			document.all["ApplyButtonDiv"].innerHTML = '<a href="javascript:ClearForm(document.forms[0]);"><img src="/images/corp/button/en/but_resetyl.gif" alt="Reset" border="0" /></a><img height="1" src="/images/blank.gif" width="28"><img src="/images/corp/button/en/but_subappyl.gif" border="0">';
		}
	} else {
		if (status == 1) {
			document.getElementById("ApplyButtonDiv").innerHTML = '<a href="javascript:ClearForm(document.forms[0]);"><img src="/images/corp/button/en/but_resetyl.gif" alt="Reset" border="0" /></a><img height="1" src="/images/blank.gif" width="28"><a href="javascript:validation(document.forms[0]);void(0);"><img src="/images/corp/button/en/but_subappyl_on.gif" border="0"></a>';
		} else {
			document.getElementById("ApplyButtonDiv").innerHTML = '<a href="javascript:ClearForm(document.forms[0]);"><img src="/images/corp/button/en/but_resetyl.gif" alt="Reset" border="0" /></a><img height="1" src="/images/blank.gif" width="28"><img src="/images/corp/button/en/but_subappyl.gif" border="0">';
		}
	}
}

function ChangeRedemptionButton(status) {
	if (IE) {
		if (status == 1) {
			//document.all["PrintFormButtonDiv"].innerHTML = '<a href="javascript:gotoPrint(\'printform.aspx\');"><img src="/images/corp/button/en/button_printredemption.gif" border="0"></a>';
			document.all["PrintFormButtonDiv"].innerHTML = '<a href="javascript:PrintPage(this.form);void(0);"><img src="/images/corp/button/en/button_printredemption.gif" border="0"></a>';
			document.all["RedemptionButtonDiv"].innerHTML = '<a href="javascript:Validate(document.forms[0]);void(0);"><img src="/images/corp/button/en/button_redeemonline.gif" border="0"></a>'; 
			//document.all["RedemptionButtonDiv"].innerHTML = '<img src="/images/corp/button/en/button_redeemonline_off.gif" border="0">';faizsl do one
		} else {
			document.all["PrintFormButtonDiv"].innerHTML = '<img src="/images/corp/button/en/button_printredemption_off.gif" border="0">';
			document.all["RedemptionButtonDiv"].innerHTML = '<img src="/images/corp/button/en/button_redeemonline_off.gif" border="0">';
		}
	} else {
		if (status == 1) {
			document.getElementById("PrintFormButtonDiv").innerHTML = '<a href="javascript:gotoPrint(\'printform.aspx\');"><img src="/images/corp/button/en/button_printredemption.gif" border="0"></a>';
			document.getElementById("PrintFormButtonDiv").innerHTML = '<a href="javascript:PrintPage(this.form);void(0);"><img src="/images/corp/button/en/button_printredemption.gif" border="0"></a>';
			document.getElementById("RedemptionButtonDiv").innerHTML = '<a href="javascript:Validate(document.forms[0]);void(0);"><img src="/images/corp/button/en/button_redeemonline.gif" border="0"></a>'; 
			//document.getElementById("RedemptionButtonDiv").innerHTML = '<img src="/images/corp/button/en/button_redeemonline_off.gif" border="0">';faizal
		} else {		
			document.getElementById("PrintFormButtonDiv").innerHTML = '<img src="/images/corp/button/en/button_printredemption_off.gif" border="0">';
			document.getElementById("RedemptionButtonDiv").innerHTML = '<img src="/images/corp/button/en/button_redeemonline_off.gif" border="0">';
		}
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ChangeButton_bak(formobj) {
	OutDayObj = eval("formobj.outDayList");
	InDayObj = eval("formobj.inDayList");
	if (OutDayObj[OutDayObj.selectedIndex].value == "" || InDayObj[InDayObj.selectedIndex].value == "") {
		changeCheckButton(0);
	}
	if (OutDayObj[OutDayObj.selectedIndex].value != "" && InDayObj[InDayObj.selectedIndex].value != "") {
		changeCheckButton(1);
	}	
}

// Preload user control agency image
/* Put 4 lines into CheckInOutDate.ascx.cs
but_agency_on = new Image();
but_agency_on.src = "/images/hotels/city/ucontrol/en/h_ucbut_cta_on.gif";
but_agency_off = new Image();
but_agency_off.src = "/images/hotels/city/ucontrol/en/h_ucbut_cta_off.gif";
*/

// Javascript of the DHTML Tree Menu

function setLMCookie(name, value)
{
	document.cookie = name + '=' + value + ';path=/';
}

function getLMCookie(name)
{
	foobar = document.cookie.split(name + '=');
	if (foobar.length < 2) {
		return null;
	}
	tempString = foobar[1];
	if (tempString.indexOf(';') == -1) {
		return tempString;
	}
	yafoobar = tempString.split(';');
	return yafoobar[0];
}

function parseExpandString()
{
	expandString = getLMCookie('phplm_expand');
	phplm_expand = new Array();
	if (expandString) {
		expanded = expandString.split('|');
		for (i=0; i<expanded.length-1; i++) {
			phplm_expand[expanded[i]] = 1;
		}
	}
}

function parseCollapseString()
{
	collapseString = getLMCookie('phplm_collapse');
	phplm_collapse = new Array();
	if (collapseString) {
		collapsed = collapseString.split('|');
		for (i=0; i<collapsed.length-1; i++) {
			phplm_collapse[collapsed[i]] = 1;
		}
	}
}

parseExpandString();
parseCollapseString();

function saveExpandString()
{
	expandString = '';
	for (i=0; i<phplm_expand.length; i++) {
		if (phplm_expand[i] == 1) {
			expandString += i + '|';
		}
	}
	setLMCookie('phplm_expand', expandString);
}

function saveCollapseString()
{
	collapseString = '';
	for (i=0; i<phplm_collapse.length; i++) {
		if (phplm_collapse[i] == 1) {
			collapseString += i + '|';
		}
	}
	setLMCookie('phplm_collapse', collapseString);
}

function toggletreemenu1(nodeid)
{
	if ((!DOM || Opera56 || Konqueror22) && !IE4) {
		return;
	}
	layersMoved = 0;
	parseExpandString();
	parseCollapseString();
	var sonLayer = "";
	if (!IE4) {
		sonLayer = document.getElementById('jt' + nodeid + 'son');
		nodeLayer = document.getElementById('jt' + nodeid + 'node');
		folderLayer = document.getElementById('jt' + nodeid + 'folder');
	} else {
		sonLayer = document.all('jt' + nodeid + 'son');
		nodeLayer = document.all('jt' + nodeid + 'node');
		folderLayer = document.all('jt' + nodeid + 'folder');
	}
	if (sonLayer.style.display == 'none') {
		// open the hidden section
		sonLayer.style.display = 'block';
		if (nodeid == 2) {
			ImgOn('but_agency');
		}
		phplm_expand[nodeid] = 1;
		phplm_collapse[nodeid] = 0;
	} else {
		// close the hidden section
 		sonLayer.style.display = 'none';
 		if (nodeid == 2) {
			ImgOff('but_agency');
		}
		phplm_expand[nodeid] = 0;
		phplm_collapse[nodeid] = 1;
	}
	saveExpandString();
	saveCollapseString();
}
/*
if ((DOM && !Opera56 && !Konqueror22) || IE4) {
	if (phplm_collapse[2] == 1) toggletreemenu1('2');
	if (phplm_collapse[3] == 1) toggletreemenu1('3');
}
if (NS4) alert("Only the accessibility is provided to Netscape 4 on the JavaScript Tree Menu.\nWe *strongly* suggest you to upgrade your browser.");
*/

function clearFormElement(formobj, formelm) {
	ClearObj = eval("formobj." + formelm);
	ClearObj.value = "";
}

function virtualTourPopUp(targetURL)
{
	OpenWin = window.open(targetURL, 'VTP', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=355,height=362,left=90,top=90');
}

function photoGalleryPopUp(targetURL)
{
	OpenWin = window.open(targetURL, '', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=355,height=380,left=90,top=90');
}

function mapPopUp(targetURL)
{
	window.open(targetURL, '', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=440,height=390,left=90,top=90');
}

function careerPopUp(targetURL)
{
	var browser = new BrowserDetect();
	if ( browser.isIE ) { 
			OpenWin = window.open(targetURL, 'CareerWindow', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=516,height=450,left=90,top=90');
	} else if( browser.isMac && browser.isNS7up ) { 
		OpenWin = window.open(targetURL, 'CareerWindow', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=498,height=490,left=90,top=90');
	} else if( browser.isMac || browser.isNS62down ) {
		OpenWin = window.open(targetURL, 'CareerWindow', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=498,height=450,left=90,top=90');
	}  else {
		OpenWin = window.open(targetURL, 'CareerWindow', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=498,height=455,left=90,top=90');
	}
}

function gcBenefitPopUp(targetURL)
{
	var browser = new BrowserDetect();
	if( browser.isMac && browser.isNS7up ) { 
		OpenWin = window.open(targetURL, 'CareerWindow', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=no,width=464,height=490,left=90,top=90');
	} else if( browser.isMac || browser.isNS62down ) {
		OpenWin = window.open(targetURL, 'CareerWindow', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=no,width=462,height=490,left=90,top=90');
	}  else {
		OpenWin = window.open(targetURL, 'CareerWindow', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=no,width=489,height=490,left=90,top=90');
	}
}


function PopUpWindow (url,width,height,resizable) {
	OpenWin = window.open(url, "CtrlWindow", "status=no,toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable="+resizable+",width="+ width + ",height=" + height + ",left=90,top=90");
}

/*
function changeVT(selObj, tergetURL)
{ 
	selectedVTNumber = selObj.options[selObj.selectedIndex].value
	if ( selectedVTNumber!="#" )
	{
		location.href = tergetURL + selectedVTNumber;
	}
}
*/

function changeVT(selObj, tergetURL, target)
{ 
	selectedVTNumber = selObj.options[selObj.selectedIndex].value
	if ( selectedVTNumber!="#" )
	{
		if (target == "self" || target == "") {
			//alert(tergetURL + selectedVTNumber);
			location.href = tergetURL + selectedVTNumber;
		} else {
			//tempWeb = eval("document." + target + ".location");
			tempWeb = eval("parent.frames['" + target + "'].location");
			//tempWeb = eval("document.layers['" +target + "'].location");
			tempWeb.href = tergetURL + selectedVTNumber;
		}
		
	}
}

function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS62down = (this.isNS && this.versionMajor < 6.2);
   this.isNS7down = (this.isNS && this.versionMajor < 7);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE55down = (this.isIE && this.versionMinor < 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isSafari1down = (this.isSafari && this.versionMajor <= 1);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}

var expDays = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
	var j = i + alen;    
	if (document.cookie.substring(i, j) == arg)      
	return getCookieVal (j);    
	i = document.cookie.indexOf(" ", i) + 1;    
	if (i == 0) break;   
	}  
	return null;
}
function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : "/";
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function BrowserSupportPopup(langCode) {
	var isBrowserChecked = GetCookie('browserDetected');
	if (isBrowserChecked == null) {
		SetCookie('browserDetected', 'true', exp);
		var browser = new BrowserDetect();
		if (browser.isMac) {
			if (browser.isSafari1down || browser.isNS7down || browser.isIE) {
				PopUpWindow('/common/browserupgrade/' + langCode + '/index.aspx', 440, 280, 'no');		
			}
		}
		if (browser.isWin || browser.isWin32) {
			if (browser.isIE55down || browser.isNS62down) {
			//if (browser.isIE5up || browser.isNS62down) {
				PopUpWindow('/common/browserupgrade/' + langCode + '/index.aspx', 440, 280, 'no');
			}
		}
	}
}

function NetscapeDetection() {
	var browser = new BrowserDetect();
	if ((browser.isWin || browser.isWin32) && browser.isNS62down) {
		return false;
	}
	return true;
}


function FlashBrowserDetect(langCode) {
	var browser = new BrowserDetect();
	if ((browser.isWin || browser.isWin32) && browser.isNS62down) {
		return false;
	}
	else {
		var flashinstalled = 0;
		var flashversion = 0;
		if (navigator.plugins && navigator.plugins.length) {
			if( !navigator.plugins["Shockwave Flash"] && !navigator.plugins["Shockwave Flash 2.0"] ) {
					return false;
			}
		} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
			x = navigator.mimeTypes['application/x-shockwave-flash'];
			if( !(x && x.enabledPlugin) ) {
				return false;
			}
		}	
	}
	return true;
}


// for popup calendar use
function UpdatePopUpCalendar(selectedSource, date, month, addDay) {
	if (selectedSource == "in") {
		OutMonthObj = eval("document.forms[0].outMonthList");
		OutDayObj = eval("document.forms[0].outDayList");
		InMonthObj = eval("document.forms[0].inMonthList");
		InDayObj = eval("document.forms[0].inDayList");
		InMonthObj.selectedIndex = month;
		clearOption(InDayObj);
		if (hotelType == "") {
			addOption(InDayObj, InDayObj.length, "", "--");
		}
		for (i=1;i<=thisDayArray[month];i++) {
			addOption(InDayObj, InDayObj.length, i, i);
		}

		if (hotelType == "") {
			InDayObj.selectedIndex = date;
		} else {
			InDayObj.selectedIndex = date - 1;
		}
		
		UpdateInOutDate(InMonthObj, InDayObj, OutMonthObj, OutDayObj, addDay);	
	} else {
		sourceMonthObj = eval("document.forms[0]." + selectedSource + "MonthList");
		sourceDayObj = eval("document.forms[0]." + selectedSource + "DayList");

		sourceMonthObj.selectedIndex = month;
		clearOption(sourceDayObj);
		if (hotelType == "") {
			addOption(sourceDayObj, sourceDayObj.length, "", "--");
		}
		for (i=1;i<=thisDayArray[month];i++) {
			addOption(sourceDayObj, sourceDayObj.length, i, i);
		}

		if (hotelType == "") {
			sourceDayObj.selectedIndex = date;
		}
		else {
			sourceDayObj.selectedIndex = date-1;
		}
	}
	ChangeButton(document.forms[0]);
}

function PopUpCalendar(inComingString, langCode, addDay) {
	window.selectedDate=eval('document.forms[0].' + inComingString + 'DayList');
	window.selectedMonth=eval('document.forms[0].' + inComingString + 'MonthList');
	window.selectedLang = langCode;
	window.selectedSource = inComingString;
	window.addDay = addDay;
	var url = '/common/calendar/' + langCode + '/index.html';
	
	
	var loc = document.location.toString();
	var index = loc.indexOf(":");
	if( index=="5" ) {
		url = 'https://' + document.domain + '/common/calendar/' + langCode + '/index.html';
	}
	
	var browser = new BrowserDetect();
	var windowWidth = 160;
	var windowHeight = 190;
	if (browser.isMac) {
		if( browser.isNS7up ) {
			windowWidth = 158;
			windowHeight = 245;	
		} else {
			windowWidth = 158;
			windowHeight = 205;	
		}
	} else if (browser.isNS || browser.isMozilla) {
		windowWidth = 160;
		windowHeight = 205;	
	} 
	calendar=window.open(url,"Calendar","status=no,toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=no,width=" + windowWidth + ",height=" + windowHeight + ",left=90,top=90");
	calendar.window.focus();
}

function PopUpPassword(langCode) {

	var url = "/member/" + langCode + "/forgotpwd2.aspx";
	var browser = new BrowserDetect();
	var windowWidth = 431;
	var windowHeight = 400;
	if( browser.isMac && browser.isNS7up ) {
		windowWidth = 431;
		windowHeight = 460;	 
	} else if (browser.isNS || browser.isMozilla) {
		windowWidth = 431;
		windowHeight = 400;	
	} 
	PwdWin=window.open(url,"Forgot","status=no,toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=no,width=" + windowWidth + ",height=" + windowHeight + ",left=90,top=90");
	PwdWin.window.focus();
}

function AccountActivationPopUp(url) {
	var browser = new BrowserDetect();
	var windowWidth = 500;
	var windowHeight = 328;
	if (browser.isMac) {
		windowWidth = 498;
		if( browser.isNS7up ) {
			windowHeight = 365;
		} else {
			windowHeight = 328;
		}
	}
	PwdWin=window.open(url,"Forgot","status=no,toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=no,width=" + windowWidth + ",height=" + windowHeight + ",left=90,top=90");
	PwdWin.window.focus();
}

function opt(href,text, k) {
	var optionName = new Option(text, href, false, false)
	var length = parseInt(k);
	document.forms[0].GC_STATE.options[length] = optionName;
	document.forms[0].GC_STATE.options[0].selected = true;  
	length = length + 1;
	return length;
}	



// Dynamic generate corresponding states, especially Australia,China,Malaysia,United Kingdom&USA
function showlinks(country,k) {
	var count = parseInt(k);

	if ( !(country=='Australia') && !(country=='China') && !(country=='Malaysia') && !(country=='United Kingdom') && !(country=='United States') && !(country=='United Arab Emirates') && !(country=='Russian Federation') && !(country=='India') && !(country=='Ireland(Eire)') ) {	
		count = opt('','Select one...', count);
	}	
	
    	if ( country=='Australia' ) {
		count = opt('','Select one...', count);
	    	count = opt('ACT','Aust Cap. Territory', count);
		count = opt('NSW','New South Wales', count);
		count = opt('NT','Northern Territory', count);
		count = opt('QLD','Queensland', count);
		count = opt('SA','South Australia', count);
		count = opt('TAS','Tasmania', count);
		count = opt('VIC','Victoria', count);
		count = opt('WA','Western Australia', count);
    	}
    	
    	if ( country=='China' ) {
		count = opt('','Select one...', count);
		count = opt('AHS','Anhui Province', count);
		count = opt('PEK','Beijing', count);
		count = opt('CKG','Chongqing', count);
		count = opt('FJS','Fujian Province', count);
		count = opt('GSS','Gansu Province', count);
		count = opt('GDS','Guangdong Province', count);
		count = opt('GXZ','Guangxi Province', count);
		count = opt('GZS','Guizhou Province', count);
		count = opt('HNS','Hainan Province', count);
		count = opt('HBS','Hebei Province', count);
		count = opt('HLJ','Heilongjiang Prov', count);
		count = opt('HEN','Henan Province', count);
		count = opt('HUS','Hubei Province', count);
		count = opt('HUN','Hunan Province', count);
		count = opt('JSS','Jiangsu Province', count);
		count = opt('JXS','Jiangxi Province', count);
		count = opt('JLS','Jilin Province', count);
		count = opt('LNS','Liaoning Province', count);
		count = opt('NMZ','Neimenggu', count);
		count = opt('NXZ','Ningxia', count);
		count = opt('QHS','Qinghai Province', count);
		count = opt('SDS','Shandong Province', count);
		count = opt('SHA','Shanghai', count);
		count = opt('SIS','Shanxi Prov (Datong)', count);
		count = opt('SXS','Shanxi Prov (Xian)', count);
		count = opt('SZX','Shenzhen (Guangdong)', count);
		count = opt('SCS','Sichuan Province', count);
		count = opt('TSN','Tianjin', count);
		count = opt('XJW','Xinjiang', count);
		count = opt('XZZ','Xizang', count);
		count = opt('YNS','Yunnan', count);
		count = opt('ZJS','Zhejiang Province', count);
    	}
    	
	if ( country=='Canada' ) {
		count = opt('AB','Alberta', count);
		count = opt('BC','British Columbia', count);
		count = opt('MB','Manitoba', count);
		count = opt('NB','New Brunswick', count);
		count = opt('NF','Newfoundland', count);
		count = opt('NT','Northwest Territory', count);
		count = opt('NS','Nova Scotia', count);
		count = opt('ON','Ontario', count);
		count = opt('PE','Prince Edward Island', count);
		count = opt('PQ','Quebec', count);
		count = opt('SK','Saskatchewan', count);
		count = opt('YT','Yukon Territories', count);
	}
	
    	if ( country=='Malaysia' ) {
		count = opt('','Select one...', count);
		count = opt('JH','Johor', count);
		count = opt('KD','Kedah', count);
		count = opt('KT','Kelantan', count);
		count = opt('KL','Kula Lumpur W.P.', count);
		count = opt('LB','Labuan W.P', count);
		count = opt('ML','Melaka', count);
		count = opt('NS','Negeri Sembilan', count);
		count = opt('PH','Pahang', count);
		count = opt('PG','Penang', count);
		count = opt('PK','Perak', count);
		count = opt('PL','Perlis', count);
		count = opt('SB','Sabah', count);
		count = opt('SW','Sarawak', count);
		count = opt('SL','Selangor', count);
		count = opt('TG','Terengganu', count);
    	}
    	
	if ( country=='United Kingdom' ) {
		count = opt('','Select one...', count);
		count = opt('AVN','Avon', count);
		count = opt('BDF','Bedfordshire', count);
		count = opt('BEL','Belfast (N. Ireland)', count);
		count = opt('BRK','Berkshire', count);
		count = opt('BOR','Borders (Scotland)', count);
		count = opt('BKM','Buckinghamshire', count);
		count = opt('CAM','Cambridgeshire', count);
		count = opt('CEN','Central (Scotland)', count);
		count = opt('CHS','Cheshire', count);
		count = opt('CLV','Cleveland', count);
		count = opt('CWD','Clwyd (Wales)', count);
		count = opt('CON','Cornwall', count);
		count = opt('ANT','County Antrim (N. Ireland)', count);
		count = opt('DOW','County Down (N. Ireland)', count);
		count = opt('LDY','County Londonderry (N. Ireland)', count);
		count = opt('ARM','County Armagh (N. Ireland)', count);
		count = opt('FER','County Fermanagh (N. Ireland)', count);
		count = opt('TYR','County Tyrone (N. Ireland)', count);
		count = opt('CMA','Cumbria', count);
		count = opt('DBY','Derbyshire', count);
		count = opt('DEV','Devon', count);
		count = opt('DOR','Dorset', count);
		count = opt('DGY','Dumfries & Galloway (Scotland)', count);
		count = opt('DUR','Durham', count);
		count = opt('DFD','Dyfed (Wales)', count);
		count = opt('SXE','East Sussex', count);
		count = opt('ESS','Essex', count);
		count = opt('FIF','Fife (Scotland)', count);
		count = opt('GLS','Gloucestershire', count);
		count = opt('GMP','Grampian (Scotland)', count);
		count = opt('LON','Greater London', count);
		count = opt('GTM','Greater Manchester', count);
		count = opt('GNT','Gwent (Wales)', count);
		count = opt('GWN','Gwynedd (Wales)', count);
		count = opt('HAM','Hampshire', count);
		count = opt('HWR','Hereford & Worcester', count);
		count = opt('HRT','Hertfordshire', count);
		count = opt('HLD','Highland (Scotland)', count);
		count = opt('HUM','Humberside', count);
		count = opt('IOM','Isle of Man', count);
		count = opt('IOW','Isle Of Wight', count);
		count = opt('IOS','Isles of Scilly', count);
		count = opt('KEN','Kent', count);
		count = opt('LAN','Lancashire', count);
		count = opt('LEI','Leicestershire', count);
		count = opt('LIN','Lincolnshire', count);
		count = opt('LTN','Lothian (Scotland)', count);
		count = opt('MSY','Merseyside', count);
		count = opt('MGM','Mid Glamorgan-Wales', count);
		count = opt('NFK','Norfolk', count);
		count = opt('NYK','North Yokrshire', count);
		count = opt('NTH','Northamptonshire', count);
		count = opt('NBL','Northumberland', count);
		count = opt('NTT','Nottinghamshire', count);
		count = opt('OKI','Orkney (Scotland)', count);
		count = opt('OXF','Oxfordshire', count);
		count = opt('POW','Powys (Wales)', count);
		count = opt('SHI','Shetland (Scotland)', count);
		count = opt('SAL','Shropshire', count);
		count = opt('SOM','Somerset', count);
		count = opt('SGM','South Glamorgan (Wales)', count);
		count = opt('SYK','South Yorkshire', count);
		count = opt('STS','Staffordshire', count);
		count = opt('STD','Strathclyde (Scotland)', count);
		count = opt('SFK','Suffolk', count);
		count = opt('SRY','Surrey', count);
		count = opt('TAY','Tayside (Scotland)', count);
		count = opt('TWR','Tyne & Wear', count);
		count = opt('WAR','Warwickshire', count);
		count = opt('WGM','West Glamorgan (Wales)', count);
		count = opt('WMD','West Midland', count);
		count = opt('SXW','West Sussex', count);
		count = opt('WYK','West Yorkshire', count);
		count = opt('WIS','Western Isles (Scotland)', count);
		count = opt('WIL','Wiltshire', count);
	}

	if ( country=='United States' ) {
		count = opt('','Select one...', count);
		count = opt('AL','Alabama', count);
		count = opt('AK','Alaska', count);
		count = opt('AS','American Samoa', count);
		count = opt('AZ','Arizona', count);
		count = opt('AR','Arkansas', count);
		count = opt('AA','Armed Forces America', count);
		count = opt('AE','Armed Forces Europe', count);
		count = opt('AP','Armed Forces Pacific', count);
		count = opt('CA','California', count);
		count = opt('CO','Colorado', count);
		count = opt('CT','Connecticut', count);
		count = opt('DE','Delaware', count);
		count = opt('DC','District of Columbia', count);
		count = opt('FL','Florida', count);
		count = opt('GA','Georgia', count);
		count = opt('GU','Guam', count);
		count = opt('HI','Hawaii', count);
		count = opt('ID','Idaho', count);
		count = opt('IL','Illinois', count);
		count = opt('IN','Indiana', count);
		count = opt('IA','Iowa', count);
		count = opt('KS','Kansas', count);
		count = opt('KY','Kentucky', count);
		count = opt('LA','Louisiana', count);
		count = opt('ME','Maine', count);
		count = opt('MD','Maryland', count);
		count = opt('MA','Massachusetts', count);
		count = opt('MI','Michigan', count);
		count = opt('MN','Minnesota', count);
		count = opt('MS','Mississippi', count);
		count = opt('MO','Missouri', count);
		count = opt('MT','Montana', count);
		count = opt('NE','Nebraska', count);
		count = opt('NV','Nevada', count);
		count = opt('NH','NewHampshire', count);
		count = opt('NJ','NewJersey', count);
		count = opt('NM','NewMexico', count);
		count = opt('NY','NewYork', count);
		count = opt('NC','North Carolina', count);
		count = opt('ND','North Dakota', count);
		count = opt('OH','Ohio', count);
		count = opt('OK','Oklahoma', count);
		count = opt('OR','Oregon', count);
		count = opt('PA','Pennsylvania', count);
		count = opt('PR','Puerto Rico', count);
		count = opt('RI','Rhode Island', count);
		count = opt('SC','South Carolina', count);
		count = opt('SD','South Dakota', count);
		count = opt('TN','Tennessee', count);
		count = opt('TX','Texas', count);
		count = opt('UT','Utah', count);
		count = opt('VT','Vermont', count);
		count = opt('VI','Virgin Islands', count);
		count = opt('VA','Virginia', count);
		count = opt('WA','Washington', count);
		count = opt('WV','West Virginia', count);
		count = opt('WI','Wisconsin', count);
		count = opt('WY','Wyoming', count);
    	}
    
    	if ( country=='United Arab Emirates' ) {
		count = opt('','Select one...', count);
		count = opt('AUH','Abu Dhabi', count);    
		count = opt('DXB','Dubai', count);    
		count = opt('SHJ','Sharjah', count);    
		count = opt('AJM','Ajman', count);    
		count = opt('UIK','Umm al-Qaiwain', count);    
		count = opt('RKT','Ras al-Khaimah', count);    
		count = opt('FJR','Fujairah', count);    
    	}
    
    	if ( country=='Russian Federation' ) {
		count = opt('','Select one...', count);
		count = opt('ADY','Adygeya', count);
        	count = opt('ALT','Altai', count);
        	count = opt('BAS','Bashkortostan', count);
        	count = opt('BYT','Buryatia', count);
        	count = opt('CJC','Chechnya', count);
        	count = opt('CHU','Chuvash', count);
        	count = opt('RUT','Daghestan', count);
        	count = opt('ING','Ingushetia', count);
        	count = opt('KBB','Kabardino-Balkarian', count);
        	count = opt('KGZ','Kalmykia', count);
        	count = opt('KCC','Karachayevo-Circassian', count);
        	count = opt('KAR','Karelia', count);
        	count = opt('KKS','Khakassia', count);
        	count = opt('KOM','Komi', count);
        	count = opt('MAR','Marii El', count);
        	count = opt('MOR','Mordovia', count);
        	count = opt('NOS','North Ossetia', count);
        	count = opt('SAK','Sakha (Yakutia)', count);
        	count = opt('TAT','Tatarstan', count);
        	count = opt('TZK','Tuva', count);
        	count = opt('UDM','Udmurtia', count);
    	}

    	if ( country=='India' ) {
		count = opt('','Select one...', count);
        	count = opt('AN','Andaman & Nicobar', count);
        	count = opt('AP','Andhra Pradesh', count);
        	count = opt('AR','Arunachal Pradesh', count);
        	count = opt('AS','Assam', count);
        	count = opt('BR','Bihar', count);
        	count = opt('CHD','Changigarh', count);
        	count = opt('CT','Chhattisgarh', count);
        	count = opt('DHH','Dadra & Nagar Haveli', count);
        	count = opt('DD','Daman & Diu', count);
        	count = opt('DEL','Delhi', count);
        	count = opt('GOA','Goa', count);
        	count = opt('GUJ','Gujarat', count);
        	count = opt('HR','Haryana', count);
        	count = opt('HP','Himachal Pradesh', count);
        	count = opt('JK','Jammu & Kashmir', count);
	        count = opt('JH','Jharkhand', count);
	        count = opt('KRN','Karnataka', count);
	        count = opt('KER','Kerala', count);
	        count = opt('LKP','Lakshadweep', count);
	        count = opt('MP','Madhya Pradesh', count);
	        count = opt('MAH','Maharashtra', count);
	        count = opt('MNP','Manipur', count);
	        count = opt('MEG','Meghalaya', count);
	        count = opt('MIZ','Mizoram', count);
	        count = opt('NLD','Nagaland', count);
	        count = opt('OR','Orissa', count);
	        count = opt('PDY','Pondicherry', count);
	        count = opt('PB','Punjab', count);
	        count = opt('RAJ','Rajasthan', count);
	        count = opt('SKM','Sikkim', count);
	        count = opt('TN','Tamil Nadu', count);
	        count = opt('TRP','Tripura', count);
	        count = opt('UP','Uttar Pradesh', count);
	        count = opt('UL','Uttaranchai', count);
	        count = opt('WB','West Bengal', count);		
    	}

    	if ( country=='Ireland(Eire)' ) {
		count = opt('','Select one...', count);
	        count = opt('CAR','Carlow (Ireland)', count);
	        count = opt('CAV','Cavan (Ireland)', count);
	        count = opt('CLA','Clare (Ireland)', count);
	        count = opt('COR','Cork (Ireland)', count);
	        count = opt('DON','Donegal (Ireland)', count);
	        count = opt('DUB','Dublin (Ireland)', count);
	        count = opt('GAL','Galway (Ireland)', count);
	        count = opt('KER','Kerry (ireland)', count);
	        count = opt('KID','Kildare (Ireland)', count);
	        count = opt('KIK','Kilkenny (Ireland) ', count);
	        count = opt('LEX','Laois (Ireland)', count);
	        count = opt('LET','Leitrim (Ireland)', count);
	        count = opt('LIM','Limerick (Ireland)', count);
	        count = opt('LOG','Longford (Ireland)', count);
	        count = opt('LOU','Louth (Ireland)', count);
	        count = opt('MAY','Mayo (Ireland)', count);
	        count = opt('MEA','Meath (Ireland)', count);
	        count = opt('MOG','Monaghan (Ireland)', count);
	        count = opt('OFF','Offaly (Ireland)', count);
	        count = opt('ROS','Roscommon (Ireland)', count);
	        count = opt('SLI','Sligo (Ireland)', count);
	        count = opt('TIP','Tipperary (Ireland)', count);
	        count = opt('WAT','Waterford (Ireland)', count);
	        count = opt('WEM','Westmeath (Ireland)', count);
	        count = opt('WEX','Wexford (Ireland)', count);
	        count = opt('WIC','Wicklow (Ireland)', count);
    	}
}


function reshow() {
	var k = 0;
	for (i=document.forms[0].GC_STATE.length; i >0; i--) {
		document.forms[0].GC_STATE.options[i] = null;							
	}

	for (i=0; i<document.forms[0].GC_LAND.length; i++) {
		if ( document.forms[0].GC_LAND[i].selected ) {
			country = document.forms[0].GC_LAND[i].text						
		}
	}
	
	document.forms[0].GC_STATE.options[0] = null;
	showlinks(country, k);
	document.forms[0].GC_STATE.options[0].selected = true;   
}

function gotoPrint(thisURL)
{
    msgWin = window.open(thisURL,"printWindowOpener","HEIGHT=600,WIDTH=620,resizeable=no,status=no,toolbar=yes,directories=no,menubar=yes,location=no,scrollbars=yes,left=90,top=90");
    if (!msgWin.opener) msgWin.opener = self;
    setTimeout("msgWin.focus()",500);
}

function gotoReservationsPrint(thisURL)
{
    msgWin = window.open(thisURL,"printWindowOpener","HEIGHT=600,WIDTH=665,resizeable=no,status=no,toolbar=yes,directories=no,menubar=yes,location=no,scrollbars=yes,left=90,top=90");
    if (!msgWin.opener) msgWin.opener = self;
    setTimeout("msgWin.focus()",500);
}

// For Currency Converter
function popConverter() {
  msg = open("/common/en/converter.htm","ConverterWindow","HEIGHT=280,WIDTH=525,status=no,toolbar=no,directories=no,menubar=no,location=no,scrollbars=yes,left=90,top=90");
}

function UpgradeImageOn(imgname) {
  if (document.images) {
    var src = document[imgname].src;
    var mode = src.lastIndexOf("_off");
    if (mode != -1)
      document[imgname].src = src.substring(0,mode) + "_on.gif";
  }
}
function UpgradeImageOff(imgname) {
  if (document.images) {
    var src = document[imgname].src;
    var mode = src.lastIndexOf("_on");
    if (mode != -1)
      document[imgname].src = src.substring(0,mode) + "_off.gif";
  }
}

function UpgradePhaseChange(imgpath) {
  if (document.images) {
    document['phase'].src  = imgpath;
    
  }
}

function UpgradeGalleryPopUp(targetURL)
{
	var browser = new BrowserDetect();
	if (browser.isMac) {
		if( browser.isNS7up ) {
			OpenWin = window.open(targetURL, '', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=353,height=420,left=90,top=90');
		} else {
			OpenWin = window.open(targetURL, '', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=353,height=380,left=90,top=90');
		}
	} else {
		OpenWin = window.open(targetURL, '', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=355,height=380,left=90,top=90');
	}
}


function FaqPopUp(thisURL) {
	var browser = new BrowserDetect();
	if ((browser.isWin || browser.isWin32) && browser.isNS62down) {
		var faq = window.open(thisURL,'faqpop','scrollbars=yes,resizable=no,width=714,height=450,screenX=30,screenY=30,top=30,left=30');
		faq.focus();
	} else if (browser.isMac) {
		var faq = window.open(thisURL,'faqpop','scrollbars=yes,resizable=no,width=713,height=450,screenX=30,screenY=30,top=30,left=30');
		faq.focus();
	} else { 
		var faq = window.open(thisURL,'faqpop','scrollbars=yes,resizable=no,width=716,height=450,screenX=30,screenY=30,top=30,left=30');
		faq.focus();
	}
}

function ReservationPopUp(targetURL)
{
	var browser = new BrowserDetect();
	if (browser.isMac) {
		if( browser.isNS7up ) {
			OpenWin = window.open(targetURL, '', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=353,height=420,left=90,top=90');
		} else {
			OpenWin = window.open(targetURL, '', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=353,height=380,left=90,top=90');
		}
	} else {
		OpenWin = window.open(targetURL, '', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=355,height=380,left=90,top=90');
	}
}

function RateDetailPopUp(targetURL)
{
	var browser = new BrowserDetect();
	if (browser.isMac) {
		if( browser.isNS7up ) {
			OpenWin = window.open(targetURL, '', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=353,height=420,left=90,top=90');
		} else {
			OpenWin = window.open(targetURL, '', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=353,height=380,left=90,top=90');
		}
	} else {
		OpenWin = window.open(targetURL, '', 'status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=353,height=380,left=90,top=90');
	}
}

function AirPackagePopUp(country)
{
	var cook = document.cookie;
	//alert(cook);
	if( country>0 ) {
		country = country-1;
		path = new Array();
		//US
		path[0] = "http://travel.wwte1.com/pubspec/scripts/eap.asp?goto=eta&eapid=11582-30001&lang=1033&ovrd=3";
		//UK
		path[1] = "http://uk.wwte4.com/pubspec/scripts/eap.asp?goto=eta&eapid=216-30004&lang=2057&ovrd=3";
		//alert(path[country]);
		var browser = new BrowserDetect();
		if (browser.isMac) {
			window.open(path[country], 'AirPackage', 'status=yes,toolbar=yes,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,location=no');
		} else {
			window.open(path[country], 'AirPackage', 'status=yes,toolbar=yes,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+screen.width*0.99+',height='+screen.height*0.78+',left=0,top=0');
		}
		return true;
	}
	return false;
}

function AirPackageCheckCookies(name, originalURL)
{
	var cook = document.cookie;
	//alert(cook);
	if( document.cookie) {
		var cookiesArray = cook.split(";");
		//alert(cookiesArray.length);
		for(i=0; i<cookiesArray.length; i++) {   
			var temp = cookiesArray[i].split("=");
			//alert(temp[0]);
			//alert(name);
			//alert(temp.length);
			temp[0] = temp[0].replace(/^\s*|\s*$/g,"");;
			if( (temp[0]==name) && (temp.length>1) ) {
				var valueArray = temp[1].split(":");
				//alert(valueArray[0]);
				var country = valueArray[0];
				//alert(country);
				if( AirPackagePopUp(country) ) {
					return;
				}
			}
		}
	}
	location.replace(originalURL);
}

function ShangriLaHomePagePopUp()
{
	var path = "http://www.shangri-la.com";

	var browser = new BrowserDetect();
	if (browser.isMac) {
		window.open(path, 'AirPackage', 'status=yes,toolbar=yes,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,location=no');
	} else {
		window.open(path, 'AirPackage', 'status=yes,toolbar=yes,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+screen.width*0.99+',height='+screen.height*0.78+',left=0,top=0');
	}
	return true;
}

function printpage() {
	var pr = (window.print) ? 1 : 0;
	var mac = (navigator.userAgent.indexOf("Mac") != -1);
	if (mac) {
		if (pr) {
			window.print();
			setTimeout('closeAll()', 60000);		
		}
	} else {
		print();
		setTimeout('window.close()', 60000);
	}
}

var loc = document.location.toString();
var index = loc.indexOf(":");
var url = loc.substring(index, loc.length);
var needSSL = false;
path = new Array()
path[0] = "/gc/";
path[1] = "/offers/en/subscribe.aspx";
path[2] = "/offers/en/subscribeack.aspx";
path[3] = "/offers/en/modify.aspx";
path[4] = "/offers/en/modifyack.aspx";
path[5] = "/offers/en/unsubscribe.aspx";
path[6] = "/offers/en/unsubscribeack.aspx";
path[7] = "/reservations/request/en/index.aspx";
path[8] = "/reservations/request/en/acknowledgement.aspx";
path[9] = "/reservations/booking/en/header.aspx";
path[10] = "/reservations/booking/en/pegasus.aspx";
path[11] = "/reservations/mybookings/en/index.aspx";
path[12] = "/careers/apply/en/index.aspx";
path[13] = "/careers/apply/en/acknowledgement.aspx";
path[14] = "/meetings/rfp/en/index.aspx";
path[15] = "/meetings/rfp/en/acknowledgement.aspx";
path[16] = "/reservations/booking/en/bookingdetails.aspx";
path[17] = "/reservations/booking/en/acknowledgement.aspx";
path[18] = "/reservations/popup/en/printthispage.aspx";
path[19] = "/reservations/mybookings/";
path[20] = "/reservations/account/";



for(i=0; i<path.length && needSSL==false; i++) {   
	var exist = url.indexOf(path[i]);
	if( exist!="-1" ) {
		needSSL = true;
	}
}

if( (index=="4") && (needSSL==true) ) {
	secureUrl = "https" + url;
	//location.replace(secureUrl); // get rid of current page in history
//	location.href = secureUrl;
} else if( (index=="5") && (needSSL==false) ) {
	secureUrl = "http" + url;
//	location.replace(secureUrl); // get rid of current page in history
}

function isSpecial(c){ 
	return ((c==",")||(c==".")||(c=="~")||(c=="'")||(c=="`")||(c==":")||(c==";")||(c=="!")||(c=="?")||(c=="&")||(c=="@")||(c=="#")||(c=="$")||(c=="%")||(c=="^")||(c=="*")||(c=="(")||(c==")")||(c=="_")||(c=="-")||(c=="+")||(c=="=")||(c=="{")||(c=="}")||(c=="[")||(c=="]")||(c=="|")||(c=="<")||(c==">")||(c=="/")||(c=="\\")||(ascii(c)==34))
}

function isChar(str){
	for(i=0; i<str.length; i++){
		cCode = str.charCodeAt(i);
		cChar = str.charAt(i);
		//alert("cChar= " + cChar + "cCode= " + cCode);
		if ((cCode>=97 && cCode<=122) || (cCode>=65 && cCode<=90) || ( cCode==32)) {
			//alert("cChar= " + cChar + "cCode= " + cCode);
			return true;
		}
	}
}

function isDigit(c){ 
	return ((c >= "0") && (c <= "9"))
}

function isAlphanumeric(s){  
	var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number or letter.
        var c = s.charAt(i);

        if (! (isChar(c) || isDigit(c) || isSpecial(c)))
        return false;
    }

    // All characters are numbers or letters.
    return true;
}


function getElement(id) {
return document.getElementById ? document.getElementById(id) : 
document.all ? document.all(id) : null;
}

function getRealLeft(id) {
var el = getElement(id);
if (el) {
xPos = el.offsetLeft;
tempEl = el.offsetParent;
while (tempEl != null) {
xPos += tempEl.offsetLeft;
tempEl = tempEl.offsetParent;
}
return xPos;
}
}

function getRealTop(id) {
var el = getElement(id);
if (el) {
yPos = el.offsetTop;
tempEl = el.offsetParent;
while (tempEl != null) {
yPos += tempEl.offsetTop;
tempEl = tempEl.offsetParent;
}
return yPos;
}
}

function getRealRight(id) {
return getRealLeft(id) + getElement(id).offsetWidth;
}

function getRealBottom(id) {
return getRealTop(id) + getElement(id).offsetHeight;
}

