if("object"!=typeof window.google||!window.google.maps)throw"Google Maps API is required. Please register the following JavaScript library http://maps.google.com/maps/api/js?sensor=true.";var extend_object=function(t,e){var i;if(t===e)return t;for(i in e)t[i]=e[i];return t},replace_object=function(t,e){var i;if(t===e)return t;for(i in e)void 0!=t[i]&&(t[i]=e[i]);return t},array_map=function(t,e){var i,n=Array.prototype.slice.call(arguments,2),r=[],o=t.length;if(Array.prototype.map&&t.map===Array.prototype.map)r=Array.prototype.map.call(t,function(t){return callback_params=n,callback_params.splice(0,0,t),e.apply(this,callback_params)});else for(i=0;o>i;i++)callback_params=n,callback_params.splice(0,0,t[i]),r.push(e.apply(this,callback_params));return r},array_flat=function(t){var e,i=[];for(e=0;e<t.length;e++)i=i.concat(t[e]);return i},coordsToLatLngs=function(t,e){var i=t[0],n=t[1];return e&&(i=t[1],n=t[0]),new google.maps.LatLng(i,n)},arrayToLatLng=function(t,e){var i;for(i=0;i<t.length;i++)t[i]=t[i].length>0&&"number"!=typeof t[i][0]?arrayToLatLng(t[i],e):coordsToLatLngs(t[i],e);return t},getElementById=function(t,e){var i,t=t.replace("#","");return i="jQuery"in this&&e?$("#"+t,e)[0]:document.getElementById(t)},findAbsolutePosition=function(t){var e=0,i=0;if(t.offsetParent)do e+=t.offsetLeft,i+=t.offsetTop;while(t=t.offsetParent);return[e,i]},GMaps=function(){"use strict";var t=document,e=function(i){if(!this)return new e(i);i.zoom=i.zoom||15,i.mapType=i.mapType||"roadmap";var n,r=this,o=["bounds_changed","center_changed","click","dblclick","drag","dragend","dragstart","idle","maptypeid_changed","projection_changed","resize","tilesloaded","zoom_changed"],a=["mousemove","mouseout","mouseover"],s=["el","lat","lng","mapType","width","height","markerClusterer","enableNewStyle"],l=i.el||i.div,c=i.markerClusterer,h=google.maps.MapTypeId[i.mapType.toUpperCase()],u=new google.maps.LatLng(i.lat,i.lng),d=i.zoomControl||!0,p=i.zoomControlOpt||{style:"DEFAULT",position:"TOP_LEFT"},f=p.style||"DEFAULT",g=p.position||"TOP_LEFT",m=i.panControl||!0,v=i.mapTypeControl||!0,y=i.scaleControl||!0,x=i.streetViewControl||!0,b=b||!0,w={},_={zoom:this.zoom,center:u,mapTypeId:h},k={panControl:m,zoomControl:d,zoomControlOptions:{style:google.maps.ZoomControlStyle[f],position:google.maps.ControlPosition[g]},mapTypeControl:v,scaleControl:y,streetViewControl:x,overviewMapControl:b};if(this.el="string"==typeof i.el||"string"==typeof i.div?getElementById(l,i.context):l,"undefined"==typeof this.el||null===this.el)throw"No element defined.";for(window.context_menu=window.context_menu||{},window.context_menu[r.el.id]={},this.controls=[],this.overlays=[],this.layers=[],this.singleLayers={},this.markers=[],this.polylines=[],this.routes=[],this.polygons=[],this.infoWindow=null,this.overlay_el=null,this.zoom=i.zoom,this.registered_events={},this.el.style.width=i.width||this.el.scrollWidth||this.el.offsetWidth,this.el.style.height=i.height||this.el.scrollHeight||this.el.offsetHeight,google.maps.visualRefresh=i.enableNewStyle,n=0;n<s.length;n++)delete i[s[n]];for(1!=i.disableDefaultUI&&(_=extend_object(_,k)),w=extend_object(_,i),n=0;n<o.length;n++)delete w[o[n]];for(n=0;n<a.length;n++)delete w[a[n]];this.map=new google.maps.Map(this.el,w),c&&(this.markerClusterer=c.apply(this,[this.map]));var C=function(t,e){var i="",n=window.context_menu[r.el.id][t];for(var o in n)if(n.hasOwnProperty(o)){var a=n[o];i+='<li><a id="'+t+"_"+o+'" href="#">'+a.title+"</a></li>"}if(getElementById("gmaps_context_menu")){var s=getElementById("gmaps_context_menu");s.innerHTML=i;var l=s.getElementsByTagName("a"),c=l.length;for(o=0;c>o;o++){var h=l[o],u=function(i){i.preventDefault(),n[this.id.replace(t+"_","")].action.apply(r,[e]),r.hideContextMenu()};google.maps.event.clearListeners(h,"click"),google.maps.event.addDomListenerOnce(h,"click",u,!1)}var d=findAbsolutePosition.apply(this,[r.el]),p=d[0]+e.pixel.x-15,f=d[1]+e.pixel.y-15;s.style.left=p+"px",s.style.top=f+"px",s.style.display="block"}};this.buildContextMenu=function(t,e){if("marker"===t){e.pixel={};var i=new google.maps.OverlayView;i.setMap(r.map),i.draw=function(){var n=i.getProjection(),r=e.marker.getPosition();e.pixel=n.fromLatLngToContainerPixel(r),C(t,e)}}else C(t,e)},this.setContextMenu=function(e){window.context_menu[r.el.id][e.control]={};var i,n=t.createElement("ul");for(i in e.options)if(e.options.hasOwnProperty(i)){var o=e.options[i];window.context_menu[r.el.id][e.control][o.name]={title:o.title,action:o.action}}n.id="gmaps_context_menu",n.style.display="none",n.style.position="absolute",n.style.minWidth="100px",n.style.background="white",n.style.listStyle="none",n.style.padding="8px",n.style.boxShadow="2px 2px 6px #ccc",t.body.appendChild(n);var a=getElementById("gmaps_context_menu");google.maps.event.addDomListener(a,"mouseout",function(t){t.relatedTarget&&this.contains(t.relatedTarget)||window.setTimeout(function(){a.style.display="none"},400)},!1)},this.hideContextMenu=function(){var t=getElementById("gmaps_context_menu");t&&(t.style.display="none")};for(var S=function(t,e){google.maps.event.addListener(t,e,function(t){void 0==t&&(t=this),i[e].apply(this,[t]),r.hideContextMenu()})},T=0;T<o.length;T++){var M=o[T];M in i&&S(this.map,M)}for(var T=0;T<a.length;T++){var M=a[T];M in i&&S(this.map,M)}google.maps.event.addListener(this.map,"rightclick",function(t){i.rightclick&&i.rightclick.apply(this,[t]),void 0!=window.context_menu[r.el.id].map&&r.buildContextMenu("map",t)}),this.refresh=function(){google.maps.event.trigger(this.map,"resize")},this.fitZoom=function(){var t,e=[],i=this.markers.length;for(t=0;i>t;t++)e.push(this.markers[t].getPosition());this.fitLatLngBounds(e)},this.fitLatLngBounds=function(t){for(var e=t.length,i=new google.maps.LatLngBounds,n=0;e>n;n++)i.extend(t[n]);this.map.fitBounds(i)},this.setCenter=function(t,e,i){this.map.panTo(new google.maps.LatLng(t,e)),i&&i()},this.getElement=function(){return this.el},this.zoomIn=function(t){t=t||1,this.zoom=this.map.getZoom()+t,this.map.setZoom(this.zoom)},this.zoomOut=function(t){t=t||1,this.zoom=this.map.getZoom()-t,this.map.setZoom(this.zoom)};var L,A=[];for(L in this.map)"function"!=typeof this.map[L]||this[L]||A.push(L);for(n=0;n<A.length;n++)!function(t,e,i){t[i]=function(){return e[i].apply(e,arguments)}}(this,this.map,A[n])};return e}(this);GMaps.prototype.createControl=function(t){var e=document.createElement("div");e.style.cursor="pointer",e.style.fontFamily="Arial, sans-serif",e.style.fontSize="13px",e.style.boxShadow="rgba(0, 0, 0, 0.398438) 0px 2px 4px";for(var i in t.style)e.style[i]=t.style[i];t.id&&(e.id=t.id),t.classes&&(e.className=t.classes),t.content&&(e.innerHTML=t.content);for(var n in t.events)!function(e,i){google.maps.event.addDomListener(e,i,function(){t.events[i].apply(this,[this])})}(e,n);return e.index=1,e},GMaps.prototype.addControl=function(t){var e=google.maps.ControlPosition[t.position.toUpperCase()];delete t.position;var i=this.createControl(t);return this.controls.push(i),this.map.controls[e].push(i),i},GMaps.prototype.createMarker=function(t){if(void 0==t.lat&&void 0==t.lng&&void 0==t.position)throw"No latitude or longitude defined.";var e=this,i=t.details,n=t.fences,r=t.outside,o={position:new google.maps.LatLng(t.lat,t.lng),map:null};delete t.lat,delete t.lng,delete t.fences,delete t.outside;var a=extend_object(o,t),s=new google.maps.Marker(a);if(s.fences=n,t.infoWindow){s.infoWindow=new google.maps.InfoWindow(t.infoWindow);for(var l=["closeclick","content_changed","domready","position_changed","zindex_changed"],c=0;c<l.length;c++)!function(e,i){t.infoWindow[i]&&google.maps.event.addListener(e,i,function(e){t.infoWindow[i].apply(this,[e])})}(s.infoWindow,l[c])}for(var h=["animation_changed","clickable_changed","cursor_changed","draggable_changed","flat_changed","icon_changed","position_changed","shadow_changed","shape_changed","title_changed","visible_changed","zindex_changed"],u=["dblclick","drag","dragend","dragstart","mousedown","mouseout","mouseover","mouseup"],c=0;c<h.length;c++)!function(e,i){t[i]&&google.maps.event.addListener(e,i,function(){t[i].apply(this,[this])})}(s,h[c]);for(var c=0;c<u.length;c++)!function(e,i,n){t[n]&&google.maps.event.addListener(i,n,function(i){i.pixel||(i.pixel=e.getProjection().fromLatLngToPoint(i.latLng)),t[n].apply(this,[i])})}(this.map,s,u[c]);return google.maps.event.addListener(s,"click",function(){this.details=i,t.click&&t.click.apply(this,[this]),s.infoWindow&&(e.hideInfoWindows(),s.infoWindow.open(e.map,s))}),google.maps.event.addListener(s,"rightclick",function(i){i.marker=this,t.rightclick&&t.rightclick.apply(this,[i]),void 0!=window.context_menu[e.el.id].marker&&e.buildContextMenu("marker",i)}),s.fences&&google.maps.event.addListener(s,"dragend",function(){e.checkMarkerGeofence(s,function(t,e){r(t,e)})}),s},GMaps.prototype.addMarker=function(t){var e;if(t.hasOwnProperty("gm_accessors_"))e=t;else{if(!(t.hasOwnProperty("lat")&&t.hasOwnProperty("lng")||t.position))throw"No latitude or longitude defined.";e=this.createMarker(t)}return e.setMap(this.map),this.markerClusterer&&this.markerClusterer.addMarker(e),this.markers.push(e),GMaps.fire("marker_added",e,this),e},GMaps.prototype.addMarkers=function(t){for(var e,i=0;e=t[i];i++)this.addMarker(e);return this.markers},GMaps.prototype.hideInfoWindows=function(){for(var t,e=0;t=this.markers[e];e++)t.infoWindow&&t.infoWindow.close()},GMaps.prototype.removeMarker=function(t){for(var e=0;e<this.markers.length;e++)if(this.markers[e]===t){this.markers[e].setMap(null),this.markers.splice(e,1),GMaps.fire("marker_removed",t,this);break}return t},GMaps.prototype.removeMarkers=function(t){for(var t=t||this.markers,e=0;e<this.markers.length;e++)this.markers[e]===t[e]&&this.markers[e].setMap(null);for(var i=[],e=0;e<this.markers.length;e++)null!=this.markers[e].getMap()&&i.push(this.markers[e]);this.markers=i},GMaps.prototype.drawOverlay=function(t){var e=new google.maps.OverlayView,i=!0;return e.setMap(this.map),null!=t.auto_show&&(i=t.auto_show),e.onAdd=function(){var i=document.createElement("div");i.style.borderStyle="none",i.style.borderWidth="0px",i.style.position="absolute",i.style.zIndex=100,i.innerHTML=t.content,e.el=i,t.layer||(t.layer="overlayLayer");var n=this.getPanes(),r=n[t.layer],o=["contextmenu","DOMMouseScroll","dblclick","mousedown"];r.appendChild(i);for(var a=0;a<o.length;a++)!function(t,e){google.maps.event.addDomListener(t,e,function(t){-1!=navigator.userAgent.toLowerCase().indexOf("msie")&&document.all?(t.cancelBubble=!0,t.returnValue=!1):t.stopPropagation()})}(i,o[a]);google.maps.event.trigger(this,"ready")},e.draw=function(){var n=this.getProjection(),r=n.fromLatLngToDivPixel(new google.maps.LatLng(t.lat,t.lng));t.horizontalOffset=t.horizontalOffset||0,t.verticalOffset=t.verticalOffset||0;var o=e.el,a=o.children[0],s=a.clientHeight,l=a.clientWidth;switch(t.verticalAlign){case"top":o.style.top=r.y-s+t.verticalOffset+"px";break;default:case"middle":o.style.top=r.y-s/2+t.verticalOffset+"px";break;case"bottom":o.style.top=r.y+t.verticalOffset+"px"}switch(t.horizontalAlign){case"left":o.style.left=r.x-l+t.horizontalOffset+"px";break;default:case"center":o.style.left=r.x-l/2+t.horizontalOffset+"px";break;case"right":o.style.left=r.x+t.horizontalOffset+"px"}o.style.display=i?"block":"none",i||t.show.apply(this,[o])},e.onRemove=function(){var i=e.el;t.remove?t.remove.apply(this,[i]):(e.el.parentNode.removeChild(e.el),e.el=null)},this.overlays.push(e),e},GMaps.prototype.removeOverlay=function(t){for(var e=0;e<this.overlays.length;e++)if(this.overlays[e]===t){this.overlays[e].setMap(null),this.overlays.splice(e,1);break}},GMaps.prototype.removeOverlays=function(){for(var t,e=0;t=this.overlays[e];e++)t.setMap(null);this.overlays=[]},GMaps.prototype.drawPolyline=function(t){var e=[],i=t.path;if(i.length)if(void 0===i[0][0])e=i;else for(var n,r=0;n=i[r];r++)e.push(new google.maps.LatLng(n[0],n[1]));var o={map:this.map,path:e,strokeColor:t.strokeColor,strokeOpacity:t.strokeOpacity,strokeWeight:t.strokeWeight,geodesic:t.geodesic,clickable:!0,editable:!1,visible:!0};t.hasOwnProperty("clickable")&&(o.clickable=t.clickable),t.hasOwnProperty("editable")&&(o.editable=t.editable),t.hasOwnProperty("icons")&&(o.icons=t.icons),t.hasOwnProperty("zIndex")&&(o.zIndex=t.zIndex);for(var a=new google.maps.Polyline(o),s=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],l=0;l<s.length;l++)!function(e,i){t[i]&&google.maps.event.addListener(e,i,function(e){t[i].apply(this,[e])})}(a,s[l]);return this.polylines.push(a),GMaps.fire("polyline_added",a,this),a},GMaps.prototype.removePolyline=function(t){for(var e=0;e<this.polylines.length;e++)if(this.polylines[e]===t){this.polylines[e].setMap(null),this.polylines.splice(e,1),GMaps.fire("polyline_removed",t,this);break}},GMaps.prototype.removePolylines=function(){for(var t,e=0;t=this.polylines[e];e++)t.setMap(null);this.polylines=[]},GMaps.prototype.drawCircle=function(t){t=extend_object({map:this.map,center:new google.maps.LatLng(t.lat,t.lng)},t),delete t.lat,delete t.lng;for(var e=new google.maps.Circle(t),i=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],n=0;n<i.length;n++)!function(e,i){t[i]&&google.maps.event.addListener(e,i,function(e){t[i].apply(this,[e])})}(e,i[n]);return this.polygons.push(e),e},GMaps.prototype.drawRectangle=function(t){t=extend_object({map:this.map},t);var e=new google.maps.LatLngBounds(new google.maps.LatLng(t.bounds[0][0],t.bounds[0][1]),new google.maps.LatLng(t.bounds[1][0],t.bounds[1][1]));t.bounds=e;for(var i=new google.maps.Rectangle(t),n=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],r=0;r<n.length;r++)!function(e,i){t[i]&&google.maps.event.addListener(e,i,function(e){t[i].apply(this,[e])})}(i,n[r]);return this.polygons.push(i),i},GMaps.prototype.drawPolygon=function(t){var e=!1;t.hasOwnProperty("useGeoJSON")&&(e=t.useGeoJSON),delete t.useGeoJSON,t=extend_object({map:this.map},t),0==e&&(t.paths=[t.paths.slice(0)]),t.paths.length>0&&t.paths[0].length>0&&(t.paths=array_flat(array_map(t.paths,arrayToLatLng,e)));for(var i=new google.maps.Polygon(t),n=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup","rightclick"],r=0;r<n.length;r++)!function(e,i){t[i]&&google.maps.event.addListener(e,i,function(e){t[i].apply(this,[e])})}(i,n[r]);return this.polygons.push(i),GMaps.fire("polygon_added",i,this),i},GMaps.prototype.removePolygon=function(t){for(var e=0;e<this.polygons.length;e++)if(this.polygons[e]===t){this.polygons[e].setMap(null),this.polygons.splice(e,1),GMaps.fire("polygon_removed",t,this);break}},GMaps.prototype.removePolygons=function(){for(var t,e=0;t=this.polygons[e];e++)t.setMap(null);this.polygons=[]},GMaps.prototype.getFromFusionTables=function(t){var e=t.events;delete t.events;var i=t,n=new google.maps.FusionTablesLayer(i);for(var r in e)!function(t,i){google.maps.event.addListener(t,i,function(t){e[i].apply(this,[t])})}(n,r);return this.layers.push(n),n},GMaps.prototype.loadFromFusionTables=function(t){var e=this.getFromFusionTables(t);return e.setMap(this.map),e},GMaps.prototype.getFromKML=function(t){var e=t.url,i=t.events;delete t.url,delete t.events;var n=t,r=new google.maps.KmlLayer(e,n);for(var o in i)!function(t,e){google.maps.event.addListener(t,e,function(t){i[e].apply(this,[t])})}(r,o);return this.layers.push(r),r},GMaps.prototype.loadFromKML=function(t){var e=this.getFromKML(t);return e.setMap(this.map),e},GMaps.prototype.addLayer=function(t,e){e=e||{};var i;switch(t){case"weather":this.singleLayers.weather=i=new google.maps.weather.WeatherLayer;break;case"clouds":this.singleLayers.clouds=i=new google.maps.weather.CloudLayer;break;case"traffic":this.singleLayers.traffic=i=new google.maps.TrafficLayer;break;case"transit":this.singleLayers.transit=i=new google.maps.TransitLayer;break;case"bicycling":this.singleLayers.bicycling=i=new google.maps.BicyclingLayer;break;case"panoramio":this.singleLayers.panoramio=i=new google.maps.panoramio.PanoramioLayer,i.setTag(e.filter),delete e.filter,e.click&&google.maps.event.addListener(i,"click",function(t){e.click(t),delete e.click});break;case"places":if(this.singleLayers.places=i=new google.maps.places.PlacesService(this.map),e.search||e.nearbySearch){var n={bounds:e.bounds||null,keyword:e.keyword||null,location:e.location||null,name:e.name||null,radius:e.radius||null,rankBy:e.rankBy||null,types:e.types||null};e.search&&i.search(n,e.search),e.nearbySearch&&i.nearbySearch(n,e.nearbySearch)}if(e.textSearch){var r={bounds:e.bounds||null,location:e.location||null,query:e.query||null,radius:e.radius||null};i.textSearch(r,e.textSearch)}}return void 0!==i?("function"==typeof i.setOptions&&i.setOptions(e),"function"==typeof i.setMap&&i.setMap(this.map),i):void 0},GMaps.prototype.removeLayer=function(t){if("string"==typeof t&&void 0!==this.singleLayers[t])this.singleLayers[t].setMap(null),delete this.singleLayers[t];else for(var e=0;e<this.layers.length;e++)if(this.layers[e]===t){this.layers[e].setMap(null),this.layers.splice(e,1);break}};var travelMode,unitSystem;GMaps.prototype.getRoutes=function(t){switch(t.travelMode){case"bicycling":travelMode=google.maps.TravelMode.BICYCLING;break;case"transit":travelMode=google.maps.TravelMode.TRANSIT;break;case"driving":travelMode=google.maps.TravelMode.DRIVING;break;default:travelMode=google.maps.TravelMode.WALKING}unitSystem="imperial"===t.unitSystem?google.maps.UnitSystem.IMPERIAL:google.maps.UnitSystem.METRIC;var e={avoidHighways:!1,avoidTolls:!1,optimizeWaypoints:!1,waypoints:[]},i=extend_object(e,t);i.origin=/string/.test(typeof t.origin)?t.origin:new google.maps.LatLng(t.origin[0],t.origin[1]),i.destination=/string/.test(typeof t.destination)?t.destination:new google.maps.LatLng(t.destination[0],t.destination[1]),i.travelMode=travelMode,i.unitSystem=unitSystem,delete i.callback;var n=this,r=new google.maps.DirectionsService;r.route(i,function(e,i){if(i===google.maps.DirectionsStatus.OK)for(var r in e.routes)e.routes.hasOwnProperty(r)&&n.routes.push(e.routes[r]);t.callback&&t.callback(n.routes)})},GMaps.prototype.removeRoutes=function(){this.routes=[]},GMaps.prototype.getElevations=function(t){t=extend_object({locations:[],path:!1,samples:256},t),t.locations.length>0&&t.locations[0].length>0&&(t.locations=array_flat(array_map([t.locations],arrayToLatLng,!1)));var e=t.callback;delete t.callback;var i=new google.maps.ElevationService;if(t.path){var n={path:t.locations,samples:t.samples};i.getElevationAlongPath(n,function(t,i){e&&"function"==typeof e&&e(t,i)})}else delete t.path,delete t.samples,i.getElevationForLocations(t,function(t,i){e&&"function"==typeof e&&e(t,i)})},GMaps.prototype.cleanRoute=GMaps.prototype.removePolylines,GMaps.prototype.drawRoute=function(t){var e=this;this.getRoutes({origin:t.origin,destination:t.destination,travelMode:t.travelMode,waypoints:t.waypoints,unitSystem:t.unitSystem,callback:function(i){i.length>0&&(e.drawPolyline({path:i[i.length-1].overview_path,strokeColor:t.strokeColor,strokeOpacity:t.strokeOpacity,strokeWeight:t.strokeWeight}),t.callback&&t.callback(i[i.length-1]))}})},GMaps.prototype.travelRoute=function(t){if(t.origin&&t.destination)this.getRoutes({origin:t.origin,destination:t.destination,travelMode:t.travelMode,waypoints:t.waypoints,callback:function(e){if(e.length>0&&t.start&&t.start(e[e.length-1]),e.length>0&&t.step){var i=e[e.length-1];if(i.legs.length>0)for(var n,r=i.legs[0].steps,o=0;n=r[o];o++)n.step_number=o,t.step(n,i.legs[0].steps.length-1)}e.length>0&&t.end&&t.end(e[e.length-1])}});else if(t.route&&t.route.legs.length>0)for(var e,i=t.route.legs[0].steps,n=0;e=i[n];n++)e.step_number=n,t.step(e)},GMaps.prototype.drawSteppedRoute=function(t){var e=this;if(t.origin&&t.destination)this.getRoutes({origin:t.origin,destination:t.destination,travelMode:t.travelMode,waypoints:t.waypoints,callback:function(i){if(i.length>0&&t.start&&t.start(i[i.length-1]),i.length>0&&t.step){var n=i[i.length-1];if(n.legs.length>0)for(var r,o=n.legs[0].steps,a=0;r=o[a];a++)r.step_number=a,e.drawPolyline({path:r.path,strokeColor:t.strokeColor,strokeOpacity:t.strokeOpacity,strokeWeight:t.strokeWeight}),t.step(r,n.legs[0].steps.length-1)}i.length>0&&t.end&&t.end(i[i.length-1])}});else if(t.route&&t.route.legs.length>0)for(var i,n=t.route.legs[0].steps,r=0;i=n[r];r++)i.step_number=r,e.drawPolyline({path:i.path,strokeColor:t.strokeColor,strokeOpacity:t.strokeOpacity,strokeWeight:t.strokeWeight}),t.step(i)},GMaps.Route=function(t){this.origin=t.origin,this.destination=t.destination,this.waypoints=t.waypoints,this.map=t.map,this.route=t.route,this.step_count=0,this.steps=this.route.legs[0].steps,this.steps_length=this.steps.length,this.polyline=this.map.drawPolyline({path:new google.maps.MVCArray,strokeColor:t.strokeColor,strokeOpacity:t.strokeOpacity,strokeWeight:t.strokeWeight}).getPath()},GMaps.Route.prototype.getRoute=function(t){var i=this;this.map.getRoutes({origin:this.origin,destination:this.destination,travelMode:t.travelMode,waypoints:this.waypoints||[],callback:function(){i.route=e[0],t.callback&&t.callback.call(i)}})},GMaps.Route.prototype.back=function(){if(this.step_count>0){this.step_count--;var t=this.route.legs[0].steps[this.step_count].path;for(var e in t)t.hasOwnProperty(e)&&this.polyline.pop()}},GMaps.Route.prototype.forward=function(){if(this.step_count<this.steps_length){var t=this.route.legs[0].steps[this.step_count].path;for(var e in t)t.hasOwnProperty(e)&&this.polyline.push(t[e]);this.step_count++}},GMaps.prototype.checkGeofence=function(t,e,i){return i.containsLatLng(new google.maps.LatLng(t,e))},GMaps.prototype.checkMarkerGeofence=function(t,e){if(t.fences)for(var i,n=0;i=t.fences[n];n++){var r=t.getPosition();this.checkGeofence(r.lat(),r.lng(),i)||e(t,i)}},GMaps.prototype.toImage=function(t){var t=t||{},e={};if(e.size=t.size||[this.el.clientWidth,this.el.clientHeight],e.lat=this.getCenter().lat(),e.lng=this.getCenter().lng(),this.markers.length>0){e.markers=[];for(var i=0;i<this.markers.length;i++)e.markers.push({lat:this.markers[i].getPosition().lat(),lng:this.markers[i].getPosition().lng()})}if(this.polylines.length>0){var n=this.polylines[0];e.polyline={},e.polyline.path=google.maps.geometry.encoding.encodePath(n.getPath()),e.polyline.strokeColor=n.strokeColor,e.polyline.strokeOpacity=n.strokeOpacity,e.polyline.strokeWeight=n.strokeWeight}return GMaps.staticMapURL(e)},GMaps.staticMapURL=function(t){function e(t,e){if("#"===t[0]&&(t=t.replace("#","0x"),e)){if(e=parseFloat(e),e=Math.min(1,Math.max(e,0)),0===e)return"0x00000000";e=(255*e).toString(16),1===e.length&&(e+=e),t=t.slice(0,8)+e}return t}var i,n=[],r="http://maps.googleapis.com/maps/api/staticmap";t.url&&(r=t.url,delete t.url),r+="?";var o=t.markers;delete t.markers,!o&&t.marker&&(o=[t.marker],delete t.marker);var a=t.styles;delete t.styles;var s=t.polyline;if(delete t.polyline,t.center)n.push("center="+t.center),delete t.center;else if(t.address)n.push("center="+t.address),delete t.address;else if(t.lat)n.push(["center=",t.lat,",",t.lng].join("")),delete t.lat,delete t.lng;else if(t.visible){var l=encodeURI(t.visible.join("|"));n.push("visible="+l)}var c=t.size;c?(c.join&&(c=c.join("x")),delete t.size):c="630x300",n.push("size="+c),t.zoom||t.zoom===!1||(t.zoom=15);var h=t.hasOwnProperty("sensor")?!!t.sensor:!0;delete t.sensor,n.push("sensor="+h);for(var u in t)t.hasOwnProperty(u)&&n.push(u+"="+t[u]);if(o)for(var d,p,f=0;i=o[f];f++){d=[],i.size&&"normal"!==i.size?(d.push("size:"+i.size),delete i.size):i.icon&&(d.push("icon:"+encodeURI(i.icon)),delete i.icon),i.color&&(d.push("color:"+i.color.replace("#","0x")),delete i.color),i.label&&(d.push("label:"+i.label[0].toUpperCase()),delete i.label),p=i.address?i.address:i.lat+","+i.lng,delete i.address,delete i.lat,delete i.lng;for(var u in i)i.hasOwnProperty(u)&&d.push(u+":"+i[u]);d.length||0===f?(d.push(p),d=d.join("|"),n.push("markers="+encodeURI(d))):(d=n.pop()+encodeURI("|"+p),n.push(d))}if(a)for(var f=0;f<a.length;f++){var g=[];a[f].featureType&&"all"!=a[f].featureType&&g.push("feature:"+a[f].featureType),a[f].elementType&&"all"!=a[f].elementType&&g.push("element:"+a[f].elementType);for(var m=0;m<a[f].stylers.length;m++)for(var v in a[f].stylers[m]){var y=a[f].stylers[m][v];("hue"==v||"color"==v)&&(y="0x"+y.substring(1)),g.push(v+":"+y)}var x=g.join("|");""!=x&&n.push("style="+x)}if(s){if(i=s,s=[],i.strokeWeight&&s.push("weight:"+parseInt(i.strokeWeight,10)),i.strokeColor){var b=e(i.strokeColor,i.strokeOpacity);s.push("color:"+b)}if(i.fillColor){var w=e(i.fillColor,i.fillOpacity);s.push("fillcolor:"+w)}var _=i.path;if(_.join)for(var k,m=0;k=_[m];m++)s.push(k.join(","));else s.push("enc:"+_);s=s.join("|"),n.push("path="+encodeURI(s))}return n=n.join("&"),r+n},GMaps.prototype.addMapType=function(t,e){if(!e.hasOwnProperty("getTileUrl")||"function"!=typeof e.getTileUrl)throw"'getTileUrl' function required.";e.tileSize=e.tileSize||new google.maps.Size(256,256);var i=new google.maps.ImageMapType(e);this.map.mapTypes.set(t,i)},GMaps.prototype.addOverlayMapType=function(t){if(!t.hasOwnProperty("getTile")||"function"!=typeof t.getTile)throw"'getTile' function required.";var e=t.index;delete t.index,this.map.overlayMapTypes.insertAt(e,t)},GMaps.prototype.removeOverlayMapType=function(t){this.map.overlayMapTypes.removeAt(t)},GMaps.prototype.addStyle=function(t){var e=new google.maps.StyledMapType(t.styles,{name:t.styledMapName});this.map.mapTypes.set(t.mapTypeId,e)},GMaps.prototype.setStyle=function(t){this.map.setMapTypeId(t)},GMaps.prototype.createPanorama=function(t){return t.hasOwnProperty("lat")&&t.hasOwnProperty("lng")||(t.lat=this.getCenter().lat(),t.lng=this.getCenter().lng()),this.panorama=GMaps.createPanorama(t),this.map.setStreetView(this.panorama),this.panorama},GMaps.createPanorama=function(t){var e=getElementById(t.el,t.context);t.position=new google.maps.LatLng(t.lat,t.lng),delete t.el,delete t.context,delete t.lat,delete t.lng;for(var i=["closeclick","links_changed","pano_changed","position_changed","pov_changed","resize","visible_changed"],n=extend_object({visible:!0},t),r=0;r<i.length;r++)delete n[i[r]];for(var o=new google.maps.StreetViewPanorama(e,n),r=0;r<i.length;r++)!function(e,i){t[i]&&google.maps.event.addListener(e,i,function(){t[i].apply(this)})}(o,i[r]);return o},GMaps.prototype.on=function(t,e){return GMaps.on(t,this,e)},GMaps.prototype.off=function(t){GMaps.off(t,this)},GMaps.custom_events=["marker_added","marker_removed","polyline_added","polyline_removed","polygon_added","polygon_removed","geolocated","geolocation_failed"],GMaps.on=function(t,e,i){if(-1==GMaps.custom_events.indexOf(t))return google.maps.event.addListener(e,t,i);var n={handler:i,eventName:t};return e.registered_events[t]=e.registered_events[t]||[],e.registered_events[t].push(n),n},GMaps.off=function(t,e){-1==GMaps.custom_events.indexOf(t)?google.maps.event.clearListeners(e,t):e.registered_events[t]=[]},GMaps.fire=function(t,e,i){if(-1==GMaps.custom_events.indexOf(t))google.maps.event.trigger(e,t,Array.prototype.slice.apply(arguments).slice(2));else if(t in i.registered_events)for(var n=i.registered_events[t],r=0;r<n.length;r++)!function(t,e,i){t.apply(e,[i])}(n[r].handler,i,e)},GMaps.geolocate=function(t){var e=t.always||t.complete;navigator.geolocation?navigator.geolocation.getCurrentPosition(function(i){t.success(i),e&&e()},function(i){t.error(i),e&&e()},t.options):(t.not_supported(),e&&e())},GMaps.geocode=function(t){this.geocoder=new google.maps.Geocoder;var e=t.callback;t.hasOwnProperty("lat")&&t.hasOwnProperty("lng")&&(t.latLng=new google.maps.LatLng(t.lat,t.lng)),delete t.lat,delete t.lng,delete t.callback,this.geocoder.geocode(t,function(t,i){e(t,i)})},google.maps.Polygon.prototype.getBounds||(google.maps.Polygon.prototype.getBounds=function(){for(var t,e=new google.maps.LatLngBounds,i=this.getPaths(),n=0;n<i.getLength();n++){t=i.getAt(n);for(var r=0;r<t.getLength();r++)e.extend(t.getAt(r))}return e}),google.maps.Polygon.prototype.containsLatLng||(google.maps.Polygon.prototype.containsLatLng=function(t){var e=this.getBounds();if(null!==e&&!e.contains(t))return!1;for(var i=!1,n=this.getPaths().getLength(),r=0;n>r;r++)for(var o=this.getPaths().getAt(r),a=o.getLength(),s=a-1,l=0;a>l;l++){var c=o.getAt(l),h=o.getAt(s);(c.lng()<t.lng()&&h.lng()>=t.lng()||h.lng()<t.lng()&&c.lng()>=t.lng())&&c.lat()+(t.lng()-c.lng())/(h.lng()-c.lng())*(h.lat()-c.lat())<t.lat()&&(i=!i),s=l}return i}),google.maps.LatLngBounds.prototype.containsLatLng=function(t){return this.contains(t)},google.maps.Marker.prototype.setFences=function(t){this.fences=t},google.maps.Marker.prototype.addFence=function(t){this.fences.push(t)},google.maps.Marker.prototype.getId=function(){return this.__gm_id},Array.prototype.indexOf||(Array.prototype.indexOf=function(t){"use strict";if(null==this)throw new TypeError;var e=Object(this),i=e.length>>>0;if(0===i)return-1;var n=0;if(arguments.length>1&&(n=Number(arguments[1]),n!=n?n=0:0!=n&&1/0!=n&&n!=-1/0&&(n=(n>0||-1)*Math.floor(Math.abs(n)))),n>=i)return-1;for(var r=n>=0?n:Math.max(i-Math.abs(n),0);i>r;r++)if(r in e&&e[r]===t)return r;return-1});