function loginVal() {
	var nickname = $("#nickName").val();
	var logpsw = $("#logPsw").val();
	var code = $("#code").val();
	
	if(nickname==""){
		alert("请输入用户名!");
        $("#nickName").focus();
        refreshCap();
        return false;
	}
	if(logpsw==""){
		alert("请输入密码!");
        $("#logPsw").focus();
        refreshCap();
        return false;
	}
	if(code==""){
		alert("请输入验证码!");
        $("#code").focus();
        refreshCap();
        return false;
	}
	
	var codeRet = $.ajax({
	                url : "/regCaptcha.do?captcha=" + code,
	                async : false,
	                cache : false
	            }).responseText;
	            
	if(codeRet=="0"){
		alert("验证码错误");
		$("#code").focus();
		refreshCap();
        return false;
	}else{
		var nicknameRet = $.ajax({
	                url : "/regNickname.do?nickname=" + nickname,
	                async : false,
	                cache : false
	            }).responseText;
	    if(nicknameRet=="1"){
	    	alert("用户名不存在");
	    	$("#nickName").focus();
	    	refreshCap();
            return false;
	    }else{
	    	var logpswRet = $.ajax({
	                url : "/regPswForAjax.do?logpsw=" + logpsw + "&nickname=" + nickname,
	                async : false,
	                cache : false
	            }).responseText;
	        if(logpswRet=="0"){
	        	alert("用户密码错误");
	        	$("#logPsw").focus();
	        	refreshCap();
                return false;
	        }
	    }        
	}
	
	var md5random = $.ajax({
	                url : "/getmd5random.do",
	                async : false,
	                cache : false
	            }).responseText;
	$("#logPsw").val(hex_md5(hex_md5(logpsw)+md5random));
	
	var cardid = $("#cardid").val();
//	var thisurl = document.URL;
//	$("#thisurl").val(thisurl);
	if(cardid.startWith("28") && cardid.endWith("03")){
		var game_id = $("#game_id").val();
		var group_id = $("#group_id").val();
		var server_id = $("#server_id").val();
		var ware_id = $("#ware_id").val();
		var counttype = $("#counttype").val();
		document.orderLogin.action = "/loginpersonDdtx.do?cardid="+cardid+"&game_id="+game_id+"&group_id="+group_id+"&ware_id="+ware_id+"&server_id="+server_id+"&counttype="+counttype;
		document.orderLogin.submit();
	}else if(cardid.startWith("28") && cardid.endWith("02")){
		var game_id = $("#game_id").val();
		var group_id = $("#group_id").val();
		var server_id = $("#server_id").val();
		var ware_id = $("#ware_id").val();
		var counttype = $("#counttype").val();
		
		document.orderLogin.action = "/loginpersonDdtx.do?cardid="+cardid+"&game_id="+game_id+"&group_id="+group_id+"&ware_id="+ware_id+"&server_id="+server_id+"&counttype="+counttype;
		document.orderLogin.submit();
	}else{			
		document.orderLogin.action = "/loginpersonDdtx.do?cardid="+cardid;
		document.orderLogin.submit();
	}
}

var VerifyCodeTimes=1;

function refreshCap(){
	document.getElementById("imgs").src = "/imagesCaptcha.jsp?"+(VerifyCodeTimes++);
}

function OrderieHandler(){
    if(event.keyCode==13){
    	loginVal();
    }
}