//=====考试时间开始===============================
var hasuseMinu=0,loops =0,totalTime=0,timevalue=0,min1=0;
var tmpobj;
$(document).ready(function(){
  hasUseTime=$("#HasUseTime").val().split(':');
  loops = 60-parseInt(hasUseTime[1]);
  hasuseMinu=parseInt(hasUseTime[0]);
  totalTime=KSSJ-hasuseMinu;
  timevalue=totalTime-1;
  min1=-1;
  tmpobj = setInterval("addtime()",1000);
 });
function addtime() {
loops--;
if((timevalue<=0)&&(loops==0)) {
    $.dialog.alert("提示:<br/>考试时间到，系统将强迫停止考试!");
    clearInterval(tmpobj);
    getAnswer();
    jQuery('#myform').submit();
}
else{
	if (loops<0) { loops=59;timevalue--; min1++; }
	 $("#HasUseTime").val((hasuseMinu+min1+1)+":"+(60-loops)); //保存已用时间 
	 $("#timeout").val((hasuseMinu+min1+1)+"分钟"+(60-loops)+"秒"); 
	 if ((loops==1)||(loops==2)||(loops==3)||(loops==4)||(loops==5)||(loops==6)||(loops==7)||(loops==8)||(loops==9)){
	  theA=timevalue+"<img src='"+examInstallDir+"images/t/tfen.gif'/>0"+loops+"<img src='"+examInstallDir+"images/t/tmiao.gif'/>";
	 }else {
	  theA=timevalue+"<img src='"+examInstallDir+"images/t/tfen.gif'/>"+loops+"<img src='"+examInstallDir+"images/t/tmiao.gif'/>";
	 }
	 for(var i=0;i<10;i++){  
	   var temp="/"+i.toString()+"/ig";
	   theA=theA.replace(eval(temp),'<img src="'+examInstallDir+'images/t/t'+i.toString()+'.gif" />');
	 }
	// $("#Time1").html(theA);
	 var s='';
	 for(var i=0;i<String(timevalue).length;i++){
		 s+="<span class='fen'>"+String(timevalue).substr(i,1)+"</span>";
	 }
	 s+="<span class='miao'>:</span>";
	 for(var i=0;i<String(loops).length;i++){
		 s+="<span class='miao'>"+String(loops).substr(i,1)+"</span>";
	 }
	 $("#Time1").html(s);
	 
	  if ((timevalue==20) && (loops==59)){
		  $.dialog.alert("提示:考试时间还剩二十分钟,请抓紧时间做题!");
	  }
	  if ((timevalue==5) && (loops==59)){
		  $.dialog.alert("提示:考试时间还剩最后五分钟,请做好保存!");
	 }
 }
}
//================考试时间结束================================================