



var aKeepSelectsHidden = false;

function submitViaEnter(pEvent, pForm)
{
if (pEvent.keyCode == 13)
{
pForm.submit();
}
}

function continueViaEnter(pEvent, pJavaScript)
{
if (pEvent.keyCode == 13)
{
eval(pJavaScript);
return false;
}
return true;
}


function OpenPopupWindow(pBodyUri, pWindowTitle, pScrollOption, pFrameOption, pWidth, pHeight, pResizable)
{

var undefined = void 0;
var lWidth = (pWidth == undefined) ? 351 : pWidth;
var lHeight = (pHeight == undefined) ? 275 : pHeight;
var lResizable = (pResizable == undefined) ? "no" : pResizable;
var lProtocol = document.location.protocol;
var lWindowOptions = "width=" + lWidth + ",height=" + lHeight + ",toolbar=no,menubar=no,scrollbars=no,resizable=" + lResizable;
var lPopupPath = (lProtocol == "https:" && pFrameOption == "N") ? "/common/secure/popup.jsp" : "/common/popup.jsp";
var lWindowPath = lPopupPath + "?bodyUri=" + escape(pBodyUri) + "&title=" + escape(pWindowTitle) + "&scroll=" + pScrollOption + "&frames=" + pFrameOption;
var lWindowName = "";
for (i=0; i<pWindowTitle.length; i++)
{
var lChar = pWindowTitle.charAt(i);
if (lChar != ' ' && lChar != '-' && lChar != '&')
{
lWindowName += lChar;
}
}
var lWindowTitle = pWindowTitle;
window.open(lWindowPath, lWindowName, lWindowOptions);
}


function OpenGenericPopupWindow(pBodyUri, pWindowTitle, pScrollOption, pFrameOption, pWidth, pHeight, pResizable)
{

var undefined = void 0;
var lWidth = (pWidth == undefined) ? 351 : pWidth;
var lHeight = (pHeight == undefined) ? 275 : pHeight;
var lResizable = (pResizable == undefined) ? "no" : pResizable;
var lProtocol = document.location.protocol;
var lWindowOptions = "width=" + lWidth + ",height=" + lHeight + ",toolbar=no,menubar=no,scrollbars=no,resizable=" + lResizable;
var lPopupPath = (lProtocol == "https:" && pFrameOption == "N") ? "/common/secure/genericpopup.jsp" : "/common/genericpopup.jsp";
var lWindowPath = lPopupPath + "?bodyUri=" + escape(pBodyUri) + "&title=" + escape(pWindowTitle) + "&scroll=" + pScrollOption + "&frames=" + pFrameOption;
var lWindowName = "";
for (i=0;i<pWindowTitle.length;i++)
{
var lChar = pWindowTitle.charAt(i);
if (lChar != ' ' && lChar != '-' && lChar != '&')
{
lWindowName += lChar;
}
}
var lWindowTitle = pWindowTitle;
window.open(lWindowPath, lWindowName, lWindowOptions).focus();
}

var sPanelName = '';

function hidePanelPopup()
{
$(sPanelName).style.display = 'none';
sPanelName = '';
}








function showPanelPopup(pPanelName, pXPos, pYPos)
{
var lPanel = $(pPanelName);
var lXPos = (pXPos) ? pXPos : 300;
var lYPos = (pYPos) ? pYPos : 300;
var lScrollAmount = document.body.scrollTop;

lYPos = (lYPos + lScrollAmount);

lPanel.style.position = 'absolute';
lPanel.style.left = lXPos;
lPanel.style.top = lYPos;
lPanel.style.display = 'block';
sPanelName = pPanelName;
}

function OpenHotelMap (pBrandUrl, pHotelCode)
{
var lWindowOptions = "width=800,height=550,toolbar=no,menubar=no,scrollbars=yes,resizable=yes";
var lWindowPath = "http://" + pBrandUrl + "/common/map.do?hotelCode=" + pHotelCode + "&mapType=hotel.map";
window.open(lWindowPath, "Map", lWindowOptions);
}

function OpenDynamicMap (pHotelCode, pHotelBrandCode)
{
var lWindowOptions = "width=810,height=465,toolbar=no,menubar=no,scrollbars=yes,resizable=yes";
var lWindowPath = "/destinations/property.do?hotelCode=" + pHotelCode + "&directions=true";
window.open(lWindowPath, "Map", lWindowOptions);
}

function OpenStaticMap (pHotelImage)
{
var lWindowOptions = "width=800,height=550,toolbar=no,menubar=no,scrollbars=yes,resizable=yes";
window.open(pHotelImage, "Map", lWindowOptions);
}

function OpenCityMap (pCity, pState, pCountry, pShowCrossBrandMap)
{
var lWindowOptions = "width=600,height=528,toolbar=no,menubar=no,scrollbars=yes,resizable=yes";
var lWindowPath = "/common/map.do?mapType=city.map&city=" + pCity + "&state=" + pState + "&country=" + pCountry;
if (pShowCrossBrandMap)
{
lWindowPath += "&crossBrand=true";
}
window.open(lWindowPath, "Map", lWindowOptions);
}

function popEmail(pSubject, pBody)
{
var doc = "mailto:" + "?subject=" + escape(pSubject) + "&body=" + escape(pBody);
window.location = doc;
}

function goToLink(pSelect)
{
if (pSelect[pSelect.selectedIndex].value.substring(0, 4) == "http")
{
window.open(pSelect[pSelect.selectedIndex].value,'_blank');
}
else if (pSelect[pSelect.selectedIndex].value.substring(0, 3) == "www")
{
window.open("http://" + pSelect[pSelect.selectedIndex].value, '_top');
}
else
{
window.open(pSelect[pSelect.selectedIndex].value, '_top');
}
}

function handleLanguageChange(pEnglish)
{
var lLanguageOptions = document.localeform.language.options;
var lSelectedOption = lLanguageOptions[lLanguageOptions.selectedIndex];
document.localeform.submit();
}

function handleCountryChange(pCountryCode)
{
if($('country').value == 'US' || $('country').value == 'CA')
{
$('taxId').readOnly = false;
$('taxId').className = 'editable';
}
else if($('taxId').value == '')
{
$('taxId').readOnly = true;
$('taxId').className = 'uneditable';
}

if (pCountryCode.value == '' || pCountryCode.value == '-')
{
$('workCountryPrefix').value = '';
$('homeCountryPrefix').value = '';
}
else
{
$('workCountryPrefix').value = countryCodes[pCountryCode.value];
$('homeCountryPrefix').value = countryCodes[pCountryCode.value];
}
pCountryCode.focus();
}

function handleGuestCountryChanged(pUpdateStateOptions)
{
assignCountryCode(sContactFormFields.country, sContactFormFields.countryPrefix);
adjustInputBoxWidth();
if(pUpdateStateOptions)
{
updateStateOptions(sContactFormFields.state, sContactFormFields.country.value);
}
updatePhoneNumberForm(true);
}

function assignCountryCode(pCountryCode, pCountryPrefix)
{
if (pCountryCode.value == '' || pCountryCode.value == '-')
{
pCountryPrefix.value = '';
}
else
{
pCountryPrefix.value = countryCodes[pCountryCode.value];
}
pCountryCode.focus();
}

function updatePhoneNumberForm(pDisplayCountryCodeDesc)
{
if(sContactFormFields.countryPrefix.value != '')
{
$$('div.countryPrefixDiv').each(function(element){
element.style.visibility = 'visible';
});
if(pDisplayCountryCodeDesc)
{
$$('span.countryCodeDesc').each(function(element){
element.style.visibility = 'visible';
});
}
}
else
{
$$('div.countryPrefixDiv').each(function(element){
element.style.visibility = 'hidden';
});
if(pDisplayCountryCodeDesc)
{
$$('span.countryCodeDesc').each(function(element){
element.style.visibility = 'hidden';
});
}
}

if(sContactFormFields.countryPrefix.value == 1)
{
$$('span.countryPrefixEqualsOne').each(function(element){
element.style.display = 'inline';
});
$$('span.countryPrefixNotEqualsOne').each(function(element){
element.style.display = 'none';
});
sContactFormFields.areaCode.value = sContactFormFields.areaCode.value.substring(0,3);
sContactFormFields.areaCode.maxLength = 3;
if(sContactFormFields.phoneNumber.value != '' )
{
sContactFormFields.centralOfficeNumber.value = sContactFormFields.phoneNumber.value.substring(0,3);
sContactFormFields.subscriberNumber.value = sContactFormFields.phoneNumber.value.substring(3,7);
sContactFormFields.phoneNumber.value = sContactFormFields.centralOfficeNumber.value.concat(sContactFormFields.subscriberNumber.value);
}
}
else
{
$$('span.countryPrefixEqualsOne').each(function(element){
element.style.display = 'none';
});
$$('span.countryPrefixNotEqualsOne').each(function(element){
element.style.display = 'inline';
});
sContactFormFields.areaCode.maxLength = 6;
if(sContactFormFields.centralOfficeNumber.value != '' && sContactFormFields.subscriberNumber.value != '')
{
sContactFormFields.phoneNumber.value = sContactFormFields.centralOfficeNumber.value.concat(sContactFormFields.subscriberNumber.value);
}
}

}

function focusNextBox(pInputBox, pNextInputBox)
{
if(pInputBox.value.length == pInputBox.maxLength && sContactFormFields.countryPrefix.value == 1)
{
pInputBox.form[pNextInputBox.valueOf()].focus();
}
}

function handlePhoneNumberChanged()
{
sContactFormFields.phoneNumber.value = '';
if(sContactFormFields.centralOfficeNumber.value != '' && sContactFormFields.subscriberNumber.value != '')
{
sContactFormFields.phoneNumber.value = sContactFormFields.centralOfficeNumber.value.concat(sContactFormFields.subscriberNumber.value);
}
}

function adjustInputBoxWidth()
{
var lWidths = {1 : '8', 2 : '15', 3 : '22'};
if(sContactFormFields.countryPrefix.value.length != 0 ||
sContactFormFields.countryPrefix.value.length != 'undefined')
{
var lWidth = lWidths[sContactFormFields.countryPrefix.value.length];
sContactFormFields.countryPrefix.style.width = lWidth;
}
}


function RemoveInvalidPostalCodeCharacters(pPostalCode, pCountry)
{

var lValidUsMxChar = /[0-9\-]/;

var lValidOtherChar = /[a-zA-Z0-9\-]/;
var lCounter;
var lPostalCode = "";

if (pPostalCode != "")
{
for (lCounter = 0; lCounter < pPostalCode.length; lCounter++)
{
lTemp = pPostalCode.charAt(lCounter);

if (pCountry == "US" || pCountry == "MX")
{
if (lValidUsMxChar.test(lTemp))
{
lPostalCode += lTemp;
}
}
else
{
if (lValidOtherChar.test(lTemp))
{
lPostalCode += lTemp;
}
}
}
}

return lPostalCode;
}

