var ggMaps;var ggMapsIcon;var ggMaps_geo;var ggMaps_smallMapControl;var ggMaps_extLargeMapControl;var initMarker=null;var initMarker_latlng=null;var defLat;function ggMaps_register(){this.initialize=function(){window.eval('ggMaps_registerController = this;');ggMaps=new GMap2(document.getElementById("ggMapsContainer"));defLat=new GLatLng(def_lat,def_lon);ggMaps.setCenter(defLat,12);ggMaps_smallMapControl=new GSmallMapControl();ggMaps_extLargeMapControl=new ExtLargeMapControl();ggMaps.addControl(ggMaps_smallMapControl);ggMaps.hideControls();GEvent.addListener(ggMaps,"mouseover",function(){ggMaps.showControls();handleMap=ggMaps;GEvent.addDomListener(ggMaps.getContainer(),"DOMMouseScroll",wheel);ggMaps.getContainer().onmousewheel=wheel;});GEvent.addListener(ggMaps,"mouseout",function(){ggMaps.hideControls();handleMap=null;GEvent.addDomListener(ggMaps.getContainer(),"DOMMouseScroll",function(){});ggMaps.getContainer().onmousewheel=void(0);});ggMaps.enableContinuousZoom();ggMaps.enableDoubleClickZoom();ggMaps.enableScrollWheelZoom();ggMaps.getContainer().style.overflow="hidden";ggMapsIcon=new GIcon();ggMapsIcon.image=base_url+'application/images/googlemap/icon_blue.png';ggMapsIcon.shadow=base_url+'application/images/googlemap/icon_shadow.png';ggMapsIcon.iconSize=new GSize(24,30);ggMapsIcon.iconAnchor=new GPoint(3,30);ggMapsIcon.shadowSize=new GSize(40.0,30.0);ggMapsIcon.infoWindowAnchor=new GPoint(12.0,15.0);GEvent.addListener(ggMaps,"click",ggMaps_registerController.addpoint);if(g_admaps_latlon!=null){window.eval('this_g_admaps_latlon = new GLatLng('+g_admaps_latlon[0]+','+g_admaps_latlon[1]+');');this.addpoint(null,this_g_admaps_latlon);ggMaps.setCenter(this_g_admaps_latlon,12);}
ggMaps_geo=new GClientGeocoder();};this.addpoint=function(overlay,latlng){if(latlng){if(initMarker!=null){ggMaps.removeOverlay(initMarker);}
var marker=new GMarker(latlng,{icon:ggMapsIcon,draggable:true});document.getElementById("user_location_ggmaps").value=marker.getPoint().toUrlValue();ggMaps.addOverlay(marker);marker.enableDragging();GEvent.addListener(marker,"dragend",function(){document.getElementById("user_location_ggmaps").value=marker.getPoint().toUrlValue();ggMaps.panTo(marker.getPoint());initMarker_latlng=marker.getPoint();});initMarker=marker;initMarker_latlng=latlng;}}
this.place=function(lat,lng){var point=new GLatLng(lat,lng);ggMaps.setCenter(point,12);this.addpoint(null,point);};this.showAddress=function(){var city=$("#city").val();var country=$("#country").val();var search=city+', '+country;if(city!=''&&country!=''){ggMaps_geo.getLocations(search,function(result){ggMaps.clearOverlays();if(result.Status.code==G_GEO_SUCCESS){if(result.Placemark.length>1){}
else{var p=result.Placemark[0].Point.coordinates;ggMaps_registerController.place(p[1],p[0]);}}
else{var reason="Code "+result.Status.code;if(ggBigMaps_reasons[result.Status.code]){reason=ggBigMaps_reasons[result.Status.code]}}});}};this.expandMap=function(){$("#ggMapsContainer").animate({height:"400px"},500,function(){var center=ggMaps.getCenter();if(initMarker_latlng!=null){center=initMarker_latlng;}
ggMaps.checkResize();ggMaps.panTo(center);ggMaps.removeControl(ggMaps_smallMapControl);ggMaps.addControl(ggMaps_extLargeMapControl);$("#ggMaps_registerBtnExpand").fadeOut("fast",function(){$("#ggMaps_registerBtnReduce").fadeIn();});$("#ggMaps_registerBtnExpand2").fadeOut("fast",function(){$("#ggMaps_registerBtnReduce2").fadeIn();});});}
this.reduceMap=function(){$("#ggMapsContainer").animate({height:"145px"},500,function(){var center=ggMaps.getCenter();if(initMarker_latlng!=null){center=initMarker_latlng;}
ggMaps.checkResize();ggMaps.panTo(center);ggMaps.removeControl(ggMaps_extLargeMapControl);ggMaps.addControl(ggMaps_smallMapControl);$("#ggMaps_registerBtnReduce").fadeOut("fast",function(){$("#ggMaps_registerBtnExpand").fadeIn();});$("#ggMaps_registerBtnReduce2").fadeOut("fast",function(){$("#ggMaps_registerBtnExpand2").fadeIn();});});}}
$(document).ready(function(){var register=new ggMaps_register();register.initialize();});