var runner=new Ext.util.TaskRunner();var task=runner.newTask({run:function(){Ext.getCmp("resendOtpCnt").show();task.stop();},interval:20000});Ext.define("PortalLogin.controller.Main",{extend:"Ext.app.Controller",views:["Viewport","RegForm","LoginForm","ForgetPassword","TwoFA","LogonSimulatorView","CitrixView","RegFormCS","LoginFormCS","ForgetPasswordCS","TwoFACS","SaaSRegistrationView","LoginFormSaaS","RegFormSaaS","TwoFASaaS","ForgetPasswordSaaS"],refs:[{selector:"viewport",ref:"viewport"},{selector:"RegForm",ref:"RegForm"},{selector:"LoginForm",ref:"LoginForm"},{selector:"ForgetPassword",ref:"ForgetPassword"},{selector:"TwoFA",ref:"TwoFA"},{selector:"LogonSimulatorView",ref:"LogonSimulatorView"},{selector:"CitrixView",ref:"CitrixView"},{selector:"RegFormCS",ref:"RegFormCS"},{selector:"LoginFormCS",ref:"LoginFormCS"},{selector:"ForgetPasswordCS",ref:"ForgetPasswordCS"},{selector:"TwoFACS",ref:"TwoFACS"},{selector:"SaaSRegistrationView",ref:"SaaSRegistrationView"},{selector:"LoginFormSaaS",ref:"LoginFormSaaS"},{selector:"RegFormSaaS",ref:"RegFormSaaS"},{selector:"TwoFASaaS",ref:"TwoFASaaS"},{selector:"ForgetPasswordSaaS",ref:"ForgetPasswordSaaS"}],init:function(){thisController=this;
appCnt=this;this.control({"LogonSimulatorView":{"afterrender":this.afterrender},"CitrixView":{"afterrender":this.afterrender},"SaaSRegistrationView":{"afterrender":this.afterrender},'RegForm button[id="reg"]':{"click":this.register},"RegForm":{"afterrender":this.OnKeyupregform},'LoginForm button[id="login"]':{"click":this.login},"LoginForm":{"afterrender":this.OnKeyuploginform},'ForgetPassword button[id="getPassword"]':{"click":this.getPassword},'TwoFA button[id="2fa_submit"]':{"click":this.twofalogin},'RegFormCS button[id="reg"]':{"click":this.register},"RegFormCS":{"afterrender":this.OnKeyupregform},'LoginFormCS button[id="login"]':{"click":this.login},"LoginFormCS":{"afterrender":this.OnKeyuploginform},'ForgetPasswordCS button[id="getPassword"]':{"click":this.getPassword},'TwoFACS button[id="2fa_submit"]':{"click":this.twofalogin},'RegFormSaaS button[id="reg"]':{"click":this.register},"RegFormSaaS":{"afterrender":this.OnKeyupregform},'LoginFormSaaS button[id="login"]':{"click":this.login},"LoginFormSaaS":{"afterrender":this.OnKeyuploginform},'ForgetPasswordSaaS button[id="getPassword"]':{"click":this.getPassword},'TwoFASaaS button[id="2fa_submit"]':{"click":this.twofalogin}});
},afterrender:function(){var a=Ext.getCmp("mainTab");if(isSecondaryMgr){if(reqFrom=="citrix"&&cloudModel=="default"){Ext.getCmp("changeShade").removeCls("loginShade");Ext.getCmp("changeShade").addCls("loginShadeSecondary");}Ext.get("gotologindiv").show();Ext.getCmp("signup").setVisible(false);Ext.getCmp("RegForm").setVisible(false);
Ext.getCmp("ForgetPassword").setVisible(false);Ext.getCmp("forgotpwd").setVisible(false);Ext.getCmp("auth").setVisible(false);Ext.getCmp("TwoFA").setVisible(false);Ext.getCmp("signin").setVisible(false);Ext.getCmp("LoginForm").setVisible(true);Ext.get("forgetpwddiv").on("click",function(){if(!Ext.isEmpty(Ext.getCmp("errorState"))){Ext.getCmp("errorState").hide();
}Ext.getCmp("signin").setVisible(false);Ext.getCmp("LoginForm").setVisible(false);Ext.getCmp("signup").setVisible(false);Ext.getCmp("RegForm").setVisible(false);Ext.getCmp("auth").setVisible(false);Ext.getCmp("TwoFA").setVisible(false);Ext.getCmp("ForgetPassword").setVisible(true);Ext.getCmp("forgotpwd").setVisible(false);
Ext.getCmp("fpusername").focus(true,500);});Ext.get("gotologindiv").on("click",function(){if(!Ext.isEmpty(Ext.getCmp("errorState"))){Ext.getCmp("errorState").hide();}Ext.getCmp("signup").setVisible(false);Ext.getCmp("RegForm").setVisible(false);Ext.getCmp("ForgetPassword").setVisible(false);Ext.getCmp("forgotpwd").setVisible(false);
Ext.getCmp("auth").setVisible(false);Ext.getCmp("TwoFA").setVisible(false);Ext.getCmp("signin").setVisible(false);Ext.getCmp("LoginForm").setVisible(true);});}else{if(reqFrom=="citrix"&&cloudModel=="default"){Ext.getCmp("changeShade").removeCls("loginShadeSecondary");Ext.getCmp("changeShade").addCls("loginShade");
}Ext.get("gotologindiv").hide();if(email!="null"&&first_name!="null"&&last_name!="null"&&!Ext.isEmpty(email)&&!Ext.isEmpty(first_name)&&!Ext.isEmpty(last_name)){Ext.getCmp("signin").setVisible(false);Ext.getCmp("LoginForm").setVisible(false);Ext.getCmp("ForgetPassword").setVisible(false);Ext.getCmp("forgotpwd").setVisible(false);
Ext.getCmp("auth").setVisible(false);Ext.getCmp("TwoFA").setVisible(false);Ext.getCmp("signup").setVisible(true);Ext.getCmp("RegForm").setVisible(true);Ext.getCmp("fname").setValue(first_name);Ext.getCmp("lname").setValue(last_name);Ext.getCmp("emailid").setValue(email);if(phoneNo!="null"&&company!="null"&&!Ext.isEmpty(phoneNo)&&!Ext.isEmpty(company)){Ext.getCmp("phoneNo").setValue(phoneNo);
Ext.getCmp("company").setValue(company);}Ext.getCmp("password").focus(true,500);}else{Ext.getCmp("signup").setVisible(false);Ext.getCmp("RegForm").setVisible(false);Ext.getCmp("ForgetPassword").setVisible(false);Ext.getCmp("forgotpwd").setVisible(false);Ext.getCmp("auth").setVisible(false);Ext.getCmp("TwoFA").setVisible(false);
Ext.getCmp("signin").setVisible(true);Ext.getCmp("LoginForm").setVisible(true);if(uName!="null"&&!Ext.isEmpty(uName)){Ext.getCmp("username").setValue(uName);Ext.getCmp("pass").focus(true,500);}else{Ext.getCmp("username").focus(true,500);}}if(action.toLowerCase()=="registration"){Ext.getCmp("signin").setVisible(false);
Ext.getCmp("LoginForm").setVisible(false);Ext.getCmp("ForgetPassword").setVisible(false);Ext.getCmp("forgotpwd").setVisible(false);Ext.getCmp("auth").setVisible(false);Ext.getCmp("TwoFA").setVisible(false);Ext.getCmp("signup").setVisible(true);Ext.getCmp("RegForm").setVisible(true);}Ext.get("forgetpwddiv").on("click",function(){if(!Ext.isEmpty(Ext.getCmp("errorState"))){Ext.getCmp("errorState").hide();
}Ext.getCmp("signin").setVisible(false);Ext.getCmp("LoginForm").setVisible(false);Ext.getCmp("signup").setVisible(false);Ext.getCmp("RegForm").setVisible(false);Ext.getCmp("auth").setVisible(false);Ext.getCmp("TwoFA").setVisible(false);Ext.getCmp("ForgetPassword").setVisible(true);Ext.getCmp("forgotpwd").setVisible(true);
Ext.getCmp("fpusername").focus(true,500);});Ext.Ajax.request({url:"/final/portal/PortalLogin/data/EgLogonp.jsp?comeFrom=getTimeZoneAndSimulator",method:"POST",success:function(d){var c=d.responseText;var k=Ext.decode(c);var i=Ext.getCmp("timeZone");i.getStore().loadRawData(k["timeZone"]);var j=Ext.getCmp("simulator");
j.getStore().suspendEvents(true);j.getStore().loadRawData(k["simulator"]);if(platform!="null"&&!Ext.isEmpty(platform)){var f="";if(platform.toLowerCase()=="citrix xenapp/xendesktop"){f="Citrix_XcLogon_Emulation";}else{if(platform.toLowerCase()=="vmware horizon"){f="Hrzn_Logon_Emulation";}}Ext.getCmp("simulator").setValue(f);
}j.getStore().resumeEvents();var g=new Date().getTimezoneOffset();var h=-Math.round(g/60)+":"+-(g%60);var b=h;b=b.replace(":",".");if(b>0){h="+"+h;}var e=i.getStore().find("displayField",h,0,true,false,false);if(e!=-1){i.setValue(i.getStore().getAt(e));}}});}},goToSignIn:function(){if(!Ext.isEmpty(Ext.getCmp("errorState"))){Ext.getCmp("errorState").hide();
}Ext.getCmp("signin").setVisible(true);Ext.getCmp("LoginForm").setVisible(true);Ext.getCmp("username").focus(true);Ext.getCmp("signup").setVisible(false);Ext.getCmp("RegForm").setVisible(false);Ext.getCmp("ForgetPassword").setVisible(false);Ext.getCmp("forgotpwd").setVisible(false);Ext.getCmp("auth").setVisible(false);
Ext.getCmp("TwoFA").setVisible(false);if(reqFrom!=null&&reqFrom=="citrix"){if(cloudModel!=null&&cloudModel.toLowerCase()!="phoenix"){Ext.getCmp("changeShade").removeCls("registerShade");Ext.getCmp("changeShade").addCls("loginShade");}}},goToSignUp:function(){if(!Ext.isEmpty(Ext.getCmp("errorState"))){Ext.getCmp("errorState").hide();
}Ext.getCmp("signin").setVisible(false);Ext.getCmp("LoginForm").setVisible(false);Ext.getCmp("ForgetPassword").setVisible(false);Ext.getCmp("forgotpwd").setVisible(false);Ext.getCmp("auth").setVisible(false);Ext.getCmp("TwoFA").setVisible(false);Ext.getCmp("signup").setVisible(true);Ext.getCmp("RegForm").setVisible(true);
Ext.getCmp("fname").focus(true);if(reqFrom!=null&&reqFrom=="citrix"){if(cloudModel!=null&&cloudModel.toLowerCase()!="phoenix"){Ext.getCmp("changeShade").removeCls("loginShade");Ext.getCmp("changeShade").addCls("registerShade");}}},OnKeyuploginform:function(a,b){Ext.EventManager.on(a.getEl(),"keyup",function(c,d,e){if(c.keyCode===Ext.EventObject.ENTER){this.login();
}},this);},OnKeyupregform:function(a,b){Ext.EventManager.on(a.getEl(),"keyup",function(c,d,e){if(c.keyCode===Ext.EventObject.ENTER){this.register();}},this);},termsOfService:function(){var a="";if(reqFrom!=null&&reqFrom=="clsTrial"){a="Terms_of_Service_eG_Enterprise_Express_Logon_Simulator";}else{if(reqFrom!=null&&reqFrom=="citrix"){if(cloudModel!=null&&cloudModel.toLowerCase()=="phoenix"){a="Terms_of_Service_eG_Express_Cloud";
}else{a="Terms_of_Service_eG_Enterprise_Cloud";}}}if(Ext.isEmpty(Ext.getCmp("termsOfServWindow"))){Ext.create("Ext.window.Window",{title:"<span style='text-transform:none;'>Terms of Service</span>",modal:true,ui:"newPopupWindow newplainHeader_border popupWindowBlueHeader",ghost:false,id:"termsOfServWindow",closeAction:"destroy",height:500,width:800,border:true,bodyPadding:0,header:{padding:"12 0",margin:"0 20 0 20",},listeners:{show:function(b){if(this.modal){var c=Ext.dom.Query.select(".x-mask");
for(var d in c){this.dom=c[d];if(!Ext.isEmpty(this.dom.offsetParent)){if(this.dom.offsetParent.tagName=="BODY"){Ext.fly(this.dom).addCls("windowModal");}}}}},hide:function(b){if(this.modal){Ext.fly(this.dom).removeCls("windowModal");}},afterrender:function(){Ext.EventManager.onWindowResize(function(){var b=this;
b.center();},this);}},resizable:false,layout:"fit",html:'<iframe width="800" frameborder="0" height="465" src="/final/docs/'+a+'.pdf#toolbar=0&navpanes=0&scrollbar=0" name="aaa" frameborder="0" allowfullscreen allowtransparency="true"></iframe>'}).show();}},pwdComplexityCheck:function(e,g){var c="^";
var a="";var f=".+$";var m="";var b=".";var l="<br/>";if(g!=null&&g!=undefined){m="false#";if(g.indexOf(",")>-1){var i=g.split(",");for(var d=0;d<i.length;d++){var j=i[d].toLowerCase();if(j=="lc"){a+="(?=.*[a-z])";m+=l+(d+1)+b+" "+passCheckMsg1;}else{if(j=="uc"){a+="(?=.*[A-Z])";m+=l+(d+1)+b+" "+passCheckMsg2;
}else{if(j=="dg"){a+="(?=.*[0-9])";m+=l+(d+1)+b+" "+passCheckMsg3;}else{if(j=="sp"){a+="(?=.*[^0-9a-zA-Z])";m+=l+(d+1)+b+" "+passCheckMsg4;}}}}}}else{var j=g.toString().toLowerCase();if(j=="lc"){a+="(?=.*[a-z])";m+=passCheckMsg1;}else{if(j=="uc"){a+="(?=.*[A-Z])";m+=passCheckMsg2;}else{if(j=="dg"){a+="(?=.*[0-9])";
m+=passCheckMsg3;}else{if(j=="sp"){a+="(?=.*[^0-9a-zA-Z])";m+=passCheckMsg4;}}}}}var h=new RegExp(c+a+f);if(h.test(e)){m="true";}}return m;},register:function(){var c=Ext.getCmp("fname").getValue();var i=Ext.getCmp("lname").getValue();var f=Ext.getCmp("emailid").getValue();var l=Ext.getCmp("password").getValue();
l=Ext.String.trim(l);var j=Ext.getCmp("cpassword").getValue();j=Ext.String.trim(j);var g=Ext.getCmp("company").getValue();var a=Ext.getCmp("errorState1");var m=Ext.getCmp("timeZone").getValue();var d=Ext.getCmp("phoneNo").getValue();var o=Ext.getCmp("simulator").getValue();var h=/[\#]?([a-zA-Z0-9]+[\#\ \_\.\-\&]?)*[a-zA-Z0-9]\@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]/g;
var k=/^(\+\d\d)?[0-9]+$/g;var b=f.match(h);var e=false;if(d!=""){e=validateMobileNo(d);}if(c==""){thisController.validateErrorTextTooltip("fname",fnameMsg,a);return false;}else{if(c.length<=1){thisController.validateErrorTextTooltip("fname",fnamevalMsg,a);return false;}else{if(i==""){thisController.validateErrorTextTooltip("lname",lnameMsg,a);
return false;}else{if(i.length<=1){thisController.validateErrorTextTooltip("lname",lnamevalMsg,a);return false;}else{if(f==""){thisController.validateErrorTextTooltip("emailid",validMailIdMsg,a);return false;}else{if(b!=f.toString()){thisController.validateErrorTextTooltip("emailid",validMailIdMsg,a);
return false;}else{if(b==f.toString()){var n=false;Ext.Ajax.request({url:"/final/portal/PortalLogin/data/EgLogonp.jsp?emailid="+encodeURIComponent(parent.filterEncode(f))+"&comeFrom=emailValidation&reqFrom="+reqFrom,method:"POST",success:function(u){var s=u.responseText;var w=Ext.decode(s);var D=w["validEmail"];
var p=w["domainAllowed"];var x=w["pwdLength"];var q=w["pwdComplexityCount"];var y=w["pwdComplexity"];if(x==""||x<2){x=8;}else{if(x!=""&&x<q){x=q;}}var A=appCnt.pwdComplexityCheck(l,y);if(D==false){thisController.validateErrorTextTooltip("emailid",validMailIdMsg,a);return false;}else{if(p==false){thisController.validateErrorTextTooltip("emailid",domainRestrictedMsg,a);
return false;}else{if(l==""){thisController.validateErrorTextTooltip("password",passMsg,a);return false;}else{if(Ext.String.trim(f.toLowerCase())==l.toLowerCase()){thisController.validateErrorTextTooltip("password",emailpassMsg,a);return false;}else{if(!checkloginpass(l)){thisController.validateErrorTextTooltip("password",_checkspecial,a);
return false;}else{if(l.length<x){thisController.validateErrorTextTooltip("password",passCheckMsg5+" "+x+" "+passCheckMsg6,a);return false;}else{if(A.indexOf("false")>-1){var v=A.substring(A.indexOf("false#")+6);thisController.validateErrorTextTooltip("password",passCheckMsg7+". "+passCheckMsg5+" "+v+".",a);
return false;}else{if(j==""){thisController.validateErrorTextTooltip("cpassword",confPassMsg,a);return false;}else{if(l!=j){thisController.validateErrorTextTooltip("cpassword",pwdInCorrect,a);return false;}else{if(g==""){thisController.validateErrorTextTooltip("company",validCompMsg,a);return false;}else{if(d==""){thisController.validateErrorTextTooltip("phoneNo",enterPhoneNoMsg,a);
return false;}else{if(e==false){thisController.validateErrorTextTooltip("phoneNo",validPhoneNoMsg,a);return false;}else{if(m==null||m==""){thisController.validateErrorTextTooltip("timeZone",validTimeZoneMsg,a);return false;}else{if(defaultLS.toLowerCase()=="all"&&reqFrom.toLowerCase()!="citrix"&&(o==null||o=="")){thisController.validateErrorTextTooltip("simulator",validSimulatorMsg,a);
return false;}else{if(o==null||o==""){if(defaultLS!="all"){Ext.getCmp("simulator").setValue(defaultLS);}else{Ext.getCmp("simulator").setValue("Citrix_XcLogon_Emulation");}}var C=Ext.getCmp("emailid").getValue();var B=Ext.getCmp("password").getValue();var z=Ext.getCmp("cpassword").getValue();C=parent.filterEncode(C);
B=parent.filterEncode(B);z=parent.filterEncode(z);Ext.getCmp("emailid").setValue(C);Ext.getCmp("password").setValue(B);Ext.getCmp("cpassword").setValue(z);var r=new Ext.LoadMask(Ext.getBody(),{msg:"Registration in progress..."});r.show();if(reqFrom!=null&&reqFrom=="clsTrial"){a.show();}else{if(cloudModel!=null&&cloudModel.toLowerCase()=="phoenix"){a.show();
}}var t=Ext.getCmp("RegForm").getForm();t.submit({url:"/final/portal/PortalLogin/data/EgLogonp.jsp?comeFrom=register&reqFrom="+reqFrom,method:"POST",success:function(H,J){r.hide();if(J.response.status==200&&!Ext.isEmpty(J.response.responseText)){var I=J.response.responseText;var G=Ext.decode(I);if(G["success"]=="user"){thisController.validateErrorTextTooltip("",G["screenLabels"]["userErr"],a);
return false;}else{if(G["success"]=="extagent"){thisController.validateErrorTextTooltip("",G["screenLabels"]["extAgentErr"],a);return false;}else{if(G["success"]=="comp"){thisController.validateErrorTextTooltip("",G["screenLabels"]["compErr"],a);return false;}else{if(G["success"]=="true"){if(!Ext.isEmpty(Ext.getCmp("errorState"))){Ext.getCmp("errorState").hide();
}var F=Ext.getCmp("emailid").getValue();var E=Ext.getCmp("password").getValue();Ext.getCmp("hiddenFName").setValue(c);Ext.getCmp("hiddenLName").setValue(i);Ext.getCmp("hiddenEmail").setValue(F);Ext.getCmp("hiddenpass").setValue(E);Ext.getCmp("hiddenComp").setValue(g);Ext.getCmp("hiddenTimeZone").setValue(m);
Ext.getCmp("hiddenPhoneNo").setValue(d);if(reqFrom=="clsTrial"){Ext.getCmp("mailIdLabel").update('<div class="verificationMsg">Enter the verification code sent to your email address <span class="mailText">'+F+"</span></div>");}else{if(reqFrom=="citrix"){if(cloudModel!=null&&cloudModel.toLowerCase()=="phoenix"){Ext.getCmp("mailIdLabel").update('<div class="verificationMsg">Enter the verification code sent to your email address <span class="mailText">'+F+"</span></div>");
}else{Ext.getCmp("mailIdLabel").update('<div class="cs_verificationMsg">Enter the verification code sent to your email address<br/> <span class="cs_mailText">'+F+"</span></div>");}}}if(G["2FA"]=="true"){thisController.sendOtp(F,"register","sendOTP");}else{thisController.finalReg("register");}}}}}}},failure:function(E,F){r.hide();
}});}}}}}}}}}}}}}}}});}}}}}}}},sendOtp:function(b,e,d){var c="";if(e!=null&&e=="register"){c=Ext.getCmp("RegForm").getForm();}else{c=Ext.getCmp("TwoFA").getForm();}var a=new Ext.LoadMask(Ext.getBody(),{msg:"Verification code is being sent to your email address..."});a.show();c.submit({url:"/final/portal/PortalLogin/data/twoFactorAuthenticationPage.jsp",method:"POST",params:{"email":parent.filterEncode(b),"requestFrom":"sendOTP","from":e,"action":d,"reqFrom":reqFrom},async:false,success:function(h,j){a.hide();
if(j.response.status==200&&!Ext.isEmpty(j.response.responseText)){var i=j.response.responseText;publicJSON=Ext.decode(i);var f=publicJSON.mailStatus;var g=Ext.getCmp("errorState1");if(!Ext.isEmpty(f)&&(parseInt(f)==1||parseInt(f)==2||parseInt(f)==3)){thisController.validateErrorTextTooltip("",mailNotSentMsg,g);
}else{if(!Ext.isEmpty(f)&&parseInt(f)==4){thisController.validateErrorTextTooltip("",invalidMailID,g);}else{Ext.getCmp("signin").setVisible(false);Ext.getCmp("LoginForm").setVisible(false);Ext.getCmp("signup").setVisible(false);Ext.getCmp("RegForm").setVisible(false);Ext.getCmp("ForgetPassword").setVisible(false);
Ext.getCmp("forgotpwd").setVisible(false);Ext.getCmp("TwoFA").getForm().reset();if(!isSecondaryMgr){Ext.getCmp("auth").setVisible(true);}Ext.getCmp("TwoFA").setVisible(true);if(reqFrom!=null&&reqFrom=="citrix"&&cloudModel!=null&&cloudModel.toLowerCase()!="phoenix"){if(e!=null&&e=="register"){Ext.getCmp("changeShade").removeCls("registerShade");
Ext.getCmp("changeShade").addCls("loginShade");Ext.getCmp("auth").update('<div id="loginHeader"><div style="z-index:4"><table width="100%" border="0px" cellpadding="0px" cellspacing="0px"><tr><td align="right" style="cursor:pointer;" width="50%"><div class="cs_signIn_Register_Text" onclick="javascript:thisController.goToSignIn();" >SIGN IN</div></td><td align="left" style="cursor:pointer;" width="50%"><div class="cs_registerButtonOuter"><div class="cs_tabButtonShadeRegister"></div><div class="cs_signIn_Register_Text_selected" onclick="javascript:thisController.goToSignUp();">REGISTER</div></div></td></tr></table></div></div>');
}else{if(e!=null&&e=="login"){Ext.getCmp("changeShade").removeCls("registerShade");if(isSecondaryMgr){Ext.getCmp("changeShade").addCls("loginShadeSecondary");}else{Ext.getCmp("changeShade").addCls("loginShade");}Ext.getCmp("auth").update('<div id="loginHeader"><div style="z-index:4"><table width="100%" border="0px" cellpadding="0px" cellspacing="0px"><tr><td align="right" style="cursor:pointer;" width="50%"><div class="cs_signInButtonOuter"><div class="cs_signIn_Register_Text_selected" onclick="javascript:thisController.goToSignIn();">SIGN IN</div><div class="cs_tabButtonShadeSignIn"></div></div></td><td align="left" style="cursor:pointer;" width="50%"><div class="cs_signIn_Register_Text" onclick="javascript:thisController.goToSignUp();">REGISTER</div></td></tr></table></div></div>');
}}}else{Ext.getCmp("otperrorState").hide();}Ext.getCmp("resendOtpCnt").hide();Ext.getCmp("otp").setValue("");Ext.getCmp("otp").focus(true);Ext.getCmp("_empcode").setValue(b);Ext.getCmp("_from").setValue(e);}}}},failure:function(f,g){a.hide();}});task.start();},sendOtpForLogin:function(c,g,e,b){var d=Ext.getCmp("TwoFA").getForm();
var a=new Ext.LoadMask(Ext.getBody(),{msg:"Verification code is being sent to your email address..."});a.show();var f=Ext.Date.format(new Date(),"m/d/Y H:i:s");d.submit({url:"/final/portal/PortalLogin/data/twoFactorAuthenticationPage.jsp",method:"POST",params:{"email":parent.filterEncode(c),"requestFrom":"sendOTP","from":g,"action":e,"reqFrom":reqFrom,"twoFA":b,"userTimeZoneDate":f},async:false,success:function(j,l){a.hide();
if(l.response.status==200&&!Ext.isEmpty(l.response.responseText)){var k=l.response.responseText;publicJSON=Ext.decode(k);var h=publicJSON.mailStatus;var i=Ext.getCmp("errorState1");if(!Ext.isEmpty(h)&&(parseInt(h)==1||parseInt(h)==2||parseInt(h)==3)){thisController.validateErrorTextTooltip("",mailNotSentMsg,i);
}else{if(!Ext.isEmpty(h)&&parseInt(h)==4){thisController.validateErrorTextTooltip("",invalidMailID,i);}else{Ext.getCmp("signin").setVisible(false);Ext.getCmp("LoginForm").setVisible(false);Ext.getCmp("signup").setVisible(false);Ext.getCmp("RegForm").setVisible(false);Ext.getCmp("ForgetPassword").setVisible(false);
Ext.getCmp("forgotpwd").setVisible(false);Ext.getCmp("TwoFA").getForm().reset();if(!isSecondaryMgr){Ext.getCmp("auth").setVisible(true);}Ext.getCmp("TwoFA").setVisible(true);if(reqFrom!=null&&reqFrom=="citrix"&&cloudModel!=null&&cloudModel.toLowerCase()!="phoenix"){Ext.getCmp("changeShade").removeCls("registerShade");
if(isSecondaryMgr){Ext.getCmp("changeShade").addCls("loginShadeSecondary");}else{Ext.getCmp("changeShade").addCls("loginShade");}Ext.getCmp("auth").update('<div id="loginHeader"><div style="z-index:4"><table width="100%" border="0px" cellpadding="0px" cellspacing="0px"><tr><td align="right" style="cursor:pointer;" width="50%"><div class="cs_signInButtonOuter"><div class="cs_signIn_Register_Text_selected" onclick="javascript:thisController.goToSignIn();">SIGN IN</div><div class="cs_tabButtonShadeSignIn"></div></div></td><td align="left" style="cursor:pointer;" width="50%"><div class="cs_signIn_Register_Text" onclick="javascript:thisController.goToSignUp();">REGISTER</div></td></tr></table></div></div>');
}else{Ext.getCmp("otperrorState").hide();}Ext.getCmp("resendOtpCnt").hide();Ext.getCmp("otp").setValue("");Ext.getCmp("otp").focus(true);Ext.getCmp("_empcode").setValue(c);Ext.getCmp("_from").setValue(g);Ext.getCmp("_twoFA").setValue(b);}}}},failure:function(h,i){a.hide();}});if(b=="forwardTo2faLoginPg"){task.start();
}},twofalogin:function(){var e=Ext.getCmp("otp").getValue();e=e.replace(/-|\s/g,"");var d=Ext.getCmp("otperrorState");var h=Ext.Date.format(new Date(),"m/d/Y H:i:s");if(Ext.isEmpty(e)){thisController.validateErrorTextTooltip("otp",verificationMsg,d);return false;}else{var c=Ext.getCmp("_empcode").getValue();
var g=Ext.getCmp("_from").getValue();var b=Ext.getCmp("_twoFA").getValue();if(!Ext.isEmpty(b)&&(b=="fwdToGoogleAuthLoginPage"||b=="forwardTo2faLoginPg")){thisController.authenticate(e);}else{var f=Ext.getCmp("TwoFA").getForm();var a=new Ext.LoadMask(Ext.getBody(),{msg:"Verification in progress..."});
a.show();Ext.Ajax.request({url:"/final/portal/PortalLogin/data/twoFactorAuthenticationPage.jsp",method:"POST",params:{"email":parent.filterEncode(c),"requestFrom":"validateOTP","otp":e,"from":g,"reqFrom":reqFrom,"twoFA":b,"userTimeZoneDate":h},async:false,success:function(j){a.hide();var k=j.responseText;
publicJSON=Ext.decode(k);var i=publicJSON.status;if(!Ext.isEmpty(i)&&i=="right"){if(g!=null&&g=="register"){thisController.finalReg("twofa");}else{if(g!=null&&g=="login"){thisController.finalLogin("twofa");}}}else{if(!Ext.isEmpty(i)&&i=="expired"){thisController.validateErrorTextTooltip("otp",expVerMsg,d);
return false;}else{if(!Ext.isEmpty(i)&&i=="wrong"){thisController.validateErrorTextTooltip("otp",invalidVerMsg,d);return false;}}}}});}}},finalReg:function(h){var j=Ext.getCmp("hiddenFName").getValue();var k=Ext.getCmp("hiddenLName").getValue();var f=Ext.getCmp("hiddenEmail").getValue();var i=Ext.getCmp("hiddenpass").getValue();
var e=Ext.getCmp("hiddenComp").getValue();var l=Ext.getCmp("hiddenTimeZone").getValue();var d=Ext.getCmp("hiddenPhoneNo").getValue();var a;if(h!=null&&h=="register"){a=Ext.getCmp("errorState1");}else{if(h!=null&&h=="twofa"){a=Ext.getCmp("otperrorState");}}var n=Ext.getCmp("emailid").getValue();var m=Ext.getCmp("password").getValue();
var g=Ext.getCmp("cpassword").getValue();n=parent.filterEncode(n);m=parent.filterEncode(m);g=parent.filterEncode(g);Ext.getCmp("emailid").setValue(n);Ext.getCmp("password").setValue(m);Ext.getCmp("cpassword").setValue(g);var b=new Ext.LoadMask(Ext.getBody(),{msg:"Registration in progress..."});b.show();
var c=Ext.getCmp("RegForm").getForm();c.submit({url:"/final/portal/PortalLogin/data/EgLogonp.jsp?comeFrom=register"+"&from=twofalogin&reqFrom="+reqFrom,method:"POST",success:function(s,u){b.hide();if(u.response.status==200&&!Ext.isEmpty(u.response.responseText)){var t=u.response.responseText;var q=Ext.decode(t);
if(q["success"]=="user"){thisController.validateErrorTextTooltip("",q["screenLabels"]["userErr"],a);return false;}else{if(q["success"]=="extagent"){thisController.validateErrorTextTooltip("",q["screenLabels"]["extAgentErr"],a);return false;}else{if(q["success"]=="comp"){thisController.validateErrorTextTooltip("",q["screenLabels"]["compErr"],a);
return false;}else{if(q["success"]=="true"){if(enableUserTracking!=null&&(enableUserTracking=="true"||enableUserTracking=="yes")){var r=window.location.href;_gaq.push(["_trackEvent","logon simulator registration","submit",r]);}var o=q["enc"];var p=q["defaultLS"];if(q["autoLogin"]=="true"){Ext.Ajax.request({url:"/final/servlet/com.egurkha.LoginServlet",params:"uname="+encodeURIComponent(f)+"&upass="+encodeURIComponent(o),scope:this,timeout:120000,success:function(y){var x=y.responseText;
var A=x.split(":");if(A[0]=="Error"){var z;if(h!=null&&h=="register"){z=Ext.getCmp("errorState1");}else{if(h!=null&&h=="twofa"){z=Ext.getCmp("otperrorState");}}var w=A[1];if(w!=null&&((w.indexOf("The session is being used")!=-1))){w="The user has been registered successfully. Please sign in to continue";
}thisController.validateErrorTextTooltip("",w,z);return false;}else{if(reqFrom.toLowerCase()=="citrix"){if(cloudModel.toLowerCase()=="phoenix"){Ext.Ajax.request({url:"/final/portal/PortalLogin/data/twoFactorAuthenticationPage.jsp",method:"POST",params:{"email":parent.filterEncode(f),"fname":j,"requestFrom":"sendSuccessfulRegMail"},async:false,success:function(v){var B=v.responseText;
publicJSON=Ext.decode(B);}});}else{Ext.Ajax.request({url:"/final/portal/PortalLogin/data/twoFactorAuthenticationPage.jsp",method:"POST",params:{"email":parent.filterEncode(f),"fname":j,"lname":k,"comp":e,"timeZone":l,"phoneNo":d,"remoteIP":remoteIP,"requestFrom":"sendSelfRegMail"},async:false,success:function(v){var B=v.responseText;
publicJSON=Ext.decode(B);}});}Ext.Ajax.request({url:"/final/portal/PortalLogin/data/EgSetSessionAttribute.jsp?reqFrom="+reqFrom+"&via=register",method:"POST",scope:this,timeout:120000,success:function(v){window.location.href="/final/egm";},failure:function(v){}});}else{if(p!=null&&p.toLowerCase()=="all"){Ext.Ajax.request({url:"/final/portal/PortalLogin/data/EgSetSessionAttribute.jsp?entry=admin&reqFrom="+reqFrom+"&tab=comp&help=true&url="+url,method:"POST",scope:this,timeout:120000,success:function(v){window.location.href="/final/egm";
},failure:function(v){}});}else{Ext.Ajax.request({url:"/final/portal/PortalLogin/data/EgSetSessionAttribute.jsp?entry=admin&reqFrom="+reqFrom+"&tab=configure&help=true&url="+url,method:"POST",scope:this,timeout:120000,success:function(v){window.location.href="/final/egm";},failure:function(v){}});}}}},failure:function(v,w){thisController.validateErrorTextTooltip("","Failed!,Sorry! Problem occured while logging in",a);
}});}else{thisController.validateErrorTextTooltip("","Registered successfully. Please sign in to continue.",a);}}}}}}},failure:function(o,p){b.hide();}});},login:function(){var d=Ext.getCmp("username").getValue();var b=Ext.getCmp("pass").getValue();var a=Ext.getCmp("errorState");if(d!=null&&d==""){thisController.validateErrorTextTooltip("username",mailIDMsg,a);
return false;}else{if(d.indexOf(" ")==0){thisController.validateErrorTextTooltip("username",userIDValidationMsg1,a);return false;}else{if(d.lastIndexOf(" ")==d.length-1){thisController.validateErrorTextTooltip("username",userIDValidationMsg2,a);return false;}else{if(b!=null&&b==""){thisController.validateErrorTextTooltip("pass",passMsg,a);
return false;}else{b=parent.filterEncode(b);var c=new Ext.LoadMask(Ext.getBody(),{msg:"Signing in..."});c.show();Ext.Ajax.request({url:"/final/portal/PortalLogin/data/EgLogonp.jsp?username="+encodeURIComponent(parent.filterEncode(d))+"&key="+encodeURIComponent(b)+"&comeFrom=logincheck&reqFrom="+reqFrom,method:"POST",success:function(g){c.hide();
var j=g.responseText;publicJSON=Ext.decode(j);var i=publicJSON["userCheck"];var f=publicJSON["2FA"];var h=publicJSON["mailID"];var e=publicJSON["enc"];if(i!=null&&i!="undefined"&&i=="failure"){thisController.validateErrorTextTooltip("",mailIDCheckMsg,a);return false;}else{if(i!=null&&i!="undefined"&&i=="error"){thisController.validateErrorTextTooltip("",mailIDAuthMsg,a);
return false;}else{Ext.getCmp("hiddenuser").setValue(d);Ext.getCmp("hiddenpwd").setValue(e);if(Ext.isEmpty(h)){h=d;}if(reqFrom=="clsTrial"){if(f=="fwdToGoogleAuthLoginPage"){Ext.getCmp("mailIdLabel").update('<div class="verificationMsg">Enter the verification code generated on your Google Authenticator</div>');
}else{Ext.getCmp("mailIdLabel").update('<div class="verificationMsg">Enter the verification code sent to your email address <span class="mailText">'+h+"</span></div>");}}else{if(reqFrom=="citrix"){if(cloudModel!=null&&cloudModel.toLowerCase()=="phoenix"){if(f=="fwdToGoogleAuthLoginPage"){Ext.getCmp("mailIdLabel").update('<div class="verificationMsg">Enter the verification code generated on your Google Authenticator</div>');
}else{Ext.getCmp("mailIdLabel").update('<div class="verificationMsg">Enter the verification code sent to your email address <span class="mailText">'+h+"</span></div>");}}else{if(f=="fwdToGoogleAuthLoginPage"){Ext.getCmp("mailIdLabel").update('<div class="cs_verificationMsg">Enter the verification code generated on your Google Authenticator</div>');
}else{Ext.getCmp("mailIdLabel").update('<div class="cs_verificationMsg">Enter the verification code sent to your email address<br/> <span class="cs_mailText">'+h+"</span></div>");}}}}if(f=="true"){thisController.sendOtp(d,"login","sendOTP");}else{if(f=="fwdToGoogleAuthLoginPage"||f=="forwardTo2faLoginPg"){thisController.sendOtpForLogin(d,"login","sendOTP",f);
}else{thisController.finalLogin("login");}}}}}});}}}}},authenticate:function(a){var e=Ext.getCmp("hiddenuser").getValue();var b=Ext.getCmp("hiddenpwd").getValue();var c=new Ext.LoadMask(Ext.getBody(),{msg:"Signing in..."});c.show();var d=Ext.Date.format(new Date(),"m/d/Y H:i:s");Ext.Ajax.request({url:"/final/servlet/com.egurkha.LoginServlet",params:"uname="+encodeURIComponent(e)+"&upass="+encodeURIComponent(b)+"&requestFrom=check2faotp&otp="+encodeURIComponent(a)+"&userTimeZoneDate="+d,scope:this,timeout:120000,success:function(h){c.hide();
var n=h.responseText;var i=n.split(":");if(i[0]=="Error"){var f=Ext.getCmp("otperrorState");var j=i[1];var l="";if(j!=null&&((j.indexOf("The password is incorrect")!=-1)||(j.indexOf("password may be incorrect")!=-1))){var m=Ext.getCmp("pass").getValue();l="pass";}thisController.validateErrorTextTooltip(l,j,f);
return false;}else{if(reqFrom!=null&&reqFrom.toLowerCase()=="clstrial"){if(enableUserTracking!=null&&(enableUserTracking=="true"||enableUserTracking=="yes")){var k=window.location.href;_gaq.push(["_trackEvent","logon simulator login","login",k]);}Ext.Ajax.request({url:"/final/portal/PortalLogin/data/EgLogonp.jsp?username="+encodeURIComponent(parent.filterEncode(e))+"&comeFrom=login&reqFrom="+reqFrom,method:"POST",success:function(o){var r="";
var p="false";var t=o.responseText;var u=Ext.decode(t);var q=u["tab"];if(q!=null&&q!="monitor"){r="admin";p="yes";}var s=u["compType"];Ext.Ajax.request({url:"/final/portal/PortalLogin/data/EgSetSessionAttribute.jsp?entry="+r+"&reqFrom="+reqFrom+"&tab="+q+"&compType="+s+"&help="+p,method:"POST",scope:this,timeout:120000,success:function(v){window.location.href="/final/egm";
},failure:function(v){}});}});}else{if(reqFrom!=null&&reqFrom.toLowerCase()=="citrix"){var g="";Ext.Ajax.request({url:"/final/portal/PortalLogin/data/EgSetSessionAttribute.jsp?entry="+g+"&reqFrom="+reqFrom,method:"POST",scope:this,timeout:120000,success:function(o){window.location.href="/final/egm";},failure:function(o){}});
}}}},failure:function(f){c.hide();Ext.Msg.alert("Failed!","Sorry! Problem occured while logging in.");}});},finalLogin:function(e){var d=Ext.getCmp("hiddenuser").getValue();var b=Ext.getCmp("hiddenpwd").getValue();var c=new Ext.LoadMask(Ext.getBody(),{msg:"Signing in..."});c.show();if(e!=null&&e=="login"){var a=Ext.getCmp("errorState");
}else{if(e!=null&&e=="twofa"){var a=Ext.getCmp("otperrorState");}}Ext.Ajax.request({url:"/final/servlet/com.egurkha.LoginServlet",params:"uname="+encodeURIComponent(d)+"&upass="+encodeURIComponent(b)+"&comeFrom=clsTrial",scope:this,timeout:120000,success:function(h){c.hide();var g=h.responseText;var l=g.split(":");
if(l[0]=="Error"){var j;if(e!=null&&e=="login"){j=Ext.getCmp("errorState");}else{if(e!=null&&e=="twofa"){j=Ext.getCmp("otperrorState");}}var f=l[1];var m="";if(f!=null&&((f.indexOf("The password is incorrect")!=-1)||(f.indexOf("password may be incorrect")!=-1))){var i=Ext.getCmp("pass").getValue();m="pass";
}thisController.validateErrorTextTooltip(m,f,j);return false;}else{if(reqFrom!=null&&reqFrom.toLowerCase()=="clstrial"){if(enableUserTracking!=null&&(enableUserTracking=="true"||enableUserTracking=="yes")){var k=window.location.href;_gaq.push(["_trackEvent","logon simulator login","login",k]);}Ext.Ajax.request({url:"/final/portal/PortalLogin/data/EgLogonp.jsp?username="+encodeURIComponent(parent.filterEncode(d))+"&comeFrom=login&reqFrom="+reqFrom,method:"POST",success:function(n){var q="";
var o="false";var s=n.responseText;var t=Ext.decode(s);var p=t["tab"];if(p!=null&&p!="monitor"){q="admin";o="yes";}var r=t["compType"];Ext.Ajax.request({url:"/final/portal/PortalLogin/data/EgSetSessionAttribute.jsp?entry="+q+"&reqFrom="+reqFrom+"&tab="+p+"&compType="+r+"&help="+o,method:"POST",scope:this,timeout:120000,success:function(u){window.location.href="/final/egm";
},failure:function(u){}});}});}else{if(reqFrom!=null&&reqFrom.toLowerCase()=="citrix"){Ext.Ajax.request({url:"/final/portal/PortalLogin/data/EgSetSessionAttribute.jsp?entry=&reqFrom="+reqFrom,method:"POST",scope:this,timeout:120000,success:function(n){window.location.href="/final/egm";},failure:function(n){}});
}}}},failure:function(f,g){c.hide();thisController.validateErrorTextTooltip("","Failed!,Sorry! Problem occured while logging in",a);}});},getPassword:function(){var a=Ext.getCmp("fpusername").getValue();var b=Ext.getCmp("errorState2");if(a!=null&&a==""){thisController.validateErrorTextTooltip("fpusername",fmailIdMsg,b);
return false;}else{var c=new Ext.LoadMask(Ext.getBody(),{msg:"Fetching..."});c.show();Ext.Ajax.request({url:"/final/servlet/com.eg.LoginHelperServlet",params:"user="+encodeURIComponent(a),scope:this,timeout:120000,success:function(e){c.hide();var g=e.responseText;var d="";if(g!=null&&((g.indexOf("Username does not exist")!=-1))){g=mailIDCheckMsg;
d="fpusername";}var f=Ext.getCmp("errorState2");thisController.validateErrorTextTooltip(d,g+".",f);},failure:function(d){c.hide();thisController.validateErrorTextTooltip("","Problem occured while fetching the password.",b);}});}},closeGenericErrorTip:function(){Ext.getCmp("errorState").hide();},validateErrorTextTooltip:function(e,f,b){if(reqFrom=="clsTrial"){var d='<table width="100%" cellpadding="0px" cellspacing="0" class="ls_loginErrorMsg"><tr><td style="padding:10px 10px 10px 20px;valign:middle"><div class="iconExclamation"></div></td><td align="left" valign="middle" style="padding:10px 10px 10px 0px;font-size:11px;">'+f+"</td></tr></table>";
b.show();b.setErrors(d);if(!Ext.isEmpty(e)){Ext.getCmp(e).focus();}}else{if(reqFrom=="citrix"){if(cloudModel!=null&&cloudModel.toLowerCase()=="phoenix"){var d='<table width="100%" cellpadding="0px" cellspacing="0" class="ls_loginErrorMsg"><tr><td style="padding:10px 10px 10px 20px;valign:middle"><div class="iconExclamation"></div></td><td align="left" valign="middle" style="padding:10px 10px 10px 0px;font-size:11px;">'+f+"</td></tr></table>";
b.show();b.setErrors(d);if(!Ext.isEmpty(e)){Ext.getCmp(e).focus();}}else{if(!Ext.isEmpty(e)){var a=Ext.fly(e).getXY()[0];var g=Ext.fly(e).getXY()[1];if(e=="otp"){g=g+6;}var c=new Ext.ToolTip({anchor:"top",anchorOffset:0,anchortoTarget:true,mouseOffset:[0,-5],html:f,autoHide:false,cls:"cs_validateErrorTextTooltip",}).showAt([a,g+43]);
Ext.getCmp(e).addCls("cs_warning");}else{var d='<div class="cs_loginErrorMsg">'+f+'</div><div style="float:right"><img src="/final/images/spacer.gif" class="errorClose" id="errorClose" style="cursor:pointer;" onclick="javascript:thisController.closeGenericErrorTip();"></div>';Ext.getCmp("errorState").update(d);
Ext.getCmp("errorState").show();}}}}}});function checkspecial(d,b){var c=d;for(var a=0;a<c.length;a++){check_char=b.indexOf(c.charAt(a));if(check_char>=0){return false;}}return true;}function validateMobileNo(c){var j=/^(\+\d\d)?[0-9]+$/g;var h=/(\+?( |-|\.)?\d{1,2}( |-|\.)?)?(\(?\d{3}\)?|\d{3})( |-|\.)?(\d{3}( |-|\.)?\d{4})/gm;
var g=c.split(",");var e=g.length;var d=false;if(e!=null&&e==1){if(g.toString().length>=7&&g.toString().length<=20){var b=g.toString().match(j);var a=g.toString().match(h);if(g!=null&&b==g.toString()){d=true;}else{if(g!=null&&a==g.toString()){d=true;}else{d=false;}}if(g.toString().indexOf("123456789")!=-1){d=false;
}if(g.toString().match(/^(.)\1+$/gm)==g.toString()){d=false;}}else{d=false;}}else{for(var f=0;f<g.length;f++){if(g[f].length>=7&&g[f].length<=20){var b=g[f].match(j);var a=g[f].match(h);if(g!=null&&b==g[f]){d=true;}else{if(g!=null&&a==g[f]){d=true;}else{d=false;break;}}if(g[f].indexOf("123456789")!=-1){d=false;
break;}if(g[f].match(/^(.)\1+$/gm)==g[f]){d=false;break;}}else{d=false;break;}}}return d;}