// JavaScript Document
var newpage;
var infoboard;
function  change_act(addr)
{
	 document.form1.action=addr;
}

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

function jscheck_corrent_answer_s(page,zong_sele_num,id,answer,mode)
{
        
		var get_id;
		var retCode;
		
		var url;
		var checkinfo_str;
		var answer_info;
		var infoboard;
		var infoboard2;
		var answer_value;
		var sele_info;
		
		var sele_obj1;
		var sele_value1;
		
		var sele_obj2;
		var sele_value2;
		
		var sele_obj3;
		var sele_value3;
		
		var sele_obj4;
		var sele_value4;
		
		var answer_obj_a;
		var answer_obj_b;
		var answer_obj_c;
		var answer_obj_d;
		
		
	    url=window.location.href;
        //alert(window.location.href);
        var point;
	    point=url.lastIndexOf('/')+1;
        var strstr= url.substring(0,point);
        //url 除过最后的文件------------------
	    //alert(str);
		
		get_id=id;
		
		//所有选项置为黑色-------------------
		sele_obj1=document.getElementById("s_sele"+id+"a");
		sele_value1=document.getElementById("s_sele"+id+"a").innerText;
		sele_obj1.innerHTML="<font color=#000000>"+sele_value1+"</font>";
		
		sele_obj2=document.getElementById("s_sele"+id+"b");
		sele_value2=document.getElementById("s_sele"+id+"b").innerText;
		sele_obj2.innerHTML="<font color=#000000>"+sele_value2+"</font>";
		
		sele_obj3=document.getElementById("s_sele"+id+"c");
		sele_value3=document.getElementById("s_sele"+id+"c").innerText;
		sele_obj3.innerHTML="<font color=#000000>"+sele_value3+"</font>";
		
		sele_obj4=document.getElementById("s_sele"+id+"d");
		sele_value4=document.getElementById("s_sele"+id+"d").innerText;
		sele_obj4.innerHTML="<font color=#000000>"+sele_value4+"</font>";
		
		//所有选项置为黑色-------------------
		answer_obj_a=document.getElementById("s_answer"+id+"a");
		answer_obj_b=document.getElementById("s_answer"+id+"b");
		answer_obj_c=document.getElementById("s_answer"+id+"c");
	    answer_obj_d=document.getElementById("s_answer"+id+"d");
		
		answer_obj_a.innerHTML="";
		answer_obj_b.innerHTML="";
		answer_obj_c.innerHTML="";
		answer_obj_d.innerHTML="";
		
		
		myobja=document.getElementById("sa"+id);    //用ID获得
		
		if (myobja.checked)
		{ 
		  sele_obj1.innerHTML="<font color=#ff0000>"+sele_value1+"</font>";
		 }  
		else 
		{
		   sele_obj1.innerHTML="<font color=#000000>"+sele_value1+"</font>";
		}
		
		myobjb=document.getElementById("sb"+id);
		
		if (myobjb.checked)
		{ 
		  sele_obj2.innerHTML="<font color=#ff0000>"+sele_value2+"</font>";
		}  
		else 
		{
		   sele_obj2.innerHTML="<font color=#000000>"+sele_value2+"</font>";
		}
		
		
		myobjc=document.getElementById("sc"+id);
		
		if (myobjc.checked)
		{ 
		  sele_obj3.innerHTML="<font color=#ff0000>"+sele_value3+"</font>";
		}  
		else 
		{
		   sele_obj3.innerHTML="<font color=#000000>"+sele_value3+"</font>";
		}
		
			
		myobjd=document.getElementById("sd"+id);
		
		if (myobjd.checked)
		{ 
		  sele_obj4.innerHTML="<font color=#ff0000>"+sele_value4+"</font>";
		  
		}  
		else 
		{
		   sele_obj4.innerHTML="<font color=#000000>"+sele_value4+"</font>";
		}
		
		
        //infoBoard.innerText='已保存...'; 
        myurl=strstr+"check_correct_answer_s.php?id="+get_id;
        //myurl="http://127.0.0.1:8080/check_correct_answer.asp?id="+get_id;
		myurl=myurl+"&page="+page;
		myurl=myurl+"&zong_sele_num="+zong_sele_num;
		myurl=myurl+"&answer="+answer;
		//alert(myurl);
		
        retCode=openUrl(myurl); 
		retCode=trim(retCode);
        //alert("服务器返回值："+retCode);
		
		
		if  (mode==0)
		{
				
       	 switch(retCode)
	   	{ 
		
       		case "-2": 
              	
				//infoBoard2.innerHTML='<font color=red>查询失败</font>';
			    break;
				 
        	case "1": 
			
	             //--回答正确--- 		
				 if  (myobja.checked)  answer_obj_a.innerHTML='<font color=#ff0000><b>已保存</b></font>';
			     if  (myobjb.checked)  answer_obj_b.innerHTML='<font color=#ff0000><b>已保存</b></font>';
				 if  (myobjc.checked)  answer_obj_c.innerHTML='<font color=#ff0000><b>已保存</b></font>';
				 if  (myobjd.checked)  answer_obj_d.innerHTML='<font color=#ff0000><b>已保存</b></font>';
					//var newpage=0;
					//setTimeout('fetch_s_next_ti('+newpage+','+zong_sele_num+')',1000);//延时1秒
                 break;
				  
			case "2": 
			    	
				 //--回答正确--- 	
				 if  (myobja.checked)  answer_obj_a.innerHTML='<font color=#ff0000><b>已保存</b></font>';
			     if  (myobjb.checked)  answer_obj_b.innerHTML='<font color=#ff0000><b>已保存</b></font>';
				 if  (myobjc.checked)  answer_obj_c.innerHTML='<font color=#ff0000><b>已保存</b></font>';
				 if  (myobjd.checked)  answer_obj_d.innerHTML='<font color=#ff0000><b>已保存</b></font>';
					//var newpage=0;
					//setTimeout('fetch_s_next_ti('+newpage+','+zong_sele_num+')',1000);//延时1秒
                 break;
				
           case "3": 
                
				 //--回答错误---
				 if  (myobja.checked)  answer_obj_a.innerHTML='<font color=#ff0000><b>已保存</b></font>';
			     if  (myobjb.checked)  answer_obj_b.innerHTML='<font color=#ff0000><b>已保存</b></font>';
				 if  (myobjc.checked)  answer_obj_c.innerHTML='<font color=#ff0000><b>已保存</b></font>';
				 if  (myobjd.checked)  answer_obj_d.innerHTML='<font color=#ff0000><b>已保存</b></font>';
					//var newpage=0;
					//setTimeout('fetch_s_next_ti('+newpage+','+zong_sele_num+')',1000);//延时1秒
                 break;
				 
		   case "4": 
				//--不用---
				//var newpage=0;
				//setTimeout('fetch_s_next_ti('+newpage+','+zong_sele_num+')',1000);//延时1秒
                break; 
		   case "5": 
				//--不用---
				//var newpage=parseInt(page);
				//setTimeout('fetch_s_next_ti('+newpage+','+zong_sele_num+')',300);//延时1秒
				break; 
				
       	} 
		
		}
		
		if  (mode==1)    //正式考试模式------------------------
		{
		         if  (myobja.checked)  answer_obj_a.innerHTML='<font color=#ff0000><b> 已保存 </b></font>';
			     if  (myobjb.checked)  answer_obj_b.innerHTML='<font color=#ff0000><b> 已保存 </b></font>';
				 if  (myobjc.checked)  answer_obj_c.innerHTML='<font color=#ff0000><b> 已保存 </b></font>';
				 if  (myobjd.checked)  answer_obj_d.innerHTML='<font color=#ff0000><b> 已保存 </b></font>';
		}
	   
	  
       return; 
} 

