if(!GBrowserIsCompatible()){throw new Error("Could not load 'MashupMap'; Request is not GBrowser compatible.")}if(typeof dojo=="undefined"){throw new Error("MapMashup is dependent on the Dojo toolkit.  It must be loaded before mapmashup.js")}if(!djConfig){djConfig={}}djConfig.usePlainJson=true;dojo.declare("MashupMap",null,{constructor:function(D,A,B){this._id=D;this._map=new GMap2($(A));this._geocoder=new GClientGeocoder();this._markers=[];this._cmenu=null;this._rgeocoder=null;try{this._rgeocoder=new GReverseGeocoder(this._map)}catch(C){}this._defaulticon=B.defaulticon?B.defaulticon:{};this._zoomlevel=0;if(B.zoomlevel&&!isNaN(B.zoomlevel)&&(B.zoomlevel>0&&B.zoomlevel<=19)){this._zoomlevel=B.zoomlevel}if(B.onclick&&typeof B.onclick=="function"){GEvent.addListener(this._map,"click",function(F,E){if(!F&&E){B.onclick.call(this,E)}})}if(B.ondblclick&&typeof B.ondblclick=="function"){GEvent.addListener(this._map,"dblclick",function(F,E){if(!F&&E){B.ondblclick.call(this,E)}})}this._onaddmarker=null;if(B.onaddmarker&&typeof B.onaddmarker=="function"){this._onaddmarker=B.onaddmarker}if(B.showzoom){this._map.addControl(new GLargeMapControl())}if(B.showsmallzoom){this._map.addControl(new GSmallMapControl())}if(B.showtype){this._map.addControl(new GMapTypeControl())}if(B.showoverview){this._map.addControl(new GOverviewMapControl())}this.reset()},load:function(B,A,D){this.reset();if(!D){D={}}ondataload=D.ondataload;oncomplete=D.oncomplete;var C=this;if(dojo.string.startsWith(B,"http")){dfd=dojo.io.script.get({url:B,checkString:"MashupMap.json"}).addCallback(function(){data=MashupMap.json;if(!data){return }if(ondataload&&typeof ondataload=="function"){ondataload.call(this,data);return }if(!data.markers){return }C.loadMarkersFromData(data.markers,A);if(oncomplete&&typeof oncomplete=="function"){oncomplete.call(this,C)}})}else{dojo.xhrGet({url:B,handleAs:"json",load:function(E){if(!E){return }if(ondataload&&typeof ondataload=="function"){ondataload.call(this,E);return }if(!E.markers){return }C.loadMarkersFromData(E.markers,A);if(oncomplete&&typeof oncomplete=="function"){oncomplete.call(this,C)}},error:function(E){alert("Markers could not be loaded from remote source. Err: "+E)}})}},loadMarkersFromData:function(B,A){that=this;if(!A){A={}}A.icon=this._defaulticon?this._defaulticon:{};dojo.forEach(B,function(C){if(C.icon){A.icon.image=C.icon}_m=new Marker(C.id,C.lat,C.lng,A);_m.setCommitted();that.addMarker(_m)})},getGMap:function(){return this._map},getId:function(){return this._id},getContextMenu:function(){if(!this._cmenu){this._cmenu=new ContextMenu(this._map)}return this._cmenu},getGeocode:function(A,B){if(!B||typeof B!="function"){return }this._geocoder.getLocations(A,function(D){var C;if(D&&D.Status.code==200){C=new PlaceMark(D.Placemark[0])}B.call(this,C)})},getReverseGeocode:function(B,A,C){if(!C||typeof C!="function"){return }if(!this._rgeocoder){C.call(this,null);return }ret=false;GEvent.addListener(this._rgeocoder,"load",function(D){if(!ret){C.call(this,new PlaceMark(D));ret=true}});GEvent.addListener(this._rgeocoder,"error",function(){if(!ret){C.call(this);ret=true}});this._rgeocoder.reverseGeocode(new GLatLng(B,A))},addMarker:function(B,A){if(A!=null&&typeof A!="undefined"&&A){this.reset()}if(!B.getIcon()&&this._defaulticon){B.changeIcon(this._defaulticon)}this._markers.push(B);B.setMap(this);this._map.addOverlay(B.getGMarker());if(this._onaddmarker){this._onaddmarker.call(this,B)}return true},getMarker:function(A){result=dojo.filter(this._markers,function(B){return B.getId()==A});return result.length>0?result[0]:null},getMarkerByGeoData:function(C,A){for(var B=0;B<this._markers.length;B++){m=this._markers[B];if(m.lat()==C&&m.lng()==A){return m}}return null},removeMarker:function(C){var B,A;for(B=0;B<this._markers.length;B++){A=this._markers[B];if(A.getId()==C){break}}if(A){this._map.removeOverlay(A.getGMarker());this._markers.splice(B,1)}},getMarkers:function(){return this._markers},clear:function(){this._map.clearOverlays()},reset:function(){this.clear();this._markers=[];this._map.setCenter(new GLatLng(0,0),0)},refresh:function(){bounds=new GLatLngBounds();dojo.forEach(this._markers,function(A){A.closeInfoWindow();bounds.extend(A.getGMarker().getLatLng())});this._map.setZoom((this._zoomlevel>0)?this._zoomlevel:this._map.getBoundsZoomLevel(bounds));this._map.setCenter(bounds.getCenter())}});MashupMap.jsonCallback=function(A){MashupMap.json=dojo.fromJson(A)};dojo.declare("Marker",null,{constructor:function(D,C,B,A){this._id=D;this._gopts={clickable:true};this._dragcallback=null;this._clickcallback=null;this._remoteinfouri=null;this._infohtml="";this._actions=[];this._map;this._committed=false;this._parseOptions(A);this._init(C,B)},_init:function(B,A){this._marker=new GMarker(new GLatLng(B,A),this._gopts);if(this._dragcallback){cbk=this._dragcallback;GEvent.addListener(this._marker,"dragend",GEvent.callbackArgs(this._marker,function(C,D){C.closeInfoWindow();D.call(this,C)},this,cbk))}if(this._clickcallback){cbk=this._clickcallback;GEvent.addListener(this._marker,"click",GEvent.callbackArgs(this._marker,function(C,D){D.call(this,C)},this,cbk))}},_parseOptions:function(A){if(!A){return }if(A.icon){this._gopts.icon=this._createIcon(A.icon)}if(A.ondragend&&typeof A.ondragend=="function"){this._gopts.draggable=true;this._dragcallback=A.ondragend}if(A.onclick&&typeof A.onclick=="function"){this._clickcallback=A.onclick}},_createIcon:function(A){icon=new GIcon(G_DEFAULT_ICON);if(A.image){icon.image=A.image;iconSize=A.size?A.size:[32,32];icon.iconSize=new GSize(iconSize[0],iconSize[1]);if(A.shadow&&!dojo.string.blank(A.shadow)){icon.shadow=A.shadow}else{if((A.autoshadow&&typeof A.autoshadow=="boolean")){if(dojo.string.startsWith(A.image,"http://maps.google.com/mapfiles/ms/micons")){if(/\w+-dot.png$/.test(A.image)){icon.shadow=A.image.substr(0,A.image.lastIndexOf("/")+1)+"msmarker.shadow.png"}else{if(/\w+-pushpin.png$/.test(A.image)){icon.shadow=A.image.substr(0,A.image.lastIndexOf("/")+1)+"pushpin_shadow.png"}else{icon.shadow=A.image.substr(0,A.image.lastIndexOf("."))+".shadow.png"}}}else{A.image.substr(0,A.image.lastIndexOf("."))+".shadow.png"}}}shadowSize=A.shadowsize?A.shadowsize:[59,32];icon.shadowSize=new GSize(shadowSize[0],shadowSize[1])}return icon},_getActionInfo:function(){html="<div style='margin: auto; padding: 5px 0;'>";for(var A=0;A<this._actions.length;A++){html+=this._actions[A];if(A<this._actions.length-1){html+=" - "}}html+="</div>";return html},isCommitted:function(){return this._committed},setCommitted:function(){this._committed=true},getMap:function(){return this._map},setMap:function(A){this._map=A},getIcon:function(){return this._gopts.icon},getId:function(){return this._id},getGMarker:function(){return this._marker},changeIcon:function(A){this._gopts.icon=this._createIcon(A);glatlng=this._marker.getLatLng();this._init(glatlng.lat(),glatlng.lng())},openRemoteInfoWindow:function(A){if(!dojo.string.blank(A)){that=this;dojo.xhrGet({url:A,load:function(B){that.openInfoWindow(B)}})}},openInfoWindow:function(A){if(dojo.isString(A)&&!dojo.string.blank(A)){this._infohtml=A}else{if(dojo.string.blank(this._infohtml)){return }}this._marker.openInfoWindow(this._infohtml+"<div style='clear: both' />"+this._getActionInfo())},openInfoWindowWithActionContent:function(A){if(this._actions.length==0||dojo.string.blank(this._infohtml)){return }addhtml="<div style='padding-top: 5px'>"+A+"</div>";addhtml+="<div style='padding-top: 3px; font-size: 11px;'><a style='color: #666699;' href='javascript:void(0)' onclick=\"window['"+this._map.getId()+"'].getMarker("+this._id+').openInfoWindow()">&lt;&lt Back</a></p>';this._marker.openInfoWindow(this._infohtml+"<div style='clear: both' />"+addhtml)},addInfoWindowAction:function(A,B){if(!dojo.isString(B)){alert("Action arguments of incorrect type");return }alink="<a href='javascript:void(0)' onclick=\""+B+"("+this._id+",window['"+this._map.getId()+"'].getMarker("+this._id+'))">'+A+"</a>";this._actions.push(alink)},getInfo:function(){return this._infohtml},enableDirections:function(){this.addInfoWindowAction("Get Directions","Marker.directionsActionClick")},closeInfoWindow:function(){this._marker.closeInfoWindow()},lat:function(){return this._marker.getLatLng().lat()},lng:function(){return this._marker.getLatLng().lng()}});Marker.directionsActionClick=function(B,A){Marker.renderDirections(A,"to")};Marker.renderDirections=function(A,B){html="<div id=addressText><br><strong>Get Directions:</strong> ";if(B=="to"){html+="To here - <a href=\"javascript:Marker.renderDirections(window['"+A.getMap().getId()+"'].getMarker("+A.getId()+'),\'from\')">From here</a><br><span style="color: gray; font-size: 85%">Start address:</span><form action="http://maps.google.com/maps" method="get" target="_blank"><input type="text" style="width: 13.45em" name="saddr" id="saddr" value="" /> <INPUT value="Go" TYPE="SUBMIT"><input type="hidden" id="daddr" name="daddr" value="'+A.lat()+","+A.lng()+'"/></form></div>'}else{html+="<a href=\"javascript:Marker.renderDirections(window['"+A.getMap().getId()+"'].getMarker("+A.getId()+'),\'to\')">To here</a> - From here<br><span style="color: gray; font-size: 85%">End address:</span><form action="http://maps.google.com/maps" method="get" target="_blank"><input type="text" style="width: 13.45em" name="daddr" id="daddr" value="" /> <INPUT value="Go" TYPE="SUBMIT"><input type="hidden" id="saddr" name="saddr" value="'+A.lat()+","+A.lng()+'"/></form></div>'}A.openInfoWindowWithActionContent(html)};dojo.declare("PlaceMark",null,{constructor:function(A){this._place=A;this._addressdata=A.AddressDetails;this._point=A.Point},getFullAddress:function(){return this._place.address},getStreetAddress:function(){var A=this.getCity();if(!A){A=this.getLocality()}if(A&&A.Thoroughfare){return A.Thoroughfare.ThoroughfareName}else{return""}},getCity:function(){var A=this.getLocality();if(!A){A=this.getProvince()}return A.Locality},getCityName:function(){city=this.getCity();if(city){return city.LocalityName}else{return""}},getLocality:function(){return this.getProvince().SubAdministrativeArea},getLocalityName:function(){locality=this.getLocality();if(locality){locality.SubAdministrativeAreaName}else{return""}},getProvince:function(){return this.getCountry().AdministrativeArea},getProvinceName:function(){return this.getProvince().AdministrativeAreaName},getCountry:function(){return this._addressdata.Country},getCountryCode:function(){return this.getCountry().CountryNameCode},getPostalCode:function(){var A=this.getCity();if(!A){A=this.getLocality()}if(A&&A.PostalCode){return A.PostalCode.PostalCodeNumber}else{return""}},lat:function(){return this._point.coordinates[1]},lng:function(){return this._point.coordinates[0]}});dojo.declare("ContextMenu",null,{constructor:function(A){this.map=A;var B=this;this.contextmenu=document.createElement("div");this.contextmenu.className="contextmenu";this.ul_container=document.createElement("ul");this.ul_container.id="context_menu_ul";this.contextmenu.appendChild(this.ul_container);this.contextmenu.style.display="none";this.map.getContainer().appendChild(this.contextmenu);GEvent.addListener(A,"singlerightclick",function(D,E){B.clickedPixel=D;var C=D.x;var G=D.y;if(C>B.map.getSize().width-160){C=B.map.getSize().width-160}if(G>B.map.getSize().height-120){G=B.map.getSize().height-120}var F=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(C,G));F.apply(B.contextmenu);B.contextmenu.style.display=""});GEvent.addListener(A,"move",function(){B.contextmenu.style.display="none"});GEvent.addListener(A,"click",function(D,C){B.contextmenu.style.display="none"})},addCenterMapLink:function(){var A=this;this.addLink("Center Map Here",function(B){A.map.panTo(B)})},addLink:function(B,C){if(!dojo.trim(B)){return }var A=this;a_link=document.createElement("li");a_link.innerHTML="<a href='javascript:void(0);'>&raquo;&nbsp;"+B+"</a>";GEvent.addDomListener(a_link,"click",function(){if(C&&typeof C=="function"){var D=A.map.fromContainerPixelToLatLng(A.clickedPixel);C.call(this,D)}A.contextmenu.display="none"});this.ul_container.appendChild(a_link)}});document.write("\n<style>\ndiv.contextmenu { background-color: #FFF;border: 1px solid #8888FF;}div.contextmenu ul {list-style-image:none;list-style-position:outside;list-style-type:none;margin:0;padding:0;}div.contextmenu ul li {display:block;padding:1px;line-height:100%;margin:0}div.contextmenu ul li a {border:none;padding:3px 21px 3px 10px;display:block;text-decoration:none;color:#233D6D;font-size:11px;font-family:tahoma,arial,sans-serif;}div.contextmenu ul li a:hover { color:#233d6d;background:#c3daf9;border:1px solid #8BB8F3;padding:2px 20px 2px 9px;}\n</style>\n")
