jQuery(function(s){s(".nr_gmap").each(function(){el=s(this),function(o){var e,t,a=o.attr("id"),i=o.val();i=i.length?i.split(","):o.data("coordinates").split(","),e=new google.maps.Map(document.getElementById(a+"_map"),{center:{lat:parseFloat(i[0]),lng:parseFloat(i[1])},zoom:o.data("zoom")}),i.length&&(t=new google.maps.Marker({position:{lat:parseFloat(i[0]),lng:parseFloat(i[1])},map:e}));e.addListener("click",function(n){r(n.latLng,e)}),s(document).on("click",'a[href="#attrib-brand"]',function(n){l()}),showOn=o.closest(".control-group").data("showon"),void 0!==showOn&&s('input[name="'+showOn[0].field+'"]').change(function(){l()});function l(){var n=e.getCenter();google.maps.event.trigger(e,"resize"),e.setCenter(n)}function r(n){void 0===t&&(t=new google.maps.Marker({position:n,map:e})),t.setPosition(n),function(n){s("#"+a).val(n.lat()+","+n.lng())}(n)}s(document).on("blur","#"+a,function(n){!function(n){return new RegExp(/^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/).test(n)}(o.val())?(alert(Joomla.JText.strings.NR_WRONG_COORDINATES),o.val(i.join(","))):(newCoordinates=o.val().split(","),newCoordinates=new google.maps.LatLng({lat:parseFloat(newCoordinates[0]),lng:parseFloat(newCoordinates[1])}),r(newCoordinates),e.panTo(newCoordinates))})}(el)})});

