if(typeof Maptimize=="undefined"){Maptimize={}}Maptimize.Proxy={};Maptimize.Proxy.GoogleMap=function(D,E,C){var A=this;function B(){A.map=new GMap2(D);A.map.setCenter(new GLatLng(47,1),1);A.geocoder=new GClientGeocoder;E.call(C,A.map)}if(typeof GMap2=="undefined"){if(typeof google=="undefined"){throw"Not Google Map object found, check if you have include Google Map javascript"}else{google.load("maps",2);google.setOnLoadCallback(B)}}else{setTimeout(B,10)}};Maptimize.Proxy.GoogleMap.prototype=(function(){function O(X,W,V,Y){return GEvent.bindDom(X,W,V,Y)}function P(V){GEvent.removeListener(V)}function N(){GEvent.trigger.apply(this,arguments)}function Q(V,X,W){this.geocoder.getLocations(V.join(", "),function(Y){U(Y,X,W)})}function K(){return this.map}function L(V){return V.address}function H(V){return B(V,"LocalityName")}function T(V){return B(V,"CountryName")}function F(V){return B(V,"PostalCodeName")}function J(V){return B(V,"ThoroughfareName")}function S(V){return V.Point.coordinates[1]}function M(V){return V.Point.coordinates[0]}function D(V){this.icon=V}function R(Y,X,b,W){var a=Y.AddressDetails.Accuracy,V=X?Y.address.split(",").join("<br/>"):false,Z=1;if(a>=9){Z=17}else{if(a>=6){Z=14}else{if(a>=4){Z=12}else{if(a>1){Z=6}else{Z=3}}}}this.showMarker(Y.Point.coordinates[1],Y.Point.coordinates[0],Z,V,b,W)}function A(a,W,Z,V,b,X){var Y=new GLatLng(a,W);this.map.setCenter(Y,Z);if(this.marker){this.marker.setLatLng(Y);this.marker.show()}else{this.marker=new GMarker(Y,{draggable:true,icon:this.icon});GEvent.bind(this.marker,"dragstart",this,I);GEvent.bind(this.marker,"dragend",this,E);this.map.addOverlay(this.marker)}this.draggableCallback=b;this.draggableContext=X;if(this.draggableCallback){this.marker.enableDragging()}else{this.marker.disableDragging()}if(V){this.marker.openInfoWindowHtml(V)}}function C(){if(this.marker){this.marker.closeInfoWindow();this.marker.hide()}}function G(V){var W=google&&google.loader?google.loader.ClientLocation:null;if(W){this.map.setCenter(new GLatLng(W.latitude,W.longitude),V||8)}}function U(V,X,W){if(V.Status.code==200){X.call(W,V.Placemark)}else{X.call(W,false)}}function I(){this.marker.closeInfoWindow()}function E(V){this.draggableCallback.call(this.draggableContext,V.lat(),V.lng())}function B(V,W){for(f in V){if(f==W){return V[f]}else{if(typeof V[f]=="object"){return B(V[f],W)}}}return""}return{addEventListener:O,removeEventListener:P,trigger:N,getMap:K,centerOnClientLocation:G,setIcon:D,getPlacemarks:Q,showPlacemark:R,showMarker:A,hidePlacemark:C,getLat:S,getLng:M,getAddress:L,getCity:H,getCountry:T,getZIP:F,getStreet:J}})();if(typeof Maptimize=="undefined"){Maptimize={}}Maptimize.AddressChooser={};Maptimize.AddressChooser.DefaultOptions={map:"map",lat:"lat",lng:"lng",street:"street",zip:"zip",city:"city",state:"state",country:"country",spinner:false,icon:null,auto:true,delay:300,showAddressOnMap:true,markerDraggable:true,mapProxy:Maptimize.Proxy.GoogleMap,onInitialized:function(){}};Maptimize.AddressChooser.AddressKeys=["street","city","state","country","zip"],Maptimize.AddressChooser.Widget=function(B){function C(F){return F.tagName=="INPUT"||F.tagName=="TEXTAREA"?"keyup":"change"}function E(F,H){for(var G in H){F[G]=H[G]}return F}function A(I,G){if(I){var H=I.keyCode;if(I.charCode||(H>0&&H<47&&H!=8&&H!=46)){return }}if(G){var F=this;if(this.timeout){clearTimeout(this.timeout)}this.timeout=setTimeout(function(){A.call(F)},G)}else{this.updateMap()}}function D(){var G=this.options,J=Maptimize.AddressChooser.AddressKeys.concat("lat","lng","spinner");for(var I=J.length-1;I>=0;--I){var F=J[I];this[F]=document.getElementById(G[F])}var K=document.getElementById(this.options.map);if(!this.lat||!this.lng||!K){throw"lat/lng/map are required options and valid DOM elements."}if(G.auto){var L=function(M){A.call(this,M,this.options.delay)},H=Maptimize.AddressChooser.AddressKeys;for(var I=H.length-1;I>=0;--I){var F=H[I];if(this[F]){this.mapProxy.addEventListener(this[F],C(this[F]),this,L)}}}this.options.onInitialized(this)}this.options=E({},Maptimize.AddressChooser.DefaultOptions);E(this.options,B);this.placemarks=[];this.element=document.getElementById(this.options.map);this.mapProxy=new this.options.mapProxy(this.element,D,this)};Maptimize.AddressChooser.Widget.prototype=(function(){function D(K){if(K.tagName=="INPUT"||K.tagName=="TEXTAREA"){return K.value}else{return K.options[K.selectedIndex].value}}function B(L,K){if(this.spinner){this.spinner.style.display="block"}this.mapProxy.trigger(this.element,"addresschooser:suggests:started");this.mapProxy.getPlacemarks(this.getCurrentAddress(),A,this)}function E(L){if(this.lat.value&&this.lng.value){this.mapProxy.showMarker(this.lat.value,this.lng.value,L||5,this.options.showAddressOnMap?this.getCurrentAddress().join("<br/>"):false,J,this)}else{var K=this.getCurrentAddress();if(K.length==0){this.centerOnClientLocation(L||5)}else{this.updateMap()}}}function H(K){if(this.placemarks&&K<this.placemarks.length){var L=this.placemarks[K];if(this.options.markerDraggable){this.mapProxy.showPlacemark(L,this.options.showAddressOnMap,J,this)}else{this.mapProxy.showPlacemark(L,this.options.showAddressOnMap)}this.lat.value=this.mapProxy.getLat(L);this.lng.value=this.mapProxy.getLng(L)}}function I(){var K=[],N=Maptimize.AddressChooser.AddressKeys;for(var M=N.length-1;M>=0;--M){var L=N[M];if(this[L]){var O=D(this[L]);O=O.replace(/^\s+/,"").replace(/\s+$/,"");if(O.length>0){K.unshift(O)}}}return K}function G(){return this.mapProxy}function A(K){this.placemarks=K;if(K){this.showPlacemark(0)}else{this.lat.value="";this.lng.value="";this.mapProxy.hidePlacemark()}if(this.spinner){this.spinner.style.display="none"}this.mapProxy.trigger(this.element,"addresschooser:suggests:found",K)}function F(K){return function(){var L=arguments;return this.mapProxy[K].apply(this.mapProxy,arguments)}}function J(L,K){this.lat.value=L;this.lng.value=K}function C(K,L){return this.mapProxy.addEventListener(this.element,"addresschooser:"+K,this,L)}return{initMap:E,updateMap:B,showPlacemark:H,setIcon:F("setIcon"),centerOnClientLocation:F("centerOnClientLocation"),getMapProxy:G,getCurrentAddress:I,getMap:F("getMap"),getCity:F("getCity"),getCountry:F("getCountry"),getZIP:F("getZIP"),getStreet:F("getStreet"),getAddress:F("getAddress"),addEventListener:C,removeEventListener:F("removeEventListener")}})();Mapeed=Maptimize;