/*
 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
 */
//>>built
require({cache:{"url:esri/dijit/analysis/templates/CreateDriveTimeAreas.html":"<div class=\"esriAnalysis\">\r\n    <div data-dojo-type=\"dijit/layout/ContentPane\" style=\"margin-top:0.5em; margin-bottom: 0.5em;\">\r\n      <div data-dojo-attach-point=\"_hotspotsToolContentTitle\" class=\"analysisTitle\">\r\n         <table class=\"esriFormTable\" >\r\n            <tr>\r\n              <td class=\"esriToolIconTd\"><div class=\"driveIcon\"></div></td>\r\n              <td class=\"esriAlignLeading\">${i18n.createDriveTimeAreas}</td>\r\n              <td>\r\n                <div class=\"esriFloatTrailing\" style=\"padding:0;\">\r\n                  <a href=\"#\" class='esriFloatLeading helpIcon' esriHelpTopic=\"toolDescription\"></a>\r\n                  <a href=\"#\" data-dojo-attach-point=\"_closeBtn\" title=\"${i18n.close}\" class=\"closeIcon\">              \r\n                  <img data-dojo-attach-point=\"_closeImg\" border=\"0\"/></a>\r\n                </div>\r\n              </td>\r\n            </tr>\r\n         </table>\r\n      </div>\r\n      <div style=\"clear:both; border-bottom: #333 thin solid; height:1px;width:100%;\"></div>\r\n    </div>\r\n    <div data-dojo-type=\"dijit/form/Form\" data-dojo-attach-point=\"_form\" readOnly=\"true\">\r\n     <table class=\"esriFormTable\"  data-dojo-attach-point=\"_driveTimesTable\">\r\n       <tbody>\r\n        <tr>\r\n          <td colspan=\"3\" class=\"sectionHeader\" data-dojo-attach-point=\"_driveTimeDescription\" ></td>\r\n        </tr>\r\n        <tr>\r\n          <td colspan=\"2\">\r\n            <label data-dojo-attach-point=\"_labelOne\" class=\"esriFloatLeading esriTrailingMargin025 \">${i18n.oneLabel}</label>\r\n            <label data-dojo-attach-point=\"_measurelabel\" class=\"\">${i18n.measureLabel}</label>\r\n          </td>\r\n          <td class=\"shortTextInput\">\r\n            <a href=\"#\" class='esriFloatTrailing helpIcon' data-dojo-attach-point=\"_analysisFieldHelpLink\" esriHelpTopic=\"MeasurementMethodTypicalTraffic\"></a>\r\n          </td>\r\n        </tr>\r\n        <tr>\r\n          <td style=\"padding:0.25em;width:50%\">\r\n            <div class=\"esriLeadingMargin4 bufferSelector selected\" data-dojo-attach-point=\"_drivingTime\" >\r\n              <div class=\"bufferIcon esriDrivingTimeIcon\"></div>\r\n              <div><label class=\"esriFloatLeading esriSelectLabel\">${i18n.drivingTime}</label></div>\r\n            </div>\r\n          </td>\r\n          <td style=\"padding:0.25em;width:50%\">\r\n            <div class=\"bufferSelector\" data-dojo-attach-point=\"_drivingDistance\">\r\n              <div class=\"bufferIcon esriDrivingDistanceIcon\"></div>\r\n              <div><label class=\"esriFloatLeading esriTrailingMargin2 esriSelectLabel\">${i18n.drivingDistance}</label></div>\r\n            </div>\r\n          </td>\r\n          <td></td>\r\n        </tr>\r\n        <tr>\r\n          <td style=\"padding-right:0;padding-bottom:0;width:20%;\">\r\n            <input type=\"text\" data-dojo-type=\"dijit/form/ValidationTextBox\" data-dojo-attach-event=\"onChange:_handleDistUnitsChange\" data-dojo-props=\"intermediateChanges:true,value:'5',required:true,missingMessage:'${i18n.distanceMsg}'\" data-dojo-attach-point=\"_breakValuesInput\" class=\"esriLeadingMargin2\"  style=\"width:75%;\">\r\n          </td>\r\n          <td colspan=\"2\" style=\"padding-left:0.25em;padding-bottom:0;width:60%;\">\r\n            <select class=\"mediumInput esriAnalysisSelect\" data-dojo-type=\"dijit/form/Select\" data-dojo-attach-event=\"onChange:_handleDistUnitsChange\" data-dojo-attach-point=\"_distanceUnitsSelect\" style=\"width:95%;table-layout:fixed;\">\r\n              <option value=\"Seconds\">${i18n.seconds}</option>\r\n              <option value=\"Minutes\" selected=\"selected\">${i18n.minutes}</option>\r\n              <option value=\"Hours\">${i18n.hours}</option>\r\n            </select>\r\n          </td>\r\n        </tr>\r\n        <tr>\r\n          <td style=\"padding:0\" colspan=\"3\">\r\n            <div class=\"esriLeadingMargin3\">\r\n              <label class=\"esriSmallLabel\">${i18n.measureHelp}</label>\r\n            </div>\r\n          </td>\r\n        </tr>\r\n        <tr>\r\n          <td style=\"padding:0\" colspan=\"3\">\r\n            <div style=\"width;100%\" data-dojo-type=\"esri/dijit/analysis/TrafficTime\" data-dojo-attach-point=\"_trafficTimeWidget\"></div>\r\n          </td>\r\n        </tr>\r\n        <tr>\r\n          <td colspan=\"2\">\r\n            <label data-dojo-attach-point=\"_labelTwo\" class=\"esriFloatLeading esriTrailingMargin025 \">2.</label>\r\n            <label data-dojo-attach-point=\"_arealabel\" class=\"\">${i18n.areaLabel}</label>\r\n          </td>\r\n          <td class=\"longTextInput\">\r\n            <a href=\"#\" class='esriFloatTrailing helpIcon' data-dojo-attach-point=\"_analysisFieldHelpLink\" esriHelpTopic=\"DissolveType\"></a>\r\n          </td>\r\n        </tr>\r\n        <tr>\r\n          <td style=\"padding-top:0;padding-bottom:0;\" colspan=\"3\">\r\n            <table style=\"width:100%;padding:0.25em;\">\r\n              <tr>\r\n                <td style=\"padding-top:0;\">\r\n                  <div style=\"width:36px\" class=\"bufferSelector selected\" data-dojo-attach-point=\"_Overlap\">\r\n                    <div class=\"bufferIcon bufferOverlapIcon\" style=\"margin:5px 10px\"></div>\r\n                    <div style=\"width:100%\"><label class=\"esriLeadingMargin025  esriSelectLabel\">${i18n.overlap}</label></div>\r\n                  </div>\r\n                </td>\r\n                <td style=\"padding-top:0;\">\r\n                  <div style=\"width:36px\" class=\"bufferSelector\" data-dojo-attach-point=\"_Dissolve\">\r\n                  <div class=\"bufferIcon bufferDissolveIcon\" style=\"margin:5px 10px\"></div>\r\n                  <div style=\"width:100%\"><label class=\"esriLeadingMargin025  esriSelectLabel\">${i18n.dissolve}</label></div>\r\n                  </div>\r\n                </td>\r\n                <td style=\"padding-top:0;\">\r\n                 <div style=\"width:36px\" class=\"bufferSelector\" data-dojo-attach-point=\"_Split\">\r\n                   <div class=\"bufferIcon esriAnalysisSplitIcon\" style=\"margin:5px 10px\"></div>\r\n                   <div style=\"width:100%\"><label class=\"esriLeadingMargin1  esriSelectLabel\">${i18n.split}</label></div>\r\n                 </div>\r\n                </td>        \r\n              </tr>\r\n            </table>\r\n          </td>\r\n        </tr>\r\n\r\n        <tr>\r\n          <td colspan=\"2\">\r\n            <label data-dojo-attach-point=\"_labelThree\" class=\"esriFloatLeading esriTrailingMargin025 \">${i18n.threeLabel}</label>\r\n            <label data-dojo-attach-point=\"_resultlabel\" class=\"\">${i18n.resultLabel}</label>\r\n          </td>\r\n          <td class=\"longTextInput\">\r\n            <a href=\"#\" class='esriFloatTrailing helpIcon' data-dojo-attach-point=\"_analysisFieldHelpLink\" esriHelpTopic=\"OutputLayer\"></a>\r\n          </td>\r\n        </tr>\r\n        <tr>\r\n          <td class=\"shortTextInput\" colspan=\"3\">\r\n            <input type=\"text\" data-dojo-type=\"dijit/form/ValidationTextBox\" class=\"esriLeadingMargin1 esriOutputText\" data-dojo-props=\"required:true\" data-dojo-attach-event=\"_handleResultLyrInputChange\" data-dojo-attach-point=\"outputLayerInput\"  value=\"\">\r\n          </td>\r\n        </tr>\r\n        <tr>\r\n          <td colspan=\"3\">\r\n             <div class=\"esriLeadingMargin1\" data-dojo-attach-point=\"_chooseFolderRow\">\r\n               <label style=\"width:9px;font-size:smaller;\">${i18n.saveResultIn}</label>\r\n               <input class=\"longInput\" dojoAttachPoint=\"_webMapFolderSelect\" dojotype=\"dijit/form/ComboBox\" trim=\"true\" style=\"width:60%;height:auto\"></input>\r\n             </div>              \r\n          </td>\r\n        </tr>      \r\n       </tbody>\r\n      </table>\r\n    </div>\r\n    <div data-dojo-attach-point=\"_aggregateToolContentButtons\" style=\"padding:5px;margin-top:5px;border-top:solid 1px #BBB;\">\r\n      <div style=\"width:100%;padding:0.5em 0 0.5em 0\">\r\n        <a class=\"esriFloatTrailing esriSmallFont\"  href=\"#\" data-dojo-attach-point=\"_showCreditsLink\" data-dojo-attach-event=\"onclick:_handleShowCreditsClick\">${i18n.showCredits}</a>\r\n       <label data-dojo-attach-point=\"_chooseExtentDiv\"class=\"esriSelectLabel\" style=\"font-size:smaller;\">\r\n         <input type=\"radio\" data-dojo-attach-point=\"_useExtentCheck\" data-dojo-type=\"dijit/form/CheckBox\" data-dojo-props=\"checked:true\" name=\"extent\" value=\"true\"/>\r\n           ${i18n.useMapExtent}\r\n       </label>\r\n      </div>\r\n      <button data-dojo-type=\"dijit/form/Button\" type=\"submit\" data-dojo-attach-point=\"_saveBtn\" class=\"esriLeadingMargin4\" data-dojo-attach-event=\"onClick:_handleSaveBtnClick\">\r\n          ${i18n.runAnalysis}\r\n      </button>\r\n    </div>\r\n    <div data-dojo-type=\"dijit/Dialog\" title=\"${i18n.creditTitle}\" data-dojo-attach-point=\"_usageDialog\" style=\"width:40em;\">\r\n      <div data-dojo-type=\"esri/dijit/analysis/CreditEstimator\"  data-dojo-attach-point=\"_usageForm\"></div>\r\n    </div>    \r\n</div>\r\n"}});define("esri/dijit/analysis/CreateDriveTimeAreas",["require","dojo/_base/declare","dojo/_base/lang","dojo/_base/array","dojo/_base/connect","dojo/_base/json","dojo/has","dojo/i18n","dojo/json","dojo/string","dojo/dom-style","dojo/dom-attr","dojo/dom-construct","dojo/query","dojo/dom-class","dojo/number","dijit/_WidgetBase","dijit/_TemplatedMixin","dijit/_WidgetsInTemplateMixin","dijit/_OnDijitClickMixin","dijit/_FocusMixin","dijit/registry","dijit/form/Button","dijit/form/CheckBox","dijit/form/Form","dijit/form/Select","dijit/form/TextBox","dijit/form/ValidationTextBox","dijit/layout/ContentPane","dijit/form/ComboBox","esri/kernel","esri/dijit/analysis/AnalysisBase","esri/dijit/analysis/CreditEstimator","esri/dijit/analysis/utils","esri/dijit/analysis/TrafficTime","dojo/text!esri/dijit/analysis/templates/CreateDriveTimeAreas.html"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_1a,_1b,_1c,_1d,_1e,_1f,_20,_21,_22,_23,_24){var _25=_2([_11,_12,_13,_14,_15,_20],{declaredClass:"esri.dijit.analysis.CreateDriveTime",templateString:_24,basePath:_1.toUrl("esri/dijit/analysis"),widgetsInTemplate:true,inputLayer:null,inputType:null,outputLayerName:null,breakValues:null,showSelectFolder:false,showChooseExtent:true,overlapPolicy:"Overlap",showHelp:true,showCredits:true,i18n:null,toolName:"CreateDriveTimeAreas",helpFileName:"CreateDriveTimeAreas",resultParameter:"DriveTimeAreasLayer",constructor:function(_26,_27){this.inherited(arguments);this._pbConnects=[];if(_26.containerNode){this.container=_26.containerNode;}},destroy:function(){this.inherited(arguments);_4.forEach(this._pbConnects,_5.disconnect);delete this._pbConnects;},postMixInProperties:function(){this.inherited(arguments);_3.mixin(this.i18n,_8.getLocalization("esri","jsapi").bufferTool);_3.mixin(this.i18n,_8.getLocalization("esri","jsapi").driveTimes);},postCreate:function(){this.inherited(arguments);_f.add(this._form.domNode,"esriSimpleForm");_c.set(this._closeImg,"src",this.basePath+"/images/close.gif");this._breakValuesInput.set("validator",_3.hitch(this,this.validateDistance));this.outputLayerInput.set("validator",_3.hitch(this,this.validateServiceName));this.breakValues=[];this.breakValues.push(this._breakValuesInput.get("value"));this._buildUI();},startup:function(){},_onClose:function(_28){if(_28){this._save();this.onSave();}this.onClose();},_toUpperFirstLetter:function(str){return (str.slice(0,1).toUpperCase()+str.slice(1));},_handleShowCreditsClick:function(e){e.preventDefault();var _29={},_2a={};if(!this._form.validate()){return;}_29.InputLayer=_6.toJson(_22.constructAnalysisInputLyrObj(this.inputLayer));_29.BreakValues=_6.toJson(this.get("breakValues"));_29.Breakunits=this._distanceUnitsSelect.get("value");_29.OverlapPolicy=this.get("overlapPolicy");if(this._trafficTimeWidget.get("checked")){_29.TimeOfDay=this._trafficTimeWidget.get("timeOfDay");console.log(_29.TimeOfDay);}_29.OutputName=_6.toJson({serviceProperties:{name:this.outputLayerInput.get("value")}});if(this.showChooseExtent){if(this._useExtentCheck.get("checked")){_29.context=_6.toJson({extent:this.map.extent});}}this.getCreditsEstimate(this.toolName,_29).then(_3.hitch(this,function(_2b){this._usageForm.set("content",_2b);this._usageDialog.show();}));},_handleSaveBtnClick:function(e){var _2c={},_2d={};if(!this._form.validate()){return;}this._saveBtn.set("disabled",true);_2c.InputLayer=_6.toJson(_22.constructAnalysisInputLyrObj(this.inputLayer));_2c.BreakValues=this.get("breakValues");_2c.Breakunits=this._distanceUnitsSelect.get("value");_2c.OverlapPolicy=this.get("overlapPolicy");if(this._trafficTimeWidget.get("checked")){_2c.TimeOfDay=this._trafficTimeWidget.get("timeOfDay");console.log(_2c.TimeOfDay);}_2c.OutputName=_6.toJson({serviceProperties:{name:this.outputLayerInput.get("value")}});if(this.showChooseExtent){if(this._useExtentCheck.get("checked")){_2c.context=_6.toJson({extent:this.map.extent});}}_2d.jobParams=_2c;_2d.itemParams={"description":_a.substitute(this.i18n.itemDescription,{layername:this.inputLayer.name,distance_field:_2c.Distances||_2c.Field,units:_2c.Units}),"tags":_a.substitute(this.i18n.itemTags,{layername:this.inputLayer.name}),"snippet":this.i18n.itemSnippet};if(this.showSelectFolder){_2d.itemParams.folder=this._webMapFolderSelect.item?this.folderStore.getValue(this._webMapFolderSelect.item,"id"):"";}this.execute(_2d);},_handleResultLyrInputChange:function(_2e){this.set("outputLayerName",_2e);},_handleDistUnitsChange:function(_2f){this.set("outputLayerName");},_handleDistanceTypeChange:function(_30){_f.remove(this._drivingTime,"selected");_f.remove(this._drivingDistance,"selected");if(_30){_f.add((_30==="time")?this._drivingTime:this._drivingDistance,"selected");this._trafficTimeWidget.set("disabled",_30!=="time");this._trafficTimeWidget.set("reset",_30!=="time");}if(_30==="time"){this._distanceUnitsSelect.removeOption(this._distanceUnitsSelect.getOptions());this._distanceUnitsSelect.addOption([{value:"Seconds",label:this.i18n.seconds},{value:"Minutes",label:this.i18n.minutes,selected:"selected"},{value:"Hours",label:this.i18n.hours}]);}else{this._distanceUnitsSelect.removeOption(this._distanceUnitsSelect.getOptions());this._distanceUnitsSelect.addOption([{value:"Miles",label:this.i18n.miles},{value:"Yards",label:this.i18n.yards},{value:"Feet",label:this.i18n.feet},{type:"separator"},{value:"Kilometers",label:this.i18n.kilometers},{value:"Meters",label:this.i18n.meters}]);}this.set("outputLayerName");},_handleOverlapPolicyChange:function(_31,_32){this.set("overlapPolicy",_32);dojo.removeClass(this._Overlap,"selected");dojo.removeClass(this._Dissolve,"selected");dojo.removeClass(this._Split,"selected");dojo.addClass(_31,"selected");},_save:function(){},_buildUI:function(){this._loadConnections();_22.initHelpLinks(this.domNode,this.showHelp);dojo.attr(this._driveTimeDescription,"innerHTML",dojo.string.substitute(this.i18n.toolDefine,{layername:this.inputLayer.name}));this.set("outputLayerName");_b.set(this._chooseFolderRow,"display",this.showSelectFolder===true?"block":"none");if(this.showSelectFolder){this.getFolderStore().then(_3.hitch(this,function(_33){this.folderStore=_33;this._webMapFolderSelect.set("store",_33);this._webMapFolderSelect.set("value",this.portalUser.username);}));}_b.set(this._chooseExtentDiv,"display",this.showChooseExtent===true?"block":"none");},validateTime:function(){},validateDistance:function(){var _34=this,val,_35=[],_36;_36=_f.contains(this._drivingTime,"selected")?"time":"distance";this.set("breakValues");val=_3.trim(this._breakValuesInput.get("value")).split(" ");if(val.length===0){return false;}_4.forEach(val,function(v){v=_10.parse(v);if(isNaN(v)){_35.push(0);return false;}var _37=_10.format(v,{locale:"en-us"}),_38=_3.trim(_37).match(/\D/g);if(_38){_4.forEach(_38,function(m){if(m==="."||m===","){_35.push(1);}else{if(m==="-"&&_34.inputType==="polygon"){_35.push(1);}else{_35.push(0);}}});}});if(_4.indexOf(_35,0)!==-1){return false;}return true;},_loadConnections:function(){this._connect(this,"onExecute",_3.hitch(this,"_onClose",false));this._connect(this._closeBtn,"onclick",_3.hitch(this,"_onClose",false));_5.connect(this._drivingDistance,"onclick",_3.hitch(this,"_handleDistanceTypeChange","distance"));_5.connect(this._drivingTime,"onclick",_3.hitch(this,"_handleDistanceTypeChange","time"));_5.connect(this._Overlap,"onclick",_3.hitch(this,"_handleOverlapPolicyChange",this._Overlap,"Overlap"));_5.connect(this._Dissolve,"onclick",_3.hitch(this,"_handleOverlapPolicyChange",this._Dissolve,"Dissolve"));_5.connect(this._Split,"onclick",_3.hitch(this,"_handleOverlapPolicyChange",this._Split,"Split"));},_setAnalysisGpServerAttr:function(url){this.analysisGpServer=url;this.set("toolServiceUrl",this.analysisGpServer+"/"+this.toolName);},_setInputLayerAttr:function(_39){if(_39.geometryType==="esriGeometryPoint"){this.inputLayer=_39;}},_getInputLayerAttr:function(){return this.inputLayer;},_setOverlapPolicyAttr:function(_3a){this.overlapPolicy=_3a;},_getOverlapPolicyAttr:function(){return this.overlapPolicy;},_setBreakValuesAttr:function(_3b){if(_3b){this.breakValues=_3b;}var val=_3.trim(this._breakValuesInput.get("value")).split(" "),_3c=[];_4.forEach(val,function(v){_3c.push(_10.parse(v));});this.breakValues=_3c;},_getBreakValuesAttr:function(){return this.breakValues;},_setDisableRunAnalysisAttr:function(_3d){this._saveBtn.set("disabled",_3d);},validateServiceName:function(_3e){var _3f=/(:|&|<|>|%|#|\?|\\|\"|\/|\+)/.test(_3e);if(_3e.length===0||((_a.trim(_3e)).length===0)){this.outputLayerInput.set("invalidMessage",this.i18n.requiredValue);return false;}if(_3f){this.outputLayerInput.set("invalidMessage",this.i18n.invalidServiceName);return false;}if(_3e.length>98){this.outputLayerInput.set("invalidMessage",this.i18n.invalidServiceNameLength);return false;}return true;},_setShowSelectFolderAttr:function(_40){this.showSelectFolder=_40;},_getShowSelectFolderAttr:function(){return this.showSelectFolder;},_setMapAttr:function(map){this.map=map;},_getMapAttr:function(){return this.map;},_setShowCreditsAttr:function(_41){this.showCredits=_41;},_getShowCreditsAttr:function(){return this.showCredits;},_setShowChooseExtentAttr:function(_42){this.showChooseExtent=_42;},_getShowChooseExtentAttr:function(){return this.showChooseExtent;},_setShowHelpAttr:function(_43){this.showHelp=_43;},_getShowHelpAttr:function(){return this.showHelp;},_setOutputLayerNameAttr:function(str){var _44,_45,_46,_47,_48;_46=["Seconds","Minutes","Hours","Miles","Meters","Kilometers","Feet","Yards"];if(str){this.outputLayerName=str;this.outputLayerInput.set("value",str);}else{if(this._breakValuesInput){if(!this.outputLayerName){this.outputLayerName=dojo.string.substitute(this.i18n.outputLayerName,{layername:this.inputLayer.name,breakValues:this._breakValuesInput.get("value"),breakUnits:this._distanceUnitsSelect.get("value")});}else{this.outputLayerName=this.outputLayerInput.get("value");if(this.outputLayerName.lastIndexOf("(")!==-1){_44=this.outputLayerName.substring(0,this.outputLayerName.lastIndexOf("("));_47=_a.trim(this.outputLayerName.substring(this.outputLayerName.lastIndexOf(" "),this.outputLayerName.lastIndexOf(")")));if(_4.indexOf(_46,_47)!==-1){_45=_44+"(${breakValues} ${breakUnits})";this.outputLayerName=_a.substitute(_45,{breakValues:this._breakValuesInput.get("value"),breakUnits:this._distanceUnitsSelect.get("value")});}}}this.outputLayerInput.set("value",this.outputLayerName);}}},_connect:function(_49,evt,_4a){this._pbConnects.push(_5.connect(_49,evt,_4a));},onSave:function(){},onClose:function(){}});if(_7("extend-esri")){_3.setObject("dijit.analysis.CreateDriveTimeAreas",_25,_1f);}return _25;});