// JavaScript Document

function radio_next(zong_id)
   {
		
		var retstr;
		var readflag;
		var newsubstr='';
		var read_strlen=0;
		var myurl;
		var sarray=new  Array();
		
		var a_array=new  Array();
		var b_array=new  Array();
		
		var newstr='';
		var value;
		var x;
		var nn;
		var infoBoard;
		var mydis1,mydis2;
		
		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("displayInfo"); 
		mydis1=document.getElementById("mydis1"); 
		
		
        infoBoard.innerText='查询中...'; 
        myurl=strstr+"radio_next.php?zong_id="+zong_id
        //myurl="http://127.0.0.1:8080/check_correct_answer.asp?id="+get_id;
		//alert(myurl);
		
		retstr=openUrl(myurl); 
		
        //alert("服务器返回值："+retstr);
		//全部删除------------------------
		
		
		//读标志-----------------------------------
		readflag=retstr.substring(0,1);
		
		//去掉头部的1----------------------------
		read_strlen=strlen(retstr);
		
		retstr=retstr.substring(1,read_strlen);
		//分离#----------------------------------    
        sarray=retstr.split('#');
		 
		geshu=sarray.length-1;
		
		//alert(geshu);
		
		var  half=(geshu)/2;
        
		
        switch(readflag){ 
		
        case "-2": 
                infoBoard.innerHTML='<font color=red>抱歉，查询访问失败，请检查.</font>';
				break; 
        case "1": 
                
				infoBoard.innerHTML='<font color=009900>提示:有'+half+'个科目分类，请选择</font>';
				
				mydis1.innerHTML='<select name=juan_list id=juan_list     onChange=list_next(document.form1.juan_list.value); class=abc>   <option value=0>请选择要练习的科目</option> </select>';
				
				break; 
		case "2": 
                infoBoard.innerHTML='<font color=009900>提示：有'+half+'个科目分类，请选择</font>';
				
				mydis1.innerHTML='<select name=juan_list id=juan_list  size=10  onChange=list_next(document.form1.juan_list.value); class=abc> <option value=0>请选择要练习的科目</option> </select>';
								
				break; 
		
        case "0": 
                infoBoard.innerHTML='<font color=red>软件检测数据库错误,请检查</font>'; 
				//setTimeout(test,1000);//延时1秒
       } 
	   
	   
	   delete_all_select();
	   
	   for(var v=0;v<half;v++)
        {
		   a_array[v]=sarray[v];
		}
		
		nn=0;
		for(var v=half;v<geshu;v++)
        {
		   b_array[nn]=sarray[v];
		   nn=nn+1;
		}
       //----------------------------动态增加--------------------
        for(var v=0;v<half;v++)
        {
		  //document.form1.juan_list.options.add(new Option(sarray[v],v+1));
		  if (v<10)
		  {
			x=v;
			newstr='0'+x+' '+a_array[v]; 
		  }
		  if (v>=10)
		  {
			x=v;
			newstr=x+' '+a_array[v];   
		  }
		  
		  value=b_array[v];
		  
		  document.form1.juan_list.options.add(new Option(newstr,value));
		  
		  
        }     
	   
       return; 
} 

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 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 delete_all_select()
{
    var   theSelect=document.all.juan_list;   
    for(var i=theSelect.options.length-1;i>=0;i--)   
          theSelect.options.remove(i);   
}

function list_next(juan_id)
{
        
	    var retstr;
		var readflag;
		var newsubstr='';
		var read_strlen=0;
		var myurl;
		var sarray=new  Array();
		
		var a_array=new  Array();
		var b_array=new  Array();
		
		var newstr='';
		var value;
		var x;
		var nn;
		
		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("displayInfo2"); 
        infoBoard.innerText='查询中...'; 
        myurl=strstr+"list_next.php?juan_id="+juan_id
        
		//alert(myurl);
		
		retstr=openUrl(myurl); 
		
        //alert("服务器返回值："+retstr);
		
		infoBoard.innerHTML=retstr;
		
		/**
		//读标志-----------------------------------
		readflag=retstr.substring(0,1);
		
		//去掉头部的1----------------------------
		read_strlen=strlen(retstr);
		
		retstr=retstr.substring(1,read_strlen);
		//分离#----------------------------------    
		
        switch(readflag){ 
		
        case "-2": 
                infoBoard.innerHTML='<font color=red>抱歉</font>,查询失败';
				break; 
        case "1": 
                infoBoard.innerHTML=retstr;
				//setTimeout(test,1000);//延时1秒
				break; 
        case "0": 
                infoBoard.innerHTML='<font color=red>no</font>'; 
				//setTimeout(test,1000);//延时1秒
       } 
	   
	   */
	   
       return; 
	
}