function openUrl(url)
 
 { 
    var objxml=new ActiveXObject("Microsoft.XMLHttp") 
    objxml.open("GET",url,false); 
    objxml.send(); 
    retInfo=objxml.responseText; 
    if (objxml.status=="200")
	{ 
      return retInfo; 
    } 
    else
	{ 
      return "-2"; 
    } 
} 



function fetch_s_next_ti(page,zong_sele_num)
{
        
		var get_id;
		var retCode;
		var newpage;
		
		if (page<zong_sele_num)
		{
			 newpage=parseInt(page)+1;
		}
		else
		{
			newpage=1;
		}
		
		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);
		
		
		infoBoard=document.getElementById("s_all"); 
        infoBoard.innerText='保存中...'; 
        myurl=strstr+"a0middle_s.php?page="+newpage;
       
		//alert(page);
		//alert(myurl);
        retCode=openUrl(myurl); 
		retCode=trim(retCode);
        //alert("服务器返回值："+retCode);
		
		infoBoard.innerHTML=retCode;
	   
       return; 
} 




function fetch_s_prior_ti(page,zong_sele_num)
{
        
		var get_id;
		var retCode;
		var newpage;
		
		if (page>1)
		{
			 newpage=parseInt(page)-1;
		}
		else
		{
			newpage=zong_sele_num;
		}
		
		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);
		
		
		infoBoard=document.getElementById("s_all"); 
        infoBoard.innerText='查询中...'; 
        myurl=strstr+"a0middle_s.php?page="+newpage;
       
		//alert(page);
		//alert(myurl);
        retCode=openUrl(myurl); 
		retCode=trim(retCode);
        //alert("服务器返回值："+retCode);
		
		infoBoard.innerHTML=retCode;
	   
       return; 
} 
