// Copyright (c) 2008 Synology Inc. All rights reserved.
SYNOPHOTO_LOGINDIALOG=function(_1){config={modal:true,autoTabs:true,autoCreate:true,width:370,height:250,shadow:true,minWidth:370,minHeight:250,proxyDrag:true,closable:true,collapsible:false,center:{autoScroll:false,tabPosition:"top",closeOnTab:true,titlebar:false,alwaysShowTabs:true}};SYNOPHOTO_LOGINDIALOG.superclass.constructor.call(this,_1,config);this.addButton(photo_str_btnOK,this.onClickSubmit,this);this.addButton(photo_str_btnClose,this.hide,this);this.init();this.getLayout().getRegion("center").showPanel(0);this.addKeyListener(27,this.hide,this);this.addKeyListener([10,13],this.onClickSubmit,this);};Ext.extend(SYNOPHOTO_LOGINDIALOG,Ext.LayoutDialog,{form:null,messageContainer:Ext.id(),text_field_username:null,photo_url:null,init:function(){var _2=Ext.id();var _3=String.format("<div style=\"margin:20px; font-size:12px;\" id=\"{0}\">{1}</div><div style=\"margin:20px;\" id=\"{2}\"></div>",this.messageContainer,photo_login_hint,_2);var _4=this.getLayout();_4.beginUpdate();var cp=_4.add("center",new Ext.ContentPanel(Ext.id(),{autoCreate:true,title:photo_login,background:true}));_4.endUpdate();cp.setContent(_3);this.form=new Ext.form.Form({labelWidth:100,labelAlign:"right",buttonAlign:"right",trackResetOnLoad:true});this.text_field_username=new Ext.form.TextField({fieldLabel:photo_username,name:"username",allowBlank:false,width:170,validateOnBlur:true,validationEvent:"blur"});this.form.column({width:300},this.text_field_username,new Ext.form.TextField({fieldLabel:photo_password,name:"passwd",inputType:"password",width:170,validateOnBlur:true,validationEvent:"blur"}));this.form.render(_2);SYNOBLOG_UTILS.SetTextMaxLen(this.form,"username",15);SYNOBLOG_UTILS.SetTextMaxLen(this.form,"passwd",128);this.on("show",function(_6){_6.text_field_username.focus();});var el;this.form.on("actioncomplete",function(_8,_9){if(_9.result.success=="login_error"){el=Ext.get(this.messageContainer);el.dom.innerHTML="<font color='#FF0000'>"+photo_login_failed+"</font><br>"+photo_login_hint;}else{if(_9.result.success=="disable_account"){el=Ext.get(this.messageContainer);el.dom.innerHTML="<font color='#FF0000'>"+photo_login_disabled+"</font><br>"+photo_login_hint;}else{this.hide();var _a="/photo/index.php";if(this.photo_url!=null&&this.photo_url!=""){_a=this.photo_url;}window.location=_a;}}},this);},reset:function(){this.form.reset();var el=Ext.get(this.messageContainer);el.dom.innerHTML=photo_login_hint;},onClickSubmit:function(){if(this.form.isValid()){this.form.submit({url:"/blog/login.php",waitTitle:" ",waitMsg:photo_str_plz_wait,params:{action:"login",url:this.photo_url}});}},show_dialog:function(_c){this.photo_url=_c;this.show();}});function onLogin(_d){var _e=Ext.DialogManager.get("login-dlg");if(!_e){_e=new SYNOPHOTO_LOGINDIALOG("login-dlg");}_e.reset();_e.show_dialog(_d);}Ext.namespace("SYNOBLOG_UTILS");Ext.Ajax.on("requestcomplete",function(_1,_2,_3){if(SYNOBLOG_UTILS.checkServerError(_2)){_1.purgeListeners();}});SYNOBLOG_UTILS.SetTextMaxLen=function(_4,_5,_6){var _7=_4.findField(_5);if(_7){_7.getEl().dom.setAttribute("maxLength",_6);}};SYNOBLOG_UTILS.checkServerError=function(_8){if(_8&&_8.getResponseHeader){var _9=_8.getResponseHeader["x-request-error"];if(_9){_9=Ext.util.Format.trim(_9);var _a=blog_str_common_system_error;if(_9=="error_timeout"){_a=blog_str_common_session_timeout;}alert(_a);var _b=window.location.href;if(_b.indexOf("/blog")>=0){window.location="/blog/index.php";}else{window.location="/photo/index.php";}return true;}}return false;};SYNOBLOG_UTILS.arrayFindIndex=function(_c,_d){var i,_f=-1;for(i in _c){if(_c[i]==_d){_f=i;break;}}return _f;};Ext.form.SRadio=function(cfg){if(cfg.indent&&cfg.indent>0){var _11=13*cfg.indent;var _12=String.format("display: inline;width:{0}px;",_11);cfg.labelStyle=_12;cfg.labelSeparator="";}Ext.form.SRadio.superclass.constructor.apply(this,arguments);};Ext.extend(Ext.form.SRadio,Ext.form.Radio,{setValue:function(v){var _14=this.el.up("form").query("input[name="+this.el.dom.name+"]");if(typeof v=="string"){for(var j=0;j<_14.length;j++){var _16=Ext.getCmp(_14[j].id);if(_14[j].value==v){_14[j].checked=true;}else{_14[j].checked=false;}_16.checked=_14[j].checked;_16.fireEvent("check",_16,_16.checked);}}else{if(typeof v=="boolean"){if(v===true){this.setValue(this.el.dom.value);}}}},onClick:function(){if(this.el.dom.checked!=this.checked){this.setValue(this.el.dom.value);}}});