///
///
///
// initialise HC namespaces..
if (typeof (HC) == "undefined") {
var HC = {};
}
hotelPageCityName = "";
// initialise global variables..
var monthsLong = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var weekdaysShort = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
var calTitle = "Choose a date:";
var myLabelYearPosition = 2;
var myLabelMonthPosition = 1;
var myLabelYearSuffix = "";
var myLabelMonthSuffix = " ";
HC.gSearching = false;
HC.currentRateTabId = "rateViewSimple";
function ReverseString(value) {
if (value == null) {
return null;
}
var output = "";
for (i = 0; i < value.length; i++) {
output = value.charAt(i) + output;
}
return output;
}
HC.QS = {
AppendFilename: function(qString) {
if (!qString) {
return HC.query;
}
if (qString.indexOf("fileName") == -1) {
if (HC.query != "") {
if (qString.indexOf("languageCode") > -1) {
qString = this.remQStringName(qString, "languageCode");
}
return qString + "&" + HC.query;
}
else {
return qString;
}
}
else {
return qString;
}
},
//unencode url-encoded string
URLDecode: function(urlStr) {
return decodeURIComponent(urlStr);
},
//replace or add name/value pairs in url-encoded querystring
setQStringName: function (qString, name, arrVal) {
var qStringNew = this.remQStringName(qString, name);
var start = qStringNew == "" ? 1 : 0;
for (var i = 0; i < arrVal.length; i++) {
qStringNew += "&" + encodeURIComponent(name) + "=" + encodeURIComponent(arrVal[i]);
}
return qStringNew.substr(start);
},
//remove all name/value pairs with the passed name from url-encoded querystring
remQStringName: function (qString, name) {
var i;
var qStringNew = "";
if (qString != "") {
var curName;
var arrNameVal = qString.split('&');
for (i = 0; i < arrNameVal.length; i++) {
curName = this.URLDecode(arrNameVal[i].split('=')[0]);
if (curName.toLowerCase() != name.toLowerCase()) {
qStringNew += "&" + arrNameVal[i];
}
}
}
return qStringNew.substr(1);
},
//extract (first!) value from querystring for the passed name
GetQSVal: function(qsName) {
try {
var qsPair;
var i;
var qString = location.search.substr(1);
if (qString == null || qString.length == 0) {
qString = HC.query;
}
var arrNameVal = qString.split('&');
for (i = 0; i < arrNameVal.length; i++) {
qsPair = arrNameVal[i].split('=');
if (this.URLDecode(qsPair[0]).toLowerCase() == qsName.toLowerCase()) {
return this.URLDecode(qsPair[1]);
}
}
}
catch (e) {
}
return "";
}
};
//reload page with the new querystring name-value pair
function Reload(name, val, anchor) {
var qString = location.search.substr(1);
qString = HC.QS.AppendFilename(qString);
//Change the currency in the returnPath as well
if (name == "currencyCode") {
var returnPath = HC.QS.GetQSVal("returnPath");
if (returnPath) {
returnPath = HC.QS.remQStringName(returnPath, "currencyCode");
returnPath = HC.QS.setQStringName(returnPath, "currencyCode", [val]);
returnPath = HC.QS.remQStringName(returnPath, "lowRate");
returnPath = HC.QS.remQStringName(returnPath, "highRate");
qString = HC.QS.remQStringName(qString, "returnPath");
qString = HC.QS.setQStringName(qString, "returnPath", [returnPath]);
}
}
//always reset page to 1
if (name != "pageIndex") {
var page = HC.QS.GetQSVal("pageIndex");
if (page != "0" && page != "") {
qString = HC.QS.setQStringName(qString, "pageIndex", new Array("0"));
}
}
//Pass across the page size if available
var pageSize = $("#pageSize");
if (pageSize.length == 1) {
qString = HC.QS.setQStringName(qString, "pageSize", [pageSize[0].value]);
}
qString = HC.QS.setQStringName(qString, name, new Array(val.toString()));
qString = HC.QS.remQStringName(qString, "scroll");
//Remove customFileName
qString = HC.QS.remQStringName(qString, 'fileNameType');
if (typeof gCityFileName != "undefined") {
qString = HC.QS.setQStringName(qString, "fileName", [gCityFileName]);
}
// display view layout..
qString = HC.QS.remQStringName(qString, "view");
qString += "&view=" + HC.Design.GetSRLayout();
if (qString.indexOf("&") == 0) {
qString = qString.substr(1);
}
var anchorTag = "";
if (typeof anchor != 'undefined' && anchor != "") {
anchorTag = "#" + anchor;
}
if (typeof HC.path != 'undefined' && HC.path != null && HC.path.length > 0) {
location = HC.path + "?" + qString + anchorTag;
}
else {
location = location.pathname + "?" + qString + anchorTag;
}
return false;
}
function setGuestValue(containerId, select) {
document.getElementById(containerId + '_Guests').value = select.options[select.selectedIndex].value;
return false;
}
function setRoomValue(containerId, select, target) {
if (target == undefined || target == null) {
target = "_self";
}
if (select.value == "5") {
select.selectedIndex = 0;
var r = confirm(typeof (JavaScriptSearchMoreRoom) == 'undefined' ? 'We only support searching for up to four rooms at once, would you like to use our partner site Hotelplanner.com to search for more rooms?' : JavaScriptSearchMoreRoom);
if (r == true) {
window.open("/ProviderRedirect.ashx?Label=Direct&key=" + HC.gHotelPlannerLink, target);
return false;
}
}
else {
document.getElementById(containerId + '_Rooms').value = select.options[select.selectedIndex].value;
}
return false;
}
function getDate(dateString) {
var year = dateString.substr(0, 4);
var month = dateString.substr(5, 2) - 1;
var day = dateString.substr(8, 2);
return new Date(year, month, day);
}
// validate dates
function ValidateDates() {
var inDate = Date.fromString(document.getElementById(calendar1Id).value, ShortDatePatternVariable);
var outDate = Date.fromString(document.getElementById(calendar2Id).value, ShortDatePatternVariable);
var currentDate = new Date();
// validate checkin - checkout difference (date range too big)
// 86400000 is one days in milliseconds
if ((outDate - inDate) / 86400000 >= 31) {
alert(typeof (JavaScriptPeriodOfStay) == 'undefined' ? 'Your period of stay should be no longer than 30 nights.' : JavaScriptPeriodOfStay);
return false;
}
// validate checkout <= checkin
if (outDate - inDate <= 0) {
alert(typeof (JavaScriptEnsureCheckoutAfterCheckin) == 'undefined' ? 'Please ensure that the check-out date is after the check-in date.' : JavaScriptEnsureCheckoutAfterCheckin);
return false;
}
//validate checkin/checkout is less than one year in advance
if ((outDate - currentDate) / 86400000 >= 364) {
alert(typeof (JavaScriptBookWithinOneYear) == 'undefined' ? 'You cannot book more than 1 year in advance.' : JavaScriptBookWithinOneYear);
return false;
}
return true;
}
function getCookie(cookieName) {
if (document.cookie != null && document.cookie.length > 0) {
var start = document.cookie.indexOf(cookieName + "=");
if (start != -1) {
start = start + cookieName.length + 1;
var end = document.cookie.indexOf(";", start);
if (end == -1) {
end = document.cookie.length;
}
return unescape(document.cookie.substring(start, end));
}
}
return "";
}
//only used by two affiliate search boxes
function CitySelect(cityFileName) {
document.getElementById(cityFileName).checked = "checked";
document.getElementById("citySearch").value = "";
document.getElementById("selectedFileName").value = cityFileName;
}
//this function used only by legacy search boxes
function DoHomePageSearch(languageCode, target, affiliateId, city, domain, brandId, options, containerId) {
var calendar1Id = containerId + '_Checkin';
var calendar2Id = containerId + '_Checkout';
if (HC.gSearching) {
return false;
}
options = options || {};
var redirection;
var affiliateParam;
var brandParam;
var host;
var locationParam = "";
var isAutoComplete = false;
if (!ValidateCalendarDates(calendar1Id, calendar2Id, true)) {
return false
}
//in home page, if city name is autocomplete text, redirect to searchResults.aspx, otherwise redirect to search.aspx
if (document.getElementById('citySearch') != null && document.getElementById('selectedCityName') != null) {
if (document.getElementById('citySearch').value != 0 && document.getElementById('selectedCityName').value != 0) {
if (document.getElementById('citySearch').value == document.getElementById('selectedCityName').value) {
isAutoComplete = true;
// If Location supplied by autosuggest
var locationID = document.getElementById("selectedLocationID").value;
if (locationID && !isNaN(locationID)) {
locationParam = "&locationId=" + locationID + "&sort=Distance-asc";
}
}
}
}
city = encodeURIComponent(city);
if (typeof (brandId) == 'undefined' || brandId == "0") {
brandParam = '';
}
else {
brandParam = '&brandId=' + brandId;
}
if (affiliateId == null || affiliateId == '') {
affiliateParam = '';
host = '';
}
else {
affiliateParam = '&a_aid=' + affiliateId;
// backwards compatability for existing affiliate scripts
if (typeof (domain) == 'undefined' || domain == '') {
host = 'http://www.hotelscombined.com';
}
else {
host = 'http://' + domain;
}
}
var defaultSort = HC.QS.GetQSVal("sort");
if (document.getElementById("M_C_Locations") != null) {
if (sortDistance) {
defaultSort = "Distance-asc";
}
}
if (defaultSort.length > 0) {
defaultSort = "&sort=" + defaultSort;
}
//convert dates from localized format to default one
checkinValue = HC.Calendar.formatDate(Date.fromString(document.getElementById(calendar1Id + "Value").value, ShortDatePatternVariable), DefaultShortDatePatternVariable);
checkoutValue = HC.Calendar.formatDate(Date.fromString(document.getElementById(calendar2Id + "Value").value, ShortDatePatternVariable), DefaultShortDatePatternVariable);
//if come from home page without an autocompleted city name or come from city/searchResult pages with a new city name entered in the 'City' textbox
if ((document.getElementById("citySearchRadio") != null && document.getElementById("citySearchRadio").checked && !isAutoComplete) || document.getElementById("M_C_SearchBox1_SearchResultCity") != null) {
if (city == null || city.length < 3) {
alert(typeof (JavaScriptEnterCityName) == 'undefined' ? 'Please enter a city name that is at least 3 characters in length' : JavaScriptEnterCityName);
return false;
}
redirection = "http://www.hotel.omeilleursprix.com/Search.aspx?Label=Direct&search=" + encodeURIComponent(city) + "&checkin=" + checkinValue + "&checkout=" + checkoutValue + "&languageCode=" + languageCode + affiliateParam + brandParam + defaultSort;
//if come from city or search result pages, add query info
if (document.getElementById("M_C_SearchBox1_SearchResultCity") != null) {
var currency = document.getElementById("M_C_Filter1_currencies");
redirection += currency == null ? "" : "¤cyCode=" + currency.options[currency.selectedIndex].id;
if (document.getElementById("M_C_Filter1_LowRate") != null) {
if (document.getElementById("M_C_Filter1_LowRate").value != null && document.getElementById("M_C_Filter1_LowRate").value != 0) {
redirection += "&lowRate=" + encodeURIComponent(document.getElementById("M_C_Filter1_LowRate").value);
}
}
if (document.getElementById("M_C_Filter1_HighRate") != null) {
if (document.getElementById("M_C_Filter1_HighRate").value != null && document.getElementById("M_C_Filter1_HighRate").value != 0) {
redirection += "&highRate=" + encodeURIComponent(document.getElementById("M_C_Filter1_HighRate").value);
}
}
redirection += HC.Common.GetStarValue(redirection, document.getElementById("M_C_Filter1_M_C_Star5"), "star5");
redirection += HC.Common.GetStarValue(redirection, document.getElementById("M_C_Filter1_M_C_Star4"), "star4");
redirection += HC.Common.GetStarValue(redirection, document.getElementById("M_C_Filter1_M_C_Star3"), "star3");
redirection += HC.Common.GetStarValue(redirection, document.getElementById("M_C_Filter1_M_C_Star2"), "star2");
redirection += HC.Common.GetStarValue(redirection, document.getElementById("M_C_Filter1_M_C_Star1"), "star1");
redirection += "&cityName=" + city;
if (document.getElementById("M_C_Filter1_HotelName") != null) {
if (document.getElementById("M_C_Filter1_HotelName").value != null && document.getElementById("M_C_Filter1_HotelName").value != 0) {
redirection += "&hotelName=" + encodeURIComponent(document.getElementById("M_C_Filter1_HotelName").value);
}
}
if (document.getElementById("M_C_Filter1_ShowSoldOut") != null) {
redirection += document.getElementById("M_C_Filter1_ShowSoldOut").checked ? "" : "&showSoldOut=false";
}
if (document.getElementById("M_C_InstantOnly") != null) {
redirection += document.getElementById("M_C_InstantOnly").checked ? "" : "&instantOnly=false";
}
}
}
else {
var searchTermType = document.getElementById("selectSearchTermType").value;
redirection = "http://www.hotel.omeilleursprix.com/SearchTermTypeRedirection.ashx?Label=Direct&fileName=" + document.getElementById("selectedFileName").value + "&checkin=" + checkinValue + "&checkout=" + checkoutValue + "&languageCode=" + languageCode + affiliateParam + brandParam + defaultSort + locationParam + "&sttype=" + searchTermType;
}
//Show the searching image
if (options.changeClass && options.searchButton) {
$(options.searchButton).removeClass(options.changeClass[0]).addClass(options.changeClass[1]);
}
//if checkin and checkout date were not specified redirect to static city page
var checkinText = document.getElementById(calendar1Id).value;
var checkoutText = document.getElementById(calendar2Id).value;
var cityFileName = document.getElementById('selectedFileName').value;
if (!checkinText && !checkoutText) {
setTimeout(function () { window.location = host + "City/" + cityFileName + '.htm'; }, 10); // _self
return;
}
var inputIdParts = calendar1Id.split('_');
var containerId = inputIdParts[0];
var guestsEl = document.getElementById(containerId + "_GuestsValue");
var roomsEl = document.getElementById(containerId + "_RoomsValue");
redirection += guestsEl == null ? "" : "&Adults=" + guestsEl.value;
redirection += roomsEl == null ? "" : "&Rooms=" + roomsEl.value;
// locations
var locations = document.getElementById("M_C_Locations");
if (locations != null) {
if (locations.value != 0) {
redirection += "&locationId=" + locations.options[locations.selectedIndex].value;
}
}
// location distance
var distance = document.getElementById("M_C_Distance");
if (distance != null) {
if (distance.value != 0) {
redirection += "&distance=" + distance.options[distance.selectedIndex].value;
}
}
// hotel brands
if (document.getElementById("p-chain") != null) {
if (chainId != null && chainId != "") {
if (document.getElementById("M_C_HotelChainAll") != null) {
if (document.getElementById("M_C_HotelChainAll").checked == false) {
var checkedChain = "";
var chain = chainId.split(',');
for (var i = 0; i < chain.length; i++) {
if (document.getElementById("M_C_HotelChain" + chain[i]) != null) {
if (document.getElementById("M_C_HotelChain" + chain[i]).checked) {
checkedChain += chain[i] + ",";
}
}
}
if (checkedChain != "") {
var strLen = checkedChain.length;
checkedChain = checkedChain.slice(0, strLen - 1);
redirection += "&chain=" + checkedChain;
}
}
}
}
}
// add facilities to query if come from search result page
if (document.getElementById("M_C_Filter1_HotelFacility1") != null) {
for (var i = 1; i <= facilityCount; i++) {
if (document.getElementById("M_C_Filter1_HotelFacility" + i).checked) {
var facilityId = $("#M_C_Filter1_HotelFacility" + i).parent()[0].attributes["faclityId"].value;
facility += facilityId + ",";
}
}
if (facility != "") {
var strLen = facility.length;
facility = facility.slice(0, strLen - 1);
redirection += "&facilities=" + facility;
}
}
//Add disable access (Don't care about the facility above
//As this should never happen on our site)
if (HC.disabilityEnabled) {
redirection += "&facilities=10";
}
// add noPropType to query if some property types are unchecked
var noPropType = "";
for (var i = 0; i <= 9; i++) {
if (document.getElementById("M_C_Filter1_PropertyType" + i) != null) {
if (document.getElementById("M_C_Filter1_PropertyType" + i).checked == false) {
noPropType += i + ',';
}
}
}
if (noPropType != "") {
var strLen = noPropType.length;
noPropType = noPropType.slice(0, strLen - 1);
redirection += "&noPropType=" + noPropType;
}
if (options.append) redirection += options.append;
redirection = host + redirection;
HC.gSearching = true;
switch (target) {
case "_blank":
HC.gSearching = false;
window.open(redirection).focus();
break;
case "_parent":
window.parent.location = redirection;
break;
case "_top":
window.top.location = redirection;
break;
default:
setTimeout(function() { window.location = redirection; }, 10); // _self
}
return false;
}
function DoCitySearchBoxSearch(languageCode, target, affiliateId, fileName, domain, brandId, applyFilters) {
var redirection;
var affiliateParam;
var brandParam;
var host;
if (HC.Common.isFieldEmpty('hotelCheckin', 'hotelCheckout')) {
return false;
}
else {
if (!ValidateDates()) {
return false;
}
if (typeof (brandId) == 'undefined' || brandId == "0") {
brandParam = '';
}
else {
brandParam = '&brandId=' + brandId;
}
if (affiliateId == null || affiliateId == '') {
affiliateParam = '';
host = '';
}
else {
affiliateParam = '&a_aid=' + affiliateId;
// backwards compatability for existing affiliate scripts
if (typeof (domain) == 'undefined' || domain == '') {
host = 'http://www.hotelscombined.com';
}
else {
host = 'http://' + domain;
}
}
var guest = document.getElementById('guestValue') == null ? "" : "&Adults=" + document.getElementById("guestValue").value;
var room = document.getElementById('roomValue') == null ? "" : "&Rooms=" + document.getElementById('roomValue').value;
redirection = "http://www.hotel.omeilleursprix.com/SearchResults.aspx?Label=Direct&fileName=" + fileName + "&checkin=" + document.getElementById("checkinValue").value + "&checkout=" + document.getElementById("checkoutValue").value + "&languageCode=" + languageCode + affiliateParam + brandParam + guest + room;
if (applyFilters) {
redirection = HC.Common.SetStarValue(redirection, document.getElementById("M_C_Filter1_Star5"), 'star5');
redirection = HC.Common.SetStarValue(redirection, document.getElementById("M_C_Filter1_Star4"), 'star4');
redirection = HC.Common.SetStarValue(redirection, document.getElementById("M_C_Filter1_Star3"), 'star3');
redirection = HC.Common.SetStarValue(redirection, document.getElementById("M_C_Filter1_Star2"), 'star2');
redirection = HC.Common.SetStarValue(redirection, document.getElementById("M_C_Filter1_Star1"), 'star1');
redirection = HC.QS.setQStringName(redirection, "sort", new Array(document.getElementById("sortBy").options[document.getElementById("sortBy").selectedIndex].value));
var currency = document.getElementById("currencies");
redirection = HC.QS.setQStringName(redirection, 'currencyCode', new Array(currency.options[currency.selectedIndex].text))
if (document.getElementById("AvailableOnly").checked) {
redirection = HC.QS.remQStringName(redirection, "availableOnly");
}
else {
redirection = HC.QS.setQStringName(redirection, "availableOnly", new Array("false"));
}
}
redirection = host + redirection;
switch (target) {
case "_blank":
window.open(redirection).focus();
break;
case "_parent":
window.parent.location = redirection;
break;
case "_top":
window.top.location = redirection;
break;
default:
window.location = redirection; // _self
}
return false;
}
}
function DoHotelSearch(languageCode, hotelFileName, target, affiliateId, domain, brandId) {
var affiliateParam;
var host;
var brandParam;
if (typeof (brandId) == 'undefined' || brandId == "0") {
brandParam = '';
}
else {
brandParam = '&brandId=' + brandId;
}
if (affiliateId == null || affiliateId == '') {
affiliateParam = '';
host = '';
}
else {
affiliateParam = '&a_aid=' + affiliateId;
// backwards compatability for existing affiliate scripts
if (typeof (domain) == 'undefined' || domain == '') {
host = 'http://www.hotelscombined.com';
}
else {
host = 'http://' + domain;
}
}
var guest = document.getElementById('guestValue') == null ? "" : "&Adults=" + document.getElementById("guestValue").value;
var room = document.getElementById('roomValue') == null ? "" : "&Rooms=" + document.getElementById('roomValue').value;
var redirection = host + "/Hotel.aspx?Label=Direct&fileName=" + hotelFileName + "&checkin=" + document.getElementById("checkinValue").value + "&checkout=" + document.getElementById("checkoutValue").value + "&languageCode=" + languageCode + affiliateParam + brandParam + guest + room;
switch (target) {
case "_blank":
window.open(redirection).focus();
break;
case "_parent":
window.parent.location = redirection;
break;
case "_top":
window.top.location = redirection;
break;
default:
window.location = redirection; // _self
}
return false;
}
//Custom function to turn strings into ellipsis
String.prototype.ellipsisString = function(length) {
var result = this;
if (this.length > length + 1) {
result = result.substring(0, length);
result = result.substring(0, result.lastIndexOf(' '));
var lastChar = result.charAt(result.length - 1);
if (lastChar == "." || lastChar == "," || lastChar == "-") {
if (result.length > 1) {
result = result.substring(0, result.length - 1);
}
}
return result + "...";
}
else {
return this;
}
return this + length;
}
// visibility control for hotel.aspx page rate tab first calendar and city.aspx first calendar
function hideHotelDiv(e) {
var target = (e ? e.target : event.srcElement);
var checkinCalDiv = document.getElementById("checkinCalContainer");
var checkinDiv = document.getElementById("hotelCheckin");
var checkoutCalDiv = document.getElementById("checkoutCalContainer");
var checkoutDiv = document.getElementById("hotelCheckout");
if (checkinCalDiv != null && checkinDiv != null && checkoutCalDiv != null && checkoutDiv != null) {
(HC.Common.isChild(target, checkinCalDiv) || target == checkinDiv) ? null : checkinCalDiv.style.display = 'none';
(HC.Common.isChild(target, checkoutCalDiv) || target == checkoutDiv) ? null : checkoutCalDiv.style.display = 'none';
}
}
// visibility control for hotel.aspx page rate tab second calendar.
function hideRateDiv(e) {
var target = (e ? e.target : event.srcElement);
var checkinCalDiv = document.getElementById("rateTabCheckinCalContainer");
var checkinDiv = document.getElementById("rateTabCheckin");
var checkoutCalDiv = document.getElementById("rateTabCheckoutCalContainer");
var checkoutDiv = document.getElementById("rateTabCheckout");
if (checkinCalDiv != null && checkinDiv != null && checkoutCalDiv != null && checkoutDiv != null) {
(HC.Common.isChild(target, checkinCalDiv) || target == checkinDiv) ? null : checkinCalDiv.style.display = 'none';
(HC.Common.isChild(target, checkoutCalDiv) || target == checkoutDiv) ? null : checkoutCalDiv.style.display = 'none';
}
}
// visibility control for city.aspx page popup calendar.
function hidePopupDiv(e) {
var target = (e ? e.target : event.srcElement);
var checkinCalDiv = document.getElementById("popupCheckinCalContainer");
var checkinDiv = document.getElementById("popupCheckin");
var checkoutCalDiv = document.getElementById("popupCheckoutCalContainer");
var checkoutDiv = document.getElementById("popupCheckout");
if (checkinCalDiv != null && checkinDiv != null && checkoutCalDiv != null && checkoutDiv != null) {
(HC.Common.isChild(target, checkinCalDiv) || target == checkinDiv) ? null : checkinCalDiv.style.display = 'none';
(HC.Common.isChild(target, checkoutCalDiv) || target == checkoutDiv) ? null : checkoutCalDiv.style.display = 'none';
}
}
//change date format from yyyy-mm-dd to mm/dd/yyyy
function reFormatDate(date) {
var year = date.substr(0, 4);
var month = date.substr(5, 2);
var day = date.substr(8, 2);
return month + "/" + day + "/" + year;
}
function dateFormat(date) {
return date.toString().length == 1 ? "0" + date : date;
}
/***************** End of yahoo calendar ************************/
/********************** dropdown checkin box **********************/
//changes departure month when arrival month is changed
function checkinUpdated() {
inM = document.getElementById("checkinMonth");
inD = document.getElementById("checkinDay");
outM = document.getElementById("checkoutMonth");
outD = document.getElementById("checkoutDay");
var res = adjustDate(inM.options.selectedIndex, inD);
if (res != 0) {
outD.options.selectedIndex = 0;
if (inM.options.selectedIndex == 11) {
outM.options.selectedIndex = 0;
}
else if (res == 4) {
outM.options.selectedIndex = inM.options.selectedIndex + 1;
outD.options.selectedIndex = 0;
}
else {
outM.options.selectedIndex = inM.options.selectedIndex + 1;
outD.options.selectedIndex = 1;
}
} else {
outM.options.selectedIndex = inM.options.selectedIndex;
if (outD.options.selectedIndex <= inD.options.selectedIndex) {
outD.options.selectedIndex = inD.options.selectedIndex + 2;
}
}
var checkinMonth = inM.options[inM.selectedIndex].value * 1;
var checkinDay = inD.options[inD.selectedIndex].value * 1;
var checkoutMonth = outM.options[outM.selectedIndex].value * 1;
var checkoutDay = outD.options[outD.selectedIndex].value * 1;
document.getElementById("checkinValue").value = getYear(inM.selectedIndex) + "-" + checkinMonth + "-" + checkinDay;
document.getElementById("checkoutValue").value = getYear(outM.selectedIndex) + "-" + checkoutMonth + "-" + checkoutDay;
return;
}
function checkoutUpdated() {
outM = document.getElementById("checkoutMonth");
outD = document.getElementById("checkoutDay");
adjustDate(outM.options.selectedIndex, outD);
var checkoutMonth = outM.options[outM.selectedIndex].value * 1;
var checkoutDay = outD.options[outD.selectedIndex].value * 1;
document.getElementById("checkoutValue").value = getYear(outM.selectedIndex) + "-" + checkoutMonth + "-" + checkoutDay;
return;
}
function isLeapYear(yrStr) {
var leapYear = false;
var year = parseInt(yrStr, 10);
// every fourth year is a leap year
if (year % 4 == 0) {
leapYear = true;
// unless it's a multiple of 100
if (year % 100 == 0) {
leapYear = false;
// unless it's a multiple of 400
if (year % 400 == 0) {
leapYear = true;
}
}
}
return leapYear;
}
function getDaysInMonth(mthIdx, YrStr) {
// all the rest have 31
var maxDays = 31
// expect Feb. (of course)
if (mthIdx == 1) {
if (isLeapYear(YrStr)) {
maxDays = 29;
} else {
maxDays = 28;
}
}
// thirty days hath...
if (mthIdx == 3 || mthIdx == 5 || mthIdx == 8 || mthIdx == 10) {
maxDays = 30;
}
return maxDays;
}
function getYear(mthIdx) {
var today = new Date();
var theYear = parseInt(today.getFullYear());
if (mthIdx < today.getMonth()) {
theYear = (parseInt(today.getFullYear()) + 1);
}
return theYear;
}
// do not allow selection of days that are not valid
// return non-zero if it is the last day of the month
function adjustDate(mthIdx, Dt) {
var value = 0;
var theYear = getYear(mthIdx);
var numDays = getDaysInMonth(mthIdx, theYear);
if (mthIdx == 1) {
if (Dt.options.selectedIndex + 2 < numDays) {
return 0;
} else {
if (Dt.options.selectedIndex + 1 > numDays) {
Dt.options.selectedIndex = numDays - 1;
}
//check for leap year
if ((Dt.options.selectedIndex + 1) == numDays) {
return 1;
} else {
return 4;
}
}
}
if (Dt.options.selectedIndex + 2 < numDays) {
value = 0;
}
else {
if (Dt.options.selectedIndex + 1 > numDays) {
Dt.options.selectedIndex--;
value = 3;
}
else if (Dt.options.selectedIndex + 1 == numDays) {
//index is 31 or 30
value = 2;
}
else {
value = 4;
}
}
return value;
}
/********************** end of dropdown checkin box **********************/
function AffiliateClick(requestUrl, friendlyUrl) {
var isFramed = (self != top);
var img = document.getElementById("hc_affiliateClick");
if (!img) {
img = new Image();
}
img.src = "/" + "AffiliateClick" + "." + "ashx?Label=Direct&requestUrl=" + requestUrl + "&friendlyUrl=" + friendlyUrl + "&isFramed=" + isFramed + "&random=" + Math.random().toString();
}
// Namespace for common elements.
HC.Common = {
isRightToLeft: false,
_abTests: {},
_currencyCode: null,
_googleMapsCallback: null,
_googleMapsLoaded: false,
//Please all common init stuff here
Init: function (abTests, currencyCode) {
if (currencyCode) {
this._currencyCode = currencyCode;
}
this._abTests = abTests;
this.GoogleTrackLanguageCurrencyChange();
},
TestOn: function (testName) {
return HC.Common._abTests[testName];
},
GetCurrencyCode: function () {
return HC.Common._currencyCode;
},
AnalyticsTrackVisitor: function (guid, domain) {
var tracked = HC.Cookies.get("VisitTracked");
if (tracked && tracked.value == "1") {
return;
}
var image = document.getElementById("hc_visitorTracking");
var url = "/Analytics/Visitor.ashx?Label=Direct&VisitGuid=" + encodeURIComponent(guid);
if (domain) {
url = "http://" + domain + url;
}
image.src = url;
HC.Cookies.set({
name: "VisitTracked",
values: ["1"]
});
},
JSObfuscateURL: function (url) {
return ReverseString(url);
},
isFieldEmpty: function (fieldOneId, fieldTwoId) {
if (document.getElementById(fieldOneId) != null && document.getElementById(fieldTwoId) != null) {
if (document.getElementById(fieldOneId).value == 0 || document.getElementById(fieldTwoId).value == 0) {
alert(typeof (JavaScriptEnterCheckinCheckout) == 'undefined' ? 'Please enter your checkin and checkout date.' : JavaScriptEnterCheckinCheckout);
return true;
}
}
return false;
},
GetStarValue: function (qString, starElement, starName) {
if (starElement == null || starElement.checked) {
return "";
}
else {
return "&" + starName + "=false";
}
},
SetStarValue: function (qString, starElement, starName) {
if (starElement == null || starElement.checked) {
return HC.QS.remQStringName(qString, starName);
}
else {
return HC.QS.setQStringName(qString, starName, new Array("false"));
}
},
isChild: function (child, parent) {
while (child) {
if (child == parent) {
return true;
}
child = child.parentNode;
}
return false;
},
Jsl: function (location, languagecode) {
var str = '';
if (location == 'p') {
str = '/AboutUs/Privacy.aspx';
}
else {
str = '/AboutUs/TermsOfUse.aspx';
}
if (languagecode.length > 0) {
str = str + '?languageCode=' + languagecode;
}
window.location = str;
},
displayNone: function (id) {
document.getElementById(id).style.display = "none";
},
displayBlock: function (id) {
document.getElementById(id).style.display = "";
},
isChild: function (child, parent) {
while (child) {
if (child == parent) {
return true;
}
child = child.parentNode;
}
return false;
},
robotCheck: function () {
document.write("");
},
leftTrim: function (str, cha) {
while (str.substring(0, 1) == cha) {
str = str.substring(1, str.length);
}
return str;
},
ChangeLanguage: function (url) {
window.location = ReverseString(url);
},
GenerateQueryString: function (options) {
options = options || {};
var fields = this.fields;
var qString;
qString = "languageCode=" + fields.languageCode;
qString += "¤cyCode=" + fields.currencyCode;
if (!options.excludeFilename) {
//need to change the fileName and fileNameType back to 'normal' if it is a custom search
if ((!fields.paging) && (fields.cityFileName != null) && (fields.cityFileName != fields.fileName)) {
qString += "&fileName=" + fields.cityFileName;
qString += "&fileNameType=1";
} else {
qString += "&fileName=" + fields.fileName;
if (fields.fileNameType != undefined) {
qString += "&fileNameType=" + fields.fileNameType;
}
}
}
//get rid of indicator for paging
this.fields.paging = null;
//Remove date/people stuff
if (!options.excludeDates) {
if (fields.checkin) qString += "&checkin=" + fields.checkin;
if (fields.checkout) qString += "&checkout=" + fields.checkout;
}
//Keep the legacy generation
//TODO: Consolidate the 2 methods
if (fields.roomConfigInstance) {
qString += "&" + fields.roomConfigInstance.generateQueryString();
} else {
if ($.isArray(fields.rooms)) {
qString += '&' + HC.RoomConfig.generateQueryString(fields.rooms);
} else {
if (fields.adults) qString += "&adults=" + fields.adults;
if (fields.rooms) qString += "&rooms=" + fields.rooms;
}
}
//Set the hotel at the top of the page
if (fields.hotelID) {
qString += "&hotelId=" + fields.hotelID;
}
return qString;
},
GenerateHotelQueryString: function (fileName, options) {
var qString = "fileName=" + fileName;
//Setup any generation options
var genOptions = {};
genOptions.excludeFilename = true;
if (options.excludeDates) {
genOptions.excludeDates = true;
}
qString += "&" + HC.Common.GenerateQueryString(genOptions);
return qString;
},
FloorPrice: function (price) {
return Math.floor(price / 10) * 10;
},
CeilPrice: function (price) {
return Math.ceil(price / 10) * 10;
},
GetKey: function (e) {
var key;
if (window.event || !e.which) {
key = e.keyCode;
}
else if (e) {
key = e.which;
}
var keyChar = String.fromCharCode(key);
return { "key": key, "keyChar": keyChar };
},
langSwitchFooter: function (languageCode) {
HC.Language.changeLanguage('languageCode', languageCode);
},
langSwitch: function (e, o) {
HC.Language.changeLanguage('languageCode', o.options[o.options.selectedIndex].value);
return false;
},
currencySwitch: function (o) { // accept string values or select object..
//For Searchprogress page (trying to use the ajax version)
if (typeof (o) == "object") {
val = o.options[o.options.selectedIndex].value;
}
else {
val = o;
}
if (typeof changeLanguageOriginal != "undefined") {
changeLanguageOriginal("currencyCode", val);
}
else if (HC.SR && HC.SR.Filter) {
HC.SR.Filter.ChangeCurrency(val);
}
if (HC.SR && HC.SR.Filter) {
HC.SR.Filter.ChangeCurrency(val);
}
else {
HC.Language.changeLanguage('currencyCode', val);
}
return false;
},
setIE7Meta: function () {
var $hc_meta = $('');
$hc_meta.attr('name', 'X-UA-Compatible');
$hc_meta.attr('content', 'IE=7');
$hc_meta.appendTo('head');
},
writeDisplayNoneDivStart: function (id) {
document.write('
');
},
writeDivEnd: function () {
document.write('
');
},
expandContractGlobalSites: function (e) {
var $holder = $("#internationLinksHolder");
$holder.toggle();
var $img = $("#globalSitesLink img");
var newSource = $img[0].src;
//Toggle the image
if ($holder.is(":visible")) {
newSource = newSource.replace("/interlinking-arrow-right.gif", "/interlinking-arrow-down.gif");
$img[0].src = newSource;
$img.removeClass("contracted").addClass("expanded");
}
else {
newSource = newSource.replace("/interlinking-arrow-down.gif", "/interlinking-arrow-right.gif");
$img[0].src = newSource;
$img.removeClass("expanded").addClass("contracted");
}
},
findPos: function (obj) {
var curleft = obj.offsetLeft || 0;
var curtop = obj.offsetTop || 0;
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
return { x: curleft, y: curtop };
},
scrollTo: function (obj) {
var curtop = obj.offsetTop || 0;
while (obj = obj.offsetParent) {
curtop += $(obj).position().top;
}
return { y: curtop };
},
findPopoverPos: function (obj, popoverObj, stayWithinContent, neverReverseAlign, alwaysInViewport, alwaysBeneathObj, alwaysLeftOrRightOfObj, gutterWidth, gutterHeight) {
/* get boundaries and obj sizes */
if (typeof (gutterWidth) == "undefined" || gutterWidth == null) {
gutterWidth = 0;
}
if (typeof (gutterHeight) == "undefined" || gutterHeight == null) {
gutterHeight = 0;
}
var pos = $(obj).offset();
var pos = { x: pos.left, y: pos.top };
var pos = this.findPos(obj);
var popoverPos = { 'x': pos.x, 'y': pos.y }; // initialise popover position.
var objWidth = parseInt($(obj).outerWidth(true));
var objHeight = parseInt($(obj).outerHeight());
var windowWidth = $(window).width();
var windowHeight = $(window).height();
var windowScrollLeft = $(window).scrollLeft();
var viewportTopEdge = $(window).scrollTop();
var viewportBottomEdge = viewportTopEdge + windowHeight;
var viewportRightEdge = windowScrollLeft + windowWidth;
var viewportLeftEdge = windowScrollLeft;
var $mainWrap = $('#hc_r_content');
var contentPos = HC.Common.findPos($mainWrap[0]);
var contentWidth = $mainWrap.width();
var contentHeight = $mainWrap.outerHeight();
var contentLeftEdge = contentPos.x;
var contentRightEdge = contentLeftEdge + contentWidth;
var contentBottomEdge = $mainWrap.height();
var contentTopEdge = contentPos.y;
var popoverObjWidth = parseInt($(popoverObj).outerWidth()) + (2 * gutterWidth);
var popoverObjHeight = parseInt($(popoverObj).outerHeight()) + (2 * gutterHeight);
// check whether to stay within the content boundaries or
// simply stay within the viewport boundaries..
// ie. if the viewport is larger than the content width then allow the popover to extend past the content boundary.
var leftEdge = 0;
var rightEdge = 0;
var topEdge = 0;
var bottomEdge = 0;
if (stayWithinContent) {
// get horizontal boundaries..
leftEdge = contentLeftEdge;
rightEdge = contentRightEdge;
// get vertical boundaries..
if (alwaysBeneathObj) {
topEdge = contentTopEdge;
bottomEdge = contentBottomEdge + popoverObjHeight;
} else {
topEdge = 0; // can never go above page's topedge.
if (viewportBottomEdge > contentBottomEdge) {
bottomEdge = viewportBottomEdge;
} else {
bottomEdge = contentBottomEdge;
}
}
// correct boundaries if need to be within viewport..
if (alwaysInViewport) {
if (leftEdge < viewportLeftEdge) {
leftEdge = viewportLeftEdge;
}
if (rightEdge > viewportRightEdge) {
rightEdge = viewportRightEdge;
}
if (bottomEdge > viewportBottomEdge) {
bottomEdge = viewportBottomEdge;
}
if (topEdge < viewportTopEdge) {
topEdge = viewportTopEdge;
}
}
} else {
// no need to stay within content boundaries..
if (alwaysInViewport) {
// get horizontal boundaries..
leftEdge = viewportLeftEdge;
rightEdge = viewportRightEdge;
// get vertical boundaries..
topEdge = viewportTopEdge;
bottomEdge = viewportBottomEdge;
} else {
// get horizontal boundaries..
if (contentLeftEdge < viewportLeftEdge) {
leftEdge = contentLeftEdge;
} else {
leftEdge = viewportLeftEdge;
}
if (contentRightEdge > viewportRightEdge) {
rightEdge = contentRightEdge;
} else {
rightEdge = viewportRightEdge;
}
//alert(contentRightEdge + " - " + rightEdge);
// get vertical boundaries..
topEdge = 0; // always.
bottomEdge = null; // no bottom edge.
}
}
// Get horizontal positioning and cater for both rtl and ltr versions..
var rtl = $('body').hasClass("hc_rtl");
if (!rtl) {
// in ltr version..
if (alwaysLeftOrRightOfObj) {
// align to either left or right side of obj..
if (pos.x + objWidth + popoverObjWidth > rightEdge) {
// right edge of popover extends past rightedge boundary..
// So, either align to rightedge of obj or push over so rightedge of popoverObj is at the rightEdge boundary..
if (neverReverseAlign) {
// push over to align right edge to rightEdge..
popoverPos.x = rightEdge - popoverObjWidth + gutterWidth;
} else {
// try aligning to right edge of obj..
popoverPos.x = pos.x - gutterWidth - popoverObjWidth;
$(popoverObj).removeClass("hc_pos_top hc_pos_bottom hc_pos_right").addClass("hc_pos_left"); // indicate to object that the popover is sitting to the left of the obj.
}
// check that left edge of popover is not extended past the leftedge boundary.
// in ltr layout this should never happen.
// If so, make popoverPos.x = leftedge boundary, allowing popoverObj's right edge to extend past right boundary..
if (popoverPos.x < leftEdge) {
popoverPos.x = leftEdge + gutterWidth;
}
} else {
// right edge will fit within rightedge boundary..
popoverPos.x = pos.x + objWidth + gutterWidth;
$(popoverObj).removeClass("hc_pos_top hc_pos_bottom hc_pos_left").addClass("hc_pos_right"); // indicate to object that the popover is sitting to the right of the obj.
}
} else {
// align to either top or bottom of obj..
// So, align to leftedge of obj..
if (pos.x + popoverObjWidth > rightEdge) {
// right edge of popover extends past rightedge boundary.
// So, either align to rightedge of obj or push over so rightedge of popoverObj is at the rightEdge boundary..
if (neverReverseAlign) {
// push over to align right edge to rightEdge..
popoverPos.x = rightEdge - popoverObjWidth + gutterWidth;
} else {
// try aligning to right edge of obj..
popoverPos.x = pos.x + objWidth - popoverObjWidth + gutterWidth;
}
// check that left edge of popover is not extended past the leftedge boundary.
// in ltr layout this should never happen.
// If so, make popoverPos.x = leftedge boundary, allowing popoverObj's right edge to extend past right boundary..
if (popoverPos.x < leftEdge) {
popoverPos.x = leftEdge + gutterWidth;
}
} else {
// right edge will fit within rightedge boundary..
popoverPos.x = pos.x + gutterWidth;
}
}
} else {
// in rtl version..
if (alwaysLeftOrRightOfObj) {
// align to either left or right side of obj..
if (pos.x - popoverObjWidth < leftEdge) {
// left edge of popover extends past leftedge boundary..
// So, either align to rightedge of obj or push over so rightedge of popoverObj is at the rightEdge boundary..
if (neverReverseAlign) {
// push over to align left edge to leftEdge..
popoverPos.x = leftEdge + gutterWidth;
} else {
// try aligning to right edge of obj..
popoverPos.x = pos.x + objWidth + gutterWidth;
}
// check that right edge of popover is not extended past the rightEdge boundary.
// in rtl layout this should never happen.
// If so, align popoverObj's right edge to rightEdge boundary..
if (popoverPos.x + popoverObjWidth > rightEdge) {
popoverPos.x = rightEdge - popoverObjWidth + gutterWidth;
}
$(popoverObj).removeClass("hc_pos_top hc_pos_bottom hc_pos_left").addClass("hc_pos_right"); // indicate to object that the popover is sitting to the left of the obj.
} else {
// right edge will fit within rightedge boundary..
popoverPos.x = pos.x - popoverObjWidth + gutterWidth;
$(popoverObj).removeClass("hc_pos_top hc_pos_bottom hc_pos_right").addClass("hc_pos_left"); // indicate to object that the popover is sitting to the right of the obj.
}
} else {
// align to either top or bottom of obj..
// So, align to leftedge of obj..
if (pos.x + objWidth - popoverObjWidth < leftEdge) {
// left edge of popover extends past leftEdge boundary.
// So, either align to leftedge of obj or push over so leftedge of popoverobj is at the leftEdge boundary..
if (neverReverseAlign) {
// push over to align left edge to leftEdge..
popoverPos.x = leftEdge + gutterWidth;
} else {
// try aligning to left edge of obj..
popoverPos.x = pos.x + gutterWidth;
}
// check that right edge of popover is not extended past the rightEdge boundary.
// in rtl layout this should never happen.
// If so, align popoverObj's right edge to rightEdge boundary..
if (popoverPos.x + popoverObjWidth > rightEdge) {
popoverPos.x = rightEdge - popoverObjWidth + gutterWidth;
}
} else {
// left edge will fit within leftEdge boundary..
popoverPos.x = pos.x + objWidth - popoverObjWidth + gutterWidth;
}
}
}
// get vertical position..
if (alwaysLeftOrRightOfObj) {
// either aligning against left or right sides of obj..
popoverPos.y = pos.y + gutterHeight;
if (bottomEdge != null && (pos.y + popoverObjHeight > bottomEdge)) {
// can not fit below..
if (topEdge < bottomEdge - popoverObjHeight - Math.abs(gutterHeight * 2)) {
popoverPos.y = bottomEdge - popoverObjHeight - Math.abs(gutterHeight * 2);
} else {
popoverPos.y = topEdge;
}
}
// if pointer exists then position next to obj..
if ($pointer = $(popoverObj).find('.hc_m_popover_pointer')) {
var pointerTop = pos.y - popoverPos.y + gutterHeight;
$pointer.css("top", pointerTop + "px");
}
} else {
// either aligning to top or bottom sides of obj..
popoverPos.y = pos.y + objHeight + gutterHeight; // initialise y position to be below obj.
if (!alwaysBeneathObj) {
// popover can be positioned above obj.
// So, see if popover needs to try to fit above obj or not..
if (bottomEdge != null && (pos.y + popoverObjHeight > bottomEdge)) {
// cannot fit below so try to fit popover above obj..
if (pos.y - popoverObjHeight >= topEdge) {
// can fit above..
popoverPos.y = pos.y - popoverObjHeight + gutterHeight;
$(popoverObj).removeClass("hc_pos_bottom hc_pos_left hc_pos_right").addClass("hc_pos_top"); // indicate to object that the popover is sitting to the left of the obj.
} else {
$(popoverObj).removeClass("hc_pos_top hc_pos_left hc_pos_right").addClass("hc_pos_bottom"); // indicate to object that the popover is sitting to the left of the obj.
}
} else {
$(popoverObj).removeClass("hc_pos_top hc_pos_left hc_pos_right").addClass("hc_pos_bottom"); // indicate to object that the popover is sitting to the bottom of the obj.
}
} else {
$(popoverObj).removeClass("hc_pos_top hc_pos_left hc_pos_right").addClass("hc_pos_bottom"); // indicate to object that the popover is sitting to the bottom of the obj.
}
}
// return popover position..
// alert(popoverPos.x + " - " + popoverPos.y);
return popoverPos;
},
getNumericPortion: function (str) {
return str.match(/\d*/);
},
getScrollXY: function () {
var scrOfX = 0;
var scrOfY = 0;
if (typeof (window.pageYOffset) == 'number') {
//Netscape compliant
scrOfY = window.pageYOffset;
scrOfX = window.pageXOffset;
}
else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
//DOM compliant
scrOfY = document.body.scrollTop;
scrOfX = document.body.scrollLeft;
}
else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
//IE6 standards compliant mode
scrOfY = document.documentElement.scrollTop;
scrOfX = document.documentElement.scrollLeft;
}
return [scrOfX, scrOfY];
},
getWindowSize: function () {
var myWidth = 0;
var myHeight = 0;
if (typeof (window.innerWidth) == 'number') {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
}
else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
}
else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
return [myWidth, myHeight];
},
/**************** Google Anayltics ****************/
GoogleTrackLanguageCurrencyChange: function () {
$(function () {
$("#hc_f_language").change(function () {
HC.Common.AnalyticsTrackEvent("Language Change", this.value);
});
$("#hc_f_currency").change(function () {
HC.Common.AnalyticsTrackEvent("Currency Change", this.value);
});
});
},
AnalyticsTrackEvent: function (category, action, label) {
var track;
if (arguments.length == 3) {
track = ['_trackEvent', category, action, label];
}
else {
track = ['_trackEvent', category, action];
}
if (typeof _gaq != "undefined") {
_gaq.push(track);
} else {
$(function () {
if (typeof _gaq != "undefined") {
_gaq.push(track);
}
});
}
},
IsIE6: function () {
//if ($.browser.msie && /6.0/.test(navigator.userAgent)) { // no longer works with ie9.
if ($.browser.msie && parseInt($.browser.version) === 6) {
return true;
} else {
return false;
}
},
IsIE7: function () {
//if ($.browser.msie && /7.0/.test(navigator.userAgent)) { // no longer works with ie9.
if ($.browser.msie && parseInt($.browser.version) === 7) {
return true;
} else {
return false;
}
},
IsIE8: function () {
//if ($.browser.msie && /8.0/.test(navigator.userAgent)) { // no longer works with ie9.
if ($.browser.msie && parseInt($.browser.version) === 8) {
return true;
} else {
return false;
}
},
loadGoogleMapsScript: function (callback, languageCode) {
if (this._googleMapsLoaded) {
return;
}
var stringCallback = callback;
if ($.isFunction(callback)) {
HC.Common._googleMapsCallback = callback;
stringCallback = "HC.Common.callBackProxy";
}
var script = document.createElement("script");
script.type = "text/javascript";
script.src = 'http://maps.google.com/maps/api/js?v=3.5&sensor=false&callback=' + stringCallback + '&language=' + languageCode;
if (HC.Common.IsIE6()) {
window.setTimeout(function () {
document.body.appendChild(script);
}, 0);
} else {
document.body.appendChild(script);
}
this._googleMapsLoaded = true;
},
callBackProxy: function () {
var callback = HC.Common._googleMapsCallback;
if (callback) {
callback();
}
}
};
HC.Common.Form = {
//This function will return from the supplied form element name, all html element types listed in .find().
//Only if those elements have a "name" attribute.
//It will return an object of type {"element name" : "element value"}.
GetFormValuesObject: function (selector, form) {
var formValues = {};
if (form == undefined || form == null || form == "") {
form = 'form';
}
var a = $(form + "")
.find(selector + " input,textarea,select,hidden")
.serializeArray();
$.each(a, function () {
if (formValues[this.name]) {
if (!formValues[this.name].push) {
formValues[this.name] = [formValues[this.name]];
}
formValues[this.name].push(this.value || '');
} else {
formValues[this.name] = this.value || '';
}
});
return formValues;
}
}
// Namespace for status displays/messages
HC.Common.Status = {
DisplayFiltering: function(options) {
// options.sorting - boolean - true to show sorting
// options.paging - boolean - true to show paging
// options.loading - boolean - true to show loading
// options.loadingHotel - boolean - true to show loading hotel
// options.absoluteY - Puts the popup in an absoluteY position of the value.
// options.centerOffset - Adds the offset to the center calculation.
options = options || {};
$("#filterDiv").remove();
var text = "";
if (options.sorting) {
text = typeof (HC.Translations.searchPageSortingResults) == 'undefined' ? 'Sorting Results...' : HC.Translations.searchPageSortingResults;
}
else if (options.paging) {
text = typeof (HC.Translations.searchPageLoadingResults) == 'undefined' ? 'Loading Page...' : HC.Translations.searchPageLoadingPage;
}
else if (options.loading) {
text = typeof (HC.Translations.searchPageLoadingResults) == 'undefined' ? 'Loading Results...' : HC.Translations.searchPageLoadingResults;
}
else if (options.loadingHotel) {
text = typeof (HC.Translations.searchPageLoadingHotel) == 'undefined' ? 'Loading Hotel...' : HC.Translations.searchPageLoadingHotel;
}
else {
text = typeof (HC.Translations.pageFilteringResults) == 'undefined' ? 'Filtering Results...' : HC.Translations.pageFilteringResults;
}
//Setup filter
var filterDiv = $('
' + text + '
');
filterDiv.remove().appendTo("body").show();
var filterWidth = filterDiv.width();
var windowWidth = $(window).width();
var scrollTop = $(window).scrollTop();
var centerOffset = options.centerOffset === undefined ? 0 : options.centerOffset;
var centerPosition = (windowWidth / 2 - (filterWidth / 2)) + centerOffset;
var topPosition = options.absoluteY === undefined ? scrollTop + 300 : options.absoluteY;
var leftPosition = options.absoluteCenter === undefined ? centerPosition - 15 : options.absoluteCenter - (filterWidth / 2);
var zIndex = 999;
filterDiv.css({ left: leftPosition + "px", top: topPosition + "px", "z-index": zIndex });
var filterText = $("#filterText", filterDiv);
var top = filterDiv.height() / 2 - (filterText.height() / 2);
var left = filterDiv.width() / 2 - (filterText.width() / 2);
filterText.css({ "top": top + "px", "left": left + "px" , "z-index": zIndex});
},
HideFiltering: function() {
$("#filterDiv").hide();
}
};
// Namespace for popups
HC.Common.Popups = {
popId: "hc_popupSearch",
isIE6: false,
createPop: function () {
var width = "490px";
var height = "";
var docHeight = $(document).height();
var winHeight = $(window).height();
// IE8 has a bug with opacity and block heights (limit is 4096px - 2^12, higher results in solid bg)
var $trans = $('
');
$trans.attr("id", "PopupTransparent");
if ($.browser.msie && $.browser.version.substr(0, 1) == 8) {
$trans.css({ "position": "fixed" });
$trans.height(winHeight);
}
else {
$trans.height(docHeight);
}
$trans.appendTo('#hc_bodyElements');
// center the outside div within the viewable section of the document
var left = (HC.Common.getWindowSize()[0] / 2) + HC.Common.getScrollXY()[0] - (HC.Common.getNumericPortion(width) / 2);
var top = (HC.Common.getWindowSize()[1] / 2) - (250 / 2);
e = document.getElementById(this.popId);
//e.style.height = height;
e.style.width = width;
e.style.left = left + "px";
e.style.zIndex = "900";
e.style.display = 'block';
e = e.parentNode.removeChild(e);
var bodyElements = document.getElementById('hc_bodyElements');
bodyElements.appendChild(e);
// position of underlay iframe's parent
var underlayParentPos = $("#hc_popupSearch").offset();
// IE 7, mozilla, safari, opera 9
if (typeof document.body.style.maxHeight != "undefined") {
e.style.position = 'fixed';
e.style.top = top + "px";
}
// IE6, older browsers
else {
var ie6Top = HC.Design.getIE6FixedYPos(e);
this.isIE6 = true;
e.style.position = 'absolute';
e.style.height = "auto";
e.style.top = ie6Top;
$(window).bind("scroll", HC.Common.Popups.setIE6FixPosition);
// checkprice underlay fix for select boxes
$trans.bgIframe();
}
},
setIE6FixPosition: function () {
var e = document.getElementById(HC.Common.Popups.popId);
var ie6Top = HC.Design.getIE6FixedYPos(e);
e.style.top = ie6Top;
},
closePopUp: function () {
$("#PopupTransparent").remove();
var e = document.getElementById(this.popId);
e.style.display = 'none';
if (this.isIE6) {
$(window).unbind("scroll", HC.Common.Popups.setIE6FixPosition);
}
},
bestPriceGuaranteePopup: function () {
var languageCode = "EN";
if (typeof HC.gLanguageCode != undefined) {
languageCode = HC.gLanguageCode;
}
HC.Common.Tooltip.tooltipHide('tt1');
window.open('/BestPriceGuaranteePopup.aspx?Label=Direct&languageCode=' + languageCode, '', 'toolbar=0,status=0,menubar=0,scrollbars ,width=400,height=500', true);
},
bestPriceGuaranteePopupFooter: function (element) {
window.open(element.href, '', 'toolbar=0,status=0,menubar=0,scrollbars ,width=400,height=500', true);
},
questionAndAnswersPopup: function (hotelName, hotelId) {
window.open('/AskHotelQuestion.aspx?Label=Direct&hotelName=' + hotelName + '&hotelId=' + hotelId, '', 'toolbar=0,status=0,menubar=0,location=0,scrollbars,width=491,height=250', true);
return false;
}
};
// Namespace for creating tooltips.
HC.Common.Tooltip = {
tooltips: Array(), // array of all current page tooltips. 'add' method adds the tooltip to this array.
// initialise a new tooltip div with specific content..
add: function (myId, myContent) {
this.tooltips[myId] = $('
');
this.tooltips[myId].attr('id', myId);
this.tooltips[myId].html(this.tooltips[myId].html() + myContent);
this.tooltips[myId].appendTo('#hc_bodyElements');
},
// display requested tooltip..
show: function (mySourceObj, myId) {
var tempId = '#' + myId;
var pos = HC.Common.findPos(mySourceObj);
var myWidth = $(tempId).innerWidth();
var myHeight = $(tempId).innerHeight();
var myX = pos.x - myWidth + $(mySourceObj).innerWidth();
myX += "px";
var myY = (pos.y + $(mySourceObj).innerHeight()) + "px";
//this.showOverlay(myX, myY, myWidth, myHeight);
$(tempId).css('top', myY);
$(tempId).css('left', myX);
$(tempId).bgIframe();
$(tempId).animate({
opacity: 'toggle'
}, 300);
},
// hide requested tooltip..
hide: function (myId) {
$('#' + myId).animate({
opacity: 'toggle'
}, 300, 'linear', function () {
//HC.Common.Tooltip.hideOverlay();
});
},
showOverlay: function ($myObj) {
$myObj.bgIframe();
},
hideOverlay: function () {
},
/* Best Price Guarantee popup */
tooltipShow: function (sourceObj, tooltipElementId) {
var tooltip = document.getElementById('tt1');
var pos = HC.Common.findPos(sourceObj);
tooltip.style.top = (pos.y + 20) + "px";
tooltip.style.left = (pos.x - 250) + "px";
tooltip.style.display = 'block';
$(tooltip).bgIframe();
},
tooltipHide: function (tooltipElementId) {
var tooltip = document.getElementById('tt1');
if (tooltip != null) {
tooltip.style.display = 'none';
}
}
}
// Namespace for cookie handling.
HC.Common.Cookies = {
cookies: Array(), // cached copy of previously added / fetched cookies.
add: function (myKey, myValue, myPath, myExpiry) {
if (document.cookie != null) {
tmpCookie = "";
if (myExpiry != null && myExpiry != "") {
tmpCookie = myKey + "=" + encodeURIComponent(myValue) + "; expires=" + myExpiry + "; path=" + myPath;
} else {
tmpCookie = myKey + "=" + encodeURIComponent(myValue) + "; path=" + myPath;
}
document.cookie = tmpCookie;
// add cookie to cache..
HC.Common.Cookies.cookies[myKey] = tmpCookie;
}
},
// retrieve cookie by key/name. If useCache is true, then retrieve from cached value of this namespace if already fetched / added.
getCookie: function (myKey, useCache) {
if (document.cookie != null && document.cookie.length > 0) {
if (useCache && this.cookies[myKey] != null) {
return HC.Common.Cookies.cookies[myKey];
} else {
var start = document.cookie.indexOf(myKey + "=");
if (start != -1) {
start = start + myKey.length + 1;
var end = document.cookie.indexOf(";", start);
if (end == -1) {
end = document.cookie.length;
}
return decodeURIComponent(document.cookie.substring(start, end));
}
}
}
return "";
},
// retrieves all cookies and adds to cache. nb. will override whatever is already in the cache for that cookie key.
getAllCookies: function () {
var cookies = {};
if (document.cookie && document.cookie != '') {
var split = document.cookie.split(';');
for (var i = 0; i < split.length; i++) {
var name_value = split[i].split("=");
name_value[0] = name_value[0].replace(/^ /, '');
cookies[decodeURIComponent(name_value[0])] = decodeURIComponent(name_value[1]);
HC.Common.Cookies.cookies[decodeURIComponent(name_value[0])] = decodeURIComponent(name_value[1]); // cache cookie.
}
}
return cookies;
}
};
// Namespace for navigation, link handling and accessibility of links.
HC.Common.Navigation = {
myWins: Array(),
// parses querystrings into hash array.
parseQueryString: function (qs) {
var result = {};
if (qs == null || typeof (qs) == "undefined") {
qs = location.search ? location.search : '';
}
if (qs.indexOf('?') > -1) {
qs = qs.substring(qs.indexOf('?') + 1);
}
qs = qs.replace(/\+/g, ' ');
var params = qs.split(/[;&]/g);
for (var i = 0; i < params.length; i++) {
// extract this component's key-value pairs
var kvp = params[i].split('=');
var key = decodeURIComponent(kvp[0]);
var value = decodeURIComponent(kvp[1]);
if (!result[key]) {
result[key] = [];
}
result[key].push((kvp.length == 1) ? '' : value);
}
return result;
},
// directs user to myUrl
gotoPage: function (myUrl) {
// navigate user window to myUrl location if provided.
if (myUrl != null && myUrl != "") {
location.href = myUrl;
}
return false;
}
};
/* bgiframe plugin for jquery - automatically adds iframe for hiding select boxes in layered elements in IE6
* Usage: $('#divWrapper').bgiframe(); // applies iframe beneath element with id = divWrapper.
*/
/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* $LastChangedDate: 2007-07-21 18:44:59 -0500 (Sat, 21 Jul 2007) $
* $Rev: 2446 $
*
* Version 2.1.1
* Edited by Ben Gillies for ie9 Compatibility.
*/
$.fn.bgIframe = $.fn.bgIFrame = $.fn.bgiframe = function (s) {
// This is only for IE6
//if ($.browser.msie && /6.0/.test(navigator.userAgent)) { // ie9 fix.
if ($.browser.msie && parseInt($.browser.version) === 6) {
var style = "";
s = $.extend({
top: 'auto', // auto == .currentStyle.borderTopWidth
left: 'auto', // auto == .currentStyle.borderLeftWidth
width: 'auto', // auto == offsetWidth
height: 'auto', // auto == offsetHeight
opacity: true,
src: 'javascript:false;'
}, s || {});
var prop = function (n) { return n && n.constructor == Number ? n + 'px' : n; },
html = '';
return this.each(function () {
if ($('> iframe.bgiframe', this).length == 0)
this.insertBefore(document.createElement(html), this.firstChild);
});
return this;
}
};
/* end bgiframe plugin */
jQuery.fn.hint = function (blurClass) {
if (!blurClass) {
blurClass = 'blur';
}
return this.each(function () {
// get jQuery version of 'this'
var $input = jQuery(this);
// capture the rest of the variable to allow for reuse
var title = $input.attr('title');
var $form = jQuery(this.form);
var $win = jQuery(window);
function remove() {
if ($input.val() === title && $input.hasClass(blurClass)) {
$input.val('').removeClass(blurClass);
}
}
// only apply logic if the element has the attribute
if (title) {
// on blur, set value to title attr if text is blank
$input.blur(function () {
if (this.value === '') {
$input.val(title).addClass(blurClass);
}
}).focus(remove).blur(); // now change all inputs to title
// clear the pre-defined text when form is submitted
$form.submit(remove);
$win.unload(remove); // handles Firefox's autocomplete
}
});
};
/* The following appears to be used in some legacy static files, probably remove later on to save footprint */
HC.Language = {
changeLanguage: function(name, val) {
var qString = location.search.substr(1);
qString = HC.QS.AppendFilename(qString);
//always reset page to 1
var page = HC.QS.GetQSVal("pageIndex");
if (page != "0" && page != "") {
qString = HC.QS.setQStringName(qString, "pageIndex", new Array("0"));
}
//Pass across the page size if available
var pageSize = $("#pageSize");
if (pageSize.length == 1) {
qString = HC.QS.setQStringName(qString, "pageSize", [pageSize[0].value]);
}
qString = HC.QS.setQStringName(qString, name, new Array(val.toString()));
//remove lowrate and highrate as currency type has changed.
if (name == 'currencyCode') {
qString = HC.QS.remQStringName(qString, 'lowRate');
qString = HC.QS.remQStringName(qString, 'highRate');
}
//adjust the return path
if (name == "languageCode") {
var returnPath = HC.QS.GetQSVal("returnPath");
if (returnPath) {
returnPath = HC.QS.remQStringName(returnPath, "languageCode");
returnPath = HC.QS.setQStringName(returnPath, "languageCode", [val]);
qString = HC.QS.remQStringName(qString, "returnPath");
qString = HC.QS.setQStringName(qString, "returnPath", [returnPath]);
}
}
if (typeof HC.path != 'undefined' && HC.path != null && HC.path.length > 0) {
location = HC.path + "?" + qString;
}
else {
location = location.pathname + "?" + qString;
}
return false;
},
addLanguageFlags: function (flagDomain, languageCode) {
var flag = "
";
flag += this.addFlag("EN", flagDomain, languageCode);
flag += this.addFlag("DE", flagDomain, languageCode); // German
flag += this.addFlag("ES", flagDomain, languageCode); // Spanish
flag += this.addFlag("FR", flagDomain, languageCode); // French
flag += this.addFlag("IT", flagDomain, languageCode); // Italian
flag += this.addFlag("CS", flagDomain, languageCode); // Chinese Simplified
flag += this.addFlag("CN", flagDomain, languageCode); // Chinese Traxditional
flag += this.addFlag("JA", flagDomain, languageCode); // Japanese
flag += this.addFlag("KO", flagDomain, languageCode); // Korean
flag += this.addFlag("PT", flagDomain, languageCode); // Portugues
flag += this.addFlag("EL", flagDomain, languageCode); // Greek
flag += this.addFlag("RO", flagDomain, languageCode); // Romanian
flag += this.addFlag("RU", flagDomain, languageCode); // Russian
flag += this.addFlag("NL", flagDomain, languageCode); // Dutch
flag += "
";
$('#languageFlag').html(flag);
$('#languageUl').show();
document.onmousedown = HC.Language.hideLanguageFlag;
},
addFlag: function (flagCode, flagDomain, languageCode) {
if (flagCode == languageCode) {
return "
";
}
else {
return "
";
}
},
// visibility control for hotel.aspx page rate tab first calendar and city.aspx first calendar
hideLanguageFlag: function (e) {
var target = (e ? e.target : event.srcElement);
var flagUl = document.getElementById("languageUl");
var flagSelected = document.getElementById("selected");
if (flagUl != null && flagSelected != null) {
(HC.Common.isChild(target, flagUl) || HC.Common.isChild(target, flagSelected)) ? null : flagUl.style.display = 'none';
}
},
//add flags for pages in Widgets folder, can be removed after update Widgets files
showLanguageFlags: function (flagDomain, languageCode, currentUrl) {
var flag = "
";
flag += this.addFlagLink("EN", flagDomain, languageCode, currentUrl);
flag += this.addFlagLink("DE", flagDomain, languageCode, currentUrl); // German
flag += this.addFlagLink("ES", flagDomain, languageCode, currentUrl); // Spanish
flag += this.addFlagLink("FR", flagDomain, languageCode, currentUrl); // French
flag += this.addFlagLink("IT", flagDomain, languageCode, currentUrl); // Italian
flag += this.addFlagLink("CS", flagDomain, languageCode, currentUrl); // Chinese Simplified
flag += this.addFlagLink("CN", flagDomain, languageCode, currentUrl); // Chinese Traxditional
flag += this.addFlagLink("JA", flagDomain, languageCode, currentUrl); // Japanese
flag += this.addFlagLink("KO", flagDomain, languageCode, currentUrl); // Korean
flag += this.addFlagLink("PT", flagDomain, languageCode, currentUrl); // Portugues
flag += this.addFlagLink("EL", flagDomain, languageCode, currentUrl); // Greek
flag += this.addFlagLink("RO", flagDomain, languageCode, currentUrl); // Romanian
flag += this.addFlagLink("RU", flagDomain, languageCode, currentUrl); // Russian
flag += this.addFlagLink("NL", flagDomain, languageCode, currentUrl); // Dutch
flag += "