ralentango.gmaps={};ralentango.gmaps.version="802:2009-01-07";ralentango.gmaps.mapinit=function(map){return};ralentango.gmaps.markerfilter=function(map,marker){return true};ralentango.gmaps.buildmarker=function(marker){var h2style={style:"margin:0 0 12px 0; font:1em/150% Arial; font-weight:bold"};var pstyle={style:"margin:0 0 12px 0; font:0.9em/150% Arial"};var res=env("h2",marker.header,h2style);if(marker.detail){var res2="";$.each(marker.detail,function(i,detail){if(i>0)res+=env("br","");res+=detail});res+=env("p",res2,pstyle)}if(marker.website)res+=env("p",env("a","www."+marker.website,{href:"http://www."+marker.website,title:"The website for "+marker.header,target:"_blank"}),pstyle);if(marker.email)res+=env("p",env("a",marker.email,{href:"mailto:"+marker.email,title:"Send an email to "+marker.header}),pstyle);return res};ralentango.gmaps.openupgmarker=function(mapno,markerno){ralentango.gmaps.maps[mapno].markers[markerno].gmarker.openInfoWindowHtml(ralentango.gmaps.maps[mapno].markers[markerno].xhtml)};ralentango.gmaps.moveend=function(){return};ralentango.gmaps.mapattributes=[["id","string","required"],["north","float","required"],["east","float","required"],["width","integer","required"],["height","integer","required"],["sidebar","sidebar","optional"],["mapcontrol","string","small"],["maptypecontrol","string","standard"],["continuouszoom","boolean",true],["doubleclickzoom","boolean",true],["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"],["zindex","integer",0],["safe","boolean",false],["auto","boolean",false],["email","string","optional"]];$(document).ready(function(){if(!GBrowserIsCompatible()){alert("Your Browser is unable to render a Google map");return}var attr,attrname,mapno,map,markerno,marker;if(ralentango.gmaps.markerextras){ralentango.gmaps.markerattributes=ralentango.gmaps.markerattributes.concat(ralentango.gmaps.markerextras())}window.onunload=GUnload;var xmldata=$.ajax({url:ralentango.scriptsfromtop+"gmaps.xml",async:false}).responseXML;if(xmldata){ralentango.gmaps.maps=[];$("map",xmldata).each(function(i){ralentango.gmaps.maps[i]={markers:[]};for(attr in ralentango.gmaps.mapattributes){attrname=ralentango.gmaps.mapattributes[attr][0];ralentango.gmaps.maps[i][attrname]=this.getAttribute(attrname)}$("marker",this).each(function(j){ralentango.gmaps.maps[i].markers[j]={};for(attr in ralentango.gmaps.markerattributes){attrname=ralentango.gmaps.markerattributes[attr][0];ralentango.gmaps.maps[i].markers[j][attrname]=this.getAttribute(attrname)}})})}if(!ralentango.gmaps.maps){var json=$.ajax({url:ralentango.scriptsfromtop+"gmaps.json",async:false}).responseText;if(json){ralentango.gmaps.maps=eval("("+json+")");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 found=false;for(mapno in ralentango.gmaps.maps){map=ralentango.gmaps.maps[mapno];found=((map.id==this.id)||($(this).hasClass(map.id)));if(found)break}if(!found){console.log("No map data found for map "+this.id);return}map.gmapdiv=this;var mapdiv=document.createElement("div");var sidebar;if(map.sidebar){sidebar=$(env("div",{"class":"gmapsidebar"}));if(typeof(map.sidebar)=="number")sidebar.attr("style","float:"+(map.sidebar<0?"left":"right")+"; width:"+Math.abs(map.sidebar)+"px");if(map.sidebar!="bottom")$(this).append(sidebar)}$(this).append(mapdiv);if(map.sidebar=="bottom")$(this).append(sidebar);ralentango.gmaps.mapinit(map);gmap=new GMap2(mapdiv,{size:new GSize(map.width,map.height)});gmap.setCenter(new GLatLng(map.north,map.east),map.magnification);GEvent.addListener(gmap,"moveend",ralentango.gmaps.moveend);switch(map.mapcontrol){case"small":gmap.addControl(new GSmallMapControl);break;case"large":gmap.addControl(new GLargeMapControl);break;default:}switch(map.maptypecontrol){case"standard":gmap.addControl(new GMapTypeControl);break;case"hierarchical":gmap.addControl(new GHierarchicalMapTypeControl);break;default:}if(map.overviewscale){var mapsize=gmap.getSize();gmap.addControl(new GOverviewMapControl(new GSize(mapsize.width*map.overviewscale,mapsize.height*map.overviewscale)))}if(map.continuouszoom)gmap.enableContinuousZoom();if(map.doubleclickzoom)gmap.enableDoubleClickZoom();var res;for(markerno in map.markers){marker=map.markers[markerno];if(ralentango.gmaps.markerfilter(map,marker)){marker.xhtml=ralentango.gmaps.buildmarker(marker);addmapmarker(mapno,markerno);if(sidebar){res=env("a",{href:"javascript:ralentango.gmaps.openupgmarker("+mapno+","+markerno+")"},env("img",{src:"images/"+marker.icon}),env("h2",marker.header));if(marker.description)res+=env("h3",marker.description);if(marker.detail)for(var m in marker.detail)res+=env("p",marker.detail[m]);res+=env("p",marker.north+"N "+(marker.east>0?marker.east+"E":(-marker.east)+"W"));$(sidebar).append(env("div",res))}}}});function check(object,attributearray){var attrp,attrprops,attrname,attrtarget,attrstatus,attrvalue,goodattr,errormsg;for(attrp in attributearray){attrprops=attributearray[attrp];attrname=attrprops[0];attrtarget=attrprops[1];attrstatus=attrprops[2];attrvalue=object[attrname];goodattr=true;if(!attrvalue){switch(attrstatus){case"required":goodattr=false;break;case"inherit":object[attrname]=map[attrname];break;case"optional":break;default:object[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)object[attrname]=wint;break;case"number->sidebar":case"number->integer":object[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)object[attrname]=wint;break;case"object->splitstring":for(var detail in attrvalue){goodattr=goodattr&&(typeof(attrvalue[detail])=="string")}break;case"string->splitstring":object[attrname]=attrvalue.split("+");break;case"string->boolean":goodattr=(attrvalue=="true")||(attrvalue=="false");if(goodattr)object[attrname]=(attrvalue=="true");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(mapno,markerno){var map=ralentango.gmaps.maps[mapno];var marker=map.markers[markerno];var point=new GLatLng(marker.north,marker.east);var gmarkeroptions={zIndexProcess:zOrder};if(marker.header)gmarkeroptions.title=marker.header;if(marker.icon){var icon=new GIcon();icon.image="images/"+marker.icon;icon.shadow="images/shadow50.png";icon.iconSize=new GSize(map.iconwidth,map.iconheight);icon.shadowSize=new GSize(map.iconshadowwidth,map.iconshadowheight);icon.iconAnchor=new GPoint(map.iconanchorx,map.iconanchory);icon.infoWindowAnchor=new GPoint(map.iconwinfox,map.iconwinfoy);gmarkeroptions.icon=icon}var gmarker=new GMarker(point,gmarkeroptions);gmarker.zindex=marker.zindex;gmap.addOverlay(gmarker);GEvent.addListener(gmarker,"click",function(){gmarker.openInfoWindowHtml(marker.xhtml)});ralentango.gmaps.maps[mapno].markers[markerno].gmarker=gmarker}function zOrder(marker,b){var order=marker.zindex*1000000;order+=GOverlay.getZIndex(marker.getPoint().lat());return order}console.log("Initialised gmaps "+ralentango.gmaps.version);return true});