//AJAX请求
 function vali_login(){
		var username = document.getElementById("username").value;
		var password = document.getElementById("password").value;
		var action = document.getElementById("action").value;

		if(username.length == 0){
			$("vali_usernames").innerHTML="用户名不能为空!";
			return false;
		}else if(username.length <4 || username.length >20){
			$("vali_usernames").innerHTML="用户名长度只能是4-20字符英文字符和数字组成!";
			return false;
		}else if(password.length == 0){
			$("vali_usernames").innerHTML="密码不能为空!";
			return false;
		}else if(password.length <6 || username.length >20){
			$("vali_usernames").innerHTML="密码长度只能是6-20字符英文字符和数字组成!";
			return false;
		}else{
			password = "dhpt"+password;
			url=ourl+"productregAction.jspx?action=showUserNameLogin&username="+username+"&password="+action+"&actions="+password+"&radom="+Math.random();
			getvaloginajax(url);
		}
	}
	
   function getvaloginajax(URL){
	 var myAjax = new Ajax.Request(
	    URL,
	    {
	        method:"get",
	        onComplete:showvaloginajax
	    }
       );
	}
	///回调函数
	function showvaloginajax(result){
		var res = result.responseText;
		var flag = res.replace(/(^\s*)|(\s*$)/g,"");
		
		if(flag == "false"){
			//document.getElementById("login_div").style.visibility="visible";
			document.getElementById("username").value="";
			document.getElementById("password").value="";
	 		document.getElementById('vali_usernames').innerHTML = "用户名和密码不正确!";
	 	}
	 	else{
	 		var action= document.getElementById("action").value;
			url=ourl+"productregAction.jspx?action=showLoginpage&actions="+action+"&radom="+Math.random();
			document.location.href=url;
	 	}
	}
  
	
	//把焦点转到密码框
	function passwordonfource(){
  		document.getElementById("password").focus();
  		return;
  	}
	
	//忘记密码
	function forgetpassword(){
		url = ourl+"productUserinfoAction.jspx?action=showforgetpassword&rand="+Math.random();
		document.location.href=url;
	}
	
	//新用户？快来注册
	function newuserregister(){
		url=ourl+"productUserinfoAction.jspx?action=shownewuserregister&rand="+Math.random();
		document.location.href=url;
	}
	
	//用户框失去焦点
	function vali_user(){
		var username = document.getElementById("username").value;
		if(username.length == 0){
			$("vali_usernames").innerHTML="用户名不能为空!";
			return false;
		}else if(username.length <4 || username.length >20){
			$("vali_usernames").innerHTML="用户名长度只能是4-20字符英文字符和数字组成!";
			return false;
		}
	}
	
	//用户框获得焦点
	function focus_username(){
		$("vali_usernames").innerHTML = "";
	}
	
	//密码框失去焦点
	function vali_pwd(){
		var password = document.getElementById("password").value;
		if(password.length == 0){
			$("vali_usernames").innerHTML="密码不能为空!";
			return false;
		}else if(password.length <6 || username.length >20){
			$("vali_usernames").innerHTML="密码长度只能是6-20字符英文字符和数字组成!";
			return false;
		}
	}
	//密码框获得焦点
	function focus_pwd(){
		$("vali_usernames").innerHTML="";
	}
	
	
