// function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } // function getCookieHotels() { var props = new Array(); var i = 0; for (var recentHotelsCounter = 0; recentHotelsCounter < 9; recentHotelsCounter++) { var info = readCookie('rh' + (recentHotelsCounter + 1)); if (info != null) { props[i] = info; i++; } } return props; } // function getCookieHotelDetail(hotel, param){ var info = hotel.split('&&&') var detail = ""; var tokens; for(var i = 0; i < info.length; i++){ tokens = info[i].split('***'); if (tokens[0] == param) { detail = tokens[1]; break; } } return detail; }; // function addHotels(hotels, namelen) { var colBrandId = 'a'; var colId = 'b'; var colPropName = 'c'; var colUrl = 'v'; var colDateIn = 'r'; var colDateOut = 's'; var colAvail = 't'; for (var n = 0; n < hotels.length; n++) { var id = getCookieHotelDetail(hotels[n], colBrandId) + getCookieHotelDetail(hotels[n], colId); // modify URL var url = getCookieHotelDetail(hotels[n], colUrl); if (getCookieHotelDetail(hotels[n], colDateIn) == "" || getCookieHotelDetail(hotels[n], colDateOut) == "" || getCookieHotelDetail(hotels[n], colAvail) == "" || getCookieHotelDetail(hotels[n], colAvail) < 0) { url = 'Booking/modify_dates?tab=tab2&' + url; } else { url = 'Booking/check_avail?tab=tab2&' + url; } // modify name var name = getCookieHotelDetail(hotels[n], colPropName); name = name.replace(new RegExp('\\+', "g"), ' '); if (name.length > namelen) { name = name.substring(0, namelen-1) + '...'; } // Do not save the hotel if the URL does not contain property/brand ID pair. // This may happen due to some error. var invalidUrl = url == "" || (url.indexOf("&id=") == -1 && url.indexOf("?id=") == -1 && !("id=" == url.substring(0, "id=".length))) || (url.indexOf("&propBrandId=") == -1 && url.indexOf("?propBrandId=") == -1 && !("propBrandId=" == url.substring(0, "propBrandId=".length))); if (!invalidUrl) { addRecentHotel(id, url, name, namelen); } } } // function addRecentHotel(id, url, name, namelen) { var listbox = $('divRecentHotelsListBox'); var entry = ' » ' + name + '
'; listbox.innerHTML = entry + listbox.innerHTML; } // function clearRecentHotelsList() { var listbox = $('divRecentHotelsListBox'); listbox.innerHTML = ''; } // function makeRecentHotelsVisible() { var box = $('divRecentHotelsBox'); box.style.display = ""; } // function updateRecentHotels(namelen) { var hotels = getCookieHotels(); if (hotels.length > 0) { clearRecentHotelsList(); addHotels(hotels, namelen); makeRecentHotelsVisible(); } } //-------------------------------------SEO changes (rshotels_widget.jsp)start ---------------------------------------- var ie = document.all; var nn6 = document.getElementById && ! document.all; var isdrag = false; var x, y; var dobj; var hotelsRequest = false; var divName = "recentHotels__Div"; var iframeName = "recentHotels__iFrame"; var postProcessFunction = ""; function loadUrl(url) { hotelsRequest = getHttpObject(); if (hotelsRequest) { document.body.style.cursor = "wait"; hotelsRequest.onreadystatechange = processReqChange; hotelsRequest.open('GET', url, true); hotelsRequest.send(null); // alert("In loadUrl, request sent."); } } function processReqChange() { if (hotelsRequest.readyState == 4 && hotelsRequest.status == 200) { divElement = document.getElementById(divName); newDiv = document.createElement('div'); newDiv.innerHTML = hotelsRequest.responseText; divElement.innerHTML = ""; divElement.appendChild(newDiv); recentHotelsDivElement.style.display = "block"; recentHotelsDivElement.style.top = document.body.scrollTop +50; setIframeStyle(); document.body.style.cursor = "default"; // Engage another call of setIframeStyle() to occur // in 1 second, to compensate for possible change // in size of the Div during its rendering setTimeout("setIframeStyle()", 300); setTimeout("setIframeStyle()", 1000); setTimeout("setIframeStyle()", 3000); if (postProcessFunction != "") { eval(postProcessFunction); postProcessFunction = ""; } } } function setIframeStyle() { divElement = document.getElementById(divName); iframe = document.getElementById(iframeName); iframe.style.display = 'block'; iframe.style.width = divElement.offsetWidth; iframe.style.height = divElement.offsetHeight; iframe.style.left = divElement.offsetLeft; iframe.style.top = divElement.offsetTop; } function changeRSDivState() { //alert("Div display style: " + recentHotelsDivElement.style.display); recentHotelsDivElement = document.getElementById(divName); if (recentHotelsDivElement.style.display != "block") { currentURL = window.location.href; targetURL = "Booking/recent_hotels_popup"; loadUrl(targetURL, recentHotelsDivElement); } else { closeRHDiv(); } } function closeRHDiv() { recentHotelsDivElement = document.getElementById(divName); iframe = document.getElementById(iframeName); recentHotelsDivElement.style.display = "none"; recentHotelsDivElement.innerHTML = ""; iframe.style.display = 'none'; } function closeRHotel(brandId, propId) { // Reload the popup with URL parameters that will tell // MainServlet to remove hotel from session and cookie // Set the post-process function postProcessFunction = "hideSpan('span" + brandId + propId + "')"; targetURL = "Booking/recent_hotels_popup?brandIdR=" + brandId + "&propIdR=" + propId; loadUrl(targetURL); } function hideSpan(spanId) { spanObj = document.getElementById(spanId); if (spanObj != undefined) { spanObj.style.display = "none"; } } //End of SEO