// JavaScript Document
function  remote_login_check()
 {
			   var retstr;
		       var readflag;
		       var newsubstr='';
		       var read_strlen=0;
		
		       var studentid;
		       var password;
		      
		
		       var infoBoard;
		       var login_str;
		      
			   if (document.form1.studentid.value.length==0)
			   {
				   alert("[软件提示]：请输入用户名");
				   document.form1.studentid.focus();
				   return false;
			   }
			   
			   if (document.form1.password.value.length==0)
			   {
				   alert("[软件提示]：请输入密码"); 
				   document.form1.password.focus();
				   return false;
			   }

			   var attachCode = document.form1.attach.value;
			  
               if(attachCode.length <=0)
                {
                     alert("[软件提示]：请输入验证码！");
					 document.form1.attach.focus();
					 return false;
                }
              
			   if(attachCode.toUpperCase()!=code)
               {
                   alert("[软件提示]：验证码输入错误！");
                   createCode();//刷新验证码
				   document.form1.attach.focus();
				   return false;
				   
               }
			   
			   //-------检查是否注册，密码是否错误-------------------------
			   studentid=document.form1.studentid.value;
		       password=document.form1.password.value;
			   
			   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);
		
			   
		
               myurl=strstr+"login_check.php?studentid="+studentid;
               myurl=myurl+"&password="+password;
			   
               retstr=openUrl(myurl);
			   //alert(retstr); 
		       retstr=trim(retstr);
		       readflag=retstr.substring(0,1);
			   
		       read_strlen=strlen(retstr);
		
		       newsubstr=retstr.substring(1,read_strlen); 
			   
						
               switch(readflag)
		       { 
                case "a": 
                    alert(newsubstr);break; //没有注册    ; 
                case "b": 
		            alert(newsubstr);break; //密码错误              
	            case "c": 
		             alert(newsubstr);  //登录成功，自动转向考试页面
					 window.location.href="index.php";   
			    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"; 
     } 
} 

function trim(str)
{
  return str.replace(/(^\s*)|(\s*$)/g,"");
}
