"mololo.map".namespace();
mololo.map.GeoCoderVO=Class.create({locations:null,states:null,subcategories:null,city:null,street:null,buildingNr:null,onlyCityMandatory:null,initialize:function(C,G,B,E,A,F,D){this.locations=$(F);
this.states=$(C);
this.city=$(G);
this.street=$(B);
this.buildingNr=$(E);
this.maincategories=$(A);
this.onlyCityMandatory=D
},getStates:function(){return this.states
},getCity:function(){return this.city
},getStreet:function(){return this.street
},getBuildingNr:function(){return this.buildingNr
},getLocations:function(){return this.locations
},getMainCategories:function(){return this.maincategories
},toAddress:function(){var A=this.states==null?"":this.states.value;
var C=this.street==null?"":this.street.value;
var B=this.buildingNr==null?"":this.buildingNr.value;
return"Polska, "+A+" "+this.city.value+" "+C+" "+B
},getOnlyCityMandatory:function(){return this.getOnlyCityMandatory
}});
mololo.map.GeoCoderUtils={geocoder:new google.maps.ClientGeocoder(),multiResults:false,_clearLocations:function(B){B.getLocations().style.display="none";
for(var A=B.getLocations().options.length;
A>0;
A--){B.getLocations().remove(A-1)
}},_validate:function(A){if(A.getCity().value==""||(!A.getOnlyCityMandatory()&&A.getStates().value=="-1")){mololo.WindowUtils.alert(mololo.msg.noCityNorStateEntered);
return false
}return true
},_isResponseEmpty:function(A){return A.Placemark==null||A.Placemark.length==0
},_isSingleResult:function(A){return A.Placemark!=null&&A.Placemark.length==1
},_createLatLng:function(A){return new google.maps.LatLng(A.Point.coordinates[1],A.Point.coordinates[0])
},_sendEvent:function(A,B){mololo.globals.DISPATCHER.sendEvent(A,B)
},_assignResults:function(E,F,B,D,G,A,C){$(B).value=E.lat().toString();
$(D).value=E.lng().toString();
$(G).value=F;
$(C).value=A
},geocode:function(B,O,H,G,E,I,Q,N,J,M,L,P,A,C){var D=new mololo.map.GeoCoderVO(O,H,G,E,I,Q,C);
var K=this;
K.multiResults=false;
this.locations=[];
var F=this.locations;
if(K._validate(D)){K._clearLocations(D);
K.geocoder.getLocations(D.toAddress(),function(S){if(K._isSingleResult(S)){if(K.allDataDefined(S.Placemark[0])){var X=K._createLatLng(S.Placemark[0]);
var T=K.parseCityName(S.Placemark[0]);
var W=K.parseCityFullName(S.Placemark[0]);
K._assignResults(X,W,N,J,M,T,P);
var V=D.getMainCategories()!=null?D.getMainCategories().value:null;
K._sendEvent(B,new mololo.map.LocalizeEvent(true,true,X,V,A))
}else{mololo.WindowUtils.alert(mololo.msg.noCityResultsFound)
}}else{if(!K._isResponseEmpty(S)){var U=D.getLocations().options;
U[0]=new Option(mololo.msg.selectOne);
S.Placemark.forEach(function(Y){if(K.allDataDefined(Y)){F[U.length]=Y;
U[U.length]=new Option(Y.address,mololo.map.MapUtils.latlng2String(K._createLatLng(Y)))
}});
if(U.length>1){K.multiResults=true;
D.getLocations().style.display="inline";
if(L!=null){var R=$(L);
if(R!=null){R.style.display="inline"
}}}else{U=null;
mololo.WindowUtils.alert(mololo.msg.noCityResultsFound)
}}else{mololo.WindowUtils.alert(mololo.msg.noCityResultsFound)
}}})
}return K.multiResults
},allDataDefined:function(A){if(A.AddressDetails!=undefined&&A.AddressDetails.Country!=undefined&&A.AddressDetails.Country.AdministrativeArea!=undefined&&A.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea!=undefined&&A.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality!=undefined){return true
}return false
},parseCityName:function(A){return A.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName
},parseCityFullName:function(A){return A.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName+" "+A.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName+" "+A.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName
},sendEvent:function(A){var C=A.getLocationsIds();
var B=this.locations[C.selectedIndex];
var D=mololo.map.MapUtils.parseLatLng(C.value);
this._assignResults(D,this.parseCityFullName(B),A.getGeoLatId(),A.getGeoLngId(),A.getGeoFullNameId(),this.parseCityName(B),A.getGeoCityNameId());
this._sendEvent(A.getAction(),new mololo.map.LocalizeEvent(A.getClearMarkers(),A.getSuspendMarkerSearch(),mololo.map.MapUtils.parseLatLng(C.value),A.getMainCategoryCode(),A.getPermanent()));
C.hide()
}};
mololo.map.GeoCoderEvent=Class.create({action:null,clearMarkers:null,suspendMarkerSearch:null,locationsIds:null,geoLatId:null,geoLngId:null,geoFullNameId:null,geoCityNameId:null,permanent:null,mainCategoryCode:null,initialize:function(B,D,H,I,E,G,J,A,C,F){this.action=B;
this.mainCategoryCode=$(D)!=undefined?$(D).value:null;
this.locationsIds=$(H);
this.geoLatId=I;
this.geoLngId=E;
this.geoFullNameId=G;
this.geoCityNameId=J;
this.permanent=A;
this.clearMarkers=C;
this.suspendMarkerSearch=F
},getAction:function(){return this.action
},getLocationsIds:function(){return this.locationsIds
},getGeoLatId:function(){return this.geoLatId
},getGeoLngId:function(){return this.geoLngId
},getGeoFullNameId:function(){return this.geoFullNameId
},getGeoCityNameId:function(){return this.geoCityNameId
},getPermanent:function(){return this.permanent
},getClearMarkers:function(){return this.clearMarkers
},getSuspendMarkerSearch:function(){return this.suspendMarkerSearch
},getMainCategoryCode:function(){return this.mainCategoryCode
}});