/*
 * 
 */
var helpWin=new Ext.Window({title:EMASUK.locale.helpTitle,height:200,layout:"fit",closeAction:"hide",iconCls:"icon-help-small",constrain:true,renderTo:typeof(viewport)!="undefined"?viewport.workspace.getEl():"",cls:"window-help",tbar:[{iconCls:"icon-help-back",handler:function(){helpWin.navigate("back")}},{iconCls:"icon-help-forward",handler:function(){helpWin.navigate("forward")}},"-",{iconCls:"icon-help-home",handler:function(){helpWin.setTopic("index")}},"-",{iconCls:"icon-email",handler:function(){supportWin.show()}}],listeners:{hide:function(a){if(a.isWarning){a.removeWarning()}}},history:[],historyPosition:0,isWarning:false,topic:"",getTopic:function(){return helpWin.topic},navigate:function(c){var b=helpWin.history;var a=helpWin.historyPosition;if((c=="back")&&(a!=0)){helpWin.setTopic(b[a-1],true);helpWin.historyPosition=a-1}else{if((c=="forward")&&(a!=b.length-1)){helpWin.setTopic(b[a+1],true);helpWin.historyPosition=a+1}}},removeWarning:function(){helpWin.setTitle(helpWin.initialConfig.title);helpWin.setIconClass(helpWin.initialConfig.iconCls)},setTopic:function(a,e,b){if(b){helpWin.warning()}else{if(helpWin.isWarning){helpWin.removeWarning()}}var d=helpWin.history;var c=helpWin.historyPosition;helpWin.load({url:"/requestHandler.aspx",params:{action:"help",topic:a},callback:function(j,k,g,h){helpWin.postProcess();helpWin.topic=h.params.topic;if(!e){Ext.each(helpWin.history,function(n,m,l){if(m>helpWin.historyPosition){l.pop()}});helpWin.history.push(h.params.topic);helpWin.historyPosition=helpWin.history.length-1}var i=helpWin.getTopToolbar().items.items[0];if(helpWin.historyPosition>0){i.enable()}else{i.disable()}var f=helpWin.getTopToolbar().items.items[1];if(helpWin.historyPosition<helpWin.history.length-1){f.enable()}else{f.disable()}}})},toggleToolbar:function(b){var a=helpWin.getTopToolbar();if(b){a.show()}else{a.hide()}},warning:function(){helpWin.setTitle("Warning");helpWin.setIconClass("icon-warning");helpWin.isWarning=true},postProcess:function(){Ext.each(helpWin.getEl().query(".x-window-body a[@class!=no-postprocessing]"),function(e,b,a){var f=document.location.protocol+"//"+document.location.hostname+"/";var g=".html";var d=(e.href).replace(f,"").replace(g,"");var c=new Ext.Element(e);c.set({href:"#"});c.on("click",function(){helpWin.setTopic(d)})})}});var supportWin=new Ext.Window({title:EMASUK.locale.supportTitle,height:340,minHeight:340,width:500,minWidth:500,iconCls:"icon-email",layout:"fit",closeAction:"hide",constrain:true,items:[{xtype:"form",border:false,baseCls:"x-plain",bodyStyle:"padding:5px;",monitorValid:true,url:"/requestHandler.aspx",baseParams:{action:"support-submit"},waitMsgTarget:true,method:"post",labelWidth:170,defaults:{allowBlank:false,xtype:"textfield",anchor:"-20"},items:[{xtype:"box",anchor:0,height:30,autoEl:{tag:"div",cls:"login-message",html:EMASUK.locale.supportInstructions}},{name:"name",fieldLabel:EMASUK.locale.supportNameField},{name:"username",fieldLabel:EMASUK.locale.supportUsernameField,allowBlank:true},{name:"membership-number",fieldLabel:EMASUK.locale.supportMembershipField,allowBlank:true},{name:"email",fieldLabel:EMASUK.locale.supportEmailField},{name:"telephone",fieldLabel:EMASUK.locale.supportTelephoneField,allowBlank:true},{xtype:"textarea",name:"message",fieldLabel:EMASUK.locale.supportMessageField,height:100}]}],buttons:[{text:EMASUK.locale.supportSendButton,iconCls:"icon-email",handler:function(){supportWin.sendMessage()}}],listeners:{beforeshow:function(a){a.form=a.findByType("form")[0];var b=a.form.getForm().findField("username");if(Ext.util.Cookies.get("emasuk-username")){b.setValue(Ext.util.Cookies.get("emasuk-username"))}}},sendMessage:function(){var a=supportWin.form;var b=a.getForm();var c=supportWin.buttons[0];if(b.isValid()){a.getEl().mask(EMASUK.locale.supportSendingMask,"x-mask-loading");c.disable();b.doAction("submit",{success:function(d,e){a.getEl().unmask();c.enable();Ext.Msg.show({title:EMASUK.locale.supportSentTitle,msg:EMASUK.locale.supportSent,buttons:Ext.Msg.OK,fn:function(f){supportWin.hide();b.reset()},icon:Ext.MessageBox.INFO})},failure:function(d,e){a.getEl().unmask();c.enable()}})}}});var loginWin=new Ext.Window({title:"&nbsp;",width:314,height:225,layout:"vbox",closable:false,resizable:false,maskDisabled:true,buttonAlign:"left",fbar:[{text:EMASUK.locale.helpButton,iconCls:"icon-help-small",handler:function(){helpWin.setSize(200,loginWin.getHeight());helpWin.setPagePosition(loginWin.getPosition()[0]+loginWin.getWidth()+3,loginWin.getPosition()[1]);helpWin.show();helpWin.toggleToolbar(false);helpWin.setTopic("login")}},"->",{text:EMASUK.locale.loginButton,iconCls:"icon-login",handler:function(){loginWin.processLogin()}}],items:[{xtype:"box",height:45,autoEl:{tag:"img",src:"/images/login.jpg"}},{xtype:"form",ref:"form",border:false,baseCls:"x-plain",bodyStyle:"padding:5px;",monitorValid:true,url:"/requestHandler.aspx",baseParams:{action:"login"},waitMsgTarget:true,method:"post",width:300,usernameTextField:new Ext.form.TextField({name:"u",ref:"usernameField",fieldLabel:EMASUK.locale.usernameField}),usernameTriggerField:new Ext.form.TriggerField({name:"u",ref:"usernameField",triggerConfig:{title:EMASUK.locale.usernameFieldTrigger,tag:"img",src:Ext.BLANK_IMAGE_URL,cls:"x-form-trigger x-form-clear-trigger"},fieldLabel:EMASUK.locale.usernameField,listeners:{beforerender:{fn:function(a){a.onTriggerClick=function(b){Ext.util.Cookies.clear("emasuk-username");loginWin.form.remove(a);loginWin.form.insert(1,loginWin.form.usernameTextField);loginWin.form.doLayout();loginWin.form.usernameTextField.focus()}}}}}),defaults:{allowBlank:false,xtype:"textfield",anchor:"-20"},items:[{xtype:"box",anchor:0,height:35,ref:"notifier",autoEl:{tag:"div",cls:"login-notifier",html:EMASUK.locale.notifierDefault}},{name:"p",inputType:"password",ref:"passwordField",fieldLabel:EMASUK.locale.passwordField}],keys:{key:[10,13],fn:function(){loginWin.processLogin()}},listeners:{afterrender:{fn:function(b){var a=Ext.util.Cookies.get("emasuk-username");if(a){var c=b.insert(1,b.usernameTriggerField);c.setValue(a);b.passwordField.focus(false,1000)}else{var c=b.insert(1,b.usernameTextField);c.focus(false,1000)}}}}}],listeners:{show:function(a){if(Ext.isIE6){helpWin.setSize(200,a.getHeight());helpWin.setPagePosition(a.getPosition()[0]+a.getWidth()+3,a.getPosition()[1]);helpWin.show();helpWin.toggleToolbar(false);helpWin.setTopic("support-ie6",true,true)}}},processLogin:function(){var b=this;var a=this.form;if(a.getForm().isValid()){a.notifier.removeClass("login-notifier-error");a.notifier.getEl().update("");b.body.mask(EMASUK.locale.notifierProcessingLogin,"x-mask-loading");a.getForm().doAction("submit",{success:function(c,d){b.body.mask(EMASUK.locale.notifierSuccess,"x-mask-loading");Ext.util.Cookies.set("emasuk-username",a.usernameField.getValue());window.location=("/index.aspx")},failure:function(c,e){var f;if(e.result){if(!e.result.success){f=e.result.reason}}if(f=="bad-login"){var d=e.result.message;b.body.unmask();a.notifier.getEl().update(d);a.notifier.addClass("login-notifier-error");a.passwordField.reset();a.passwordField.focus()}}})}}});
