function AJAXLogin(login){
	var username=document.forms[login].username.value
	var Password=document.forms[login].Password.value
    var validate=document.forms[login].validate.value
	if(username.length<1){
		alert("错误提示：用户名不能为空！    ");
		return false;
	}else if(Password.length<1){
		alert("错误提示：密码不能为空！    ");
		return false;
	}else if(validate.length!=4){
		alert("错误提示：验证码只能为4位数！    ");
		return false;
	}else {
		var ajax=new AJAXRequest;
		ajax.postf(login,function (obj){
			var TempStr = obj.responseText;
           if(TempStr == 1){
              setTimeout("location.reload()", 0000);
		   }else {
			  alert(TempStr);
		   }
		}
		);
	}
}

function AJAXLogout(){
	var ajax=new AJAXRequest;
	ajax.get("Action.asp?action=ajaxlogout",
    function (obj){setTimeout("location.reload()", 0000);}
 );
}

function openclose(where){
	var openclose=$(where);
   if (openclose.style.display =="none"){
	openclose.style.display="block";}
    else{
    openclose.style.display="none";
   }
  }

function showajaxlogin(){
document.writeln("<style type=\"text\/css\">");
document.writeln("#AJAXLoginContainers{");
document.writeln("	position:fixed;");
document.writeln("	top:100px;");
document.writeln("	left:0px;");
document.writeln("	text-align:center;");
document.writeln("	z-index:20;");
document.writeln("	width:100%;");
document.writeln("	position:absolute;");
document.writeln("	top:expression(offsetParent.scrollTop + 220 + \"px\");");
document.writeln("}");
document.writeln("#AJAXLoginContainers #AJAXLogins{");
document.writeln("	top:100px;");
document.writeln("	border:3px double #000000;");
document.writeln("	margin:auto;");
document.writeln("	width:260px;");
document.writeln("	padding:10px;");
document.writeln("}");
document.writeln("#AJAXLoginContainers #AJAXLogins #MsgHead{");
document.writeln("	padding:5px;");
document.writeln("	text-align:center;");
document.writeln("	font:bold 11px \"Trebuchet MS\";");
document.writeln("	color:#9C0;");
document.writeln("	letter-spacing:3px");
document.writeln("}");
document.writeln("<\/style>")
document.writeln("<div id=\"AJAXLoginContainers\" style=\"display:none;\">")
document.writeln("<div id=\"AJAXLogins\">")
document.writeln("<div id=\"MsgHead\"><span style=\"font-size:16px\">           用户登录<\/span>          <input type=\"image\" src=\"images\/icon_del.gif\" align=\"absMiddle\" border=\"0\" id=\"AJAXCancelBtns\" onclick=\"openclose('AJAXLoginContainers');\" title=\"关闭登录框\"\/><br><\/div><\/br>");
document.writeln("<form name=\"ajaxloginx\" id=\"ajaxloginx\" action=\"Action.asp?action=ajaxlogin\" method=\"post\" style=\"margin:0px;\">")
document.writeln("<label><b>用户名︰<\/b><input type=\"text\" name=\"username\" class=\"userpass\" size=\"15\"\/><\/label><br\/>")
document.writeln("<label><b>密　码︰<\/b><input type=\"password\" name=\"Password\" class=\"userpass\" size=\"15\"\/><\/label><br>")
document.writeln("<label><b>验证码：<\/b><input type=\"text\" name=\"validate\" class=\"userpass\" size=\"8\" maxlength=\"4\"\/><\/label><img id=\"vcodeImg\" src=\"about:blank\" alt=\"验证码\" title=\"看不清楚?换一张\" style=\"cursor:pointer;width:40px;height:18px;margin-bottom:-4px;margin-top:3px;\" onclick=\"src=\'common\/getcode.asp?s=\'+Math.random()\"\/><br>")
document.writeln("<label style=\"margin-left:-35px;\"><b>保　存︰<\/b><\/label><select size=\"1\" name=\"AJAXKeepLogin\"><option selected=\"selected\" value=\"0\">不保存<\/option><option value=\"1\">一　天<\/option><option value=\"7\">一星期<\/option><option value=\"30\">一个月<\/option><option value=\"365\">一　年<\/option><\/select><br><br>")
document.writeln("<input type=\"button\" value=\"登　陆\" class=\"userbutton\" onclick=\"AJAXLogin('ajaxloginx');\"\/>")
document.writeln("<input type=\"button\" value=\"用户注册\" class=\"userbutton\" onclick=\"location.href=\'\/register.asp\'\"\/><br\/>")
document.writeln("<\/form>")
document.writeln("<\/div>")
document.writeln("<\/div>")
}
