
function checkpwd(){
	trimspace($$("oldpass"));
	if( $$("oldpass").value==""){
		alert("对不起,请输入原始密码！");
		$$("oldpass").focus();
		return false;
	}
	trimspace($$("userpass"));
	if( $$("userpass").value.length<6 || $$("userpass").value.length>15){
		alert("对不起,新密码只允许6-15 个字符！");
		$$("userpass").focus();
		return false;
	}
	if (!isRightPW($$("userpass").value)){
		alert("对不起,密码必须由字母、数字构成！");
		$$("userpass").select();
		return false;
   }
	trimspace($$("password"));
	if( $$("password").value==""){
		alert("对不起,请输入确认密码！");
		$$("password").focus();
		return false;
	}
	if( $$("password").value!=$$("userpass").value){
		alert("对不起,确认密码和新密码不一致，请重新输入！");
		$$("password").select();
		return false;
	}
	
}


function echo(obj,html)
{
	$$(obj).innerHTML=html;
}
function fopen(obj)
{
	$$(obj).style.display="";
}
function fclose(obj)
{
	$$(obj).style.display="none";
}

function Login(str1,str2,str3)
{
	var url="../request.aspx?action=login&str1="+escape(str1)+"&str2="+str2+"&str3="+str3;
	if(window.location.href.indexOf("loginother")!=-1){
		url = url.replace("../","");
	}
	var  Digital=new  Date();
	Digital=Digital+40000;
	url=url+"&k="+Digital;
	xmlHttp=GetXmlHttpObject(requestlogin)
	xmlHttp.open("POST", url , true)
	xmlHttp.send(null)
}
function requestlogin()
{
	if(xmlHttp.readyState==4)
	{
		if(xmlHttp.status==200)
		{
			var output=xmlHttp.responseText;
			if(output==3){
				output=1;	
				alert("尊贵的用户,您是第一次登陆本站，请更新您的个人资料。谢谢！");
			}
			else if(output==4){
				output=3;	
				alert("尊贵的用户,您是第一次登陆本站，请更新您的个人资料。谢谢！");
			}
			if(output==2)
			{
				parent.LoginHide();
				var s=getCookie("gotourl");
				if(s)
				{   
					if(s.indexOf("baoming.aspx?activeid=")!=-1){
						var nowid=s.replace("../baoming.aspx?activeid=","");
						parent.showwybaoming(nowid);	
					}
					else if(s.indexOf("order.aspx?id=")!=-1){
						var nowid=s.replace("../order.aspx?id=","");
						parent.showorder(nowid);	
					}
					else{
						parent.location.href=s;
					}
				}
			}
			else if(output==1)
			{
				var ss=getCookie("logingoto");
				
				var agan=getCookie("aganparent");
				if(agan=="1"){
					delCookie("aganparent");
					parent.LoginHide();
					var next = getCookie("nextcookie");
					delCookie("nextcookie");
					if(next){
						var nextvalue = next.split(",");
						if(nextvalue[0]=="1"){
							parent.showorder(nextvalue[1]);	
						}
						else if(nextvalue[0]=="2"){
							parent.showwybaoming(nextvalue[1]);	
						}
						else if(nextvalue[0]=="3"){
							parent.showtoujianli(nextvalue[1]);	
							//parent.window.location.href=parent.window.location.href;
						}
					}
				}
				else{
					if(ss){
						window.location.href=ss;
					}else{
						window.location.href="index.html";
					}
				}
			}
			else{
				alert(output);	
			}
						
		}
	}
}
		
 function checkinput(o) {
            var sberr = o.submitBackError;
        	if(sberr!= null){
        	  var p =sberr.parentNode;
        	  p.removeChild(sberr);
        	}
        
        	var logname = o.logname;
        	var logemail = logname.value;
      	 	var originalPW  = o.originalLogpasswd;
        	var oPW = originalPW.value;
			var showCode = '<div id="wrongshow">';
        	var hasWrongPW = false;
        	var WrongTipStr = "";
        	var isnulllogemail=(logemail=="")||(logemail==null)||(logemail.length==0);
			var lent=judgeString(logemail);
        	var isnullopw=oPW== "" || oPW == null || oPW.length == 0;
        	if(isnulllogemail&&isnullopw){
        		showCode +=　"请输入用户名和密码";
				logname.focus();
        		hasWrongPW = true;
        	} else if(isnulllogemail){
				logname.focus();
        		showCode += "请输入用户名";
        		hasWrongPW = true;
        	}
			else if(lent < 3 || lent > 16) {
        		showCode += '用户名长度为3到20个字';
				logname.select();
        		hasWrongPW = true;
        	} 
			else if(isnullopw) {
        		showCode += '必须填写密码';
				originalPW.focus();
        		hasWrongPW = true;
        	} else if(oPW.length < 6 || oPW.length > 32) {
        		showCode += '密码最少6个字，不得超过32个字';
				originalPW.select();
        		hasWrongPW = true;
        	} else if (!isRightPW(oPW)){
        		showCode += '密码必须由字母、数字构成';
				originalPW.select();
        		hasWrongPW = true;
        	} else {
        		hasWrongPW = false;
        	}
        	if(hasWrongPW)
        	{
        		showCode += '</tr></table>';
       			o.wrongTip.innerHTML = showCode;
        		o.wrongTip.style.visibility = "visible";
        		return false;
        	}
			var remeber=o.remember_password.checked;
			Login(logemail,oPW,remeber);
        	return false;
        }
		
function checkfloatlogin(){
	trimspace($$("logname"));
	trimspace($$("originalLogpasswd"));
	var logname = $$("logname")
    var logemail = logname.value;
    var originalPW  = $$("originalLogpasswd");
    var oPW = originalPW.value;
	var isnulllogemail=(logemail=="")||(logemail==null)||(logemail.length==0);
var lent=judgeString(logemail);
    var isnullopw=oPW== "" || oPW == null || oPW.length == 0;
	if(isnulllogemail){
	   logname.focus();
		alert("对不起,请输入您的用户名!");
	  return false;
   }
	if(lent < 3 || lent > 20) { 
		alert("对不起,用户名长度为3到20位!");
 	  return false;
   } 
  // setmsg('loginnamecheck','ok');
   if(isnullopw) {
		 alert("对不起,请输入您的密码!");
 	  return false;
   } else if(oPW.length < 6 || oPW.length > 32) {
		 alert("对不起,请输入6-32位的密码!");
 	  return false;
   } else if (!isRightPW(oPW)){
		  alert("对不起,请输入正确的密码!");
 	  return false;
   }
   //setmsg('loginpwdcheck','ok');
   Login(logemail,oPW,"agan");
   return false;
}
function checkloginname(){
	trimspace($$("logname"));
    var logemail = $$("logname").value;
	var isnulllogemail=(logemail=="")||(logemail==null)||(logemail.length==0);
	if(isnulllogemail){
		alert("对不起,请输入您的用户名!");
	 	return false;
   }
	var lent=judgeString(logemail);
	if(lent < 3 || lent > 20) {
		alert("对不起,用户名长度为3到20位!");
 	   return false;
   }  
}

function checkloginpwd(){
	trimspace($$("originalLogpasswd"));
    var originalPW  = $$("originalLogpasswd");
    var oPW = originalPW.value;
	 if(oPW.length < 6 || oPW.length > 32) {
		 alert("对不起,请输入6-32位的密码!");
 	 	 return false;
	  } 
	  else if (!isRightPW(oPW)){
		  alert("对不起,请输入正确的密码!");
		  return false;
	   }
  	 //setmsg('loginpwdcheck','ok');
}