var loginuid;
var loginuname;
var xmlHttp;
function cxhr()
{
	if (window.ActiveXObject)
	{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest)
	{
		xmlHttp=new XMLHttpRequest();
	}	
	
}
function checkTextDataForENGLISH(strValue) {
	var regTextEnglish = /^[a-zA-Z0-9]*$/;
	return regTextEnglish.test(strValue);
}



function checkForm() 
{
	
	var uname = document.logindd.username.value;
	var passwd = document.logindd.password.value;
	var verifycode = document.logindd.verifycode.value;
	if(uname == "" ) {
		alert('请输入用户名！');
		document.logindd.username.focus();
		return false;
	}
	if(passwd=="") {
		alert('请输入密码！');
		document.logindd.password.focus();
		return false;
	}
	if(verifycode == "" ) {
		alert('请输入验证码！');
		document.logindd.verifycode.focus();
		return false;
	}
	if (!checkTextDataForENGLISH(uname)){
	    alert("尊敬得用户，所有会员用户名将只容许英文、数字组合,请您用上几秒钟修改你得用户信息!");  
		this.location.href=this.location.href;
		return false;
	 }
	 
	    err.innerHTML='<img src=/images/loading.gif>正在登陆...';
        cxhr();
		//var url="http://www.i-jjj.com/users/checklogin.asp?username="+uname+"&password="+passwd+"&verifycode="+verifycode+"";
		var url="checklogin_ajx.asp?username="+uname+"&password="+passwd;
	   xmlHttp.open("get",url,true); 
       xmlHttp.onreadystatechange=function() 
        { 
            if(xmlHttp.readyState==4) 
            { 
                if(xmlHttp.status==200) 
                { 
				// alert(xmlHttp.responseText);
				
				  var errs=xmlHttp.responseText;
				  if (errs=="0")
				  {
				    err.innerHTML='登录用户名或密码错误！';
					return false;
				  }
				  if (errs=="1")
				  {
				  //  login_box.innerHTML="<table width=90% border=0 align=center cellpadding=0 cellspacing=0 class=f_3><tr><td width=39>帐号：</td><td width=80>"+userid+"</td><td width=33 align=center>密码:</td> <td width=64>******</td></tr></table>";
					//login_btn.innerHTML="<a  style=cursor:hand onClick=userout('../users/Login_out.asp'); >[退出]</a> ";
					alert('登录成功');
					err.innerHTML='登录成功！';
					doOk();
				  }
                } 
            } 
        } 
        xmlHttp.send(null); 
    } 
