function do_Login() {
	var username   = document.loginForm.username.value;
	var password   = document.loginForm.password.value;
	var loginType   = document.loginForm.loginType.value;
	
    xmlHttp = createXMLHttpRequest();
	var url = "/login.php";
	//需要POST的值，把每个变量都通过&来联接
	var postStr   = "username="+ username +"&password="+ password+"&loginType="+loginType;
	xmlHttp.onreadystatechange = handleReadyStateChangeCount;
    xmlHttp.open("POST", url, true);　//传递数据的方法同样有GET和POST两种,但是当方法为POST时下面的一句话就必须写
    xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    xmlHttp.send(postStr);//null
}
function handleReadyStateChangeCount() {

    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
			var ajaxValue = xmlHttp.responseText;
			Url = ajaxValue.split("@&");//按照"&@"分割   
			if(ajaxValue == 'No'){
				document.getElementById('errorDivLogin').style.display="block";
			}
			if(ajaxValue == 'consult'){
				window.document.MyFormCompare.postType.value = 'consult';
				document.getElementById("MyFormCompare").submit();
			}
			if(ajaxValue == 'email'){
				window.document.MyFormCompare.postType.value = 'email';
				document.getElementById("MyFormCompare").submit();
			}
			if(Url[0] == 'Yes'){
				parent.location=''+Url[1];
			}
        } else {
            alert(xmlHttp.status);
        }
    }
}

//获取URL
function getLoginBackUrl(){
	var oldhref= window.location.href;
	return oldhref.substring(0,8+oldhref) + window.location.href;//?rurl='+encodeURIComponent(oldhref);
}
document.getElementById("Url").value = getLoginBackUrl();

