/*
 COPYRIGHT 2009 ESRI

 TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
 Unpublished material - all rights reserved under the
 Copyright Laws of the United States and applicable international
 laws, treaties, and conventions.

 For additional information, contact:
 Environmental Systems Research Institute, Inc.
 Attn: Contracts and Legal Services Department
 380 New York Street
 Redlands, California, 92373
 USA

 email: contracts@esri.com
 */

if(!dojo._hasResource["esri.tasks.locator"]){dojo._hasResource["esri.tasks.locator"]=true;dojo.provide("esri.tasks.locator");dojo.require("esri.tasks._task");dojo.declare("esri.tasks.Locator",esri.tasks._Task,{constructor:function(_1){this._geocodeHandler=dojo.hitch(this,this._geocodeHandler);this._reverseGeocodeHandler=dojo.hitch(this,this._reverseGeocodeHandler);},outSpatialReference:null,setOutSpatialReference:function(sr){this.outSpatialReference=sr;},_geocodeHandler:function(_2,io,_3,_4,_5){try{var _6=_2.candidates,_7,_8=[],i,il=_6.length,sr=_2.spatialReference;for(i=0;i<il;i++){_7=_6[i];_8[i]=new esri.tasks.AddressCandidate(_7);var _9=_8[i].location;if(sr&&_9&&!_9.spatialReference){_9.setSpatialReference(new esri.SpatialReference(sr));}}this._successHandler([_8],"onAddressToLocationsComplete",_3,_5);}catch(err){this._errorHandler(err,_4,_5);}},addressToLocations:function(_a,_b,_c,_d,_e){if(_a.address){_d=_c;_c=_b;_b=_a.outFields;_e=_a.searchExtent;_a=_a.address;}var _f=this.outSpatialReference;var _10=this._encode(dojo.mixin({},this._url.query,_a,{f:"json",outSR:_f&&dojo.toJson(_f.toJson()),outFields:(_b&&_b.join(","))||null,searchExtent:_e&&dojo.toJson(_e.toJson())})),_11=this._geocodeHandler,_12=this._errorHandler;var dfd=new dojo.Deferred(esri._dfdCanceller);dfd._pendingDfd=esri.request({url:this._url.path+"/findAddressCandidates",content:_10,callbackParamName:"callback",load:function(r,i){_11(r,i,_c,_d,dfd);},error:function(r){_12(r,_d,dfd);}});return dfd;},_reverseGeocodeHandler:function(_13,io,_14,_15,dfd){try{var _16=new esri.tasks.AddressCandidate({address:_13.address,location:_13.location,score:100});this._successHandler([_16],"onLocationToAddressComplete",_14,dfd);}catch(err){this._errorHandler(err,_15,dfd);}},locationToAddress:function(_17,_18,_19,_1a){if(_17&&this.normalization){_17=_17.normalize();}var _1b=this.outSpatialReference;var _1c=this._encode(dojo.mixin({},this._url.query,{outSR:_1b&&dojo.toJson(_1b.toJson()),location:_17&&dojo.toJson(_17.toJson()),distance:_18,f:"json"})),_1d=this._reverseGeocodeHandler,_1e=this._errorHandler;var dfd=new dojo.Deferred(esri._dfdCanceller);dfd._pendingDfd=esri.request({url:this._url.path+"/reverseGeocode",content:_1c,callbackParamName:"callback",load:function(r,i){_1d(r,i,_19,_1a,dfd);},error:function(r){_1e(r,_1a,dfd);}});return dfd;},onAddressToLocationsComplete:function(){},onLocationToAddressComplete:function(){}});dojo.declare("esri.tasks.AddressCandidate",null,{constructor:function(_1f){dojo.mixin(this,_1f);this.location=new esri.geometry.Point(this.location);}});}