///////////////////////////////////////////////
function sAlert(refpage){
//	var eSrc=(document.all)?window.event.srcElement:arguments[1];
	var shield = document.createElement("div");
	shield.id = "shield";
	shield.style.position = "absolute";
	shield.style.left = "0px";
	shield.style.top = "0px";
	shield.style.width = "100%";
	shield.style.height = document.body.scrollHeight+"px";
	shield.style.background = "#333";
	shield.style.textAlign = "center";
	shield.style.zIndex = "10000";
	shield.style.filter = "alpha(opacity=0)";
	shield.style.opacity = 0;
	var alertFram = document.createElement("div");
	alertFram.id="alertFram";
	alertFram.style.position = "absolute";
	alertFram.style.left = "50%";
	alertFram.style.top = "50%";
	alertFram.style.marginLeft = "-205px" ;
	alertFram.style.marginTop = -75+document.documentElement.scrollTop+"px";
	alertFram.style.width = "0px";
	alertFram.style.height = "260px";
	alertFram.style.background = "#333";
	alertFram.style.zIndex = "10001";
	
	
	strHtml = '<div class="Login_wrap">\n';
	strHtml = strHtml +'<div class="Login_content">\n';
	strHtml = strHtml +'<a href="#" title="关闭"><img src="http://tk.i-jjj.com/images/close.gif" alt="关闭" title="关闭" id="do_OK" onclick="doOk()" class="login_close_img" /></a>\n';
	strHtml = strHtml +'<h2><span class="below"><a href="http://www.i-jjj.com/Users/register_1.asp" title="快速注册" target="_blank">快速注册?</a></span>&nbsp;&nbsp;用户登录</h2>\n';
	strHtml = strHtml +'<table height="200" width="150 border="0" align="center" cellpadding="2" cellspacing="2">\n';
	strHtml = strHtml +'<form id="logindd" name="logindd" method="post" target="_self">\n';
	
	strHtml = strHtml +'<tr><td width="190" align="right"><div style="width:50px">帐号：</div></td>\n';
	strHtml = strHtml +'<td colspan="2"><input name="username" type="text" onfocus="this.className=\'login_input Hot_input\'" onblur="this.className=\'login_input\'" class="login_input" />';
	
	strHtml = strHtml +'<input name=\"savecookic\" type=\"hidden\" value=\"yes\"/></td>\n';
	strHtml = strHtml +'</tr><tr><td width="50" align="right">密码：   </td>\n';
	strHtml = strHtml +'<td colspan="2"><input name="password" type="password" onfocus="this.className=\'login_input Hot_input\'" onblur="this.className=\'login_input\'" class="login_input" /><input name="url" type="hidden" value="" /></td>\n';
	
	strHtml = strHtml +'</tr><tr><td align="right">验证码：</td>\n';
	strHtml = strHtml +'<td colspan="2"><input name="verifycode" type="text" id="verifycode" size="10" maxlength="4" onfocus="this.className=\'login_input Hot_input\'" onblur="this.className=\'login_input\'" class="login_input" /><IMG src="http://www.i-jjj.com/Inc/verifycodes.asp"></td>\n';

	strHtml = strHtml +'</tr><tr><td height="40">&nbsp;</td><td width="35%"><input name="submit" type="button" class="C_sub_input" value="登 录" onclick="return tosubmit(this);" /></td>\n';
	strHtml = strHtml +'<td width="50"><input name="submit2" type="button" id="do_OK" onclick="doOk()" class="C_sub_input2" value="取 消" /></td>\n';
	strHtml = strHtml +'</tr><tr><td height="21">&nbsp;</td><td colspan="2" class="below"><span id=err></span></td>\n';
	strHtml = strHtml +'</tr><tr><td height="21" colspan="3" class="Orange" align="center">请输入爱家家居网通行证用户名和密码登录</td>\n';
	strHtml = strHtml +'<input name=\"refpage\" type=\"hidden\" value='+refpage+'></td>\n';
	strHtml = strHtml +'</tr></table></form></div></div>\n';
	alertFram.innerHTML = strHtml;
	document.body.appendChild(alertFram);
	document.body.appendChild(shield);
	this.setOpacity = function(obj,opacity){
		if(opacity>=1)opacity=opacity/100;
		try{ obj.style.opacity=opacity; }catch(e){}
		try{ 
			if(obj.filters.length>0&&obj.filters("alpha")){
				obj.filters("alpha").opacity=opacity*100;
			}else{
				obj.style.filter="alpha(opacity=\""+(opacity*100)+"\")";
			}
		}catch(e){}
	}
	var c = 0;
	this.doAlpha = function(){
		if (++c > 20){clearInterval(ad);return 0;}
		setOpacity(shield,c);
	}
	var ad = setInterval("doAlpha()",1);
	this.doOk = function(){
		//alertFram.style.display = "none";
		//shield.style.display = "none";
		document.body.removeChild(alertFram);
		document.body.removeChild(shield);
//		eSrc.focus();
		document.body.onselectstart = function(){return true;}
		document.body.oncontextmenu = function(){return true;}
	}
	document.getElementById("do_OK").focus();
//	eSrc.blur();
	document.body.onselectstart = function(){return false;}
	document.body.oncontextmenu = function(){return false;}
}
function tosubmit() 
{checkForm();
	//document.logindd.url.value=this.location.href;
}// JavaScript Document


