var win;var theform;function doJSON(A){try{var B=Ext.util.JSON.decode(A);return B}catch(C){Ext.MessageBox.alert("ERROR","Could not decode "+A)}}function checkLogin(theelement,theevent,theevent2){function doLogin(btn){if(btn=="ok"||btn=="yes"){return true}else{return false}}Ext.Ajax.request({url:"index.cfm",defaultHeaders:"application/ajax",params:{event:"general.userLoginCheck"},method:"POST",callback:function(options,success,response){result=doJSON(response.responseText);if(!result.SUCCESS){if(theevent=="openLogin"){openLogin(theelement,false);return false}else{Ext.Msg.confirm("Log in?","You must be logged in to perform this function.<br/><br/>Would you like to log in now?",function(btn){if(doLogin(btn)){Ext.Msg.hide();openLogin(theelement,true,theevent,theevent2)}return false})}}else{if(theevent=="openLogin"){doLoginWork()}else{eval(theevent);eval(theevent2)}return false}},scope:this})}function doLoginWork(){top.removeTab("thank-you-tab");Ext.getCmp("profilePanel").load({url:"index.cfm?event=user.common.profile.getProfileBox"});top.updateTab("UserHome","My Homepage","index.cfm?event=user.common.myHome.dspUserHome","iframepanel","profileIconTab",true,true,1);Ext.getCmp("logoff").enable();Ext.getCmp("login").disable();Ext.getCmp("signup").disable();Ext.getCmp("logoff").show();Ext.getCmp("login").hide();Ext.getCmp("signup").hide();Ext.getCmp("friendsPanel").enable();Ext.getCmp("profilePanel").enable();Ext.getCmp("messagingPanel").enable();Ext.getCmp("friendsPanel").show();Ext.getCmp("profilePanel").show();Ext.getCmp("messagingPanel").show();Ext.getCmp("messagingPanel").expand();top.CheckMessagesRequestsLogin()}function clearAccount(){delete_cookie("savedUserName");delete_cookie("savedRemUser");doLogout()}function cleanUp(){top.removeTab("UserHome");top.removeTab("messaging-tab");top.removeTab("friends-tab");top.removeTab("profile-tab");Ext.getCmp("friendsPanel").disable();Ext.getCmp("profilePanel").disable();Ext.getCmp("messagingPanel").disable();Ext.getCmp("friendsPanel").hide();Ext.getCmp("profilePanel").hide();Ext.getCmp("messagingPanel").hide();Ext.getCmp("logoff").disable();Ext.getCmp("logoff").hide();Ext.getCmp("login").enable();Ext.getCmp("signup").enable();Ext.getCmp("login").show();Ext.getCmp("signup").show();Ext.getCmp("helpPanel").expand()}function doLogout(){var A=new Ext.data.Connection();A.on({beforerequest:function(){Ext.Msg.wait("Please wait while we log you out of the system...","Logging Out")},requestcomplete:function(){Ext.Msg.hide();cleanUp()}});A.request({url:"index.cfm",defaultHeaders:"application/ajax",params:{event:"general.doLogout"},method:"POST",callback:function(C,D,B){result=doJSON(B.responseText);if(!result.SUCCESS){Ext.Msg.alert("Logout Unsuccessful","There was an error processing your logout request. Please close your browser to ensure proper logout.")}},scope:this})}function doForgotPass(){var A=get_cookie("savedUserName");if(A==null){A=""}top.updateTab("password-tab","Password Change","index.cfm?event=users.dspPasswordChangeRequest&email="+A,"iframepanel","helpIconTab");win.hide()}function doActivationHelp(){top.updateTab("help-policy","FAQs","index.cfm?event=blvdGeneral.dspFAQs&displayLayout=Layout.tier2#Activate","iframepanel","helpIconTab");win.hide()}function doSubmit(){var theUserName=Ext.getCmp("loginUsername").getValue();var thePassword=Ext.getCmp("loginPassword").getValue();var hasANextEvent=Ext.getCmp("hasNextEvent").getValue();var nxtEvent=Ext.getCmp("nextEvent").getValue();var nxtEvent2=Ext.getCmp("nextEvent2").getValue();var remUser=Ext.getCmp("rememberUser").getValue();document.getElementById("msgDisplay").innerHTML="&nbsp;";theform=Ext.getCmp("loginForm");if(theform.form.isValid()){var req=new Ext.data.Connection();req.on({beforerequest:function(){Ext.Msg.wait("Verifying login information..","Logging In")},requestcomplete:function(){Ext.Msg.hide()}});req.request({url:"index.cfm?event=general.doLogin",defaultHeaders:"application/ajax",params:{username:theUserName,password:thePassword,saveUser:remUser},method:"POST",callback:function(options,success,response){result=doJSON(response.responseText);if(!result.SUCCESS){Ext.getCmp("loginPassword").setRawValue("");document.getElementById("msgDisplay").innerHTML=result.ERROR}else{wasSuccess=1;if(remUser){set_cookie("savedUserName",theUserName,365);set_cookie("savedRemUser","1",365)}else{delete_cookie("savedUserName");set_cookie("savedRemUser","0",365)}win.hide();if(!hasANextEvent){top.doLoginWork()}else{eval(nxtEvent);eval(nxtEvent2)}}},scope:this})}else{Ext.MessageBox.alert("Submit Error","Every field must be correctly populated.")}}function initForm(){Ext.getCmp("loginUsername").setRawValue(get_cookie("savedUserName"));Ext.getCmp("rememberUser").setValue(get_cookie("savedRemUser"));Ext.getCmp("loginUsername").focus(true,60)}function openLogin(D,A,B,C){if(A){Ext.getCmp("hasNextEvent").setValue(A);Ext.getCmp("nextEvent").setValue(B);if(C){Ext.getCmp("nextEvent2").setValue(C)}}win.show(Ext.get(D),initForm,this);win.toFront()}Ext.onReady(function(){Ext.QuickTips.init();Ext.form.Field.prototype.msgTarget="side";theform=new Ext.FormPanel({labelAlign:"left",frame:true,id:"loginForm",width:260,labelWidth:65,hideParent:true,border:true,bodyBorder:true,header:false,defaultType:"textfield",defaults:{validationEvent:"false",validateOnBlur:false},items:[{id:"msgHolder",readOnly:true,disabled:true,hidden:true,hideLabel:true,listeners:{render:function(B){var A=B.getEl().up("div.x-form-element");if(A){A.createChild({tag:"div",html:"&nbsp;",id:"msgDisplay",style:"text-align:center; font-weight:bold; color:#FF0000; margin-left:5px;"})}}}},{xtype:"hidden",id:"nextEvent"},{xtype:"hidden",id:"nextEvent2"},{xtype:"hidden",id:"hasNextEvent"},{fieldLabel:"<b>Email</b>",id:"loginUsername",tabIndex:1,selectOnFocus:true,width:160,allowBlank:false,listeners:{focus:function(A){this.clearInvalid()}}},{fieldLabel:"<b>Password</b>",inputType:"password",tabIndex:2,selectOnFocus:true,id:"loginPassword",allowBlank:false,listeners:{focus:function(A){this.clearInvalid()}}},{xtype:"checkbox",boxLabel:"Remember me on this computer",id:"rememberUser",tabIndex:3,inputValue:"1",labelSeparator:"",width:"auto",listeners:{render:function(B){var A=B.getEl().up("div.x-form-item");if(A){A.createChild({tag:"div",html:'<a id="forgotPass" class="forgotPass" href="index.cfm?event=users.dspPasswordChangeRequest" title="Forgot password?" onclick="doForgotPass(); return false;">Forgot password?</a>',style:"text-align:center; font-weight:normal; color:#FF0000; margin:5px;"})}}}}],buttons:[{text:"Login",type:"submit",tabIndex:5,id:"Submit",handler:doSubmit},{text:"Cancel",tabIndex:6,handler:function(){theform.form.clearInvalid();win.hide();return false}}],keys:[{key:Ext.EventObject.ENTER,fn:doSubmit}]});if(!win){win=new Ext.Window({layout:"fit",title:"Login",id:"loginWindow",width:310,height:200,closeAction:"hide",plain:true,draggable:false,resizable:false,modal:true,border:false,items:theform})}win.on("hide",function(){document.getElementById("msgDisplay").innerHTML="&nbsp;";Ext.getCmp("loginPassword").setRawValue("");theform.form.clearInvalid()})});