// JavaScript Document
function remote_reg_stuid_check(stuid)
   {
       
		var retCode;
		var newretcode;
		var newsub='';
		var newsublen=0;
		
		var url;
	    url=window.location.href;
        //alert(window.location.href);
        var point;
	    point=url.lastIndexOf('/')+1;
        var strstr= url.substring(0,point);
        //url 除过最后的文件------------------
	    //alert(str);
		if (stuid=='')
		 return false;
			
		
		infoBoard=document.getElementById("info"); 
        infoBoard.innerText='查询中...'; 
        myurl=strstr+"remote_reg_stuid_check.php?stuid="+stuid;
        //myurl="http://127.0.0.1:8080/check_correct_answer.asp?id="+get_id;
		//alert(myurl);
        retCode=openUrl(myurl); 
        //alert("服务器返回值："+retCode);
		//alert(retCode);
		newretcode=retCode.substring(0,1);
		//alert(newretcode);
		
		newsublen=strlen(retCode);
		//alert(newsublen);
		newsub=retCode.substring(1,newsublen); 
		//alert(newsub);
						
        switch(newretcode){ 
        
        case "1": 
                infoBoard.innerHTML='<font color=#009933> ID ['+stuid+'] 未注册,可以使用 </font>';
				break; 
        case "0": 
                infoBoard.innerHTML='<font color=#ff0000>['+stuid+'] 已经注册，请换一个试试</font>'; 
				break; 
	    default: 
                infoBoard.innerHTML='<font color=red> 系统错误，请刷新页面试试!</font>';break; 	
						
       } 
       return; 
} 

function strlen(str) 
{
    var len = 0;
    for (var i = 0; i<str.length;i++)
	{
      if (str.charCodeAt(i)>255) len+= 2; 
	  else 
	   len ++;
    }
    return len;
}


function openUrl(url)
 
 { 
    var objxml=new ActiveXObject("Microsoft.XMLHttp") 
    objxml.open("GET",url,false); 
    objxml.send(); 
	
    retInfo=objxml.responseText;
	
    //---------最重要，将%20 解码成空格，Visit W3School!") ==》Visit%20W3School%21
	retInfo=unescape(retInfo);
	
    if (objxml.status=="200")
	{ 
      return retInfo; 
    } 
    else
	{ 
      return "-2"; 
     } 
} 


