﻿//###############################################################//
//##@Author: Christopher McKee <pcdevils@gmail.com> #############//
//##@Script: Mapi - Google XML hotspot/list highlight renderer ##//
//##@MIT Licence 2008/9 #########################################//
//###############################################################//
//v1.6.5 - Compressed
//var xmlHotspotFile = "cornwall_hotspots.xml";
var hotspotLocation = "/sites/cottages4you/pages/destinations/images/green16.gif"; //was greenb gif
var hotspotTransparent = "/sites/cottages4you/pages/destinations/images/tranpix.gif";
var hotspotPrint = "/sites/cottages4you/pages/destinations/images/green.gif"; //was green.gif
var searchLocation = "/sites/cottages4you/pages/";
var defaultRadius = 10; //miles
var highlightColour = "#00ff00";

var debug = 0;

var highlightCircle,highlightList,currentMarker,map,bounds;
function highlightCurrentMarker(f,e){var k=f.getPoint();f=[];if(highlightCircle){map.removeOverlay(highlightCircle);document.getElementById(highlightList).className=""}var n=G_NORMAL_MAP.getProjection(),o=map.getZoom();k=n.fromLatLngToPixel(k,o);for(var a=0;a<21;a++){var b=18*a*(Math.PI/180),c=k.x+10*Math.cos(b)+0;b=k.y+10*Math.sin(b)-0;c=new GPoint(c,b);c=n.fromPixelToLatLng(c,o);f.push(c)}highlightCircle=new GPolygon(f,"#000000",2,0,highlightColour,0.5);map.addOverlay(highlightCircle);highlightList=
e.replace("_","-");document.getElementById(highlightList).className="highlighttxt"}
function load(){if(GBrowserIsCompatible()){map=new GMap2(document.getElementById("map"));map.setCenter(new GLatLng(0,0),0);bounds=new GLatLngBounds;var f=map.getDefaultUI();f.maptypes.hybrid=false;f.maptypes.satellite=false;f.zoom.scrollwheel=false;f.controls.smallzoomcontrol3d=false;map.setUI(f);map.removeControl(GSmallMapControl());var e=new GIcon(G_DEFAULT_ICON);e.image=hotspotLocation;e.iconSize=new GSize(16,16);e.iconAnchor=new GPoint(8,8);e.infoWindowAnchor=new GPoint(0,16);e.shadow=hotspotTransparent;
e.transparent=hotspotTransparent;e.printImage=hotspotPrint;e.printShadow=hotspotPrint;function k(a,b,c,i,g,m,d,j){try{if(j<1||j=="")j=defaultRadius;a={title:c,icon:e};var q=new GLatLng(g,i),l=new GMarker(q,a);GEvent.addListener(l,"click",function(){var h=this;h.id=c.replace(" ","_");highlightCurrentMarker(h,h.id);h=new GInfoWindowTab("Location","<p><strong>"+c+"</strong><br><a href='"+searchLocation+"search.aspx?func=longlat&lat="+g+"&lng="+i+"&country="+d+"&txt="+c+"&rad="+j+"&sleeps=n'>Click to Search</a></p>");
l.openInfoWindowTabsHtml([h])});var p=document.getElementById("sidebar");if(l.length==0){p.innerHTML="No results found.";map.setCenter(new GLatLng(0,0),4)}else{var r=n(c,l,i,g,d,j);p.appendChild(r);GEvent.addListener(l,"mouseover",function(){var h=this;h.id=c.replace(" ","_");highlightCurrentMarker(h,h.id)});return l}}catch(s){alert("Error in maps: "+s)}}function n(a,b,c,i,g,m){try{var d=document.createElement("li");d.innerHTML=""+a;d.style.cursor="pointer";d.style.marginBottom="5px";d.id=a.replace(" ",
"-");GEvent.addDomListener(d,"click",function(){debug==1&&alert(searchLocation+"search.aspx?func=longlat&lat="+i+"&lng="+c+"&country="+g+"&txt="+a+"&rad="+m);if(debug!=1)window.location.href=searchLocation+"search.aspx?func=longlat&lat="+i+"&lng="+c+"&country="+g+"&txt="+a+"&rad="+m+"&sleeps=n"});GEvent.addDomListener(d,"mouseover",function(){GEvent.trigger(b,"mouseover")});return d}catch(j){alert("Error in maps: "+j)}}try{GDownloadUrl(xmlHotspotFile,function(a){a=GXml.parse(a);var b=a.getElementsByTagName("markers");
if(b.length>0)var c=b[0].getAttribute("id"),i=b[0].getAttribute("country"),j=b[0].getAttribute("zoom").valueOf();a=a.documentElement.getElementsByTagName("marker");for(b=0;b<a.length;b++){var g=new GLatLng(parseFloat(a[b].getAttribute("lat")),parseFloat(a[b].getAttribute("lng"))),m=a[b].getAttribute("location"),d=a[b].getAttribute("rad");map.addOverlay(k(g,b,m.toString(),a[b].getAttribute("lng"),a[b].getAttribute("lat"),c.toString(),i,d));bounds.extend(g)}map.setCenter(bounds.getCenter(),parseFloat(j))})}catch(o){alert("Error in maps: "+o)}}};
