/* generated Sun Feb 12 19:15:53 EST 2012 */

R9.extend("fd.hotels",{Form:function(a){R9.fd.Form.call(this,a)}});R9.fd.hotels.Form.prototype=R9.fd.Form.prototype.beget();R9.extend("fd.hotels.Form.prototype",{bindClearDates:function(){jq("#clearDates").click(jq.proxy(this.clearDates,this))},bindDoublePicker:function(){R9.dp.doublePicker({altField:"#checkin_date_domlabel",defaultDate:jq.r9datepicker.parseDate(this.inDate),selector:"#checkin_date",minRangeDays:1},{altField:"#checkout_date_domlabel",defaultDate:jq.r9datepicker.parseDate(this.outDate),onSelect:function(){compare2chk()},selector:"#checkout_date"})},bindEvents:function(){R9.fd.Form.prototype.bindEvents.call(this);this.bindClearDates();this.bindDoublePicker();this.bindSmartbox()},bindSmartbox:function(){var a=this,b=a.e;jq(b.othercity).focus(clearGeocode).smartbox({callback:function(c){c=c||{};b.citycode.value=c.id||"";b.hid.value=c.hid||"";b.lmid.value=c.lmid||"";if(c.id){compare2chk()}},callbackWithNull:true,minWidth:a.smartboxMinWidth,searchType:"hotel",smartUrl:a.smartboxUrl,timeout:a.smartboxTimeout}).blur(function(){compare2chk();geocodeAddress(false)})},clearDates:function(){var a=this.e;a.checkin_date.value=a.checkout_date.value="";jq("#checkin_date_domlabel, #checkout_date_domlabel").html("dd/mm/yy");jq.get("/s/sparkle?action=clearMetaCookies&names=STICKY_START_DATE,STICKY_END_DATE");return false},isValid:function(){var b=this.getData(),a=null;if(!b.othercity){a=this.missingLocationMessage}else{if(b.checkin_date||b.checkout_date){if(!b.checkin_date){a="Please enter a check-in date."}else{if(!b.checkout_date){a="Please enter a check-out date."}}}}return(this.error=a)===null},loadHistory:function(a,d,b){R9.fd.Form.prototype.loadHistory.call(this);var j=this,g=j.e;j.setSourceForHistory(b);j.isSubmitted=false;if(d>=0){if(b){skipCompare=true}if(j.history.length>d){var h=j.history[d];if(j.okToLoadLocationAndDates){g.location.value=j.formatLocation(h.hcity,h.hstate,h.hcntry,h.hcntryname);var f=j.getTodayDate(),k=new Date(Date.parse(h.hin)),c=new Date(Date.parse(h.hout));if(k&&k.getTime()>=f.getTime()){jq("#checkin_date").datepicker("setDate",k);jq("#checkin_date_domlabel").text(jq.datepicker.formatDate("D, d M yy",k));jq("#checkout_date").datepicker("setDate",c);jq("#checkout_date_domlabel").text(jq.datepicker.formatDate("D, d M yy",c))}else{if(!isNaN(Date.parse(h.hin))&&b){alert("The dates for this hotel search have expired, please enter new dates.");b=false}jq("#checkin_date,#checkout_date").datepicker("setDate",null);jq("#checkin_date_domlabel,#checkout_date_domlabel").text("dd/mm/yy")}g.othercity.value=g.location.value;g.citycode.value=h.hhint}else{j.okToLoadLocationAndDates=true}g.hid.value=h.hid;jq(g.rooms).val(h.hroom);roomsChanged();jq(g[h.hroom==="1"?"guests1":"guests2"]).val(h.hguest);jq(g.minstars).val(h.hstars);jq(g.provider).val(h.brandid);jq(g.maxprice).val(h.maxprice);if(h.hlandmark){if(h.hlandmark.lmid){g.searchType.value="C";g.lmid.value=h.hlandmark.lmid}else{g.searchType.value="A";g.lmid.value="";g.address.value=h.hlandmark.addr;if(h.hlandmark.addr!=h.hlandmark.name){g.address_nickname.value=h.hlandmark.name}}}else{g.searchType.value="C"}initGeocoder();g.recent.value="Y"}if(b){jq(g).submit();skipCompare=false}else{compare2chk()}}return false},loadSettings:function(a){R9.fd.Form.prototype.loadSettings.call(this,a);this.guests=a.guests;this.hasAction=!!a.hasAction;this.inDate=a.inDate;this.maxPrice=a.maxPrice;this.minStars=a.minStars;this.missingLocationMessage=a.missingLocationMessage;this.outDate=a.outDate;this.provider=a.provider;this.rooms=a.rooms;this.smartboxMinWidth=a.smartboxMinWidth||175;this.smartboxUrl=a.smartboxUrl||jq.fn.smartbox.defaults.smartUrl;this.smartboxTimeout=a.smartboxTimeout||jq.fn.smartbox.defaults.timeout;this.submitOnPost=!!a.submitOnPost;this.triggerRoomsChanged=!!a.triggerRoomsChanged;this.useLast=!!a.useLast},onLoad:function(){R9.fd.Form.prototype.onLoad.call(this);var c=this;if(document.lasttab.havesearched.value=="false"){if(c.e.Search){c.e.Search.disabled=false}if(c.maxPrice){c.e.maxprice.value=c.maxPrice}if(c.minStars){c.e.minstars.value=c.minStars}if(c.provider){c.e.provider.value=c.provider}if(c.rooms){c.e.rooms.value=c.rooms;if(c.triggerRoomsChanged){roomsChanged()}c.e[c.rooms==="1"?"guests1":"guests2"].value=c.guests}if(!c.hasAction){if(document.lasttab.havesearched.value=="false"){var b=new Date();c.e.datelimit.value=(b.getMonth()-0+1)+"/"+b.getDate()+"/"+b.getFullYear()}if(c.e.rooms.value==="2"){c.e.guests1.style.display="none";c.e.guests2.style.display="inline"}}if(c.useLast){c.loadHistory(null,0,false)}initGeocoder();try{c.e.othercity.focus()}catch(a){}}showPromo();compare2initializing=false;compare2chk();setCmp2Count();R9LoadFinished=new Date();var d=R9LoadFinished.getTime()-R9StartPage.getTime();recordEvent("client page load","front door","hotels","ms",d);if(c.submitOnPost){setTimeout(function(){jq(c.e).submit()},250)}},onSubmit:function(){R9.fd.Form.prototype.onSubmit.call(this);var a=this,c=a.e;Profiler.markSearchStart();if(!a.isSubmitted){if(a.isValid()){a.preSubmit();a.preSubmitMore();if(!c.citycode.value.length&&c.othercity.value!==c.geocoded.value){geocodeAddress(true);c.geocoded.value=c.othercity.value;return false}if(c.location.value){if(!jq("#checkin_date").datepicker("getDate")||!jq("#checkout_date").datepicker("getDate")){uncheckcomparetos(c)}if(comparewindows(c)){a.disableSearchButton();var b=a.generateSearchUrl();if(b!=null){loadResults(b);return false}return true}else{popupBlockerMsg(c)}}}else{alert(this.error)}}return false},preSubmit:function(){var a=this.e;a.guests.value=a.rooms.value==="1"?a.guests1.value:a.guests2.value;var b=a.othercity.value;if(!a.location.value){a.location.value=b}},preSubmitMore:jq.noop});function changelocation(){var b=document.hotels;if(b.newlocation!=null){var a=b.newlocation.selectedIndex;var c=b.newlocation.options[a].value.split(":");if(c.length>1){b.citycode.value=c[1]}else{b.citycode.value=""}if(c.length>3){if(c[2]=="lmid"){b.lmid.value=c[3]}else{if(c[2]=="hid"){b.hid.value=c[3]}}}b.location.value=c[0];b.othercity.value=c[0];b.lat.value="";b["long"].value="";disableSearchButton();b.submit()}}function roomsChanged(){if(document.hotels.rooms.value=="3"){if(window.confirm("We only support searching for up to two rooms at once. Would you like to use our partner site Hotelplanner.com to search for multiple rooms?")){var d=document.hotels;var e="Checkin%3D"+d.checkin_date.value;e+="%26Checkout%3D"+d.checkout_date.value;e+="%26City%3D"+d.othercity.value;var c="/k/redirect/out?url=http%3A//www.hotelplanner.com/%3F"+e+"%26sc%3D"+getGroopleTrack();var f=window.open(c);if(f==null){alert("Please make sure you turn off pop-up blockers if you wish to go to Hotelplanner.com.")}}document.hotels.rooms.value="1"}else{if(document.hotels.rooms.value=="2"){document.hotels.guests1.style.display="none";document.hotels.guests2.style.display="inline";var b=document.hotels.guests1.value;jq(document.hotels.guests2).val(b==="1"?"2":b)}else{document.hotels.guests1.style.display="inline";document.hotels.guests2.style.display="none";var a=document.hotels.guests2.value;jq(document.hotels.guests1).val(parseInt(a,10)<4?a:"4")}}}function checkin_date_changed(){var b=jq("#checkin_date").datepicker("getDate"),a=jq("#checkout_date").datepicker("getDate");if(a==null||b>a){b.setDate(b.getDate()+3);jq("#checkout_date").datepicker("setDate",b);jq("#checkout_date_domlabel").text(jq.datepicker.formatDate("D, d M yy",b))}}function initGeocoder(){document.getElementById("mapframe").src="/maps/geocoder?w=1&h=1"}function clearGeocode(){var a=document.hotels;a.searchType.value="C";a.address.value=a.address_nickname.value=a.lat.value="";a.postalcode.value=a.location.value=a["long"].value="";a.geocoded.value=""}function addressResult(d){var a=document.hotels;var e=null;clearGeocode();if(d&&d.Status.code==200&&d.Placemark){e=d.Placemark[0]}if(e&&e.address){var g=e.address.split(", ");var h=g.length;var c=g[h-1];if(e.AddressDetails&&e.AddressDetails.Country){c=e.AddressDetails.Country.CountryNameCode}else{if(c.length>2){c=c.substring(0,2)}}var b=(c=="US"||c=="CA"?3:2);if(h>=b){a.searchType.value="A";if(c=="US"||c=="CA"){a.location.value=g[h-3]+","+g[h-2].substring(0,2)+","+c;a.postalcode.value=g[h-2].substring(3)}else{if(c=="GB"){var j=new RegExp(/.* [0-9]/);if(j.test(g[h-2])){var f=g[h-2].split(" ");var i=f.length;a.location.value=f.slice(0,i-2)+",United Kingdom";a.postalcode.value=f[i-2]+" "+f[i-1]}else{a.location.value=g.slice(h-2,h-1)+",United Kingdom"}}else{a.location.value=g.slice(h-b)}}if(h>=b+1){a.address.value=g[h-b-1]}if(h>=b+2){a.address_nickname.value=g[0]}if(e.Point&&e.Point.coordinates){a["long"].value=e.Point.coordinates[0];a.lat.value=e.Point.coordinates[1]}}}if(a.location.value.length>0){if(e){a.othercity.value=e.address}}a.geocoded.value=a.othercity.value}function submitAddressResult(a){addressResult(a);disableSearchButton();document.hotels.submit()}function geocodeAddress(b){var a=document.hotels.othercity.value;if(document.hotels.citycode.value.length<1&&!document.hotels.newlocation){var c=a.split(/\W+/);if(c.length>2||a.indexOf(",")>=0){document.hotels.geocoded.value="";if(b){window.frames.mapframe.geoCodeAddressList(a,submitAddressResult)}else{window.frames.mapframe.geoCodeAddressList(a,addressResult)}}else{document.hotels.geocoded.value=a}}}var form;

;var jsck_fdhotel_en_gb="v428";
/* et=2, mt=3, c=p4, i=sparkle001, v=R114, cc=4, r=none */

