/*
 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.IdentityManager"],["require","dijit.Dialog"],["require","dijit.form.Button"],["require","dijit.form.ValidationTextBox"],["require","esri.utils"],["require","esri.IdentityManagerBase"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["esri.IdentityManager"]){_4._hasResource["esri.IdentityManager"]=true;_4.provide("esri.IdentityManager");_4.require("dijit.Dialog");_4.require("dijit.form.Button");_4.require("dijit.form.ValidationTextBox");_4.require("esri.utils");_4.require("esri.IdentityManagerBase");_4.declare("esri.IdentityManager",[esri.IdentityManagerBase],{constructor:function(_7){_4.mixin(this,_7);},_dialogContent:"<div class='dijitDialogPaneContentArea'>"+"<div style='padding-bottom: 5px; word-wrap: break-word;'>${info}</div>"+"<div style='margin: 0px; padding: 0px; height: 10px;'></div>"+"<div class='esriErrorMsg' style='display: none; color: white; background-color: #D46464; text-align: center; padding-top: 3px; padding-bottom: 3px;'>${errorMsg}</div>"+"<div style='margin: 0px; padding: 0px; height: 10px;'></div>"+"<table style='width: 100%;'>"+"<tr>"+"<td><label>${lblUser}</label><br/>"+"<input data-dojo-type='dijit.form.ValidationTextBox' data-dojo-props='type:\"text\", \"class\":\"esriIdUser\", required:true, trim:true, style:\"width: 100%;\"' /></td>"+"</tr>"+"<tr>"+"<td><label>${lblPwd}</label><br/>"+"<input data-dojo-type='dijit.form.ValidationTextBox' data-dojo-props='type:\"password\", \"class\":\"esriIdPwd\", required:true, style:\"width: 100%;\"' /></td>"+"</tr>"+"</table>"+"</div>"+"<div class='dijitDialogPaneActionBar'>"+"<button data-dojo-type='dijit.form.Button' data-dojo-props='type:\"button\", \"class\":\"esriIdSubmit\"'>${lblOk}</button>"+"<button data-dojo-type='dijit.form.Button' data-dojo-props='type:\"button\", \"class\":\"esriIdCancel\"'>${lblCancel}</button>"+"</div>",onDialogCreate:function(){},onDialogCancel:function(){},signIn:function(_8,_9){if(!this._nls){this._nls=esri.bundle.identity;}if(!this._loginDialog){this._loginDialog=(this.dialog=this._createLoginDialog());this.onDialogCreate();}var _a=this._loginDialog,_b=new _4.Deferred(function(){_a.onCancel();});if(_a.open){var _c=new Error("BUSY");_c.code="IdentityManager."+1;_c.log=_4.config.isDebug;_b.errback(_c);return _b;}esri.hide(_a.errMsg_);_a.dfd_=_b;_a.serverInfo_=_9;_a.resUrl_=_8;_4.attr(_a.resLink_,{"title":_8,"innerHTML":"("+(this.getResourceName(_8)||this._nls.lblItem)+")"});_4.attr(_a.serverLink_,{"title":_9.server,"innerHTML":(_9.server.toLowerCase().indexOf("arcgis.com")!==-1?"ArcGIS Online":_9.server)+" "});_a.txtPwd_.set("value","");_a.show();return _b;},_createLoginDialog:function(){var _d=this._nls,_e=esri.substitute(_d,this._dialogContent);_e=esri.substitute({resource:"<span class='resLink' style='word-wrap: break-word;'></span>",server:"<span class='serverLink' style='word-wrap: break-word;'></span>"},_e);var _f=new _5.Dialog({title:_d.title,content:_e,"class":"esriSignInDialog",style:"width: 18em;",esriIdMgr_:this,keypressed_:function(evt){if(evt.charOrCode===_4.keys.ENTER){this.execute_();}},execute_:function(){var usr=this.txtUser_.get("value"),pwd=this.txtPwd_.get("value"),dfd=this.dfd_,_f=this;if(!usr||!pwd){return;}this.btnSubmit_.set("label",_d.lblSigning);var _10=esri.id.findCredential(_f.serverInfo_.server,usr),_11=function(_12){_f.btnSubmit_.set("label",_d.lblOk);_f.btnSubmit_.set("disabled",false);esri.hide(_f.errMsg_);_f.hide();_5._DialogLevelManager.hide(_f);var _13=_f.serverInfo_;_f.dfd_=_f.serverInfo_=_f.generateDfd_=_f.resUrl_=null;var _14,_15,_16=_10;if(_12){_14=_12.token;_15=esri._isDefined(_12.expires)?Number(_12.expires):null;if(_16){_16.userId=usr;_16.token=_14;_16.expires=_15;_16.validity=_13.shortLivedTokenValidity;}else{_16=new esri.Credential({userId:usr,server:_13.server,token:_14,expires:_15,validity:_13.shortLivedTokenValidity});}}dfd.callback(_16);};if(_10&&!_10._enqueued){_11();return;}_f.btnSubmit_.set("disabled",true);_f.generateDfd_=esri.id.generateToken(this.serverInfo_,{username:usr,password:pwd}).addCallback(_11).addErrback(function(){_f.btnSubmit_.set("disabled",false);_f.generateDfd_=null;_f.btnSubmit_.set("label",_d.lblOk);esri.show(_f.errMsg_);});},cancel_:function(){if(_f.generateDfd_){_f.generateDfd_.cancel();}var dfd=_f.dfd_,_17=_f.resUrl_,_18=_f.serverInfo_;_f.btnSubmit_.set("disabled",false);_f.dfd_=_f.serverInfo_=_f.generateDfd_=_f.resUrl_=null;esri.hide(_f.errMsg_);_5._DialogLevelManager.hide(_f);_f.esriIdMgr_.onDialogCancel({resourceUrl:_17,serverInfo:_18});var err=new Error("ABORTED");err.code="IdentityManager."+2;err.log=_4.config.isDebug;dfd.errback(err);}});var _19=_f.domNode;_f.txtUser_=_5.byNode(_4.query(".esriIdUser",_19)[0]);_f.txtPwd_=_5.byNode(_4.query(".esriIdPwd",_19)[0]);_f.btnSubmit_=_5.byNode(_4.query(".esriIdSubmit",_19)[0]);_f.btnCancel_=_5.byNode(_4.query(".esriIdCancel",_19)[0]);_f.resLink_=_4.query(".resLink",_19)[0];_f.serverLink_=_4.query(".serverLink",_19)[0];_f.errMsg_=_4.query(".esriErrorMsg",_19)[0];_f.connect(_f.txtUser_,"onKeyPress",_f.keypressed_);_f.connect(_f.txtPwd_,"onKeyPress",_f.keypressed_);_f.connect(_f.btnSubmit_,"onClick",_f.execute_);_f.connect(_f.btnCancel_,"onClick",_f.onCancel);_f.connect(_f,"onCancel",_f.cancel_);return _f;}});}}};});