var map;var cluster;var mouselat;var mouselng;var currentAcc=0;var accs=[];var features=[];var oldGLatLng;var savedMapType;var changingMap=false;function acc(a,b){this.marker=a;this.id=b;}function showCount(){var a=document.getElementById("holiday-counter");if(currentAcc<0){a.innerHTML=accs.length+" holidays";}else{a.innerHTML="Holiday "+(currentAcc+1)+" of "+accs.length;}}function showMoreInfo(a){var d=document.getElementById("more-info");var b="<a href='/holiday-details.aspx?aid="+a+"&start="+(holidayCriteria.StartDate!=null?holidayCriteria.StartDate.getDateString():today.getDateString())+(holidayCriteria.EndDate!=null?"&end="+holidayCriteria.EndDate.getDateString():"");for(var c=0;c<holidayCriteria.Duration.length;c++){b+="&duration="+holidayCriteria.Duration[c];}b+=(holidayCriteria.Campaign!=null?"&cid="+holidayCriteria.Campaign:"")+(holidayCriteria.MaxPrice!=null&&holidayCriteria.MaxPrice!=0?"&maxprice="+holidayCriteria.MaxPrice:"")+"' onclick='return hs.htmlExpand(this, { objectType: ";b+='"iframe", width: 900} )';b+="' title='View more details for this holiday'>Tell me more...</a>";d.innerHTML=b;}function drawMap(){if(GBrowserIsCompatible()){map=new GMap2(document.getElementById("map-canvas"));map.setMapType(G_PHYSICAL_MAP);map.addControl(new GSmallMapControl());map.addControl(new GMenuMapTypeControl());map.addMapType(G_PHYSICAL_MAP);map.enableDoubleClickZoom();map.enableScrollWheelZoom();map.enableContinuousZoom();map.setCenter(new GLatLng(54.737661,-4.169041),5);cluster=new ClusterMarker(map);GEvent.addListener(map,"mousemove",function(a){mouselat=a.y.toFixed(6);mouselng=a.x.toFixed(6);});GEvent.addListener(map,"infowindowbeforeclose",function(){map.panTo(oldGLatLng);});GEvent.addListener(map,"maptypechanged",function(){if(!changingMap){savedMapType=map.getCurrentMapType();}});GEvent.addListener(map,"zoomend",function(b,a){if(a>13){document.getElementById("map-disclaimer").style.visibility="visible";if(a>b&&a>13&&map.getCurrentMapType()==G_PHYSICAL_MAP){savedMapType=map.getCurrentMapType();changingMap=true;map.setMapType(G_HYBRID_MAP);changingMap=false;}}else{document.getElementById("map-disclaimer").style.visibility="hidden";if(a<b&&a<=13){map.setMapType(savedMapType);}}});if(document.getElementById("popout-key")){document.getElementById("popout-key").style.left="-285px";}}}function createMarker(f,e,d,a,b,g,h){var c=new GMarker(f,{icon:a,title:e+" - Click for details"});c.name=e;c.id=b;c.ids=h;c.accs=g;GEvent.addListener(c,"click",function(){GetHolidayInfoWithBubble(c.ids[0],holidayCriteria.Duration,holidayCriteria.StartDate,holidayCriteria.EndDate,holidayCriteria.Campaign,holidayCriteria.MaxPrice,true);currentAcc=c.accs[0];});return c;}function moveToMarker(a){var b=currentAcc;currentAcc=currentAcc+a;if(currentAcc>=accs.length){currentAcc=0;}if(currentAcc<0){currentAcc=accs.length-1;}if(accs[b].marker.ids==accs[currentAcc].marker.ids){GetHolidayInfo(accs[currentAcc].id,holidayCriteria.Duration,holidayCriteria.StartDate,holidayCriteria.EndDate,holidayCriteria.Campaign,holidayCriteria.MaxPrice,true);}else{GetHolidayInfoWithBubble(accs[currentAcc].id,holidayCriteria.Duration,holidayCriteria.StartDate,holidayCriteria.EndDate,holidayCriteria.Campaign,holidayCriteria.MaxPrice,true);}}function placeMarkers(o){var p=[];var G=[];accs=[];currentAcc=0;map.closeInfoWindow();var z=o.documentElement.getElementsByTagName("FeatureCount")[0].childNodes;var y=o.documentElement.getElementsByTagName("m");var k=[],l=0;while(y[l]){k.push(y[l++]);}k.sort(function(i,j){if(i.getAttribute("n")>j.getAttribute("n")){return 1;}else{if(j.getAttribute("n")>i.getAttribute("n")){return -1;}else{return 0;}}});var h=parseInt(o.documentElement.getAttribute("Count"));var B=new GLatLngBounds();var g=0;if(h>0){document.getElementById("total-count").innerHTML="We found "+(h==1?"1 holiday that might ":h+" holidays that may ")+"suit you. "+(h==1?"It's ":" They're ")+"over there on the map, just click to take a look.";}else{document.getElementById("total-count").innerHTML="Sorry. We didn't find anything suitable.";}if(holidayCriteria.StartDate==null||holidayCriteria.EndDate==null){document.getElementById("date-range").innerHTML="Please choose";}else{document.getElementById("date-range").innerHTML=holidayCriteria.StartDate.getDateString()+" and "+holidayCriteria.EndDate.getDateString();}updateFeatures(h,z);var v=0;var t="<h3>Cottages</h3><ul>";var F="<h3>Boats</h3><ul>";var D="<h3>Parks &amp; Lodges</h3><ul>";var f="<h3>Multiple Accommodation Types</h3><ul>";for(var l=0;l<k.length;l++){var C=k[l].getAttribute("l").split(",");var n=parseFloat(C[0]);var w=parseFloat(C[1]);if(!isNaN(n)&&!isNaN(w)){var E=new GLatLng(w,n);B.extend(E);var c=k[l].getAttribute("n");var b=[];var d=[];var a=k[l].getAttribute("t");for(var m=0;m<k[l].getElementsByTagName("i").length;m++){b.push(k[l].getElementsByTagName("i")[m].firstChild.nodeValue);d.push(v);v++;}var q="<li><a href='/holiday-details.aspx?aid=";q+=k[l].getElementsByTagName("i")[0].firstChild.nodeValue;q+="' onclick='return indexLinkWithBubble("+k[l].getElementsByTagName("i")[0].firstChild.nodeValue+", this)'>";q+=c;if(b.length>1){q+=" ("+b.length;}switch(a){case"c":t+=q+(b.length>1?" cottages)":"")+"</a></li>";break;case"b":F+=q+(b.length>1?" boats)":"")+"</a></li>";break;case"p":D+=q+(b.length>1?" holidays)":"")+"</a></li>";break;case"m":f+=q+(b.length>1?" holidays)":"")+"</a></li>";break;}var x=new GIcon();x.iconAnchor=new GPoint(11,11);x.infoWindowAnchor=new GPoint(11,11);switch(a){case"c":x.image="/images/cottage.png";x.iconSize=new GSize(22,23);x.shadow="/images/shadow-cottage.png";x.shadowSize=new GSize(34,23);break;case"b":x.image="/images/boat.png";x.iconSize=new GSize(27,22);x.shadow="/images/shadow-boat.png";x.shadowSize=new GSize(39,22);break;case"p":x.image="/images/park.png";x.iconSize=new GSize(26,20);x.shadow="/images/shadow-park.png";x.shadowSize=new GSize(37,20);break;case"m":x.image="/images/multi.png";x.iconSize=new GSize(33,32);x.shadow="/images/shadow-park.png";x.shadowSize=new GSize(50,32);break;}if(b.length>1){c+=" (Choice of "+(b.length)+")";}var A=createMarker(E,c,0,x,g,d,b);p.push(A);for(var m=0;m<b.length;m++){accs.push(new acc(A,b[m]));}g++;}}t+="</ul>";F+="</ul>";D+="</ul>";f+="</ul>";document.getElementById("index-container-text").innerHTML=t+F+D+f;cluster.removeMarkers();cluster.addMarkers(p);cluster.refresh();if(p.length>0){var r=map.getBoundsZoomLevel(B);var e=map.getZoom();if(r>11){r=11;}map.setZoom(r);var s=(B.getNorthEast().lat()+B.getSouthWest().lat())/2;var u=(B.getNorthEast().lng()+B.getSouthWest().lng())/2;map.panTo(new GLatLng(s,u));}if(document.getElementById("tab-accommodation").style.visibility!="visible"){if(accs.length>0){document.getElementById("flick").style.visibility="visible";}else{document.getElementById("flick").style.visibility="hidden";}}showCount();if(accs.length==1){GetHolidayInfoWithBubble(accs[0].id,holidayCriteria.Duration,holidayCriteria.StartDate,holidayCriteria.EndDate,holidayCriteria.Campaign,holidayCriteria.MaxPrice,true);}}function zoom(b,f){var h=map.fromLatLngToDivPixel(new GLatLng(mouselat,mouselng));var g=map.fromLatLngToDivPixel(map.getCenter());if(f=="in"){var d=g.x-((h.x-g.x)*-0.5);var e=g.y-((h.y-g.y)*-0.5);var i=map.fromDivPixelToLatLng(new GPoint(d,e));map.setCenter(i);map.zoomIn();}else{var d=g.x-(h.x-g.x);var e=g.y-(h.y-g.y);var i=map.fromDivPixelToLatLng(new GPoint(d,e));map.setCenter(i);map.zoomOut();}}function showBusy(){document.getElementById("map-busy").style.visibility="visible";}function showContents(){if(document.getElementById("map-busy").style.visibility=="visible"){document.getElementById("map-busy").style.visibility="hidden";if(accs.length>0){document.getElementById("no-matches").style.visibility="hidden";document.getElementById("map-container").style.visibility="visible";if(document.getElementById("tab-contents").style.visibility!="hidden"){document.getElementById("flick").style.visibility="visible";}}else{document.getElementById("map-container").style.visibility="hidden";document.getElementById("no-results-msg").innerHTML=noResultsMessage();document.getElementById("no-matches").style.visibility="visible";}}else{document.getElementById("tab-contents").style.visibility="visible";document.getElementById("tab-features").style.visibility="hidden";document.getElementById("tab-info").style.visibility="hidden";document.getElementById("tab-index").style.visibility="hidden";document.getElementById("tab-events").style.visibility="hidden";document.getElementById("contents-tab").style.marginLeft="1px";document.getElementById("features-tab").style.marginLeft="0px";document.getElementById("info-tab").style.marginLeft="0px";document.getElementById("index-tab").style.marginLeft="0px";document.getElementById("events-tab").style.marginLeft="0px";if(accs.length>0){document.getElementById("flick").style.visibility="visible";}else{document.getElementById("flick").style.visibility="hidden";}}document.getElementById("tab-accommodation").style.visibility="hidden";document.getElementById("calendar-container").style.display="none";document.getElementById("left-page-corner").style.visibility="hidden";document.getElementById("right-page-corner").style.visibility="hidden";}function showFeatures(){document.getElementById("tab-features").style.visibility="visible";document.getElementById("tab-info").style.visibility="hidden";document.getElementById("tab-index").style.visibility="hidden";document.getElementById("tab-events").style.visibility="hidden";document.getElementById("tab-accommodation").style.visibility="hidden";document.getElementById("calendar-container").style.display="none";document.getElementById("tab-contents").style.visibility="hidden";document.getElementById("left-page-corner").style.visibility="hidden";document.getElementById("right-page-corner").style.visibility="hidden";document.getElementById("contents-tab").style.marginLeft="0px";document.getElementById("features-tab").style.marginLeft="1px";document.getElementById("info-tab").style.marginLeft="0px";document.getElementById("index-tab").style.marginLeft="0px";document.getElementById("events-tab").style.marginLeft="0px";if(accs.length>0){document.getElementById("flick").style.visibility="visible";}}function showAccommodation(){document.getElementById("flick").style.visibility="hidden";document.getElementById("tab-contents").style.visibility="hidden";document.getElementById("tab-features").style.visibility="hidden";document.getElementById("tab-info").style.visibility="hidden";document.getElementById("tab-index").style.visibility="hidden";document.getElementById("tab-events").style.visibility="hidden";document.getElementById("tab-accommodation").style.visibility="visible";document.getElementById("left-page-corner").style.visibility="visible";document.getElementById("right-page-corner").style.visibility="visible";document.getElementById("contents-tab").style.marginLeft="0px";document.getElementById("features-tab").style.marginLeft="0px";document.getElementById("info-tab").style.marginLeft="0px";document.getElementById("index-tab").style.marginLeft="0px";document.getElementById("events-tab").style.marginLeft="0px";document.getElementById("calendar-container").style.display="block";}function showGeneralInfo(){document.getElementById("flick").style.visibility="hidden";document.getElementById("tab-contents").style.visibility="hidden";document.getElementById("tab-features").style.visibility="hidden";document.getElementById("tab-info").style.visibility="visible";document.getElementById("tab-index").style.visibility="hidden";document.getElementById("tab-events").style.visibility="hidden";document.getElementById("tab-accommodation").style.visibility="hidden";document.getElementById("left-page-corner").style.visibility="hidden";document.getElementById("right-page-corner").style.visibility="hidden";document.getElementById("contents-tab").style.marginLeft="0px";document.getElementById("features-tab").style.marginLeft="0px";document.getElementById("info-tab").style.marginLeft="1px";document.getElementById("index-tab").style.marginLeft="0px";document.getElementById("calendar-container").style.display="none";document.getElementById("events-tab").style.marginLeft="0px";if(accs.length>0){document.getElementById("flick").style.visibility="visible";}}function showEvents(){document.getElementById("flick").style.visibility="hidden";document.getElementById("tab-contents").style.visibility="hidden";document.getElementById("tab-features").style.visibility="hidden";document.getElementById("tab-info").style.visibility="hidden";document.getElementById("tab-index").style.visibility="hidden";document.getElementById("tab-events").style.visibility="visible";document.getElementById("tab-accommodation").style.visibility="hidden";document.getElementById("left-page-corner").style.visibility="hidden";document.getElementById("right-page-corner").style.visibility="hidden";document.getElementById("contents-tab").style.marginLeft="0px";document.getElementById("features-tab").style.marginLeft="0px";document.getElementById("info-tab").style.marginLeft="0px";document.getElementById("index-tab").style.marginLeft="0px";document.getElementById("events-tab").style.marginLeft="1px";document.getElementById("calendar-container").style.display="none";if(accs.length>0){document.getElementById("flick").style.visibility="visible";}}function showIndex(){document.getElementById("flick").style.visibility="hidden";document.getElementById("tab-contents").style.visibility="hidden";document.getElementById("tab-features").style.visibility="hidden";document.getElementById("tab-info").style.visibility="hidden";document.getElementById("tab-index").style.visibility="visible";document.getElementById("tab-events").style.visibility="hidden";document.getElementById("tab-accommodation").style.visibility="hidden";document.getElementById("left-page-corner").style.visibility="hidden";document.getElementById("right-page-corner").style.visibility="hidden";document.getElementById("contents-tab").style.marginLeft="0px";document.getElementById("features-tab").style.marginLeft="0px";document.getElementById("info-tab").style.marginLeft="0px";document.getElementById("index-tab").style.marginLeft="1px";document.getElementById("events-tab").style.marginLeft="0px";document.getElementById("calendar-container").style.display="none";if(accs.length>0){document.getElementById("flick").style.visibility="visible";}}function Feature(c,b,a){this.id=c;this.desc=b;this.value=0;this.count=a;this.onimg=new Image();this.onimg.src="/images/empty.gif";this.offimg=new Image();this.offimg.src="/images/empty.gif";}function buildFeaturesArray(){features=[];features.push(new Feature("beach","with beach nearby",0));features.push(new Feature("baby","with babysitting",0));features.push(new Feature("access","wheelchair accessible",0));features.push(new Feature("entertain","with entertainment",0));features.push(new Feature("pets","allow pets",0));features.push(new Feature("satellite","with satellite TV",0));features.push(new Feature("tv","with TV",0));features.push(new Feature("golf","with golf facilities",0));features.push(new Feature("shop","with a shop",0));features.push(new Feature("gym","with gym facilities",0));features.push(new Feature("pool","with a pool",0));features.push(new Feature("nosmoke","non smoking",0));}function drawFeaturesTable(){buildFeaturesArray();var a='<table id="features">';a+="<tr><th><span id='feature-total'>0</span>&nbsp;Holidays</th><td class='yes'>Must have</td><td class='no'>Can't have</td></tr>";for(var b=0;b<features.length;b++){a+="<tr>";a+='<td class="desc" id="'+features[b].id+'">'+features[b].desc+"</td>";a+='<td><a id="on-'+features[b].id+'" href="javascript: switchFeature('+b+', true)">&nbsp;</a></td>';a+='<td><a id="off-'+features[b].id+'" href="javascript: switchFeature('+b+', false)">&nbsp;</a></td>';a+="</tr>";}a+="</table>";document.writeln(a);for(var b=0;b<features.length;b++){document.getElementById("on-"+features[b].id).appendChild(features[b].onimg);document.getElementById("off-"+features[b].id).appendChild(features[b].offimg);}}function toggleFeature(b,a){if(a){if(features[b].value==1){features[b].onimg.src="/images/empty.gif";features[b].value=0;}else{features[b].onimg.src="/images/on.gif";features[b].offimg.src="/images/empty.gif";features[b].value=1;}}else{if(features[b].value==2){features[b].offimg.src="/images/empty.gif";features[b].value=0;}else{features[b].offimg.src="/images/off.gif";features[b].onimg.src="/images/empty.gif";features[b].value=2;}}}function switchFeature(b,a){toggleFeature(b,a);GetXmlDocument();}function switchFeatures(e,b){for(var c=0;c<features.length;c++){for(var d=0;d<e.length;d++){if(features[c].id==e[d]){toggleFeature(c,true);break;}}for(var a=0;a<b.length;a++){if(features[c].id==b[a]){toggleFeature(c,false);break;}}}}function changeCottages(a){holidayCriteria.Cottages=a.checked;GetXmlDocument();}function changeBoats(a){holidayCriteria.Boats=a.checked;GetXmlDocument();}function changeParks(a){holidayCriteria.Parks=a.checked;GetXmlDocument();}function changeDuration(a){if(a.value!="0"){if(a.options[0].value=="0"){a.remove(0);}holidayCriteria.Duration.length=1;holidayCriteria.Duration[0]=parseInt(a.value);GetXmlDocument();}}function changePeople(a){if(a.value!="0"){if(a.options[0].value=="0"){a.remove(0);}holidayCriteria.People=a.value;GetXmlDocument();}}function changeMaxPrice(a){holidayCriteria.MaxPrice=a.value;GetXmlDocument();}function UpdateDates(){if(validate()){document.forms[0].elements.DatesSelected.value="true";holidayCriteria.StartDate=calStart_Object.picked.date;holidayCriteria.EndDate=calEnd_Object.picked.date;document.getElementById("date-range").innerHTML=holidayCriteria.StartDate.getDateString()+" and "+holidayCriteria.EndDate.getDateString();hs.close();GetXmlDocument();}}function updateFeatures(a,b){document.getElementById("feature-total").innerHTML=a;for(var d=0;d<features.length;d++){for(var c=0;c<b.length;c++){if(b[c].nodeName==features[d].id){features[d].count=b[c].firstChild.nodeValue;break;}}if(c==b.length){features[d].count=0;}document.getElementById(features[d].id).innerHTML="<span class='feature-count'>"+features[d].count+"</span> "+features[d].desc;}}Number.prototype.round=function(b){var a=Math.round(this*Math.pow(10,b))/Math.pow(10,b);return a;};function setCurrentIndex(b){for(var a=0;a<accs.length;a++){if(b==accs[a].id){currentAcc=a;a=accs.length;break;}}}function indexLinkWithBubble(a,b){setCurrentIndex(a);GetHolidayInfoWithBubble(a,holidayCriteria.Duration,holidayCriteria.StartDate,holidayCriteria.EndDate,holidayCriteria.Campaign,holidayCriteria.MaxPrice,true);return false;}function indexLink(a,b){setCurrentIndex(a);GetHolidayInfo(a,holidayCriteria.Duration,holidayCriteria.StartDate,holidayCriteria.EndDate,holidayCriteria.Campaign,holidayCriteria.MaxPrice,true);}