function RemoveInvalidPhoneCharacters(pNumber)
{
var lValidChars = "0123456789";
var lCounter;
var lValidNumber = "";

if (pNumber != "")
{
for (lCounter=0; lCounter < pNumber.length; lCounter++)
{
lTemp = pNumber.charAt(lCounter);
if (lValidChars.indexOf(lTemp) != "-1")
{
lValidNumber += lTemp;
}
}
}

return lValidNumber;
}

function IsValidateEmailConstruction(pEmail)
{
var validEmail = false;
var filter= /^([a-zA-Z0-9_\.\-\'])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(pEmail))
{
validEmail = true;
}

return(validEmail);
}

function isAllDigit(pStr)
{
if (pStr.value != "")
{
for (i = 0; i < pStr.length; i++)
{
if (!isDigit(pStr.charAt(i)))
{
return false;
}
}
return true;
}
return false;
}


function getCookie(pName)
{
var start = document.cookie.indexOf(pName + "=");
var len = start + pName.length + 1;
if (!start && pName != document.cookie.substring(0, pName.length ))
{
return null;
}
if (start == -1)
{
return null;
}
var end = document.cookie.indexOf(";", len);
if (end == -1)
{
end = document.cookie.length;
}
return unescape(document.cookie.substring(len, end));
}

function setCookie(pName, pValue, pExpires, pPath)
{

var today = new Date();
today.setTime(today.getTime());
var expires_date = new Date( today.getTime() + pExpires);

document.cookie = pName + "=" + escape(pValue) +
(pExpires ? ";expires=" + expires_date.toGMTString() : "") +
(pPath ? ";path=" + pPath : "");
}




function isValidDate(pDate)
{
var lLength = pDate.length;
var lMilliseconds = Date.parse(pDate);

if ((lLength != 10) && (isNaN(lMilliseconds)))
{
return false;
}

return true;
}

function handleArriveChanged(pArriveField, pDepartField, pDepartPlusOne)
{
var lArriveValid = isValidDate(pArriveField.value);
var lDepartValid = isValidDate(pDepartField.value);

if (lArriveValid && lDepartValid)
{
var lArriveMillis = Date.parse(pArriveField.value);
var lDepartMillis = Date.parse(pDepartField.value);

if (lArriveMillis > lDepartMillis)
{
pDepartField.value = "";
}
}

if (lArriveValid && pDepartPlusOne)
{
var ONE_DAY = 1000 * 60 * 60 * 24;
var lArriveMillis = Date.parse(pArriveField.value);
var lDate = new Date();
lDate.setTime(lArriveMillis + ONE_DAY);
var lMonth = (lDate.getMonth() + 1);
var lDay = (lDate.getDate());
lMonth = (lMonth > 9) ? lMonth : "0" + lMonth;
lDay = (lDay > 9) ? lDay : "0" + lDay;
var lYear = lDate.getFullYear();

var lTomorrow = lMonth + "/" + lDay + "/" + lYear;

pDepartField.value = lTomorrow;
}
}

function handleDepartChanged(pArriveField, pDepartField)
{
var lArriveValid = isValidDate(pArriveField.value);
var lDepartValid = isValidDate(pDepartField.value);

if (lArriveValid && lDepartValid)
{
var lArriveMillis = Date.parse(pArriveField.value);
var lDepartMillis = Date.parse(pDepartField.value);

if (lDepartMillis < lArriveMillis)
{
pArriveField.value = "";
}
}
}





function submitResForm(pConfNo, pStayUni, pHotelBrandCode, pSubmitAction)
{
document.myAccountForm.confNo.value = pConfNo;
document.myAccountForm.resNo.value = pStayUni;
document.myAccountForm.stayUni.value = pStayUni;
document.myAccountForm.submitAction.value = pSubmitAction;
document.myAccountForm.hotelBrandCode.value = pHotelBrandCode;

document.myAccountForm.action = "/myaccount/secure/myReservationsAction.do";

$('myAccountForm').submit();
}

function checkin(pConfNo, pStayUni, pBrandVariantCode, pCheckInUrl)
{
if (pCheckInUrl == "")
{
submitResForm(pConfNo, pStayUni, pBrandVariantCode, 'checkin');
}
else
{
var lTargetIndex = pCheckInUrl.indexOf("target=");

if (lTargetIndex >= 0)
{
var lTargetStart = (lTargetIndex + 7);
var lUrl = pCheckInUrl.substr(0, lTargetStart);
var lTargetUrl = pCheckInUrl.substr(lTargetStart);

lTargetUrl = escape(lTargetUrl);
pCheckInUrl = lUrl + lTargetUrl;
}

document.location = pCheckInUrl;
}
}

function editReservation(pConfNo, pStayUni, pHotelBrandCode)
{
submitResForm(pConfNo, pStayUni, pHotelBrandCode, "edit");
}

function confirmDeleteHotel(pHotelID, pPanelName)
{
showPanelPopup(pPanelName, 350, 300);

document.myAccountHiddenForm.submitAction.value = "delete";
document.myAccountHiddenForm.hotelID.value = pHotelID;
}

function highlightHotels()
{
new Effect.BlindDown('favoriteHotels',{ myfavoritehotelqueue: { position: 'end', scope: 'myfavoritehotelscope' } });
new Effect.Fade('indicator2');
}

function deleteHotel()
{
$('deleteHotelPanelPopup').style.display = 'none';
var lUrl = '/myaccount/secure/myFavoriteHotelAction.do'
var lPars = 'hotelID=' + $F('hotelID') + '&submitAction=delete&ajaxRequest=true';

new Effect.Appear('indicator2');
new Effect.Appear('favoriteHotels',{ myfavoritehotelqueue: { position: 'end', scope: 'myfavoritehotelscope' } });

var myAjax = new Ajax.Updater(
'favoriteHotels',
lUrl,
{
method: 'get',
parameters: lPars,
onSuccess: highlightHotels
});
}

function printReceipt(pResNo)
{
var lLink = "/myaccount/secure/printReceipt.do?action=print&resNo=" + pResNo;
window.open(lLink, "", "width=620, height=600, left=0, top=0, menubar=no, status=yes, location=no, toolbar=no, scrollbars=yes, resizable=no");
}

function HandleEYCancel()
{
document.eyPreferencesForm.action.value="cancel";
document.eyPreferencesForm.submit();
}

function switchTab(pBrand)
{
$('tabRAD').className = 'inactive';
$('tabCHI').className = 'inactive';
$('tabPII').className = 'inactive';
$('tabPKP').className = 'inactive';
$('panelRAD').className = 'inactivePanel';
$('panelCHI').className = 'inactivePanel';
$('panelPII').className = 'inactivePanel';
$('panelPKP').className = 'inactivePanel';

$('tab' + pBrand).className = 'active';
$('panel' + pBrand).className = 'activePanel';
}

function updateMyInterestsForm()
{
var lForm = document.myInterestForm;
lForm.submitAction.value="update";
lForm.submit();
}




function handlePasswordKeypress(pEvent)
{
var lEvent = (pEvent) ? pEvent : event;
var lCharCode = (lEvent.charCode) ? lEvent.charCode : ((lEvent.which) ? lEvent.which : lEvent.keyCode);
if (lCharCode == 13 || lCharCode == 3)
{
document.loginForm.submit();
return false;
}
return true;
}

function handleConfOrCCKeypress(pEvent, pForm)
{
var lEvent = (pEvent) ? pEvent : event;
var lCharCode = (lEvent.charCode) ? lEvent.charCode : ((lEvent.which) ? lEvent.which : lEvent.keyCode);
if (lCharCode == 13 || lCharCode == 3)
{
pForm.submit();
return false;
}
return true;
}





function toggleShuttleSelection(pEnabled)
{
if (pEnabled == 'true')
{
$('shuttle.shuttleUni').disabled = false;
$('shuttle.shuttleUni').className = '';
$('airlineName').disabled = false;
$('airlineName').className = '';
$('flightNumber').disabled = false;
$('flightNumber').className = '';
}
else
{
$('shuttle.shuttleUni').disabled = true;
$('shuttle.shuttleUni').className = 'disabled';
$('airlineName.disabled') = true;
$('airlineName.className') = 'disabled';
$('flightNumber.disabled') = true;
$('flightNumber.className') = 'disabled';
}
}

function toggleParkingSelection(pEnabled)
{
var lVehicleType = $('vehicleType');
var lParkingType = $('parkingType');

if (pEnabled == 'true')
{
lVehicleType.disabled = false;
lVehicleType.className = '';
lVehicleType.options[1].selected = true;
if (lParkingType)
{
lParkingType.disabled = false;
lParkingType.className = '';
}
}
else
{
lVehicleType.disabled = true;
lVehicleType.className = 'disabled';
lVehicleType.options[0].selected = true;
if (lParkingType)
{
lParkingType.disabled = true;
lParkingType.className = 'disabled';
lParkingType.options[0].selected = true;
}
}
}

function autoSelectWakeUpCall()
{
$('usingWakeUpCall').checked = true;
}

function performCheckin()
{
$('checkinButtons').style.visibility='hidden';
document.eyItineraryForm.submit();
}

function cancelEnrollment()
{
document.createAccountForm.action.value = "cancel";
document.createAccountForm.submit();
}

function createLtbAccount()
{
var lForm = document.ltbCreateAccountForm;

if (lForm.usingAgencyAddress)
{
lForm.usingAgencyAddress.value = $('usingAgencyAddress').checked;
}
if (lForm.workCountryPrefix)
{
lForm.workCountryPrefix.value = RemoveInvalidPhoneCharacters(lForm.workCountryPrefix.value);
}
if (lForm.workAreaCode)
{
lForm.workAreaCode.value = RemoveInvalidPhoneCharacters(lForm.workAreaCode.value);
}
if (lForm.workPhoneNumber)
{
lForm.workPhoneNumber.value = RemoveInvalidPhoneCharacters(lForm.workPhoneNumber.value);
}
if (lForm.homeCountryPrefix)
{
lForm.homeCountryPrefix.value = RemoveInvalidPhoneCharacters(lForm.homeCountryPrefix.value);
}
if (lForm.homeAreaCode)
{
lForm.homeAreaCode.value = RemoveInvalidPhoneCharacters(lForm.homeAreaCode.value);
}
if (lForm.homePhoneNumber)
{
lForm.homePhoneNumber.value = RemoveInvalidPhoneCharacters(lForm.homePhoneNumber.value);
}
if (lForm.taxid)
{
lForm.taxid.value = RemoveInvalidPhoneCharacters(lForm.taxid.value);
}
if (lForm.postal)
{
lForm.postal.value = RemoveInvalidPostalCodeCharacters(lForm.postal.value, lForm.country.options[lForm.country.selectedIndex].value);
}
if (!isDblClick())
{
document.ltbCreateAccountForm.submit();
}
}

function createAccount()
{
var lForm = document.getElementById('createAccountForm');

handleCreateAccountFields(lForm);

if (!isDblClick())
{
document.createAccountForm.submit();
}
}

function handleCreateAccountFields(pForm)
{
if (pForm.postal)
{
if (pForm.country && !$('country').disabled)
{
pForm.postal.value = RemoveInvalidPostalCodeCharacters(pForm.postal.value, pForm.country.options[pForm.country.selectedIndex].value);
}
}
if (pForm.countryPrefix)
{
pForm.countryPrefix.value = RemoveInvalidPhoneCharacters(pForm.countryPrefix.value);
}
if (pForm.areaCode)
{
pForm.areaCode.value = RemoveInvalidPhoneCharacters(pForm.areaCode.value);
}
if (pForm.phoneNumber)
{
pForm.phoneNumber.value = RemoveInvalidPhoneCharacters(pForm.phoneNumber.value);
}
if (pForm.GPNumber)
{
pForm.GPNumber.value = RemoveInvalidPhoneCharacters(pForm.GPNumber.value);
}

if($('emailSpecialOffers'))
{
pForm.emailSpecialOffers.value = $('emailSpecialOffers').checked;
}
}

function popupCreateAccount(pPopupDivId)
{
toggleSelects(true);
var lPopupDiv = document.getElementById(pPopupDivId);

var lSpinnerDiv = document.getElementById('spinner');
lSpinnerDiv.style.display='block';

var lForm = document.getElementById('createAccountForm');
handleCreateAccountFields(lForm);
if (!isDblClick())
{
var lOfferId = ($('offerId') != undefined ? $('offerId').value : '');
$('createAccountForm').request(
{
method:'post',
parameters: { offerId: lOfferId },
onSuccess: function(transport){
lPopupDiv.innerHTML = transport.responseText;
setDivPopupMargins(lPopupDiv, transport.responseText);
lPopupDiv.style.display='block';
lSpinnerDiv.style.display='none';
},
onFailure: function(notrans){
alert('could not get a server response for popupCreateAccount');
},
onComplete: function(){
sContactFormFields.country = $('country');
sContactFormFields.state = $('state');
sContactFormFields.countryPrefix = $('countryPrefix');
sContactFormFields.areaCode = $('areaCode');
sContactFormFields.phoneNumber = $('phoneNumber');
sContactFormFields.centralOfficeNumber = $('centralOfficeNumber');
sContactFormFields.subscriberNumber = $('subscriberNumber');
updatePhoneNumberForm(true);
adjustInputBoxWidth();
}
});
}
}

function setDivPopupMargins(popupDiv, responseText)
{
if(responseText.indexOf('joinrouter-popup')>=0) {
popupDiv.style.top="50%";
popupDiv.style.marginTop = -175/2;
popupDiv.style.marginLeft = -400/2;
} else if(responseText.indexOf('createaccount-popup')>=0) {
popupDiv.style.top = 10;
popupDiv.style.marginTop=0;
popupDiv.style.marginLeft = -400/2;
} else if(responseText.indexOf('thankyou-popup')>=0) {
popupDiv.style.top="50%";
popupDiv.style.marginTop = -471/2;
popupDiv.style.marginLeft = -400/2;
}
}




var lLastClickDate;
function isDblClick()
{
var lStatus = false;
var lThisClickDate = new Date();

if (lLastClickDate != null)
{
if ((lThisClickDate.getTime() - lLastClickDate.getTime()) < 2000)
{
lStatus = true;
}
}

lLastClickDate = lThisClickDate;

return lStatus;
}

function goToFooterLink(pSelect)
{
var lUrl = pSelect[pSelect.selectedIndex].value;
var lTarget = "_blank";

if (lUrl.indexOf("crossBrandEntry") > 0)
{
lTarget = "_top";
}

if (lUrl.substring(0,4) == "http")
{
window.open(lUrl, lTarget);
}
else if (lUrl.substring(0,3) == "www")
{
window.open("http://" + lUrl, lTarget);
}
else
{
window.open(lUrl, lTarget);
}
}

function handleCarlsonSiteSelect()
{
var lSiteOptions = document.carlsonSiteSelectForm.carlsonSiteSelect.options;
var lSelectedOption = lSiteOptions[lSiteOptions.selectedIndex];
if (lSelectedOption.value)
{
goToFooterLink(lSiteOptions);
}
}

function moreOptions(pForm, pActionPath)
{
var lForm = document.forms[pForm];
lForm.action = pActionPath;
lForm.submit();
}

function changeCountry()
{
var lForm = document.hotelSearchForm;
if (lForm.country.value != "" &&
lForm.country.value != "US" &&
lForm.country.value != "CA" &&
lForm.country.value != "MX")
{
document.getElementById("stateprovince").style.display = "none";
document.getElementById("stateprovincelabel").style.display = "none";
}
else
{
document.getElementById("stateprovince").style.display = "";
document.getElementById("stateprovincelabel").style.display = "";
}
}

function toggleTabHighlight(pTabId, pInitialClassName)
{
if (pInitialClassName == "inactivetab")
{
var lClassName = document.getElementById(pTabId).className;

if (lClassName == pInitialClassName)
{
document.getElementById(pTabId).className = "activetab";
}
else
{
document.getElementById(pTabId).className = pInitialClassName;
}
}
}





function switchTabs(pSelectedElement, pIsGppMember, pIsCdp)
{
if (pSelectedElement == "fah")
{
Element.show("fah");
Element.hide("res");

if(!pIsCdp)
{
Element.show("fahmsg");
Element.hide("resmsg");
}

$("fahtd").className = "selected";
$("vwrestd").className = "unselected";

if ($("rdmtd"))
{
$("rdmtd").className = "unselected";
}
$("rateSearchForm.redemptionSearch").value = 'false';
}
if (pSelectedElement == "res")
{
Element.hide("fah");
Element.show("res");

if(!pIsCdp)
{
Element.hide("fahmsg");
Element.show("resmsg");
}

$("vwrestd").className = "selected";

if ($("fahtd"))
{
$("fahtd").className = "unselected";
}

if ($("rdmtd"))
{
$("rdmtd").className = "unselected";
}

document.itinerarySearchForm.firstName.focus();
$("rateSearchForm.redemptionSearch").value = 'false';
}
if (pSelectedElement == "rdm")
{
Element.hide("res");
Element.hide("resmsg");
Element.show("fah");
Element.show("fahmsg");

$("vwrestd").className = "unselected";
$("fahtd").className = "unselected";

if ($("rdmtd"))
{
$("rdmtd").className = "selected";
}

$("rateSearchForm.redemptionSearch").value = 'true';
}
}

function switchTabs_old(pSelectedElement, pSetGppPromo)
{
if (pSelectedElement == "fah")
{
Element.show("fah");
Element.hide("res");

$("separator1").className = "separator";
$("fahtd").className = "selected";
$("vwrestd").className = "unselected";
$("leftcorner3").style.display = "none";
$("rightcorner1").style.display = "";
$("rightcorner3").style.display = "";
$("rightcorner1").className = "unselectedrightcorner";
$("rightcorner3").className = "unselectedrightcorner";
$("leftcorner1").className = "selectedleftcorner";
$("rightcorner1").className = "selectedrightcorner";
if ($("rdmtd"))
{
$("rdmtd").className = "unselected";
$("separator3").className = "separator";
$("leftcorner4").style.display = "none";
$("rightcorner4").className = "unselectedrightcorner";
}
}
if (pSelectedElement == "res")
{
Element.hide("fah");
Element.show("res");

$("vwrestd").className = "selected";

if ($("fahtd"))
{
$("fahtd").className = "unselected";
}

$("separator1").className = "preseparator";
$("rightcorner1").style.display = "none";
$("leftcorner3").style.display = "";
$("rightcorner3").style.display = "";
$("leftcorner3").className = "selectedleftcorner";
$("rightcorner3").className = "selectedrightcorner";
$("leftcorner1").className = "unselectedleftcorner";
if ($("rdmtd"))
{
$("rdmtd").className = "unselected";
$("separator3").className = "separator";
$("leftcorner4").style.display = "none";
$("rightcorner4").className = "unselectedrightcorner";
}

document.itinerarySearchForm.firstName.focus();
}
if (pSelectedElement == "rdm")
{
Element.show("fah");
Element.hide("res");

$("vwrestd").className = "unselected";
$("fahtd").className = "unselected";
$("separator1").className = "preseparator";
$("rightcorner1").style.display = "none";
$("rightcorner3").style.display = "none";
$("leftcorner3").style.display = "";
$("leftcorner3").className = "unselectedleftcorner";
$("leftcorner1").className = "unselectedleftcorner";

if ($("rdmtd"))
{
$("rdmtd").className = "selected";
$("separator3").className = "preseparator";
$("leftcorner4").style.display = "";
$("leftcorner4").className = "selectedleftcorner";
$("rightcorner4").className = "selectedrightcorner";
}

$("rateSearchForm.redemptionSearch").value = 'true';
}
}

function simpleSwitchTabs(pSelectedElement)
{
$("rateSearchForm.redemptionSearch").value = 'false';

if (pSelectedElement == "fah")
{
Element.show("fah");
Element.hide("res");

$("fahtd").className = "selected";
$("fahtd2").className = "selected";
$("vwrestd").className = "unselected";
$("vwrestd2").className = "";
$("rdmtd").className = "unselected";
$("rdmtd2").className = "";
}
if (pSelectedElement == "res")
{
Element.hide("fah");
Element.show("res");

$("vwrestd").className = "selected";
$("vwrestd2").className = "selected";
$("rdmtd").className = "unselected";
$("rdmtd2").className = "";

if($("fahtd"))
{
$("fahtd").className = "unselected";
$("fahtd2").className = "";
}

document.itinerarySearchForm.firstName.focus();
}
if (pSelectedElement == "rdm")
{
Element.show("fah");
Element.hide("res");

$("vwrestd").className = "unselected";
$("vwrestd2").className = "";
$("rdmtd").className = "selected";
$("rdmtd2").className = "selected";

if($("fahtd"))
{
$("fahtd").className = "unselected";
$("fahtd2").className = "";
}

$("rateSearchForm.redemptionSearch").value = 'true';
}
}




totalRooms = 9;
roomPrefix = "room";
function changeRooms(pNumRooms, pUsesPopup)
{
roomsSelected = new Number(pNumRooms.value);
if(pUsesPopup)
{
setSelectedValue($('popupRoomsCount').options, roomsSelected);
setSelectedValue($('mainRoomsCount').options, roomsSelected);
if(roomsSelected == 1)
{
hideRoomsPopup();
document.getElementById('numAdults').disabled = false;
document.getElementById('numChildren').disabled = false;
}
else {
showRoomsPopup();
document.getElementById('numAdults').disabled = true;
document.getElementById('numChildren').disabled = true;
}
for (i = 1; i <= totalRooms; i++)
{
if (i <= roomsSelected)
{
document.getElementById(roomPrefix + i).style.display = "";
document.getElementById('numAdults' + (i - 1)).disabled = false;
document.getElementById('numChildren' + (i - 1)).disabled = false;
}
else
{
document.getElementById(roomPrefix + i).style.display = "none";
document.getElementById('numAdults' + (i - 1)).disabled = true;
document.getElementById('numChildren' + (i - 1)).disabled = true;
}
}
}
else
{
for (i = 1; i <= totalRooms; i++)
{
if (i <= roomsSelected)
{
document.getElementById(roomPrefix + i).style.display = "";
document.getElementById('numAdults' + (i - 1)).disabled = false;
document.getElementById('numChildren' + (i - 1)).disabled = false;
}
else
{
document.getElementById(roomPrefix + i).style.display = "none";
document.getElementById('numAdults' + (i - 1)).disabled = true;
document.getElementById('numChildren' + (i - 1)).disabled = true;
}
}
}
}




function selectGuaranteeMethod()
{
var lForm = document.guestInfoForm;
var lSelectedMethod = lForm.deposit.options[lForm.deposit.selectedIndex].value;

lForm.cardType.selectedIndex = 0;
lForm.cardNumber.value = "";
lForm.cardExpireMonth.selectedIndex = 0;
lForm.cardExpireYear.selectedIndex = 0;
lForm.updateCards.checked = false;

if (lSelectedMethod == "CO")
{
lForm.cardType.disabled = true;
lForm.cardNumber.disabled = true;
lForm.cardExpireMonth.disabled = true;
lForm.cardExpireYear.disabled = true;
lForm.updateCards.disabled = true;

if (lForm.cardType.style)
{

lForm.cardType.style.backgroundColor="#cccccc";
lForm.cardNumber.style.backgroundColor="#cccccc";
lForm.cardExpireMonth.style.backgroundColor="#cccccc";
lForm.cardExpireYear.style.backgroundColor="#cccccc";
lForm.updateCards.style.backgroundColor="#cccccc";
}
}
else
{
lForm.cardType.disabled = false;
lForm.cardNumber.disabled = false;
lForm.cardExpireMonth.disabled = false;
lForm.cardExpireYear.disabled = false;
lForm.updateCards.disabled = false;

if (lForm.cardType.style)
{

lForm.cardType.style.backgroundColor="#ffffff";
lForm.cardNumber.style.backgroundColor="#ffffff";
lForm.cardExpireMonth.style.backgroundColor="#ffffff";
lForm.cardExpireYear.style.backgroundColor="#ffffff";
lForm.updateCards.style.backgroundColor="#ffffff";
}


for (ii=0; ii < lForm.cardType.length; ii++)
{
if (lForm.cardType.options[ii].defaultSelected)
{
lForm.cardType.selectedIndex = ii;
break;
}
}

lForm.cardNumber.value = lForm.cardNumber.defaultValue;

for (ii=0; ii < lForm.cardExpireMonth.length; ii++)
{
if (lForm.cardExpireMonth.options[ii].defaultSelected)
{
lForm.cardExpireMonth.selectedIndex = ii;
break;
}
}

for (ii=0; ii < lForm.cardExpireYear.length; ii++)
{
if (lForm.cardExpireYear.options[ii].defaultSelected)
{
lForm.cardExpireYear.selectedIndex = ii;
break;
}
}
}
}

function handleMoreOptionsLink(pFormName,pOptions)
{
var lForward="/reservation/itineraryEntrance.do";
if (pOptions != null)
{
lForward = lForward+"?"+pOptions;
}
$(pFormName).action=lForward;
$(pFormName).submit();
}

function handleOtherLocationsSearch()
{
var lForm = null;

if ($('rateSearchForm') != null)
{
lForm = $('rateSearchForm');
}
else
{
lForm = $('modifySearchForm');
}

if ($F('rateSearchHotelCode') == "search-other") 
{
lForm.action ='/reservation/displayMoreSearchOptions.do?newSearch=true&forcedCitySearch=true';
$('rateSearchHotelCode').value = "";
lForm.submit();

}
else
{
if ($('homePageSearch'))
{
lForm.action ='/home/reservation/rateSearch.do';
}
else
{
lForm.action ='/reservation/cityRateSearch.do';
}
}
}

function submitCityRateSearchForm(pShowInterimSearchPage)
{
clearBlankDates();


if ($('roomsPopup') && $('roomsPopup').style.display == '')
{
setSelectedValue($('numAdults').options, $('numAdults0').value);
setSelectedValue($('numChildren').options, $('numChildren0').value);
}



if ($('checkinDate').value == '' &&
$('checkoutDate').value == '' &&
$('country').value != '' &&
$('selectedCrossBrandSearchCodes1') == null &&
$('forcedCitySearch') == false)
{
var lUrl = '/hotels';
if ($('rateSearchForm.redemptionSearch') && $('rateSearchForm.redemptionSearch').value == 'true')
{
lUrl += '/redemption';
}
if ($('hotelselect') && $('hotelselect').value != '')
{
lUrl += '/rates/' + $('hotelselect').value + '/new';
}
else
{
lUrl += '/' + $('country').value.toLowerCase();
if ($('countryAndState') && $('countryAndState').value != '')
{
lUrl += '/' + $('countryAndState').value.substring(3,5).toLowerCase();
}
if ($('autocomplete') && $('autocomplete').value != '')
{
lUrl += '/' + $('autocomplete').value.toLowerCase().replace(/[ ]+/g, "_");
}
if ($('cityId').value != '' && $('cityId').value != 0)
{
lUrl += '/' + $('cityId').value;
}
if ($('searchCrossBrand') && $('searchCrossBrand').checked)
{
lUrl += '/all';
}
}

window.location = lUrl;
}
else
{

if ($('newSearch'))
{
$('newSearch').value = true;
}
$('cityRateSearchForm').submit();
}

if (pShowInterimSearchPage)
{
document.getElementById("bodydiv").style.display = "none";
document.getElementById("waitdiv").style.display = "";
document.getElementsByTagName("body")[0].className = "waitpage";
}
}

function submitHotelSearchForm(pShowInterimSearchPage)
{

var lForm = $('rateSearchForm') != null ? $('rateSearchForm') : $('modifySearchForm');
if ($F('rateSearchHotelCode') == "search-london") 
{
if ( $('hotelCodes') != null)
{
lForm['rateSearchForm.hotelCodes'].value = '';
}
$('rateSearchHotelCode').value = "";
lForm['citySearchForm.city'].value = 'london';
lForm['citySearchForm.country'].value = 'GB';
} 
else 
{
lForm['rateSearchForm.hotelCodes'].value = $('rateSearchHotelCode').value;
lForm['rateSearchForm.hotelCode'].value = $('rateSearchHotelCode').value;
}


lForm.action ='/reservation/cityRateSearch.do';
lForm.submit();
if (pShowInterimSearchPage)
{
$("bodydiv").style.display = "none";
$("waitdiv").style.display = "";
$$("body")[0].className = "waitpage";
}
}





function processSideItinForm()
{
if (document.resInfoForm.numberAdults)
{
var lNumAdults = document.resInfoForm.numberAdults.options[document.resInfoForm.numberAdults.selectedIndex].value;
if (parseInt(lNumAdults) == 0)
{
lNumAdults = 1;
document.resInfoForm.numberAdults.options[1].selected = true;
}
}

document.resInfoForm.submit();
}

function changeImage(pNewImage)
{
document.mainImage.src = pNewImage;
}

function makeReservation()
{
window.setTimeout("window.parent.close();", 500);
document.makeResEntranceForm.submit();
}





function brandChange()
{
document.brandForm.submit();
return true;
}

function returnHotelCode(pHotlcode)
{
parent.opener.document.resLookupForm.hotelCode.value = pHotlcode;
parent.close();
}

function returnPCRNumber(pCorpid)
{
parent.opener.document.hotelSearchForm.corporateAccountID.value = pCorpid;
parent.close();
}





function omnitureCustomLink(pBrandName,pSuiteID)
{
var s=s_gi(pSuiteID);
s.linkTrackVars='eVar9';
s.eVar9=pBrandName;
s.tl(this,'o','Referral to ' + pBrandName);
}





function changeEventResDate (pFormObj)
{
var intEventSelected, intEventDate, intArriveSelected, intDepartSelected, intArriveDate, intDepartDate, intArriveMonth, intDepartMonth;
var strEventMonth, strDepartMonth, strMonth, strYear, intCount;

intEventSelected = pFormObj.eventDay.selectedIndex;
intEventDate = pFormObj.eventDay[intEventSelected].value;
intArriveSelected = pFormObj.checkinDay.selectedIndex;
intArriveDate = pFormObj.checkinDay[intArriveSelected].value;
intDepartSelected = pFormObj.checkoutDay.selectedIndex;
intDepartDate = pFormObj.checkoutDay[intDepartSelected].value;

if (intEventDate != "")
{
if (intArriveDate != intEventDate)
{
intArriveDate = intEventDate;
}
if (intDepartDate <= intArriveDate)
{
intDepartDate = intArriveDate;
intDepartDate++;
}

intEventSelected = pFormObj.eventMonthYear.selectedIndex;
strEventMonth = pFormObj.eventMonthYear[intEventSelected].value;


if (strEventMonth.length == 8)
{
strMonth = strEventMonth.substring(0, 3);
intArriveYear = strEventMonth.substring(4, 8);

for (intCount = 0; intCount < 12; intCount++)
{
if (strMonth == strMonthArray[intCount])
{
intArriveMonth = intCount;
}
}
}

intDepartMonth= intArriveMonth;
intDepartYear = intArriveYear;


if (intDepartDate > intDaysArray[intArriveMonth])
{
intDepartDate = 1;
intDepartMonth++;

if (intDepartMonth > 11)
{
intDepartMonth = 0;
intDepartYear++;
}
}


pFormObj.checkinDay[intArriveDate].selected = true;
strMonthDisplay = strMonthArray[intArriveMonth] + " " + intArriveYear;
for (intCount = 0; intCount < pFormObj.checkinMonthYear.options.length; intCount++)
{
if (strMonthDisplay == pFormObj.checkinMonthYear[intCount].value)
{
pFormObj.checkinMonthYear[intCount].selected = true;
}
}

pFormObj.checkoutDay[intDepartDate].selected = true;
strMonthDisplay = strMonthArray[intDepartMonth] + " " + intDepartYear;
for (intCount = 0; intCount < pFormObj.checkoutMonthYear.options.length; intCount++)
{
if (strMonthDisplay == pFormObj.checkoutMonthYear[intCount].value)
{
pFormObj.checkoutMonthYear[intCount].selected = true;
}
}
}

return;
}





function handleHotelCodeChange(pSelectObject)
{
var lSelectedOption = pSelectObject[pSelectObject.selectedIndex];

if (lSelectedOption.value == 'other-locations')
{
window.location='/reservation/clearReservation.do?allowCitySearch=true';
}
else if (lSelectedOption.value == 'search-london')
{
window.location='/reservation/clearReservation.do?allowCitySearch=true&city=London';
}
}






function changeDepartDate (formObj)
{
var intSelected, intDepartSelected, intArriveDate, intDepartDate, intArriveMonth, intDepartMonth;
var strArriveMonth, strDepartMonth, strMonth, strYear, intCount;

intSelected = formObj.checkinDay.selectedIndex;
intArriveDate = formObj.checkinDay[intSelected].value;
intDepartSelected = formObj.checkoutDay.selectedIndex;
intDepartDate = formObj.checkoutDay[intDepartSelected].value;

if (intArriveDate != "")
{
if (intDepartDate <= intArriveDate)
{
intDepartDate = intArriveDate;
intDepartDate++;
}

intSelected = formObj.checkinMonthYear.selectedIndex;
strArriveMonth = formObj.checkinMonthYear[intSelected].value;


if (strArriveMonth.length == 8)
{
strMonth = strArriveMonth.substring(0, 3);
intArriveYear = strArriveMonth.substring(4, 8);

for (intCount = 0; intCount < 12; intCount++)
{
if (strMonth == strMonthArray[intCount])
{
intArriveMonth = intCount;
}
}
}
else
{
intArriveYear = strArriveMonth.substring(2, 6);
intArriveMonth = Number(strArriveMonth.substring(0, 2)) - 1;
}

intDepartMonth = intArriveMonth;
intDepartYear = intArriveYear;


if (intDepartDate > intDaysArray[intArriveMonth])
{
intDepartDate = 1;
intDepartMonth++;

if (intDepartMonth > 11)
{
intDepartMonth = 0;
intDepartYear++;
}
}



if (formObj.name == 'frmFeedback' || formObj.name == 'meetingRequestForm')
{
formObj.checkoutDay[intDepartDate].selected = true;
}
else
{
formObj.checkoutDay[intDepartDate-1].selected = true;
}

if (formObj.name == 'frmFeedback')
{
strMonthDisplay = strCSMonthArray[intDepartMonth] + intDepartYear;
}
else
{
strMonthDisplay = strMonthArray[intDepartMonth] + " " + intDepartYear;
}

for (intCount = 0; intCount < formObj.checkoutMonthYear.options.length; intCount++)
{
if (strMonthDisplay == formObj.checkoutMonthYear[intCount].value)
{
formObj.checkoutMonthYear[intCount].selected = true;
}
}
}

return;
}

function showCalendar(formObj, strType, strDirection)
{
var strMonth, intMonth, intYear, calWindow;
var loopCount, strURL;

if (strType == "event")
{
strMonth = formObj.eventMonthYear[formObj.eventMonthYear.selectedIndex].value;
}
else if (strType == "altEvent")
{
strMonth = formObj.altEventMonthYear[formObj.altEventMonthYear.selectedIndex].value;
}
else if (strType == "arrive")
{
strMonth = formObj.checkinMonthYear[formObj.checkinMonthYear.selectedIndex].value;
}
else if (formObj.checkoutMonthYear)
{
strMonth = formObj.checkoutMonthYear[formObj.checkoutMonthYear.selectedIndex].value;
}

if (strMonth != "")
{
if (strMonth.length == 8)
{
intYear = strMonth.substring(4, 8);
strMonth = strMonth.substring(0, 3);
for (i = 0; i < 12; i++)
{
if (strMonth == strMonthArray[i])
{
intMonth = i + 1;
}
}
}
else
{
intYear = strMonth.substring(2, 6);
intMonth = Number(strMonth.substring(0, 2));
}
strURL = "/reservation/calendar.jsp?direction=" + strDirection + "&field=" + strType + "&month=" + intMonth + "&year=" + intYear + "&formName=document." + formObj.name;
}
else
{
strURL = "/reservation/calendar.jsp?direction=" + strDirection + "&field=" + strType + "&formName=document." + formObj.name;
}

OpenPopupWindow(strURL, "Calendar", "no", "N");

return;
}

function getCalendarValues (fieldName, intDay, intMonth, intYear, formObj)
{
var arriveDate, arriveMonth, arriveYear;
var departDate, departMonth, departYear;

if (fieldName == "arrive")
{
arriveDate = intDay;
arriveMonth = intMonth - 1;
arriveYear = intYear;

if (formObj.checkoutDay && formObj.checkoutMonthYear)
{
departDate = Number(formObj.checkoutDay[formObj.checkoutDay.selectedIndex].value);
departMonth = formObj.checkoutMonthYear[formObj.checkoutMonthYear.selectedIndex].value;
if (departMonth.length == 8)
{
departYear = departMonth.substring(0, 3);
departMonth = departMonth.substring(4, 8);
}
else
{
departYear = departMonth.substring(2, 6);
departMonth = Number(departMonth.substring(0, 2)) - 1;
}
}
}
else
{
departDate = intDay;
departMonth = intMonth - 1;
departYear = intYear;

arriveDate = Number(formObj.checkinDay[formObj.checkinDay.selectedIndex].value);
arriveMonth = formObj.checkinMonthYear[formObj.checkinMonthYear.selectedIndex].value;

if (arriveMonth.length == 8)
{
arriveYear = arriveMonth.substring(0, 3);
arriveMonth = arriveMonth.substring(4, 8);
}
else
{
arriveYear = arriveMonth.substring(2, 6);
arriveMonth = Number(arriveMonth.substring(0, 2)) - 1;
}
}

selectDates(formObj, arriveDate, departDate, arriveMonth, departMonth, arriveYear, departYear);

if (fieldName == "arrive" && formObj.checkoutDay && formObj.checkoutMonthYear)
{
changeDepartDate(formObj);
}

return;
}

function selectDates (formObj, intArriveDate, intDepartDate, intArriveMonth, intDepartMonth, intArriveYear, intDepartYear)
{
var intCount, strMonthDisplay;



if (formObj.name == 'frmFeedback' || formObj.name == 'meetingRequestForm')
{
formObj.checkinDay.options[intArriveDate].selected = true;
if (formObj.checkoutDay)
{
formObj.checkoutDay.options[intDepartDate].selected = true;
}
}
else
{
formObj.checkinDay.options[intArriveDate-1].selected = true;
if (formObj.checkoutDay)
{
formObj.checkoutDay.options[intDepartDate-1].selected = true;
}
}



if (formObj.name == 'frmFeedback')
{
strMonthDisplay = strCSMonthArray[intArriveMonth] + intArriveYear;
}
else
{
strMonthDisplay = strMonthArray[intArriveMonth] + " " + intArriveYear;
}

for (intCount = 0; intCount < formObj.checkinMonthYear.options.length; intCount++)
{
if (strMonthDisplay == formObj.checkinMonthYear[intCount].value)
{
formObj.checkinMonthYear[intCount].selected = true;
}
}

if (formObj.name == 'frmFeedback')
{
strMonthDisplay = strCSMonthArray[intDepartMonth] + intDepartYear;
}
else
{
strMonthDisplay = strMonthArray[intDepartMonth] + " " + intDepartYear;
}

if (formObj.checkoutMonthYear)
{
for (intCount = 0; intCount < formObj.checkoutMonthYear.options.length; intCount++)
{
if (strMonthDisplay == formObj.checkoutMonthYear[intCount].value)
{
formObj.checkoutMonthYear[intCount].selected = true;
}
}
}

return;
}

function selectCity(formObj, pPrompt)
{
if (formObj.city.value == pPrompt)
{
formObj.city.select();
}
}

function setAnonymous(pForm)
{
if (pForm.anonymousRequest.checked == true)
{
pForm.firstName.value = ""; pForm.firstName.disabled = true;
pForm.lastName.value = ""; pForm.lastName.disabled = true;
pForm.addressLine1.value = ""; pForm.addressLine1.disabled = true;
pForm.addressLine2.value = ""; pForm.addressLine2.disabled = true;
pForm.addressLine3.value = ""; pForm.addressLine3.disabled = true;
pForm.city.value = ""; pForm.city.disabled = true;
pForm.state.value = ""; pForm.state.disabled = true;
pForm.zipCode.value = ""; pForm.zipCode.disabled = true;
pForm.country.value = ""; pForm.country.disabled = true;
pForm.phoneCountryCode.value = ""; pForm.phoneCountryCode.disabled = true;
pForm.phoneAreaCode.value = ""; pForm.phoneAreaCode.disabled = true;
pForm.phoneNumber.value = ""; pForm.phoneNumber.disabled = true;
pForm.phoneExtension.value = ""; pForm.phoneExtension.disabled = true;
pForm.emailAddress.value = ""; pForm.emailAddress.disabled = true;
pForm.contactRequested[0].disabled = true;
pForm.contactRequested[1].disabled = true;
pForm.contactRequested[1].checked = true;
pForm.goldRewardsNumber.value = ""; pForm.goldRewardsNumber.disabled = true;
}
else
{
pForm.firstName.disabled = false;
pForm.lastName.disabled = false;
pForm.addressLine1.disabled = false;
pForm.addressLine2.disabled = false;
pForm.addressLine3.disabled = false;
pForm.city.disabled = false;
pForm.state.disabled = false;
pForm.zipCode.disabled = false;
pForm.country.disabled = false;
pForm.phoneCountryCode.disabled = false;
pForm.phoneAreaCode.disabled = false;
pForm.phoneNumber.disabled = false;
pForm.phoneExtension.disabled = false;
pForm.emailAddress.disabled = false;
pForm.contactRequested[0].disabled = false;
pForm.contactRequested[1].disabled = false;
pForm.goldRewardsNumber.disabled = false;
}
}

function showForecast(pShow)
{
if (pShow)
{
Effect.SlideDown('forecast2');
Effect.SlideDown('forecast3');
Effect.Fade('showForecastLink');
Effect.Appear('hideForecastLink');
}
else
{
Effect.SlideUp('forecast2');
Effect.SlideUp('forecast3');
Effect.Fade('hideForecastLink');
Effect.Appear('showForecastLink');
}
}

function addHotel()
{
document.myAccountForm[1].action.value = "add";
document.myAccountForm[1].submit();
}

function showStaticDetailDiv(pElementId, pToggleItems)
{
$$('div.StaticDetailOpen').each(function(divElement) {
hideStaticDetailDiv(divElement);
});
var lToggleItems = pToggleItems == null ? true : pToggleItems;
if (lToggleItems)
{
toggleSelects(true);
toggleButtons(true);
}
new Effect.BlindDown(pElementId, { queue: 'end', duration: 0.3 });
$(pElementId).addClassName('StaticDetailOpen');
}

function hideStaticDetailDiv(pElementId, pToggleItems)
{
var lToggleItems = pToggleItems == null ? true : pToggleItems;
if (lToggleItems)
{
toggleSelects(false);
toggleButtons(false);
}
new Effect.BlindUp(pElementId, { queue: 'end', duration: 0.3 });
$(pElementId).removeClassName('StaticDetailOpen');
}

function showStaticDetailDivWithOverlay(pSourceElementId, pTargetElementId, pOverlayId, pIsCentered)
{
toggleSelects(true);
if (pOverlayId == 'transparentOverlay')
{
toggleButtons(true);
}
if (pOverlayId == null)
{
pOverlayId = 'overlay';
}
var lOverlay =$(pOverlayId);
var lBody = Element.extend(document.getElementsByTagName("body")[0]);
var lStaticPopupId = pTargetElementId;
var lIsCentered = pIsCentered == null ? true : pIsCentered;
if (lIsCentered)
{
var lStaticDiv = new Element('div');
lStaticDiv.writeAttribute('class', $(pSourceElementId).readAttribute('class'));
lStaticDiv.writeAttribute('style', $(pSourceElementId).readAttribute('style'));
lStaticDiv.update($(pSourceElementId).innerHTML);
lStaticDiv.setAttribute("id", lStaticPopupId);

if ($(lStaticPopupId))
{
$(lStaticPopupId).remove();
}
lBody.insert({'bottom':lStaticDiv});
}

if (lOverlay == null)
{
lOverlay = new Element('div', {'id':pOverlayId});
lBody.insert({'bottom':lOverlay});
}
lOverlay.style.height = $('bodydiv').getHeight() + 'px';
lOverlay.style.display = 'block';
if (lIsCentered)
{
centerStaticDiv(lStaticDiv);
}
new Effect.BlindDown(lStaticPopupId, {queue:'end', duration: 0.3});
}

function hideStaticDetailDivWithOverlay(pElementId, pOverlayId)
{
toggleSelects(false);
new Effect.BlindUp(pElementId, {queue:'end', duration: 0.3});
if (pOverlayId == null)
{
pOverlayId = 'overlay';
}
if (pOverlayId == 'transparentOverlay')
{
toggleButtons(false);
}
$(pOverlayId).style.display = 'none';
}

function showRateInfoPanel(pSourceElementId)
{
showStaticDetailDivWithOverlay(pSourceElementId, 'staticPopup');
}

function showMoreDetailsPanel(pSourceElementId)
{
showStaticDetailDivWithOverlay(pSourceElementId, 'moredetails', 'moredetailsOverlay');
}

function hideMoreDetailsPanel()
{
hideStaticDetailDivWithOverlay('moredetails', 'moredetailsOverlay');
}

function prepareRatePopupDiv(pDateSpan)
{
if (pDateSpan > 3)
{
$$('table.rates').each(function(pElement){
pElement.style.marginLeft = '10px';
});
}
else if (pDateSpan > 4)
{
$$('.rategrid').each(function(pElement){
pElement.style.float = 'left';
});
}
}

function centerStaticDiv(pStaticElement)
{
var lBody = document.getElementsByTagName("body")[0];
var lLeftOffset = ((lBody.clientWidth - pStaticElement.getWidth()) / 2) + lBody.scrollLeft + 'px';
var lTopOffset = ((lBody.clientHeight - pStaticElement.getHeight()) / 2) + lBody.scrollTop + 'px';
if (lBody.clientHeight < pStaticElement.getHeight())
{
lTopOffset = lBody.scrollTop + 'px';
}
pStaticElement.style.top = lTopOffset;
pStaticElement.style.left = lLeftOffset;
}

function toggleSelects(pMakeHidden)
{
if(!aKeepSelectsHidden)
{
var lSelectElements = document.body.getElementsByTagName("SELECT");
var lVisible = pMakeHidden ? "hidden" : "visible";

for(i = 0; i < lSelectElements.length; i++)
{
var lSelect = lSelectElements[i];
lSelect.style.visibility = lVisible;
}
}
}

function toggleButtons(pDisable)
{
var lOldId = pDisable? "v1" : "v3";
var lButtonElements = $$("td." + lOldId);

for(i = 0; i < lButtonElements.length; i++)
{
var lNewId = pDisable ? "v3" : "v1";
if(lButtonElements[i].id != 'div_popup')
{
lButtonElements[i].className = lNewId;
}
}
}

function showDetailDiv(pElementId, pDataElementId, pUri, pParams)
{
toggleSelects(true);
new Effect.BlindDown(pElementId);
var myAjax = new Ajax.Updater(
pDataElementId,
pUri,
{
method: 'get',
parameters: pParams
})
}

function hideDetailDiv(pElementId, pDataElementId, pText)
{
toggleSelects(false);
new Effect.BlindUp(pElementId);
setTimeout('$(\'' + pDataElementId + '\').innerHTML = \'' + pText + '\'', 2000);
}

function submitSpecialRates()
{
$('specialRatesForm').submit();
}

function getCityId(text, li)
{
clearCityId = false;
var lCityId = $('cityId');
lCityId.value = li.id;

lCountry = li.innerHTML.substr(li.innerHTML.indexOf('(') + 1, 2);
if ($('country'))
{
$('country').value = lCountry;
updateStateOptions($('countryAndState'), lCountry);
}

lState = '';
if (li.innerHTML.indexOf(',') > 0)
{
lState = li.innerHTML.substr(li.innerHTML.indexOf(',') + 2, 2);

if ($('countryAndState') && $('country'))
{
$('countryAndState').value = $F('country') + " " + lState;
}
}
if ($('hotelCode'))
{
$('hotelCode').value = '';
} 
lCityStateCountry = $('autocomplete').value + lState + lCountry;
}

function defaultHomePageDates()
{
var lCheckIn = document.getElementById('checkinDate');
var lCheckOut = document.getElementById('checkoutDate');

if (lCheckIn && lCheckOut)
{
var lDate = new Date();
var lServerDateAsMillis = document.getElementById('serverTime').value;

if (lServerDateAsMillis != null && lServerDateAsMillis > lDate.getTime())
{
lDate.setTime(lServerDateAsMillis);
}

var lMonth = (lDate.getMonth() + 1);
var lDay = lDate.getDate();
var lYear = lDate.getFullYear();

lMonth = (lMonth > 9) ? lMonth : "0" + lMonth;
lDay = (lDay > 9) ? lDay : "0" + lDay;

var lToday = lMonth + "/" + lDay + "/" + lYear;

lDate.setDate(lDate.getDate() + 1);
lMonth = (lDate.getMonth() + 1);
lDay = lDate.getDate();
lMonth = (lMonth > 9) ? lMonth : "0" + lMonth;
lDay = (lDay > 9) ? lDay : "0" + lDay;
lYear = lDate.getFullYear();

var lTomorrow = lMonth + "/" + lDay + "/" + lYear;

lCheckIn.value = lToday;
lCheckOut.value = lTomorrow;
}
}

function defaultBlankDates()
{
var lCheckin = $('checkinDate');
var lCheckout = $('checkoutDate');
var DATE_FORMAT = "mm/dd/yyyy";

if (lCheckin.value == "")
{
lCheckin.value = DATE_FORMAT;
}

if (lCheckout.value == "")
{
lCheckout.value = DATE_FORMAT;
}
}

function clearBlankDates(pField)
{
var DATE_FORMAT = "mm/dd/yyyy";

if(pField)
{
if(pField.value == DATE_FORMAT)
{
pField.value = "";
}
}
else
{
if ($('checkinDate').value == DATE_FORMAT)
{
$('checkinDate').value = "";
}

if ($('checkoutDate').value == DATE_FORMAT)
{
$('checkoutDate').value = "";
}
}
}

function getRadEdwAttractions(pSelect)
{
var lUrl = pSelect[pSelect.selectedIndex].value;
if (lUrl.length == 0)
{
new Effect.BlindUp('attractionResultsHeader');
return;
}

var myAjax =
new Ajax.Updater(
'attractionResults',
lUrl,
{
method: 'get',
evalScripts: true,
onComplete: function(){ new Effect.BlindDown('attractionResultsHeader');
setTimeout("new Effect.Highlight('attractionResultsHeader');", 1000);}
})
}

function getAttractions(text, li)
{
var lCityId = $('cityId');
lCityId.value = li.id;
updateAttractions();
}

function adjustAttractionUrl()
{
if (typeof lSuggests === 'undefined' || !lSuggests)
{
return;
}

var lUrl = "/lcrSearch?suggest=true&maxResults=10";
A1.url = lUrl;
}

function adjustUrl(pSecure)
{
if (typeof lSuggests === 'undefined' || !lSuggests)
{
return;
}

var lUrl = "/lcrSearch?suggest=true&maxResults=10";

if (pSecure)
{
lUrl = "/secure/lcrSearch?suggest=true&maxResults=10";
}

lCountry = '';
if ($('country') && $F('country').length > 1)
{
lCountry = $F('country');
lUrl += '&country=' + lCountry;
}
lState = '';
if ($('countryAndState') && $F('countryAndState').length > 4)
{
lState = $F('countryAndState').substr($F('countryAndState').indexOf(' ') + 1, 2);
lUrl += '&state=' + lState;
}
A1.url = lUrl;



if ($('cityId') && $F('cityId') != '')
{
if (lCityStateCountry != $F('autocomplete') + lState + lCountry)
{
$('cityId').value = '';
lCityStateCountry = '';
}
}
}

function showAttraction(pRadEdw)
{
Effect.Fade('location');
setTimeout("new Effect.Appear('attraction');", 900);
setTimeout("new Effect.Highlight('locationAttraction');", 1400);
if (!pRadEdw)
{
setTimeout("$('autocompleteAttraction').focus();", 1000);

if ($('cityId').value != '')
{
$('autocompleteAttraction').value = $('autocomplete').value;

setTimeout("updateAttractions();", 1000);
}
}
}

function updateAttractions()
{
if (!$('cityId') || $F('cityId') === '' || $F('cityId') === '0')
{
return;
}
var myAjax =
new Ajax.Updater(
'attractionResults',
'/lcrSearch',
{
method: 'get',
parameters: 'cityId=' + $('cityId').value,
onComplete: function(){ new Effect.BlindDown('attractionResultsHeader');
setTimeout("new Effect.Highlight('attractionResultsHeader');", 1200);}
})
}

function showLocation(pRadEdw)
{
Effect.Fade('attraction');
setTimeout("new Effect.Appear('location');", 900);
setTimeout("new Effect.Highlight('locationAttraction');", 1400);
if (!pRadEdw)
{
setTimeout("$('autocomplete').focus();", 1000);
}
}

function OpenPrintCardWindow(pBodyUri, pWindowTitle)
{
var lWindowTitle = "";
for (i = 0; i < pWindowTitle.length; i++)
{
var lChar = pWindowTitle.charAt(i);
if (lChar != ' ' && lChar != '-' && lChar != '&')
{
lWindowTitle += lChar;
}
}
window.open(pBodyUri, lWindowTitle,'width=400,height=300,scrollbars=1').focus();
}

function handleAddHotelClick(pHotelCode, pHotelName)
{
new Effect.BlindUp('citySearch');
$('hotelCode').value = pHotelCode;
$('hotelName').value = pHotelName;
$('hotelNameDisplay').innerHTML = pHotelName;
new Effect.BlindDown('stayInformationPanel');
}

function handleMissingStay(pHotelCode, pHotelName)
{
new Effect.BlindUp('citySearchPanel');
$('hotelCode').value = pHotelCode;
$('hotelName').value = pHotelName;
$('hotelNameDisplay').innerHTML = pHotelName;
new Effect.BlindDown('missingStayPanel');
}

function changeHotel(pHidePanel, pShowPanel)
{
setTimeout('new Effect.BlindUp(\'' + pHidePanel + '\')', 3000);
setTimeout('new Effect.BlindDown(\'' + pShowPanel + '\')', 3000);
}

function handleMissingStay(pHotelCode, pHotelName)
{
$('hotelCode').value = pHotelCode;
$('hotelName').value = pHotelName;
$('hotelNameDisplay').innerHTML = pHotelName;
new Effect.BlindUp('citySearchPanel');
new Effect.BlindDown('missingStayPanel');
}

function handleBrochureCitySearch(text, li)
{
$('selectBrochureForm').cityId.value = li.id;
$('selectBrochureForm').submit();
}

function hideInstructions(pLocation)
{
new Effect.BlindUp('instructions' + pLocation);
}

function showInstructions(pLocation)
{
new Effect.BlindDown('instructions' + pLocation);
}

function addHotelCompare(pHotelCode, pCheckbox)
{
var x = 0;
for (x = 0; x < 4; x = x + 1)
{
var lForm = $('rateSearchForm');
if(hotelCodeCompareArray[x] == pHotelCode)
{
hotelCodeCompareArray[x] = "";
return;
}
else if (null == hotelCodeCompareArray[x] ||
"" == hotelCodeCompareArray[x])
{
hotelCodeCompareArray[x] = pHotelCode;
return;
}
}
new Effect.Appear('tooManyHotelsSelected' + pHotelCode);
new Effect.Highlight('tooManyHotelsSelected' + pHotelCode, { duration: 4.0 });
setTimeout('new Effect.Fade(\'tooManyHotelsSelected' + pHotelCode + '\');', 4000);
pCheckbox.checked = false;
}

function submitHotelCompare(pCheckinDate, pCheckoutDate)
{
var lUrl = "/compare/hotels";
hotelCodeCompareArray.sort();
valid = false;
hotelsSelected = 0;
for (x = 0; x < 4; x = x + 1)
{
if (null != hotelCodeCompareArray[x] &&
"" != hotelCodeCompareArray[x])
{
valid = hotelsSelected > 0;
hotelsSelected = hotelsSelected + 1;
lUrl += "/" + hotelCodeCompareArray[x];
}
}

if (pCheckinDate && pCheckinDate != '')
{
lUrl += '?checkinDate=' + pCheckinDate;
lUrl += '&checkoutDate=' + pCheckoutDate;
}

if (valid)
{
window.location = lUrl;
}
else
{
new Effect.Appear('notEnoughHotelsSelected');
new Effect.Highlight('notEnoughHotelsSelected', { duration: 4.0 });
setTimeout('new Effect.Fade(\'notEnoughHotelsSelected\');', 4000);
}
}

function showCmsDiv(pKey, pDiv)
{
lPars = 'key=' + pKey;
new Ajax.Updater(pDiv,
'/cms/div.do',
{
method: 'get',
parameters: lPars,
onSuccess: new Effect.BlindDown(pDiv)
});
}

function hideCmsDiv(pDiv, pWebsite)
{
new Effect.BlindUp(pDiv);
if (pWebsite && pWebsite != '')
{
window.open(pWebsite);
}
}

function setSelectedValue(pOptions, pValue)
{
for (var j = 0; j < pOptions.length; j++)
{
var lOptionCode = pOptions[j];

if(lOptionCode.value == pValue)
{
pOptions.selectedIndex = j;
}
}
}





function getViewport()
{

var viewPortWidth;
var viewPortHeight;
var vpSize = document.viewport.getDimensions();

if(vpSize.height>0 && vpSize.width>0)
{
return [vpSize.width, vpSize.height];
}


if (typeof window.innerWidth != 'undefined') {
viewPortWidth = window.innerWidth,
viewPortHeight = window.innerHeight
}


else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth !=
'undefined' && document.documentElement.clientWidth != 0) {
viewPortWidth = document.documentElement.clientWidth,
viewPortHeight = document.documentElement.clientHeight
}


else {
viewPortWidth = document.getElementsByTagName('body')[0].clientWidth,
viewPortHeight = document.getElementsByTagName('body')[0].clientHeight
}

return [viewPortWidth, viewPortHeight];
}

function closePopup()
{
var lDiv = document.getElementById('gppEnrollDiv');
lDiv.style.display='none';
var overlay = document.getElementById('overlay');
overlay.style.display='none';
var lDiv = document.getElementById('spinner');
lDiv.style.display='none';
aKeepSelectsHidden=false;
toggleSelects(false);
}





function convertToEntities(pField)
{
var tstr = pField;
var bstr = '';
var padding = 4;

for (i=0; i<tstr.length; i++)
{
if (tstr.charCodeAt(i)>127)
{
var hex = tstr.charCodeAt(i).toString(16);
while (hex.length < padding)
{
hex = '0' + hex;
}
bstr += '&#x' + hex + ';';
}
else
{
bstr += tstr.charAt(i);
}
}
return bstr;
}

function showRoomsPopup()
{
setSelectedValue($('popupRoomsCount').options, $('mainRoomsCount').value);
setSelectedValue($('numAdults0').options, $('numAdults').value);
setSelectedValue($('numChildren0').options, $('numChildren').value);
$('roomSelect').style.display = "none";
$('oneRoomVersion').style.display = "none";
$('roomsPopup').style.display = "";
updateZIndexes("-1");
}

function hideRoomsPopup()
{
setSelectedValue($('mainRoomsCount').options, $('popupRoomsCount').value);
setSelectedValue($('numAdults').options, $('numAdults0').value);
setSelectedValue($('numChildren').options, $('numChildren0').value);
$('roomSelect').style.display = "";
$('roomsPopup').style.display = "none";

if($('popupRoomsCount').value == 1)
{
$('oneRoomVersion').style.display = "";
$('multiRoomVersion').style.display = "none";
}
else
{
$('multiRoomVersion').style.display = "";
$('oneRoomVersion').style.display = "none";
}
updateZIndexes("1");
}

function updateZIndexes(pValue)
{
if($('channel1')) { $('channel1').style.zIndex = pValue;}
if($('channel2')) { $('channel2').style.zIndex = pValue;}
if($('channel3')){ $('channel3').style.zIndex = pValue;}
if($('footerlinks')) {$('footerlinks').style.zIndex = pValue;}
if($('logorow')){$('logorow').style.zIndex = pValue;}
if($('carousel')){$('carousel').style.zIndex = pValue;}
if($('footer')){$('footer').style.zIndex = pValue;}
}

function adjustDealsSearchRequestParam()
{
var lSortingElements = { 2 : 'sortbylocation', 4 : 'sortbyinterest', 3 : 'sortbyofferend'};
if(sDealsFinderForm.sortingElement.value != '')
{
var lSortingElementClassName = lSortingElements[sDealsFinderForm.sortingElement.value];
$$('.' + lSortingElementClassName).each( function(pOrderIndicator){
if(pOrderIndicator.hasClassName(sDealsFinderForm.sortingOrder.value))
{
pOrderIndicator.style.display = 'inline-block';
pOrderIndicator.removeClassName('inactive');
pOrderIndicator.addClassName('active');
}
else
{
pOrderIndicator.style.display = 'none';
pOrderIndicator.removeClassName('active');
pOrderIndicator.addClassName('inactive');
}
});
}
}

function orderByColumnHandler(pSortingElement)
{
var lSortingElements = {'sortbylocation' : 2, 'sortbyinterest' : 4, 'sortbyofferend' : 3};
sDealsFinderForm.sortingElement.value = lSortingElements[pSortingElement];
$$('.' + pSortingElement).each(function(pElement){
orderIndicatorhandler(pElement);
});
clearDateLabels();
sDealsFinderForm.submit();
}

function orderIndicatorhandler(pElement)
{
if (!pElement.hasClassName('inactive') && !pElement.hasClassName('active'))
{
sDealsFinderForm.sortingOrder.value ="asc";
if (pElement.hasClassName('sortbyofferend'))
{
sDealsFinderForm.sortingOrder.value ="desc";
}
}
else if (pElement.hasClassName('inactive'))
{
sDealsFinderForm.sortingOrder.value = pElement.className.split(' ')[1];
}
}


function countOccupants()
{
totalAdultCount = 0;
totalChildrenCount = 0;
for (i = 1; i <= 9; i++)
{
if ($('roomNumber' + i).style.display != "none")
{
totalAdultCount = totalAdultCount + parseInt($('adultRoom' + i).value);
totalChildrenCount = totalChildrenCount + parseInt($('childrenRoom' + i).value);
}
}
if($('totalAdults').tagName == "INPUT")
{
$('totalAdults').value = totalAdultCount;
$('totalChildren').value = totalChildrenCount;
}
else
{
$('totalAdults').innerHTML = totalAdultCount;
$('totalChildren').innerHTML = totalChildrenCount;
}

$('adultLabel').innerHTML = totalAdultCount != 1 ? sOccupantsLabel.adults : sOccupantsLabel.adult;
$('childLabel').innerHTML = totalChildrenCount != 1 ? sOccupantsLabel.children : sOccupantsLabel.child;

}

function countPanel()
{
selectedValueChild = $('room1Children').getValue();
selectedValueAdult = $('room1Adult').getValue();
if (selectedValueChild == 1)
{
$('childLabelPanel').innerHTML = sOccupantsLabel.child;
}
else
{
$('childLabelPanel').innerHTML = sOccupantsLabel.children;
}
if (selectedValueAdult == 1)
{
$('adultLabelPanel').innerHTML = sOccupantsLabel.adult;
}
else
{
$('adultLabelPanel').innerHTML = sOccupantsLabel.adults;
}
}

function removeRoom(pRoomNumber)
{
noOfRooms = $('rooms').value;
roomsIndex = $('rooms').selectedIndex;
for (x = pRoomNumber; x <= roomsIndex; x++)
{
$('adultRoom' + x).selectedIndex = $('adultRoom' + (x+1)).selectedIndex;
$('childrenRoom' + x).selectedIndex = $('childrenRoom' + (x+1)).selectedIndex;
}
$('roomNumber' + noOfRooms).style.display = 'none';
$('adultRoom' + noOfRooms).selectedIndex = 0;
$('childrenRoom' + noOfRooms).selectedIndex = 0;
$('rooms').selectedIndex = roomsIndex - 1;
if($('room1Adult') != null && $('room1Children') != null)
{ 
if ($('rooms').selectedIndex == 0) 
{
toggleSelectAndTotalOccupants();
$('roomNumber1').style.display = 'none';
$('roomOccupantsCol').style.display = 'none';
$('room1Adult').value = $('adultRoom1').value;
$('room1Children').value = $('childrenRoom1').value;
countPanel(); 
}
}
if ($('modifySearchPanel'))
{
handleFormChange();
}
}

function toggleRoomOccupantsCol()
{
noOfRooms = $('rooms').getValue();
$('showModifyOccupants').toggle();
$('hideModifyOccupants').toggle();
for (i = 1; i <= noOfRooms; i++)
{
var lSelectedIndex = $('adultRoom' + i).getValue();
$('roomNumber' + i).style.display = lSelectedIndex > 0 ? "" : "none";
}
if ($("moreOptionsCol") != null && $("moreOptionsCol").visible())
{
$("moreOptionsCol").hide();
$('showMoreOptions').toggle();
$('hideMoreOptions').toggle();
}
$("roomOccupantsCol").style.display = $('showModifyOccupants').visible() ? "none" : "block";
}

function changeOccupants(pRoomsSelected)
{
toggleRoomOccupantsCol();
$('roomOccupantsCol').style.display = "block";
if($("moreOptionsCol") != null || $("moreOptionsCol") != undefined)
{
$('moreOptionsCol').hide();
} 
$('showModifyOccupants').hide();
$('hideModifyOccupants').show();
for (i = 1; i <= 9; i++)
{
if (i <= pRoomsSelected)
{
if ($('roomNumber' + i).style.display == "none")
{
$('adultRoom' + i).selectedIndex = 1;
$('roomNumber' + i).style.display = "";
}
}
else
{
$('adultRoom' + i).selectedIndex = 0;
$('childrenRoom' + i).selectedIndex = 0;
$('roomNumber' + i).style.display = "none";
}
}
}

function addOccupants(pRoomsSelected)
{
$("roomOccupantsCol").style.display = (pRoomsSelected >= 2) ? "block" : "none";
for (i = 1; i <= 9; i++)
{
if (i <= pRoomsSelected)
{
if ($('roomNumber' + i).style.display == "none")
{
$('adultRoom' + i).selectedIndex = 0;
$('roomNumber' + i).style.display = "";
}
}
else
{
$('adultRoom' + i).selectedIndex = 0;
$('childrenRoom' + i).selectedIndex = 0;
$('roomNumber' + i).style.display = "none";
}
}
}

function toggleSelectAndTotalOccupants()
{
noOfRooms = $('rooms').value;
if (noOfRooms >= 2)
{
$("selectNumberOccupants").style.display = "none";
$("textNumberOccupants").style.display = "block";
moveValuesFromMainToDrawer()
} 
else
{
$("selectNumberOccupants").style.display = "block";
$("textNumberOccupants").style.display = "none";
moveValuesFromDrawerToMain();
}
}

function countOccupantsLandingPage()
{
totalAdultCount = 0;
totalChildrenCount = 0;
for (i = 1; i <= 9; i++)
{
if ($('roomNumber' + i).style.display != "none")
{
totalAdultCount = totalAdultCount + parseInt($('adultRoom' + i).value);
totalChildrenCount = totalChildrenCount + parseInt($('childrenRoom' + i).value);
}
}
$('totalAdults').value = totalAdultCount;
$('totalChildren').value = totalChildrenCount;
}

function hideDrawerUponRoomRemove()
{
noOfRooms = $('rooms').value;
if (noOfRooms == 1)
{
$("roomOccupantsCol").style.display = "none"; 
toggleSelectAndTotalOccupants();
moveValuesFromDrawerToMain();
}
}

function moveValuesFromMainToDrawer()
{
$('adultRoom1').selectedIndex = $('room1Adult').selectedIndex;
$('childrenRoom1').selectedIndex = $('room1Children').selectedIndex; 
}

function moveValuesFromDrawerToMain()
{
if ($('adultRoom1').selectedIndex == 0)
{
$('room1Adult').selectedIndex = 0;
}
else
{
$('room1Adult').selectedIndex = $('adultRoom1').selectedIndex - 1;
}
$('room1Children').selectedIndex = $('childrenRoom1').selectedIndex; 
}

function submitItinerarySearchForm()
{
var lForm = document.itinerarySearchForm;
lForm.submit();
}

function handleBrandSelectionChange(pBrand)
{

if (pBrand == 'searchCrossBrand')
{
for (var i = 1; i <= sBrandCount; i++)
{
$('selectedCrossBrandSearchCodes' + i).checked = false;
}
}
else
{
$('searchCrossBrand').checked = false;
var total = 0;
for (var i = 1; i <= sBrandCount; i++)
{
if ($('selectedCrossBrandSearchCodes' + i).checked == true)
{
total += 1;
}
}

if (total == sBrandCount)
{
for (var i = 1; i <= sBrandCount; i++)
{
$('selectedCrossBrandSearchCodes' + i).checked = false;
}
$('searchCrossBrand').checked = true;
}
} 
}

function highlightBlankDates()
{
var lCheckInDate = $('checkinDate');
var lCheckOutDate = $('checkoutDate');
var lDateFormat = 'mm/dd/yyyy';
if (lCheckInDate.getValue() == "" || lCheckInDate.getValue() == lDateFormat)
{
lCheckInDate.setStyle({
backgroundColor : '#FFFF99'
});
}
if (lCheckOutDate.getValue() == "" || lCheckOutDate.getValue() == lDateFormat)
{
lCheckOutDate.setStyle({
backgroundColor : '#FFFF99'
});
}
}

function clearHighLight(pElement)
{
pElement.setStyle({backgroundColor : '#FFF'}); 
}


function showPanel(pElement, pHotelCode, pInfoPanelId) 
{
Element.extend(pElement);
var rowBubbleArrow = '.detailpointerarrow' + pHotelCode;
var bubbleArrow = pElement.next().next().next().down();
var hotelCode = pHotelCode + 'rates';
var rateDetailId = pInfoPanelId + 'details';
if ($(hotelCode) != null)
{
if ($(hotelCode).down() != null && $(hotelCode).down().identify() == rateDetailId && $(hotelCode).getStyle('display') != 'none' && bubbleArrow.getStyle('display') != 'none')
{
closeAllInRow(pHotelCode);
}
else
{
$$(rowBubbleArrow).each(function(pElement){
pElement.style.display = 'none';
});
bubbleArrow.show();
$(hotelCode).show();
}
}
}

function closeAllInRow(pHotelCode)
{
if ($(pHotelCode + "rates") != null)
{
var rowBubbleArrow = '.detailpointerarrow' + pHotelCode;
var hotelCode = pHotelCode + 'rates';
$(hotelCode).hide();
$$(rowBubbleArrow).each(function(pElement){
pElement.style.display = 'none';
});
}
}

function updateRateDetailsPanel(pRate, pHotelCode, pHideExploreHotelPanel, pShowBubble)
{
var infoPanelId = "rateinfo:" + pRate;
var hotelCode = pHotelCode + "rates";
var rateDetailId = infoPanelId + "details";
var showBubble = pShowBubble;
if (pHideExploreHotelPanel != undefined && pHideExploreHotelPanel != "false")
{
hideExploreHotelPanel(pHotelCode);
}
if ($(pHotelCode + "promoCalendarPanelBox") && $(pHotelCode + "promoCalendarPanelBox").visible())
{
$(pHotelCode + "promoCalendarPanelBox").hide();
$(pHotelCode + "promoCalendarPointerArrow").style.display = "none";
$(pHotelCode + "calicon").style.display = "";
}

if (showBubble == "false")
{
hotelCode = pRate + pHotelCode + "rates";
}
if ($(hotelCode) != null)
{
$(hotelCode).update();
var lStaticDiv = new Element('div');
lStaticDiv.writeAttribute('class', $(infoPanelId).readAttribute('class'));
lStaticDiv.writeAttribute('id', rateDetailId);
lStaticDiv.update($(infoPanelId).innerHTML);
$(hotelCode).update(lStaticDiv);
if (showBubble == "false")
{
if ($(hotelCode).getStyle('display') == 'none')
{
$(hotelCode).show();
}
else
{
$(hotelCode).hide();
}
}
}

if (typeof sOmniturePrefix != 'undefined' && $(hotelCode) != null && $(hotelCode).visible())
{
var lEvar44 = sOmniturePage + "ratedetails";
invokeOmniture(sOmniturePrefix + lEvar44, sOmnitureEvent, null, lEvar44, null, false);
}

}

function toggleAllBrands(pChecked)
{
for (var i = 1; i <= sBrandCount; i++)
{
$('selectedCrossBrandSearchCodes' + i).checked = pChecked;
}
}

function adjustMainPanel()
{
$$('.mainPanel').each(function(pMainPanel){
var lHeight = pMainPanel.getHeight();
pMainPanel.select('.column .columnWrapper').each(function(pColumn){
if (pColumn.getHeight() > lHeight)
{
lHeight = pColumn.getHeight();
}
});
if (lHeight > pMainPanel.getHeight())
{
pMainPanel.style.height = lHeight + 'px';
pMainPanel.select('.column').each(function(pColumn){
pColumn.style.height = lHeight + 'px';
});
}

});
}

function showSearchOption(pSearchTypeDiv, pSearchType)
{
$$('.searchform').each(function(pElement){
if (pElement.identify != pSearchTypeDiv)
{
pElement.select('input').each(function(pElement){
pElement.checked = '';
});
}
pElement.style.display = 'none';
});
$(pSearchTypeDiv).style.display = 'block';
adjustMainPanel();
$$('.searchTypeToggle').each(function(pElement){
pElement.removeClassName('toggled');
});
$(pSearchTypeDiv + 'Toggle').addClassName('toggled');
$('homePageSearchType').value = pSearchType;
}

function onShowAutoComplete(pInputElement, pChoicesContainer)
{ 
if (!pChoicesContainer.style.position || pChoicesContainer.style.position == 'absolute') 
{
pChoicesContainer.style.position = 'absolute';
pChoicesContainer.style.width = 'auto';
pChoicesContainer.clonePosition(pInputElement, {
setWidth: false,
setHeight: false, 
offsetTop: pInputElement.offsetHeight
});
pChoicesContainer.style.width = pInputElement.getWidth() > pChoicesContainer.getWidth() ? 
pInputElement.getWidth() + 'px' : pChoicesContainer.getWidth() + 'px';
}
Effect.Appear(pChoicesContainer,{duration:0.15}); 
};
