/*
 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
 */

window[esri._dojoScopeName||"dojo"]._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","esri.PopupBase"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["esri.PopupBase"]){_4._hasResource["esri.PopupBase"]=true;_4.provide("esri.PopupBase");_4.declare("esri.PopupBase",null,{onSetFeatures:function(){},onClearFeatures:function(){},onSelectionChange:function(){},onDfdComplete:function(){},initialize:function(){this.count=0;this.selectedIndex=-1;},cleanup:function(){this.features=this.deferreds=null;},setFeatures:function(_7){if(!_7||!_7.length){return;}this.clearFeatures();var _8,_9;if(_7[0] instanceof _4.Deferred){_9=_7;}else{_8=_7;}if(_8){this._updateFeatures(null,_8);}else{this.deferreds=_9;_9=_9.slice(0);_4.forEach(_9,function(_a){_a.addBoth(_4.hitch(this,this._updateFeatures,_a));},this);}},clearFeatures:function(){this.features=this.deferreds=null;this.count=0;var _b=this.selectedIndex;this.selectedIndex=-1;if(_b>-1){this.onSelectionChange();}this.onClearFeatures();},getSelectedFeature:function(){var _c=this.features;if(_c){return _c[this.selectedIndex];}},select:function(_d){if(_d<0||_d>=this.count){return;}this.selectedIndex=_d;this.onSelectionChange();},enableHighlight:function(_e){this._highlighted=_e.graphics.add(new esri.Graphic(new esri.geometry.Point(0,0,_e.spatialReference)));this._highlighted.hide();var _f=esri.symbol;if(!this.markerSymbol){var _10=(this.markerSymbol=new _f.SimpleMarkerSymbol());_10.setStyle(_f.SimpleMarkerSymbol.STYLE_TARGET);_10._setDim(16,16,7);_10.setOutline(new _f.CartographicLineSymbol(_f.SimpleLineSymbol.STYLE_SOLID,new _4.Color([0,255,255]),2,_f.CartographicLineSymbol.CAP_ROUND,_f.CartographicLineSymbol.JOIN_ROUND));_10.setColor(new _4.Color([0,0,0,0]));}if(!this.lineSymbol){this.lineSymbol=new _f.SimpleLineSymbol(_f.SimpleLineSymbol.STYLE_SOLID,new _4.Color([0,255,255]),2);}if(!this.fillSymbol){this.fillSymbol=new _f.SimpleFillSymbol(_f.SimpleFillSymbol.STYLE_NULL,new _f.SimpleLineSymbol(_f.SimpleLineSymbol.STYLE_SOLID,new _4.Color([0,255,255]),2),new _4.Color([0,0,0,0]));}},disableHighlight:function(map){var _11=this._highlighted;if(_11){_11.hide();map.graphics.remove(_11);delete this._highlighted;}this.markerSymbol=this.lineSymbol=this.fillSymbol=null;},showHighlight:function(){if(this._highlighted&&this.features&&this.features[this.selectedIndex]){this._highlighted.show();}},hideHighlight:function(){if(this._highlighted){this._highlighted.hide();}},updateHighlight:function(map,_12){var _13=_12.geometry,_14=this._highlighted;if(!_13||!_14){return;}_14.hide();if(!_14.getLayer()&&map){map.graphics.add(_14);}_14.setGeometry(esri.geometry.fromJson(_13.toJson()));var _15;switch(_13.type){case "point":case "multipoint":_15=this.markerSymbol;_15.setOffset(0,0);_15.setAngle(0);var lyr=_12.getLayer();if(lyr){var _16=lyr._getSymbol(_12),_17,_18,_19=0,_1a=0,_1b=0;if(_16){switch(_16.type){case "simplemarkersymbol":_17=_18=(_16.size||0);break;case "picturemarkersymbol":_17=(_16.width||0);_18=(_16.height||0);break;}_19=_16.xoffset||0;_1a=_16.yoffset||0;_1b=_16.angle||0;}if(_17&&_18){_15._setDim(_17+1,_18+1,7);}_15.setOffset(_19,_1a);_15.setAngle(_1b);}break;case "polyline":_15=this.lineSymbol;break;case "polygon":_15=this.fillSymbol;break;}_14.setSymbol(_15);},_unbind:function(dfd){var _1c=_4.indexOf(this.deferreds,dfd);if(_1c===-1){return;}this.deferreds.splice(_1c,1);if(!this.deferreds.length){this.deferreds=null;return 2;}return 1;},_updateFeatures:function(dfd,_1d){if(dfd){if(this.deferreds){var res=this._unbind(dfd);if(!res){return;}if(_1d&&_1d instanceof Error){this.onDfdComplete(_1d);if(res===2){this.onSetFeatures();}return;}if(_1d&&_1d.length){if(!this.features){this.features=_1d;this.count=_1d.length;this.selectedIndex=0;this.onDfdComplete();if(res===2){this.onSetFeatures();}this.select(0);}else{var _1e=_4.filter(_1d,function(_1f){return _4.indexOf(this.features,_1f)===-1;},this);this.features=this.features.concat(_1e);this.count=this.features.length;this.onDfdComplete();if(res===2){this.onSetFeatures();}}}else{this.onDfdComplete();if(res===2){this.onSetFeatures();}}}}else{this.features=_1d;this.count=_1d.length;this.selectedIndex=0;this.onSetFeatures();this.select(0);}}});_4.declare("esri.PopupInfoTemplate",[esri.InfoTemplate],{"-chains-":{constructor:"manual"},initialize:function(_20){if(!_20){return;}this.info=_20;this.title=this.getTitle;this.content=this.getContent;var _21=(this._fieldLabels={}),_22=(this._fieldsMap={});if(_20.fieldInfos){_4.forEach(_20.fieldInfos,function(_23){_21[_23.fieldName]=_23.label;_22[_23.fieldName]=_23;});}},toJson:function(){return _4.fromJson(_4.toJson(this.info));},getTitle:function(){},getContent:function(){},getComponents:function(_24){var _25=this.info,_26=_24.getLayer(),_27=_4.clone(_24.attributes)||{},_28=_4.clone(_27),_29=_25.fieldInfos,_2a="",_2b="",_2c,_2d,_2e,_2f=_26&&_26._getDateOpts&&_26._getDateOpts().properties,_30={dateFormat:{properties:_2f,formatter:"DateFormat"+this._dateFormats["shortDateShortTime"]}};if(_29){_4.forEach(_29,function(_31){var _32=_31.fieldName,val=_28[_32];_28[_32]=this._formatValue(val,_32,_30);if(_2f&&_31.format&&_31.format.dateFormat){var pos=_4.indexOf(_2f,_32);if(pos>-1){_2f.splice(pos,1);}}},this);}if(_26){var _33=_26.types,_34=_26.typeIdField,_35=_34&&_27[_34];for(_2d in _27){_2e=_27[_2d];if(esri._isDefined(_2e)){var _36=this._getDomainName(_26,_33,_35,_2d,_2e);if(esri._isDefined(_36)){_28[_2d]=_36;}else{if(_2d===_34){var _37=this._getTypeName(_26,_2e);if(esri._isDefined(_37)){_28[_2d]=_37;}}}}}}if(_25.title){_2a=_4.trim(esri.substitute(_28,this._fixTokens(_25.title),_30)||"");}if(_25.description){_2b=_4.trim(esri.substitute(_28,this._fixTokens(_25.description),_30)||"");}if(_29){_2c=[];_4.forEach(_29,function(_38){_2d=_38.fieldName;if(_2d&&_38.visible){_2c.push([_38.label||_2d,esri.substitute(_28,"${"+_2d+"}",_30)||""]);}});}var _39,_3a;if(_25.mediaInfos){_39=[];_4.forEach(_25.mediaInfos,function(_3b){_3a=0;_2e=_3b.value;switch(_3b.type){case "image":var url=_2e.sourceURL;url=url&&_4.trim(esri.substitute(_27,this._fixTokens(url)));_3a=!!url;break;case "piechart":case "linechart":case "columnchart":case "barchart":_3a=_4.some(_2e.fields,function(_3c){return esri._isDefined(_27[_3c]);});break;default:return;}if(_3a){_3b=_4.clone(_3b);_2e=_3b.value;_3b.title=_3b.title?_4.trim(esri.substitute(_28,this._fixTokens(_3b.title),_30)||""):"";_3b.caption=_3b.caption?_4.trim(esri.substitute(_28,this._fixTokens(_3b.caption),_30)||""):"";if(_3b.type==="image"){_2e.sourceURL=esri.substitute(_27,this._fixTokens(_2e.sourceURL));if(_2e.linkURL){_2e.linkURL=_4.trim(esri.substitute(_27,this._fixTokens(_2e.linkURL))||"");}}else{var _3d=_27[_2e.normalizeField]||0;_2e.fields=_4.map(_2e.fields,function(_3e){var _3f=_27[_3e];_3f=(_3f===undefined)?null:_3f;if(_3f&&_3d){_3f=_3f/_3d;}return {y:_3f,tooltip:(this._fieldLabels[_3e]||_3e)+":<br/>"+this._formatValue(_3f,_3e,_30)};},this);}_39.push(_3b);}},this);}return {title:_2a,description:_2b,fields:(_2c&&_2c.length)?_2c:null,mediaInfos:(_39&&_39.length)?_39:null,formatted:_28,editSummary:(_26&&_26.getEditSummary)?_26.getEditSummary(_24):""};},getAttachments:function(_40){var _41=_40.getLayer(),_42=_40.attributes;if(this.info.showAttachments&&_41&&_41.hasAttachments&&_41.objectIdField){var oid=_42&&_42[_41.objectIdField];if(oid){return _41.queryAttachmentInfos(oid);}}},_dateFormats:{"shortDate":"(datePattern: 'M/d/y', selector: 'date')","longMonthDayYear":"(datePattern: 'MMMM d, y', selector: 'date')","dayShortMonthYear":"(datePattern: 'd MMM y', selector: 'date')","longDate":"(datePattern: 'EEEE, MMMM d, y', selector: 'date')","shortDateShortTime":"(datePattern: 'M/d/y', timePattern: 'h:mm a', selector: 'date and time')","shortDateShortTime24":"(datePattern: 'M/d/y', timePattern: 'H:mm', selector: 'date and time')","longMonthYear":"(datePattern: 'MMMM y', selector: 'date')","shortMonthYear":"(datePattern: 'MMM y', selector: 'date')","year":"(datePattern: 'y', selector: 'date')"},_fixTokens:function(_43){return _43.replace(/(\{[^\{\r\n]+\})/g,"$$$1");},_formatValue:function(val,_44,_45){var _46=this._fieldsMap[_44],fmt=_46&&_46.format;if(!esri._isDefined(val)||!_46||!esri._isDefined(fmt)){return val;}var _47="",_48=[],_49=fmt.hasOwnProperty("places")||fmt.hasOwnProperty("digitSeparator"),_4a=fmt.hasOwnProperty("digitSeparator")?fmt.digitSeparator:true;if(_49){_47="NumberFormat";_48.push("places: "+(esri._isDefined(fmt.places)?Number(fmt.places):"Infinity"));if(_48.length){_47+=("("+_48.join(",")+")");}}else{if(fmt.dateFormat){_47="DateFormat"+(this._dateFormats[fmt.dateFormat]||this._dateFormats["shortDateShortTime"]);}else{return val;}}var _4b=esri.substitute({"myKey":val},"${myKey:"+_47+"}",_45)||"";if(_49&&!_4a){var _4c=_4.i18n.getLocalization("dojo.cldr","number");if(_4c.group){_4b=_4b.replace(new RegExp("\\"+_4c.group,"g"),"");}}return _4b;},_getDomainName:function(_4d,_4e,_4f,_50,_51){var _52,_53;if(_4e&&esri._isDefined(_4f)){_4.some(_4e,function(_54){if(_54.id==_4f){_52=_54.domains&&_54.domains[_50];if(_52&&_52.type==="inherited"){_52=this._getLayerDomain(_4d,_50);_53=true;}return true;}return false;},this);}if(!_53&&!_52){_52=this._getLayerDomain(_4d,_50);}if(_52&&_52.codedValues){var _55;_4.some(_52.codedValues,function(_56){if(_56.code==_51){_55=_56.name;return true;}return false;});return _55;}},_getLayerDomain:function(_57,_58){var _59=_57.fields;if(_59){var _5a;_4.some(_59,function(_5b){if(_5b.name===_58){_5a=_5b.domain;return true;}return false;});return _5a;}},_getTypeName:function(_5c,id){var _5d=_5c.types;if(_5d){var _5e;_4.some(_5d,function(_5f){if(_5f.id==id){_5e=_5f.name;return true;}return false;});return _5e;}}});}}};});