﻿/** 
 * @fileoverview Carpa Form JavaScript File 
 * @gspxname     Login.gspx 
 * @filename     Login.js 
 * @author       MyName <br> 
 * @createDate   2009-03-04 
 */ 
Type.registerNamespace('NarniaHome'); 

NarniaHome.LoginAction = function() {  
    NarniaHome.LoginAction.initializeBase(this);  
}

NarniaHome.LoginAction.prototype = {  
    initialize: function() {  
        NarniaHome.LoginAction.callBaseMethod(this, 'initialize');  
        this.get_form().username.focus();
    },

    dispose: function() {  
        NarniaHome.LoginAction.callBaseMethod(this, 'dispose');  
    },

    doLogin: function(sender) {     
        var form = this.get_form();
        if (form.get_service().get_isBusy()) {
    	    return; // 避免快速敲两次回车导致 Main.gspx 被访问两次
    	}
    	if (form.username.get_text() == "") {
    	    
    	    alert("没有输入用户名！");
    	    this.get_form().username.focus();
    	    return;
    	}
    	if (form.password.get_text() == "") {
    	    
    	    alert("没有输入密码！");
    	    this.get_form().password.focus();
    	    return;
    	}
    	if (form.verificationCode.get_text() == "") {
    	    
    	    alert("没有输入验证码！");
    	    this.get_form().verificationCode.focus();
    	    return;
    	}
        form.get_service().UserLogin(form.username.get_text(), 
            form.password.get_text(), 
            form.verificationCode.get_text(), 
            form.rbValidTime.get_selectedIndex(),
            Function.createDelegate(this, this.doReturn));
    },
    
    doReturn: function() {
        ReturnPrePage(this.get_form());
    },
    
    doCancel: function() {
        ReturnPrePage(this.get_form());
    }
}
NarniaHome.LoginAction.registerClass('NarniaHome.LoginAction', Sys.UI.PageAction);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();