var VM;(function(n){function i(n,t){for(var i=window,r=(n||"").split(".");i&&r.length;)i=i[r.shift()];return typeof i=="function"?i:(t.push(n),Function.constructor.apply(null,t))}function u(n){return n==="GET"||n==="POST"}function o(n,t){u(t)||n.setRequestHeader("X-HTTP-Method-Override",t)}function s(t,i,r){var u;r.indexOf("application/x-javascript")===-1&&(u=(t.getAttribute("data-ajax-mode")||"").toUpperCase(),n(t.getAttribute("data-ajax-update")).each(function(t,r){var f;switch(u){case"BEFORE":f=r.firstChild;n("
").html(i).contents().each(function(){r.insertBefore(this,f)});break;case"AFTER":n("").html(i).contents().each(function(){r.appendChild(this)});break;case"REPLACE-WITH":n(r).replaceWith(i);break;default:n(r).html(i)}}))}function f(t,r){var e,h,f,c;(e=t.getAttribute("data-ajax-confirm"),!e||window.confirm(e))&&(h=n(t.getAttribute("data-ajax-loading")),c=parseInt(t.getAttribute("data-ajax-loading-duration"),10)||0,n.extend(r,{type:t.getAttribute("data-ajax-method")||undefined,url:t.getAttribute("data-ajax-url")||undefined,cache:!!t.getAttribute("data-ajax-cache"),beforeSend:function(n){var r;return o(n,f),r=i(t.getAttribute("data-ajax-begin"),["xhr"]).apply(t,arguments),r!==!1&&h.show(c),r},complete:function(){h.hide(c);i(t.getAttribute("data-ajax-complete"),["xhr","status"]).apply(t,arguments)},success:function(n,r,u){s(t,n,u.getResponseHeader("Content-Type")||"text/html");i(t.getAttribute("data-ajax-success"),["data","status","xhr"]).apply(t,arguments)},error:function(){i(t.getAttribute("data-ajax-failure"),["xhr","status","error"]).apply(t,arguments)}}),r.data.push({name:"X-Requested-With",value:"XMLHttpRequest"}),f=r.type.toUpperCase(),u(f)||(r.type="POST",r.data.push({name:"X-HTTP-Method-Override",value:f})),n.ajax(r))}function h(t){var i=n(t).data(e);return!i||!i.validate||i.validate()}var t="unobtrusiveAjaxClick",r="unobtrusiveAjaxClickTarget",e="unobtrusiveValidation";n(document).on("click","a[data-ajax=true]",function(n){n.preventDefault();f(this,{url:this.href,type:"GET",data:[]})});n(document).on("click","form[data-ajax=true] input[type=image]",function(i){var r=i.target.name,u=n(i.target),f=n(u.parents("form")[0]),e=u.offset();f.data(t,[{name:r+".x",value:Math.round(i.pageX-e.left)},{name:r+".y",value:Math.round(i.pageY-e.top)}]);setTimeout(function(){f.removeData(t)},0)});n(document).on("click","form[data-ajax=true] :submit",function(i){var f=i.currentTarget.name,e=n(i.target),u=n(e.parents("form")[0]);u.data(t,f?[{name:f,value:i.currentTarget.value}]:[]);u.data(r,e);setTimeout(function(){u.removeData(t);u.removeData(r)},0)});n(document).on("submit","form[data-ajax=true]",function(i){var e=n(this).data(t)||[],u=n(this).data(r),o=u&&u.hasClass("cancel");(i.preventDefault(),o||h(this))&&f(this,{url:this.action,type:this.method||"GET",data:e.concat(n(this).serializeArray())})})})(jQuery),function(n){n.fn.mapper=function(i){var u=n.extend({locationSelector:".mapper-location",extendedLocationSelector:".mapper-location-extended",latSelector:".mapper-lat",lngSelector:".mapper-lng",mapSelector:".mapper-map",geoSearchSelector:".mapper-geo-search",geoMapSelector:".mapper-geo-map",geoCurrentSelector:".mapper-geo-current",geoFieldsSelector:".mapper-geo-fields",geoRemoveSelector:".mapper-geo-remove"},i),r=new t(u,new google.maps.Geocoder);return this.each(function(){var t=n(this);t.on("click",r.settings.geoCurrentSelector,function(){r.getCurrentLocation(t)});t.on("click",r.settings.geoMapSelector,function(){r.toggleMap(t)});t.on("click",r.settings.geoSearchSelector,function(){r.findAddress(t)});t.on("click",r.settings.geoFieldsSelector,function(){r.findAddressFields(t,n(this))});t.on("click",r.settings.geoRemoveSelector,function(){r.removeLocation(t)});t.on("keypress",r.settings.locationSelector,function(n){n.which===13&&(n.preventDefault(),r.findAddress(t))})})};var t=function(n,t){this.settings=n;this.geocoder=t};t.prototype.initializeMap=function(n,t){var r=this,u={zoom:14,center:t},f=n.find(this.settings.mapSelector),i=new google.maps.Map(f[0],u);return n.data("mapper-map",i),google.maps.event.addListener(i,"click",function(t){r.setLocation(n,t.latLng)}),i};t.prototype.getStartingLatLng=function(t){var i=(t.find(this.settings.locationSelector).val()||"").split(",");return i.length===2?new google.maps.LatLng(n.trim(parseFloat(i[0])),parseFloat(n.trim(i[1]))):new google.maps.LatLng(49.4058667,-94.1154454)};t.prototype.getCurrentLocation=function(n){var t=this;navigator.geolocation?navigator.geolocation.getCurrentPosition(function(i){t.setLocation(n,new google.maps.LatLng(i.coords.latitude,i.coords.longitude))},function(){}):alert("Your browser does not support geolocation services.")};t.prototype.removeLocation=function(n){n.find(this.settings.mapSelector).addClass("hidden");this.setMarker(n,null);this.setField(n,null)};t.prototype.toggleMap=function(n){var t=n.find(this.settings.mapSelector);t.hasClass("hidden")?this.setLocation(n):t.addClass("hidden")};t.prototype.getMap=function(n){var t=n.data("mapper-map");return t||(t=this.initializeMap(n,this.getStartingLatLng(n))),t};t.prototype.setMarker=function(n,t){var i=n.data("mapper-marker");return i&&i.setMap(null),t&&(i=new google.maps.Marker({map:this.getMap(n),position:t}),n.data("mapper-marker",i)),i};t.prototype.findAddress=function(n){this.geocodeAddress(n,n.find(this.settings.locationSelector).val())};t.prototype.findAddressFields=function(t,i){for(var u=i.data("fields").split(","),f="",r=0;r