var version="707:2008-01-29";ralentango.gmaps={};ralentango.gmaps.buildmarker=function(a){var b=env("h2",a.header);if(a.detail)for(var m in a.detail)b+=env("p",a.detail[m]);if(a.website)b+=env("p",env("a","www."+a.website,{href:"http://www."+a.website,title:"The website for "+a.header,target:"_blank"}));if(a.email)b+=env("p",env("a",a.email,{href:"mailto:"+a.email,title:"Send an email to "+a.header}));return b};ralentango.gmaps.openupgmarker=function(a,b){ralentango.gmaps.maps[a].markers[b].gmarker.openInfoWindowHtml(ralentango.gmaps.maps[a].markers[b].xhtml)};ralentango.gmaps.mapattributes=[["id","string","required"],["north","float","required"],["east","float","required"],["width","integer","required"],["height","integer","required"],["sidebar","sidebar","optional"],["magnification","integer",14],["overviewscale","float",0.25],["icon","string","optional"],["iconwidth","integer",40],["iconheight","integer",64],["iconshadowwidth","integer",74],["iconshadowheight","integer",68],["iconanchorx","integer",20],["iconanchory","integer",64],["iconwinfox","integer",20],["iconwinfoy","integer",28]];ralentango.gmaps.markerattributes=[["north","float","required"],["east","float","required"],["icon","string","inherit"],["header","string","optional"],["description","string","optional"],["detail","splitstring","optional"],["website","string","optional"],["email","string","optional"]];$(document).ready(function(){if(!GBrowserIsCompatible()){alert("Your Browser is unable to render a Google map");return}var h,attrname,mapno,map,markerno,marker;if(ralentango.gmaps.markerextras){ralentango.gmaps.markerattributes=ralentango.gmaps.markerattributes.concat(ralentango.gmaps.markerextras())}window.onunload=GUnload;var k=$.ajax({url:ralentango.scriptsfromtop+"gmaps.xml",async:false}).responseXML;if(k){ralentango.gmaps.maps=[];$("map",k).each(function(i){ralentango.gmaps.maps[i]={markers:[]};for(h in ralentango.gmaps.mapattributes){attrname=ralentango.gmaps.mapattributes[h][0];ralentango.gmaps.maps[i][attrname]=this.getAttribute(attrname)}$("marker",this).each(function(j){ralentango.gmaps.maps[i].markers[j]={};for(h in ralentango.gmaps.markerattributes){attrname=ralentango.gmaps.markerattributes[h][0];ralentango.gmaps.maps[i].markers[j][attrname]=this.getAttribute(attrname)}})})}if(!ralentango.gmaps.maps){var l=$.ajax({url:ralentango.scriptsfromtop+"gmaps.json",async:false}).responseText;if(l){ralentango.gmaps.maps=eval("("+l+")");if(!ralentango.gmaps.maps)return alert("Something went wrong evaluating the JSON map data")}}if(!ralentango.gmaps.maps)return alert("Couldn't load a maps data file");for(mapno in ralentango.gmaps.maps){map=ralentango.gmaps.maps[mapno];check(map,ralentango.gmaps.mapattributes);for(markerno in map.markers){marker=map.markers[markerno];check(marker,ralentango.gmaps.markerattributes)}}$("div.gmap").each(function(){var a=false;for(mapno in ralentango.gmaps.maps){map=ralentango.gmaps.maps[mapno];if(map.id==this.id){a=true;break}}if(!a){console.log("No map data found for map "+this.id);return}var b=document.createElement("div");var c;if(map.sidebar){c=$(env("div",{"class":"gmapsidebar"}));if(typeof(map.sidebar)=="number")c.attr("style","float:"+(map.sidebar<0?"left":"right")+"; width:"+Math.abs(map.sidebar)+"px");if(map.sidebar!="bottom")$(this).append(c)}$(this).append(b);if(map.sidebar=="bottom")$(this).append(c);gmap=new GMap2(b,{size:new GSize(map.width,map.height)});gmap.setCenter(new GLatLng(map.north,map.east),map.magnification);gmap.addControl(new GSmallMapControl);gmap.addControl(new GMapTypeControl);var d=gmap.getSize();gmap.addControl(new GOverviewMapControl(new GSize(d.width*map.overviewscale,d.height*map.overviewscale)));gmap.enableContinuousZoom();gmap.enableDoubleClickZoom();var e;for(markerno in map.markers){marker=map.markers[markerno];ralentango.gmaps.buildmarker(marker);marker.xhtml=env("div",{"class":"gmapmarker"},ralentango.gmaps.buildmarker(marker));addmapmarker(mapno,markerno);if(c){e=env("a",{href:"javascript:ralentango.gmaps.openupgmarker("+mapno+","+markerno+")"},env("img",{src:"images/"+marker.icon}),env("h2",marker.header));if(marker.description)e+=env("h3",marker.description);if(marker.detail)for(var m in marker.detail)e+=env("p",marker.detail[m]);e+=env("p",marker.north+"N "+(marker.east>0?marker.east+"E":(-marker.east)+"W"));$(c).append(env("div",e))}}});function check(a,b){var c,attrprops,attrname,attrtarget,attrstatus,attrvalue,goodattr,errormsg;for(c in b){attrprops=b[c];attrname=attrprops[0];attrtarget=attrprops[1];attrstatus=attrprops[2];attrvalue=a[attrname];goodattr=true;if(!attrvalue){switch(attrstatus){case"required":goodattr=false;break;case"inherit":a[attrname]=map[attrname];break;case"optional":break;default:a[attrname]=attrstatus}}else{attrtype=typeof(attrvalue);attrtoattr=attrtype+"->"+attrtarget;switch(attrtoattr){case"string->string":case"number->float":break;case"string->float":wint=parseFloat(attrvalue);goodattr=!isNaN(wint);if(goodattr)a[attrname]=wint;break;case"number->sidebar":case"number->integer":a[attrname]=Math.round(attrvalue);break;case"string->sidebar":if((attrvalue=="bottom")||(attrvalue=="top"))break;case"string->integer":wint=parseInt(attrvalue,10);goodattr=!isNaN(wint);if(goodattr)a[attrname]=wint;break;case"object->splitstring":for(var d in attrvalue){goodattr=goodattr&&(typeof(attrvalue[d])=="string")}break;case"string->splitstring":a[attrname]=attrvalue.split("+");break;default:goodAttr(false)}}if(!goodattr)console.log(attrname+" attribute "+(attrvalue?"has the invalid value '"+attrvalue+"' ("+attrtoattr+")":"is missing")+" in map "+(mapno+1)+(map.id?" ("+map.id+")":""))}return}function addmapmarker(a,b){var c=ralentango.gmaps.maps[a];var d=c.markers[b];var e=new GLatLng(d.north,d.east);var f;if(d.icon){var g=new GIcon();g.image="images/"+d.icon;g.shadow="images/shadow50.png";g.iconSize=new GSize(c.iconwidth,c.iconheight);g.shadowSize=new GSize(c.iconshadowwidth,c.iconshadowheight);g.iconAnchor=new GPoint(c.iconanchorx,c.iconanchory);g.infoWindowAnchor=new GPoint(c.iconwinfox,c.iconwinfoy);f=new GMarker(e,g)}else{f=new GMarker(e)}gmap.addOverlay(f);GEvent.addListener(f,"click",function(){f.openInfoWindowHtml(d.xhtml)});ralentango.gmaps.maps[a].markers[b].gmarker=f}console.log("Initialised gmaps "+version);return true});
