﻿var map,mgr,geocoder,hotelnames=[],townnames=[],citynames=[],newhotelmarkers=[],allhotelmarkers=[],geocodemarker,lockupdate=false,MAXCOUNTRYZOOM=5,MAXCITYZOOM=9,MAXTOWNZOOM=11,MAXHOTELS=50,lowerprice=75,upperprice=150,numstars=1,centrelat=15,centrelng=0,zoomlevel=3,geocodemade=false,forcegeocode=false,firstplot=true,DRAG_SENSITIVITY=0.005,COUNTRIES_PLOTTED=false,wikilayer,centrelocations=[],geocodelocation='',arrivaldatehotel,departuredatehotel,numadults,numchildren,currency="usd",currencysymbol="$",monthnames=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function checkEmail(){var i=0;if(document.getElementById('username').value.replace(" ","").length<3){document.getElementById('usernameerror').innerHTML="Please enter a name of at least 3 characters";i++}else{document.getElementById('usernameerror').innerHTML=""}
var I=document.getElementById('emailaddress').value,l=validURL(I);if(l!="email"){if(l=="space"){document.getElementById('emailaddresserror').innerHTML="Email addresses cannot contain spaces. Please remove these and try again."}else{document.getElementById('emailaddresserror').innerHTML="This is not a valid email address. Please try again."}
i++}
if(i>0){alert("Oops! There were some errors in your input. We've highlighted what you need to fix in red.");return}
document.getElementById('nameemaildiv').style.display='none';document.getElementById('adjustmapdiv').style.display='block'}
function checkEvent(){var i=0;if(document.getElementById('eventtitle').value.replace(" ","").length<3||document.getElementById('eventtitle').value=='e.g. NYC travel conference'){document.getElementById('eventtitleerror').innerHTML="Please enter an event title of at least 3 characters";i++}else{document.getElementById('eventtitleerror').innerHTML=""}
if(document.getElementById('eventlocation').value.replace(" ","").length<3||document.getElementById('eventlocation').value=='e.g. 55 Broadway, New York'){document.getElementById('eventlocationerror').innerHTML="Please enter an event location of at least 3 characters";i++}else{document.getElementById('eventlocationerror').innerHTML=""}
if(document.getElementById('eventdescription').value.replace(" ","").length<3){document.getElementById('eventdescriptionerror').innerHTML="Please enter an event description";i++}else{document.getElementById('eventdescriptionerror').innerHTML=""}
if(document.getElementById('displaystartdate').value=='dd-mm-yyyy'||document.getElementById('displayenddate').value=='dd-mm-yyyy'){document.getElementById('displaydateerror').innerHTML="<span style='color:red;'>Please complete event start and end dates (for one day events, enter the event date in both boxes)</span>";i++}else if(!checkDatesValid('displaystartdate','displayenddate','event')){document.getElementById('displaydateerror').innerHTML="<span style='color:red;'>Event end date must be on or after event start date (for one day events, enter the event date in both boxes)</span>";document.getElementById('displaydateerror').style.display="block";i++}else{document.getElementById('displaydateerror').innerHTML=""}
if(document.getElementById('startdate').value=='dd-mm-yyyy'||document.getElementById('enddate').value=='dd-mm-yyyy'){document.getElementById('dateerror').innerHTML="<span style='color:red;'>Please complete suggested hotel arrival and departure dates</span>";document.getElementById('dateerror').style.display="block";i++}else if(!checkDatesValid('startdate','enddate','hotel')){document.getElementById('dateerror').innerHTML="<span style='color:red;'>Suggested hotel departure date must be after arrival date</span>";document.getElementById('dateerror').style.display="block";i++}else{document.getElementById('dateerror').style.display="none";document.getElementById('dateerror').innerHTML=""}
if(document.getElementById('eventurl')==''||document.getElementById('eventurl').value=='eventname'){document.getElementById('eventurlerror').innerHTML="Please enter an event URL";i++}else if(document.getElementById('eventurl').value.length<3){document.getElementById('eventurlerror').innerHTML="Event URL must be at least 3 characters";i++}else{document.getElementById('eventurlerror').innerHTML=""}
var I=document.getElementById('eventurl').value,l=validURL(I);if(l!="valid"){if(l=="space"){document.getElementById('eventurlerror').innerHTML="Hotel Map URL cannot contain spaces. Please remove these and try again."}else{document.getElementById('eventurlerror').innerHTML="Hotel Map URL contains invalid characters. Please try an alternative."}
i++}
if(i>0){alert("Oops! There were some errors in your input. We've highlighted what you need to fix in red.");return}
document.getElementById('eventbutton').style.display="none";document.getElementById('eventprocessing').style.display="block";var o="dbaccess/getEventURL.php?url="+I;GDownloadUrl(o,checkEventURL)}
function checkPlacemark(){var i=0;if(document.getElementById('placemarktitle').value.replace(" ","").length<3||document.getElementById('placemarktitle').value=='e.g. Headquarters'){document.getElementById('placemarktitleerror').innerHTML="Please enter a placemark title of at least 3 characters";i++}else{document.getElementById('placemarktitleerror').innerHTML=""}
if(document.getElementById('placemarklocation').value.replace(" ","").length<3||document.getElementById('placemarklocation').value=='e.g. 55 Broadway, New York'){document.getElementById('placemarklocationerror').innerHTML="Please enter a placemark location of at least 3 characters";i++}else{document.getElementById('placemarklocationerror').innerHTML=""}
if(document.getElementById('placemarkdescription').value.replace(" ","").length<3){document.getElementById('placemarkdescriptionerror').innerHTML="Please enter a placemark description";i++}else{document.getElementById('placemarkdescriptionerror').innerHTML=""}
if(document.getElementById('placemarkurl').value==''||document.getElementById('placemarkurl').value=='placemarkname'){document.getElementById('placemarkurlerror').innerHTML="Please enter a placemark URL";i++}else if(document.getElementById('placemarkurl').value.length<3){document.getElementById('placemarkurlerror').innerHTML="Placemark URL must be at least 3 characters";i++}else{document.getElementById('placemarkurlerror').innerHTML=""}
var I=document.getElementById('placemarkurl').value,l=validURL(I);if(l!="valid"){if(l=="space"){document.getElementById('placemarkurlerror').innerHTML="Hotel Map URL cannot contain spaces. Please remove these and try again."}else{document.getElementById('placemarkurlerror').innerHTML="Hotel Map URL contains invalid characters. Please try an alternative."}
i++}
if(i>0){alert("Oops! There were some errors in your input. We've highlighted what you need to fix in red.");return}
document.getElementById('placemarkbutton').style.display="none";document.getElementById('placemarkprocessing').style.display="block";var o="dbaccess/getEventURL.php?url="+I;GDownloadUrl(o,checkPlacemarkURL)}
function checkEventURL(X){var z=GXml.parse(X);if(z.getElementsByTagName("error").length!=0){document.getElementById('eventurlerror').innerHTML="Hotel Map URL already exists. Please try a different URL.";document.getElementById('eventbutton').style.display="block";document.getElementById('eventprocessing').style.display="none";return}
var x=document.getElementById('eventtitle').value,v=document.getElementById('eventlocation').value,O=document.getElementById('eventdescription').value,C=document.getElementById('eventurl').value,i=stringToDate(document.getElementById('displaystartdate').value),l=stringToDate(document.getElementById('displayenddate').value),c=stringToDate(document.getElementById('startdate').value),V=stringToDate(document.getElementById('enddate').value);if(document.getElementById('eventpublic').checked){var o=1}else{var o=0}
if(document.getElementById('usd').checked){var I='usd'}else if(document.getElementById('eur').checked){var I='eur'}else{var I='gbp'}
submitEvent(x,v,c,V,i,l,O,I,o,C)}
function checkPlacemarkURL(c){var C=GXml.parse(c);if(C.getElementsByTagName("error").length!=0){document.getElementById('placemarkurlerror').innerHTML="Hotel Map URL already exists. Please try a different URL.";document.getElementById('placemarkbutton').style.display="block";document.getElementById('placemarkprocessing').style.display="none";return}
var O=document.getElementById('placemarktitle').value,o=document.getElementById('placemarklocation').value,l=document.getElementById('placemarkdescription').value,I=document.getElementById('placemarkurl').value;if(document.getElementById('usd').checked){var i='usd'}else if(document.getElementById('eur').checked){var i='eur'}else{var i='gbp'}
submitEvent(O,o,"","","","",l,i,0,I)}
function submitEvent(W,X,c,w,I,l,O,z,V,S){var s=map.getZoom(),i=geocodemarker.getLatLng(),v=i.lat(),C=i.lng(),x=document.getElementById('username').value,o=document.getElementById('emailaddress').value,Z="http://www.roomatlas.com/dbaccess/submitEvent.php?username="+x+"&emailaddress="+o+"&name="+W+"&location="+X+"&startdate="+c+"&enddate="+w+"&displaystartdate="+I+"&displayenddate="+l+"&description="+O+"&currency="+z+"&eventtype="+V+"&url="+S+"&zoom="+s+"&centrelat="+v+"&centrelng="+C;GDownloadUrl(Z,writeEvent)}
function writeEvent(o){document.getElementById('eventdiv').style.display="none";document.getElementById('placemarkdiv').style.display="none";document.getElementById('statusdiv').style.display="block";var l=GXml.parse(o);if(l.getElementsByTagName("url").length==0){document.getElementById('eventstatus').innerHTML="<div class='sidebarinput'><b>Apologies</b><br/>An error occurred and we were unable to create your Hotel Map. Please <a href='contact.php'>contact us</a> with your Hotel Map details and we'll create it for you.</div>";return}
var i="www.roomatlas.com/"+l.getElementsByTagName("url")[0].firstChild.nodeValue;document.getElementById('eventstatus').innerHTML="<div class='sidebarinput'><b>Congratulations</b><br/>Your Hotel Map has been created at: <div style='border:1px solid lightgrey; background-color: #f5f5ff; width: 256px; padding: 5px; margin: 5px 0; text-align: center;'><a target='_blank' href='http://"+i+"'>"+i+"</a></div><input type='button' value=' Copy to clipboard >>' id='copytoclipboard' style='margin-bottom:5px;'/><br />You may go ahead and share your Hotel Map with whoever you'd like. Thanks for using RoomAtlas!</div><div class='sidebarinput'><input type='button' onclick='window.location.href=\"index.php\";' value=' Home Page >>'>&nbsp;<input type='button' onclick='window.location.href=\"quicklink.php\";' value=' Create another >>'></div>";ZeroClipboard.setMoviePath('http://www.roomatlas.com/js/ZeroClipboard.swf');var I=new ZeroClipboard.Client();I.setHandCursor(false);I.addEventListener('mousedown',function(){I.setText(i)});I.addEventListener('complete',function(i,I){alert('Copied the Hotel Map URL to the clipboard. You can paste it into emails (or wherever you like!) now.')});I.glue('copytoclipboard')}
function validURL(i){if(i.indexOf("$")!=-1)return "invalid";if(i.indexOf("&")!=-1)return "invalid";if(i.indexOf("+")!=-1)return "invalid";if(i.indexOf(",")!=-1)return "invalid";if(i.indexOf("/")!=-1)return "invalid";if(i.indexOf(":")!=-1)return "invalid";if(i.indexOf(";")!=-1)return "invalid";if(i.indexOf("=")!=-1)return "invalid";if(i.indexOf("?")!=-1)return "invalid";if(i.indexOf(" ")!=-1)return "space";if(i.indexOf("\"")!=-1)return "invalid";if(i.indexOf("<")!=-1)return "invalid";if(i.indexOf(">")!=-1)return "invalid";if(i.indexOf("#")!=-1)return "invalid";if(i.indexOf("%")!=-1)return "invalid";if(i.indexOf("{")!=-1)return "invalid";if(i.indexOf("}")!=-1)return "invalid";if(i.indexOf("|")!=-1)return "invalid";if(i.indexOf("\\")!=-1)return "invalid";if(i.indexOf("^")!=-1)return "invalid";if(i.indexOf("~")!=-1)return "invalid";if(i.indexOf("[")!=-1)return "invalid";if(i.indexOf("]")!=-1)return "invalid";if(i.indexOf("(")!=-1)return "invalid";if(i.indexOf(")")!=-1)return "invalid";if(i.indexOf("`")!=-1)return "invalid";if(i.indexOf("'")!=-1)return "invalid";if(i.indexOf("*")!=-1)return "invalid";if(i.indexOf("£")!=-1)return "invalid";if(i.indexOf("€")!=-1)return "invalid";if(i.indexOf("@")!=-1)return "email";return "valid"}
function checkDatesValid(O,c,x){if(document.getElementById(O).value!="dd-mm-yyyy"&&document.getElementById(c).value!="dd-mm-yyyy"){var I=document.getElementById(O).value.split("-"),V=monthnames.indexOf(I[1])+1,o=I[2]+"/"+V+"/"+I[0],C=Date.parse(o),i=document.getElementById(c).value.split("-");V=monthnames.indexOf(i[1])+1;var l=i[2]+"/"+V+"/"+i[0],v=Date.parse(l);if((x=='hotel'&&v>C)||(x=='event'&&v>=C)){return true}else{return false}}else{return true}}
function stringToDate(I){var i=I.split("-");return i[2]+"-"+(monthnames.indexOf(i[1])+1)+"-"+i[0]}
function processKey(I,i){switch(I.keyCode){case 13:return false;break}
return true}
function initialize(){mapSize();map=new GMap2(document.getElementById("map_canvas"));map.addMapType(G_PHYSICAL_MAP);map.setMapType(G_PHYSICAL_MAP);map.addControl(new GHierarchicalMapTypeControl);map.addControl(new GNavLabelControl,new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(215,5)));map.addControl(new GLargeMapControl3D,new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(292,5)));map.addControl(new GScaleControl);map.enableScrollWheelZoom();map.enableContinuousZoom();map.setCenter(new GLatLng(0,0),3);mgr=new MarkerManager(map,{borderPadding:0});geocoder=new GClientGeocoder;wikilayer=new GLayer("org.wikipedia.en");GEvent.addListener(map,"dragend",catchDrag);GEvent.addListener(map,"zoomend",catchZoom);map.setCenter(new GLatLng(centrelat,centrelng),zoomlevel,G_PHYSICAL_MAP);catchZoom(17,zoomlevel)}
function setupCountries(){showLoadingMessage(true);COUNTRIES_PLOTTED=true;var i='data/countries.xml';GDownloadUrl(i,addCountryMarkersToMgr)}
function setupCities(){showLoadingMessage(true);var l=map.getBounds(),I=l.getSouthWest(),i=l.getNorthEast(),o=map.getZoom(),O='dbaccess/getCities.php?swlat='+I.lat()+'&swlng='+I.lng()+"&nelat="+i.lat()+"&nelng="+i.lng()+"&type=city";GDownloadUrl(O,addCityMarkersToMgr)}
function setupTowns(){showLoadingMessage(true);var l=map.getBounds(),I=l.getSouthWest(),i=l.getNorthEast(),o=map.getZoom(),O='dbaccess/getCities.php?swlat='+I.lat()+'&swlng='+I.lng()+"&nelat="+i.lat()+"&nelng="+i.lng()+"&type=town";GDownloadUrl(O,addTownMarkersToMgr)}
function addCountryMarkersToMgr(V){var I=[],x=GXml.parse(V),i=x.getElementsByTagName("k");for(var X=0;X<i.length;X++){var l=i[X].getAttribute("c"),v=i[X].getAttribute("n"),Z=parseFloat(i[X].getAttribute("x")),z=parseFloat(i[X].getAttribute("y"));var C=new GLatLng(Z,z);var o=parseInt(i[X].getAttribute("z"));var O=new StringBuilder;O.appendFormat("<h1>{0}</h1>",v);O.appendFormat("<br />{0} hotels",l);O.appendFormat("<br /><b><a href='#' onclick='centrelat={0};centrelng={1};firstplot=true;map.setCenter(new GLatLng({0},{1}),{2});return false;'>Zoom to towns >></a></b>",Z,z,o);var c=createMarker("country",C,l,O.toString());I.push(c)}
mgr.addMarkers(I,1,MAXCOUNTRYZOOM);mgr.refresh();showLoadingMessage(false)}
function addCityMarkersToMgr(V){var i=[],x=GXml.parse(V),I=x.documentElement.getElementsByTagName("c");for(var X=0;X<I.length;X++){var c=I[X].getAttribute("n");if(!citynames.contains(c)){var l=I[X].getAttribute("c"),Z=parseFloat(I[X].getAttribute("x")),z=parseFloat(I[X].getAttribute("y"));var v=new GLatLng(Z,z);var o=parseInt(I[X].getAttribute("z"));var O=new StringBuilder;O.appendFormat("<h1>{0}</h1>",c);O.appendFormat("<br />{0} hotels",l);O.appendFormat("<br /><b><a href='#' onclick='centrelat={0};centrelng={1};firstplot=true;map.setCenter(new GLatLng({0},{1}),{2});return false;'>Zoom to hotels >></a></b>",Z,z,o);var C=createMarker("city",v,l,O.toString());i.push(C);citynames.push(c)}}
mgr.addMarkers(i,MAXCOUNTRYZOOM+1,MAXTOWNZOOM);mgr.refresh();showLoadingMessage(false)}
function addTownMarkersToMgr(V){var i=[],x=GXml.parse(V),l=x.getElementsByTagName("c");for(var X=0;X<l.length;X++){var c=l[X].getAttribute("n");if(!townnames.contains(c)){var I=l[X].getAttribute("c"),Z=parseFloat(l[X].getAttribute("x")),z=parseFloat(l[X].getAttribute("y"));var v=new GLatLng(Z,z);var o=parseInt(l[X].getAttribute("z"));var O=new StringBuilder;O.appendFormat("<h1>{0}</h1>",c);if(I==1){O.append("<br />1 hotel");O.appendFormat("<br /><b><a href='#' onclick='centrelat={0};centrelng={1};firstplot=true;map.setCenter(new GLatLng({0},{1}),{2});return false;'>Zoom to hotel >></a></b>",Z,z,o)}else{O.appendFormat("<br />{0} hotels",I);O.appendFormat("<br /><b><a href='#' onclick='centrelat={0};centrelng={1};firstplot=true;map.setCenter(new GLatLng({0},{1}),{2});return false;'>Zoom to hotel(s) >></a></b>",Z,z,o)}
var C=createMarker("city",v,I,O.toString());i.push(C);townnames.push(c)}}
mgr.addMarkers(i,MAXCITYZOOM+1,MAXTOWNZOOM);mgr.refresh();showLoadingMessage(false)}
function catchDrag(){var o=map.getBounds(),I=o.getSouthWest(),l=o.getNorthEast();centrelat=(I.lat()+l.lat())/2;centrelng=(I.lng()+l.lng())/2;var i=map.getZoom();if(i>MAXCITYZOOM&&i<=MAXTOWNZOOM){setupCities();setupTowns()}else if(i>MAXCOUNTRYZOOM&&i<=MAXTOWNZOOM){setupCities()}else if(i>MAXTOWNZOOM&&somewhereNew(centrelat,centrelng,i)&&!lockupdate){setupHotels()}}
function catchZoom(o,i){var c=map.getBounds(),l=c.getSouthWest(),O=c.getNorthEast();centrelat=(l.lat()+O.lat())/2;centrelng=(l.lng()+O.lng())/2;var I=map.getZoom();if(o>MAXTOWNZOOM&&i<=MAXTOWNZOOM){resetMgr();map.setMapType(G_PHYSICAL_MAP);setTitleBar('zoomedout');document.getElementById('wikipedia_text').style.display='none';updateWikipedia(false)}else if(o<=MAXTOWNZOOM&&i>MAXTOWNZOOM){resetMgr();map.setMapType(G_NORMAL_MAP);document.getElementById('wikipedia_text').style.display='inline';if(document.getElementById('wikipediacheckbox').checked){updateWikipedia(true)}
firstplot=true}
if(i>MAXCITYZOOM&&i<=MAXTOWNZOOM&&somewhereNew(centrelat,centrelng,I)){setupCities();setupTowns()}else if(i>MAXCOUNTRYZOOM&&i<=MAXTOWNZOOM&&somewhereNew(centrelat,centrelng,I)){setupCities()}else if(i<=MAXCOUNTRYZOOM&&!COUNTRIES_PLOTTED){setupCountries()}else if(i>MAXTOWNZOOM&&!lockupdate&&somewhereNew(centrelat,centrelng,I)){setupHotels()}}
function setupHotels(){showLoadingMessage(true);newhotelmarkers=[];var i=makeProviderRequest();GDownloadUrl(i,addAvailabilityHotelsToMgr)}
function addGeocodeMarker(){var o=map.getBounds(),I=o.getSouthWest(),i=o.getNorthEast(),O=(I.lat()+i.lat())/2,l=(I.lng()+i.lng())/2;createAddressMarker("",O,l)}
function makeProviderRequest(q){var S=map.getBounds(),c=S.getSouthWest(),C=S.getNorthEast(),k=(c.lat()+C.lat())/2,w=(c.lng()+C.lng())/2,x=getRadius(c.lat(),C.lat());var V=new StringBuilder;var v=getNextTuesday('start'),I=v.split("/");var o=new StringBuilder;o.appendFormat("{0}/{1}/{2}",I[1],I[0],I[2]);arrivaldatehotel=o.toString();var O=getNextTuesday('end'),i=O.split("/");var l=new StringBuilder;l.appendFormat("{0}/{1}/{2}",i[1],i[0],i[2]);departuredatehotel=l.toString();var Z=1,X=0,s='',K=1,W="",z=3;if(document.getElementById('usd').checked==true){currency="usd";currencysymbol="$"}else if(document.getElementById('eur').checked==true){currency="eur";currencysymbol="&euro;"}else{currency="gbp";currencysymbol="&pound;"}
V.appendFormat("getAvailabilityXML.php?arrivalDate={0}&departureDate={1}&numAdults={2}&numChildren={3}&childAges={4}&minStars={5}&amenities={6}&sortMethod={7}&numResults={8}&latitude={9}&longitude={10}&searchRadius={11}&currency={12}",v,O,Z,X,s,K,W,z,MAXHOTELS,k,w,x,currency);return V.toString()}
function addAvailabilityHotelsToMgr(v){var V=GXml.parse(v),I=V.documentElement.getElementsByTagName("Hotel"),i=I.length,O,x;if(firstplot&&i>4){var l=[],C=I[0].getElementsByTagName("NativeNightlyRates").length-1,c=parseInt(I[0].getElementsByTagName("NativeNightlyRates")[C].getAttribute('size'));for(var X=0;X<i;X++){if(currency!="gbp"){O=parseFloat(I[X].getElementsByTagName("chargeableRoomRateTotal")[0].firstChild.nodeValue)-parseFloat(I[X].getElementsByTagName("chargeableRoomRateTaxesAndFees")[0].firstChild.nodeValue)}else{O=parseFloat(I[X].getElementsByTagName("chargeableRoomRateTotal")[0].firstChild.nodeValue)}
l.push(O/c)}
l.sort(sortNumber);lowerprice=Math.round(l[Math.round(i/4)]);upperprice=Math.round(l[Math.round(3*i/4)])}
firstplot=false;for(var X=0;X<i;X++){plotavailabilityhotel(I[X])}
mgr.addMarkers(newhotelmarkers,MAXTOWNZOOM+1,17);mgr.refresh();showLoadingMessage(false);if(i==MAXHOTELS&&map.getZoom()<=14){document.getElementById('morehotels').style.display="block"}else{document.getElementById('morehotels').style.display="none"}
if(geocodemade==true){GEvent.trigger(geocodemarker,'click')}
var o=map.getZoom();centrelocations.push(new Array(centrelat,centrelng,o));geocodemade=false}
function plotavailabilityhotel(i){var w=getValue(i.getElementsByTagName("name"));if(hotelnames.contains(w)){return}
hotelnames.push(w);var r=getValue(i.getElementsByTagName("hotelId")),W="http://www.hotels.com"+getValue(i.getElementsByTagName("thumbNailUrl")),k=getValue(i.getElementsByTagName("propertyRating")),v=getRatingImg(k),s=getValue(i.getElementsByTagName("address1")),E=parseFloat(getValue(i.getElementsByTagName("latitude"))),e=parseFloat(getValue(i.getElementsByTagName("longitude")));var K=new GLatLng(E,e);var Q=parseFloat(getValue(i.getElementsByTagName("lowRate"))),I=parseInt(i.getElementsByTagName("NativeNightlyRates")[0].getAttribute('size')),q=getValue(i.getElementsByTagName("roomDescription"));var V=new StringBuilder;V.appendFormat("<div class='bubble'><table width='340px'><tr>");if(W!="http://www.hotels.com"){V.appendFormat("<td width = \"80px\" valign='top'><img alt=\"{0}\" id=\"bubbleimg\" src=\"{1}\"></td>",w,W)}
V.appendFormat("<td valign='top'><h1>{0}</h1><br/>{1}<br /><img class=\"ratingimg\" src=\"{2}\" width=\"83\" height=\"14\"/><br />",w,s,v);if(i.getElementsByTagName("PromoRateInfo").length>0){var o=i.getElementsByTagName("PromoRateInfo")[0],C=i.getElementsByTagName("RateInfo")[0],l=parseFloat(o.getElementsByTagName("chargeableRoomRateTotal")[0].firstChild.nodeValue),c=parseFloat(C.getElementsByTagName("chargeableRoomRateTotal")[0].firstChild.nodeValue);if(currency!="gbp"){l-=parseFloat(o.getElementsByTagName("chargeableRoomRateTaxesAndFees")[0].firstChild.nodeValue);c-=parseFloat(C.getElementsByTagName("chargeableRoomRateTaxesAndFees")[0].firstChild.nodeValue)}
if(l<c){var S=0-l/I;if(i.getElementsByTagName("promoDescription").length>0){var O=getValue(i.getElementsByTagName("promoDescription"));if(O!=""){V.appendFormat('<p style="background-color: #FFFFA9;padding: 3px 5px;line-height: 200%;">{0}</p>',O)}}}else{var S=l/I}}else{var l=parseFloat(i.getElementsByTagName("chargeableRoomRateTotal")[0].firstChild.nodeValue);if(currency!="gbp"){l-=parseFloat(i.getElementsByTagName("chargeableRoomRateTaxesAndFees")[0].firstChild.nodeValue)}
var S=l/I}var Z=Math.round(S),z=Math.abs(Z);var x=new StringBuilder;V.appendFormat("<div style='margin: 3px 0'><b>Rooms from {0}{1}/night.",currencysymbol,z);x.appendFormat("hotel.php?hotel={0}&id={1}&lat={2}&lng={3}&currency={4}",w.replace(/\s/g,"-"),r,E,e,currency);V.appendFormat('<br/><p style="background-color: #FFD9D9;padding: 3px 5px;line-height: 200%;"><b><a target="_blank" href="{0}">View details and book >></a></b></p><br/><p style="line-height: 150%;"><a href="#" onclick="showTripAdvisor({1}); return false;">TripAdvisor reviews</a></p></td></tr></table></div>',x.toString(),r);var X=createMarker("hotel",K,Z,V.toString());X.id=r;newhotelmarkers.push(X);allhotelmarkers.push(X)}
function createAddressMarker(O,l,o){var i=new GIcon;i.image="http://www.roomatlas.com/images/placeicon.png";i.iconAnchor=new GPoint(9,31);i.infoWindowAnchor=new GPoint(9,1);i.iconSize=new GSize(19,32);geocodemarker=new GMarker(new GLatLng(l,o),{icon:i,draggable:true});var I=new StringBuilder;I.append("<div class='geocodebubble'><h1>Quick-Link Placemark</h1><br /><p style='display: block;'>Drag to fine-tune position, or enter a new address in the search box (top-right).</p>");GEvent.addListener(geocodemarker,'click',function(){geocodemarker.openInfoWindowHtml(I.toString())});GEvent.addListener(geocodemarker,"dragstart",function(){geocodemarker.closeInfoWindow()});GEvent.addListener(geocodemarker,"dragend",function(){geocodemarker.openInfoWindowHtml(I.toString())});map.addOverlay(geocodemarker)}
function createMarker(C,v,I,V){var l=new GIcon;l.iconAnchor=new GPoint(19,37);l.infoWindowAnchor=new GPoint(19,10);l.iconSize=new GSize(38,37);l.imageMap=[4,31,4,21,1,21,18,3,36,21,33,21,33,31,4,31];var o=new StringBuilder;if(C=="hotel"){var O=Math.abs(I);l.image=getHotelIcon(I,"mouseout");if(O<10){var i=new GSize(-7,-23)}else if(O<100){var i=new GSize(-9,-23)}else{var i=new GSize(-12,-23)}
o.appendFormat("{0}{1}",currencysymbol,O)}else{if(I<10){var i=new GSize(-3,-23)}else if(I<100){var i=new GSize(-7,-23)}else if(I<10000){var i=new GSize(-9,-23)}else{var i=new GSize(-11,-23)}
if(I>=1000){o.appendFormat("{0}k+",Math.floor(I/1000))}else{o.appendFormat("{0}",I)}
l.image="images/hotelicon-1.png"}
opts={"icon":l,"clickable":true,"labelText":o.toString(),"labelOffset":i};var c=new LabeledMarker(v,opts);GEvent.addListener(c,'mouseover',function(){if(C=="hotel"){c.setImage(getHotelIcon(I,"mouseover"))}else{c.setImage("images/hotelicon-1-sel.png")}});GEvent.addListener(c,'mouseout',function(){if(C=="hotel"){c.setImage(getHotelIcon(I,"mouseout"))}else{c.setImage("images/hotelicon-1.png")}});GEvent.addListener(c,'click',function(){c.openInfoWindowHtml(V)});return c}
function geocode(){if(geocodelocation.length>=2){if(isNaN(geocodelocation.charAt(0))&&((!isNaN(geocodelocation.charAt(1))&&geocodelocation.charAt(1)!=" ")||(!isNaN(geocodelocation.charAt(2))&&geocodelocation.charAt(2)!=" "))){geocodelocation+=",United Kingdom"}}
document.getElementById('jumptobutton').disabled=true;var i="dbaccess/writeDBSearch.php?q="+geocodelocation;GDownloadUrl(i,doGeocode)}
function getZoomLevel(o){var I,l=[3,6,7,8,15,15,15,15,15,16],i=geocodelocation.toLowerCase();if(i=="singapore"||i=="goa"||i=="chicago"){I=12}else if(i=="hong kong"){I=13}else{I=l[o]||3}
return I}
function geocodeComplete(o){if(o.Status.code!=200){alert(o.name+" not found. Try being more specific (e.g. adding a city or country name).");document.getElementById("jumptobutton").disabled=false;return}
var I,l;if(forcegeocode){I=o.Placemark[0];l=getZoomLevel(I.AddressDetails.Accuracy);setMapAfterGeocode(I.address,I.Point.coordinates[1],I.Point.coordinates[0],l)}else{var O="<div style='float:right'><a href='#' onclick='document.getElementById(\"geocoderesults\").style.display=\"none\";document.getElementById(\"jumptobutton\").disabled = false;return false;'><img style='border: 0;' src='images/redcross.png'/></a></div><h1>Did you mean...</h1>";for(i=0;i<o.Placemark.length;i++){I=o.Placemark[i];l=getZoomLevel(I.AddressDetails.Accuracy);O+='<a onclick=\'setMapAfterGeocode("'+I.address+'",'+I.Point.coordinates[1]+','+I.Point.coordinates[0]+','+l+'); return false;\' href=\'#\'>'+I.address+'</a><br/>'}
O+="<span style='line-height: 2em;'>...or somewhere else? If so, try adding more detail to your search.</span>";document.getElementById('geocoderesults').innerHTML=O;document.getElementById('geocoderesults').style.display="block"}}
function setMapAfterGeocode(o,I,l,i){if(i<=MAXTOWNZOOM){map.setCenter(new GLatLng(I,l),i,G_PHYSICAL_MAP)}else{map.setCenter(new GLatLng(I,l),i,G_NORMAL_MAP)}
if(i>MAXTOWNZOOM){createAddressMarker(o,I,l);geocodemade=true;firstplot=true;centrelocations.push(new Array(I,l,i));if(!lockupdate){setupHotels()}}
document.getElementById('geocoderesults').style.display="none";document.getElementById("jumptobutton").disabled=false}
function somewhereNew(l,I,o){for(i=0;i<centrelocations.length;i++){if(o==centrelocations[i][2]){var O=Math.pow(Math.pow(centrelocations[i][0]-l,2)+Math.pow(centrelocations[i][1]-I,2),0.5);if(O<DRAG_SENSITIVITY){return false}}}
return true}
function doGeocode(I){if(typeof(geocodemarker)!='undefined'){map.removeOverlay(geocodemarker)}
var i=map.getBounds();geocoder.setViewport(i);geocoder.getLocations(geocodelocation,geocodeComplete)}
function resetMgr(){mgr.clearMarkers();allhotelmarkers=[];hotelnames=[];citynames=[];townnames=[];centrelocations=[];document.getElementById('morehotels').style.display="none"}
function getHotelIcon(I,l){var i=new StringBuilder;i.append("images/");if(I<0){i.append("hotelicon-special")}else if(I<=lowerprice){i.append("hotelicon-3")}else if(I<upperprice){i.append("hotelicon-2")}else{i.append("hotelicon-1")}
if(l=="mouseover"){i.append("-sel")}
i.append(".png");return i.toString()}
function zIndexProcess(i,I){return i.numhotels}
function showTripAdvisor(I){var o=document.getElementById('tripadvisoriframe');o.src="http://www.tripadvisor.com/WidgetEmbed-cdspropertysummary?locationId="+I+"&partnerId=A8FC6259FF384FA3B91A218C6E25F8F2&display=true";var l=document.getElementById('closebutton'),i=document.body.offsetWidth;if(i>1280){o.style.right=Math.round(9+(i-1280)*0.5)+"px";l.style.right=Math.round(16+(i-1280)*0.5)+"px"}else{o.style.right="5px";l.style.right="16px"}
o.style.display="block";l.style.display="block"}
function showLoadingMessage(i){if(i){lockupdate=true;map.disableDragging();map.disableDoubleClickZoom();map.disableContinuousZoom();map.disableScrollWheelZoom();document.getElementById('jumptobutton').disabled=true;document.getElementById("statusmessage").style.display="block"}else{lockupdate=false;map.enableDragging();map.enableDoubleClickZoom();map.enableContinuousZoom();map.enableScrollWheelZoom();document.getElementById('jumptobutton').disabled=false;document.getElementById("statusmessage").style.display="none"}}
function setTitleBar(I){if(I=='zoomedout'){var i="<b>Drag/zoom the map and click markers to view hotels</b>. Or, jump to a place using the search box above."}else if(I=='hotelinfo'){var i="<b>Drag/zoom the map to view more hotels</b>.  <img src='images/hotelicon-ss.png'/> Special rate <img src='images/hotelicon-s3.png'/> &lt;"+currencysymbol+lowerprice+"/night&nbsp;&nbsp;<img src='images/hotelicon-s2.png'/> "+currencysymbol+lowerprice+"-"+currencysymbol+upperprice+"/night&nbsp;&nbsp;<img src='images/hotelicon-s1.png'/> &gt;"+currencysymbol+upperprice+"+/night";if(currency=="gbp"){i+=" (including tax)"}}else if(I=='hotelavailability'){var i="<b>Click markers to view details and book your room.</b>  <img src='images/hotelicon-ss.png'/> Special rate <img src='images/hotelicon-s3.png'/> &lt;"+currencysymbol+lowerprice+"/night&nbsp;&nbsp;<img src='images/hotelicon-s2.png'/> "+currencysymbol+lowerprice+"-"+currencysymbol+upperprice+"/night&nbsp;&nbsp;<img src='images/hotelicon-s1.png'/> &gt;"+currencysymbol+upperprice+"+/night";if(currency=="gbp"){i+=" (including tax)"}}else{var i=I}
document.getElementById('statusbar_text').innerHTML=i}
function getRatingImg(l){var i=Math.round(2*l);var I=new StringBuilder;I.appendFormat("images/{0}star.png",i);return I.toString()}
function getValue(i){if(i[0].hasChildNodes())return i[0].firstChild.nodeValue;else
return ""}
function getNextTuesday(O){var o=new Date;var c=o.getDay();var i=new Date(o.getFullYear(),o.getMonth(),o.getDate()-0+30-c);if(i.getMonth()==11|(i.getMonth()==10&&i.getDate()==30)){i=new Date(i.getFullYear(),i.getMonth()+1,i.getDate());var l=i.getDay();if(l<2){i=new Date(i.getFullYear(),i.getMonth(),i.getDate()-0+3-l)}else if(l>2){i=new Date(i.getFullYear(),i.getMonth(),i.getDate()-0+10-l)}}
if(O=="end"){i=new Date(i.getFullYear(),i.getMonth(),i.getDate()-0+1)}
var I=(i.getMonth()-0+1)+"/"+i.getDate()+"/"+i.getFullYear();return I}
function getRadius(I,l){var C=3959,i=(l-I)*Math.PI/180,c=Math.sin(i/2)*Math.sin(i/2),O=2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),o=C*O*0.5;if(Math.floor(o)>1){return Math.ceil(o)+1}else{return 1}}
function mapSize(){document.getElementById('map_canvas').style.height=document.body.offsetHeight-document.getElementById('header').offsetHeight-document.getElementById('statusbar').offsetHeight-document.getElementById('footer').offsetHeight+"px";if(document.body.offsetWidth>1280){document.getElementById('tripadvisoriframe').style.right=0.5*(document.body.offsetWidth-1280)+8+"px";document.getElementById('geocoderesults').style.right=0.5*(document.body.offsetWidth-1280)+8+"px"}else{document.getElementById('tripadvisoriframe').style.right="8px";document.getElementById('geocoderesults').style.right="8px"}}
function updateWikipedia(i){if(i){map.addOverlay(wikilayer)}else{map.removeOverlay(wikilayer)}}
function sortNumber(i,I){return i-I}
if(!Array.prototype.contains){Array.prototype.contains=function(i){var o=this,I=o.length;for(var l=0;l<I;l++){if(o[l]==i){return true}}
return false}}
if(!Array.prototype.indexOf){Array.prototype.indexOf=function(i){var o=this,I=o.length;for(var l=0;l<I;l++){if(o[l]==i){return l}}
return false}}
var StringBuilder=Array;Array.prototype.append=Array.prototype.push;Array.prototype._convertToArray=function(i){if(!i)return [];if(i.toArray)return i.toArray();var l=i.length
var I=new Array(l);while(l--){I[l]=i[l]}
return I};Array.prototype.appendFormat=function(i){var l=this,I=l._convertToArray(arguments).slice(1);l[l.length]=i.replace(/\{(\d+)\}/g,function(l,i){return I[i].toString()})};Array.prototype.toString=function(){var c=this,I=c._parameters!=null;I=I&&c._parameters.length>0;if(I){var l=c.join("").split('?');var i=[];for(var O=0,o=l.length;O<o;O++){i[i.length]=l[O];i[i.length]=c._parameters[O]}
return i.join("")}else{return c.join("")}};String.prototype.toProperCase=function(){return this.toLowerCase().replace(/^(.)|\s(.)/g,function(i){return i.toUpperCase()})}
$_GET=new Array
_get_set=function(_data){if(_data.match(/(.+?[^=])=(.*)/i)){eval("$_GET['"+RegExp.$1+"'] = '"+RegExp.$2+"';")}}
_SearchIn=location.href.replace(location.href.split('?')[0]+'?','')
_Variables=_SearchIn.split('&')
if(_Variables.length<2){_get_set(_SearchIn)}else{for(_s=0;_s<_Variables.length;_s++){_get_set(_Variables[_s])}}