﻿function refreshValdCode(name){
    var imgValidCode=document.getElementById(name);
    var imgSrc=imgValidCode.src;
    var index=imgSrc.indexOf("t=");
    
    if (index>0) {
        imgSrc=imgSrc.substr(0,index)+"t="+new Date();
    }
    else {
        imgSrc=imgSrc+"&t="+new Date();
        
    }
    
    imgValidCode.src=imgSrc;
}

function chgAccountType(senderName){
     var control=document.getElementById(senderName);
     if (control){
        if (control.checked){
            var lblAccountType=document.getElementById("lblAccountType");
            if (lblAccountType)
                lblAccountType.innerHTML=control.value;
        }
     }
     
}


function setTab(name,cursel,n){ 
for(i=1;i<=n;i++){ 
    var menu=document.getElementById(name+i); 
    var con=document.getElementById("con_"+name+"_"+i); 
    if (menu)
        menu.className=(i==cursel)?"hover":""; 
    if (con)
        con.style.display=(i==cursel)?"block":"none"; 
    } 
} 

$(document).ready(function(){
    //弹出窗口初始化
    $("#loginDialog").dialog({
        bgiframe: true,
        autoOpen: false,
        minHeight: 210,
        minWidth:300,
        modal: true,
        buttons: {
        },
        close: function() {
        }
    });
    
    $("#loginDialog").bind("keydown",function(event){
        if(event.keyCode==13){
            event.keyCode=9;
            return false;
         }
    })
        
    //按钮绑定单击事件(激活登录窗口)
    var allActiveFields = $([]).add($("#A2")).add($("#A3")).add($("#A4")).add($("#openDialog"));
    allActiveFields.click(function(){
        var allFields = $([]).add($("#txtUserName")).add($("#txtPassword"));
        allFields.val("");
        var allFieldValidators = $([]).add($("#rfvUserName")).add($("#rfvPassword")).add($("#rfvValidCode")).add($("#lblErrMessage"));
        allFieldValidators.text("");
        
        $('#loginDialog').dialog('open');
        $('.ui-dialog').appendTo('#form1');	
        $("#txtUserName").focus();
    })
    
    //提交登录前验证数据
    $("#Submit1").click(function(){
        debugger;
        var msg = "";
        if ($("#txtUserName").val() == ""){
            msg = "ss用户名不能为空";
        }
        if ($("#txtPassword").val() == ""){
            msg = "ss密码不能为空";
        }
        
        if (msg != ""){
            $("#lblErrMessage").text(msg);
            return false;
        }
    })
    
    //按钮样式
    //    $("input[type='button']").mouseover( function(){
    //        //debugger;
    //        $(this).attr("class","button2");
    //    });
    //    $("input[type='button'][type='submit'][type='reset']").mouseout( function(){
    //        $(this).attr("class","button1");
    //    });
})
