var loclhost=document.location.href;
function send_dsrrequests(URL,chkcode,seccode,cookietag)
{
	http_request = false;
	//开始初始化XMLHttpRequest对象
	if(window.XMLHttpRequest) { //Mozilla 浏览器
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {//设置MiME类别
			http_request.overrideMimeType("text/xml");
		}
	}
	else if (window.ActiveXObject) { // IE浏览器
		try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) { // 异常，创建对象实例失败
		window.alert("不能创建XMLHttpRequest对象实例.");
		return false;
	}
	http_request.onreadystatechange = function(){
	if (http_request.readyState == 4){
		if(http_request.status == 200){
			sinfo=http_request.responseText;
			sinfo=sinfo.replaceAll("\r\n","").trim();
			var tempInfp=sinfo;
			sinfo=sinfo.substring(0,sinfo.indexOf('-'));
			tempInfp=tempInfp.replace(sinfo+"-","");
			if(sinfo=='')
				document.getElementById("dsrerr").innerHTML="请求超时,请稍后再试！";
			else if(sinfo=='0')
				document.getElementById("dsrerr").innerHTML="异常错误！";
			else if(sinfo=='-1')
				document.getElementById("dsrerr").innerHTML="验证码不能为空！";
			else if(sinfo=='3')
				document.getElementById("dsrerr").innerHTML="验证错误！";
			else if(sinfo=='5')
				document.getElementById("dsrerr").innerHTML="该卡号被其他用户登录中！";
			else if(sinfo=='2')
				document.getElementById("dsrerr").innerHTML="验证码过期！";
			else if(sinfo=='6'){
					document.getElementById("dsrerr").innerHTML="校验码错误！";
			}else if(sinfo=='7'){
					document.getElementById("dsrerr").innerHTML="该卡号未到启用时间！";
			}else if(sinfo=='99'){
				  if(tempInfp==2 || tempInfp==3)
						window.location="http://edu.duxiu.com/vipregistry.jsp";
					else
						window.location="http://www.duxiu.com/vipregistry.jsp";
			}else if(sinfo=='1'){
				 if(loclhost.indexOf("dayi100")!=-1){
					window.location="http://www.dayi100.com";
					return;
				}else{
				    if(tempInfp==2 || tempInfp==3)
						window.location="http://edu.duxiu.com";
					else
						window.location="http://www.duxiu.com";
				}
			}
			document.getElementById("tyno").value="";
			refreshImg();
		}
	}
	} ;		
	// 确定发送请求的方式和URL以及是否同步执行下段代码
	http_request.open("GET", URL+'?chkcode='+chkcode+'&seccode='+seccode+"&cookietag="+cookietag, true);
	http_request.send(null);
}

function subdsr(){
    var chkcode=document.getElementById("tyno").value.trim();
    var seccode=document.getElementById("seccode").value.trim();
    var tmpcookietag = document.getElementById("cookietag") ;
    var cookietag="0";
    if(tmpcookietag)
    	if(tmpcookietag.checked==true)
    		cookietag="1" ;
    if(chkcode!=''&&seccode!='')
		send_dsrrequests('/dsrlogon.jsp',chkcode,seccode,cookietag);
	else if(chkcode=='')
		document.getElementById("dsrerr").innerHTML="验证码不能为空!";
	else 
		document.getElementById("dsrerr").innerHTML="校验码不能为空!";
}
function refreshImg(){
	var timenow = new Date().getTime();
	document.getElementById('secimg').src="/vImage.jsp?"+timenow;
	document.getElementById('seccode').value="";
}

