



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=800,height=550,toolbar=no,menubar=no,scrollbars=yes,resizable=yes";
var lWindowPath = "/common/map.do?hotelCode=" + pHotelCode + "&hotelBrandCode=" + pHotelBrandCode + "&mapType=hotel.map";
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 == '')
{
$('workCountryPrefix').value = '';
$('homeCountryPrefix').value = '';
}
else
{
$('workCountryPrefix').value = countryCodes[pCountryCode.value];
$('homeCountryPrefix').value = countryCodes[pCountryCode.value];
}
pCountryCode.focus();
}

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

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)
{
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 = "";
}
}
}

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)
{
$('tabREG').className = 'inactive';
$('tabRAD').className = 'inactive';
$('tabCHI').className = 'inactive';
$('tabPII').className = 'inactive';
$('tabPKP').className = 'inactive';
$('panelREG').className = 'inactivePanel';
$('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.createAccountForm;

if (lForm.postal)
{
lForm.postal.value = RemoveInvalidPostalCodeCharacters(lForm.postal.value, lForm.country.options[lForm.country.selectedIndex].value);
}
if (lForm.countryPrefix)
{
lForm.countryPrefix.value = RemoveInvalidPhoneCharacters(lForm.countryPrefix.value);
}
if (lForm.areaCode)
{
lForm.areaCode.value = RemoveInvalidPhoneCharacters(lForm.areaCode.value);
}
if (lForm.phoneNumber)
{
lForm.phoneNumber.value = RemoveInvalidPhoneCharacters(lForm.phoneNumber.value);
}
if (lForm.GPNumber)
{
lForm.GPNumber.value = RemoveInvalidPhoneCharacters(lForm.GPNumber.value);
}

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

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




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");
Element.hide("rdmmsg");
}

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

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

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

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

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

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

document.itinerarySearchForm.firstName.focus();
$("rateSearchForm.redemptionSearch").value = 'false';
}
if (pSelectedElement == "rdm")
{
Element.hide("res");
Element.hide("resmsg");
if(pIsGppMember)
{
Element.show("fah");
Element.hide("rdm");
Element.show("fahmsg");
Element.hide("rdmmsg");
}
else
{
Element.show("rdm");
Element.hide("fah");
Element.show("rdmmsg");
Element.hide("fahmsg");
$('content').style.paddingBottom = '0px';
}

$("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();
}
else
{
for (i = 1; i <= totalRooms; i++)
{
if (i <= roomsSelected)
{
document.getElementById(roomPrefix + i).style.display = "";
}
else
{
document.getElementById(roomPrefix + i).style.display = "none";
}
}
showRoomsPopup();
}
}
else
{
for (i = 1; i <= totalRooms; i++)
{
if (i <= roomsSelected)
{
document.getElementById(roomPrefix + i).style.display = "";
}
else
{
document.getElementById(roomPrefix + i).style.display = "none";
}
}
}
}




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 = $('rateSearchForm');

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

if ($('homePageSearch'))
{
lForm.action ='/home/reservation/rateSearch.do';
} 
else 
{
lForm.action ='/reservation/rateSearch.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)
{
var lUrl = '/hotels';
if ($('rateSearchForm.redemptionSearch') && $('rateSearchForm.redemptionSearch').value == 'true')
{
lUrl += '/redemption';
} 
lUrl += '/' + $('country').value.toLowerCase();
if ($('countryAndState') && $('countryAndState').value != '')
{
lUrl += '/' + $('countryAndState').value.substring(3,5).toLowerCase();
}
if ($('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 submitRateSearchForm(pShowInterimSearchPage)
{
if ($F('rateSearchHotelCode') == "search-london") 
{
var lForm = $('rateSearchForm');
lForm.action = '/reservation/cityRateSearch.do';
lForm['citySearchForm.city'].value = 'london';
lForm['citySearchForm.country'].value = 'GB';
}


$('rateSearchForm').submit();
if (pShowInterimSearchPage)
{
document.getElementById("bodydiv").style.display = "none";
document.getElementById("waitdiv").style.display = "";
document.getElementsByTagName("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)
{
$$('div.StaticDetailOpen').each(function(divElement) {
hideStaticDetailDiv(divElement);
});
toggleSelects(true);
toggleButtons(true);
new Effect.BlindDown(pElementId, { queue: 'end' });
$(pElementId).addClassName('StaticDetailOpen');
}

function hideStaticDetailDiv(pElementId)
{
toggleSelects(false);
toggleButtons(false);
new Effect.BlindUp(pElementId, { queue: 'end' });
$(pElementId).removeClassName('StaticDetailOpen');
}

function toggleSelects(pMakeHidden)
{
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;
}
}
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()
{
var lCheckin = $('checkinDate');
var lCheckout = $('checkoutDate');
var DATE_FORMAT = "mm/dd/yyyy";

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

if (lCheckout.value == DATE_FORMAT)
{
lCheckout.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 (!lSuggests)
{
return;
}

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

function adjustUrl(pSecure)
{
if (!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;
}
}
}

