/////////////////////////////////////////////////////////
function $(id){
	     return document.getElementById(id);
}
/////////////////////////////////////////////////////////
function getRandomNum(num) { 
   return Math.floor(Math.random()*num); 
} 
/////////////////////////////////////////////////////////
var se,m=0,h=0,s=0,ss=1,t="",t1="",t2=""; 
function second(){ 

if((ss%100)==0){s+=1;ss=1;} 
if(s>0 && (s%60)==0){m+=1;s=0;} 
if(m>0 && (m%60)==0){h+=1;m=0;} 
t1=(m<10)?("0"+m):m;
t2=(s<10)?("0"+s):s;
t=t1+":"+t2;
if(t1>50)
{
  SubmitExam()	
}
//t=h+":"+m+":"+s; 
document.getElementById("gettime").innerHTML=t; 
ss+=1; 
} 
se=setInterval("second()",1);
//clearInterval(se);ss=1;m=h=s=0;
/////////////////////////////////////////////////////////
 function randomOrder (targetArray)
{
    var arrayLength = targetArray.length
    //
    //先创建一个正常顺序的数组
    var tempArray1 = new Array();

    for (var i = 0; i < arrayLength; i ++)
    {
        tempArray1 [i] = i
    }
    //
    //再根据上一个数组创建一个随机乱序的数组
    var tempArray2 = new Array();

    for (var i = 0; i < arrayLength; i ++)
    {
        //从正常顺序数组中随机抽出元素
        tempArray2 [i] = tempArray1.splice (Math.floor (Math.random () * tempArray1.length) , 1)
    }
    //
    //最后创建一个临时数组存储 根据上一个乱序的数组从targetArray中取得数据
    var tempArray3 = new Array();

    for (var i = 0; i < arrayLength; i ++)
    {
        tempArray3 [i] = targetArray [tempArray2 [i]]
    }
    //
    //返回最后得出的数组
    return tempArray3
}

//使用实例

//var tmp = ["1", "2", "3", "4"];
//alert(randomOrder(tmp));
/////////////////////////////////////////////////////////

var question=new Array();
question[0]=new Array("1","问题111","4","a","a");
question[1]=new Array("2","问题2222","2","b","555");
question[2]=new Array("3","问题333","4","c","555");
question[3]=new Array("4","问题444","2","a","555");
question[4]=new Array("5","问题555","2","d","555");
question[5]=new Array("6","问题666","4","d","555");

/////////////////////////////////////////////////////////
var new_question=randomOrder(question);
var current_i=0;
function init()
{
 showquestion()
 current_i++;
}
init();
function showquestion()
{
	alert(current_i);
	$("questionanswer").value="";
	$("Myquestion").innerHTML=new_question[current_i][1]; 
	$("Myquestionpic").innerHTML=new_question[current_i][3];
	$("question_type1").style.display=(new_question[current_i][2]=="1")?"block":"none";
	$("question_type2").style.display=(new_question[current_i][2]=="2")?"block":"none";
	$("current_i").innerHTML=current_i+1+"题";
	line();
}
function hiddenbotton(b)
{ 
   if(b==1)
     {
		$("btn1").style.display="block";
		$("btn2").style.display="none";
	 }
	else if(b==2)
	 {
		$("btn1").style.display="none";
		$("btn2").style.display="block";
	 }
}
function next()
{ 
  if(current_i>new_question.length-1)
   {
	 current_i=new_question.length-1;
	 return;    
   }
   else
   {
	 showquestion();
   }
   current_i=(current_i>new_question.length-1)?new_question.length-1:++current_i;
   
}
function previous()
{	 
  if(current_i<=0)
   {
	 current_i=0;
	 return;    
   }
   else
   {
	 current_i=(current_i<=0)?0:--current_i;  
	 showquestion();
   }
   
}
/////////////////////////////////////////////////////////
