
<div id="new_style_2" style="display:block;">
<div class="new_dati">
	<layout name="doPaperFirst" />
	<layout name="doPaperSecond" />
	<layout name="doPaperThird" />
</div>
</div>

<layout name="element:submit" />

<script type="text/javascript">
$(document).ready(function() {
	$("#productsMenu_zzjs").css("display","");
	
	$("#manualscore").click(function(){
		$(".tc2").css("display","none");
		$.post("<?php echo U(MODULE_NAME.'/manualscore'); ?>",function(html){
			$(".tc1").html(html);
			$(".tc1").css("display","");
		});
	});
	
	setTime_1(0,0);

});

function saveAnswer(bank_id,answer) {
	$.post("<?php echo U(MODULE_NAME.'/saveAnswer'); ?>",{bank_id:bank_id,answer:answer},function(data)
			{
				//alert(data);
			}
		
	);
}

function finishExam(gourl_type) {
	$("#cover").css("display","");
	var i = 0;
	var line = "。";
	var amount = "";
	count(i,line,amount);
	var url="<?php echo U(MODULE_NAME.'/saveAllAnswer'); ?>";

	setTimeout('upanswer('+gourl_type+')',1000);
	
}

/* 调试保存返回的值 */
function upanswer(go_type)
{	
	var url="<?php echo U(MODULE_NAME.'/saveAllAnswer/from/doSelfPaper'); ?>";
	var gourl_1 = "<?php echo U('menu/showMenu/cd_id/'.$_SESSION['cd_id']); ?>";
	var gourl_2 = "<?php echo U(MODULE_NAME.'/showSelfPaperRecord/cd_id/'.$_SESSION['cd_id']."/record_id/".$_SESSION['info']['record_id']); ?>";
	if(go_type == 1)
	{
		go_url = gourl_1;
	}else if (go_type == 2)
	{
		go_url = gourl_2;
	}

	$.get(url,function(data) {
		location.href= go_url;
	});
}
function setTime(restTime,usedTime) {
	var time_start = parseInt($("#rest_time").attr("time_start"));
	if(time_start == 1)
	{
		var rest_time = parseInt(restTime/3600)+':'+parseInt(restTime%3600/60)+':'+parseInt(restTime%3600%60);
		var used_time = parseInt(usedTime/3600)+':'+parseInt(usedTime%3600/60)+':'+parseInt(usedTime%3600%60);
		$("#used_time").attr('value',used_time);
		$("#rest_time").html(rest_time);
		setTimeout(function() {
			if (restTime == 0) {
				alert("考试结束时间已到，请点击确定提交试卷！");
				finishExam(0);
			}
			restTime -= 1;
			usedTime += 1;
			setTime(restTime,usedTime);
		}, 1000)
	}

}
//考试时间计时
	function setTime_1(restTime,usedTime) {
		var rest_time_h = parseInt(restTime/3600);
		if (rest_time_h < 10) rest_time_h = '0'+rest_time_h;
		var rest_time_m = parseInt(restTime%3600/60);
		if (rest_time_m < 10) rest_time_m = '0'+rest_time_m;
		var rest_time_s = parseInt(restTime%3600%60);
		if (rest_time_s < 10) rest_time_s = '0'+rest_time_s;
		
		var rest_time = rest_time_h + ":" + rest_time_m + ":" + rest_time_s;
		
		$(".rest_time_1").html('离考试开始还有'+rest_time);
		setTimeout(function() {
			if (restTime == 0)
			{
				$("#new_style_1").css("display","none");
				$("#new_style_2").css("display","");
				$("#p_1").css("display","");
				var restTime_new = parseInt($("#total_time").attr('value'))*60;
				setTime(restTime_new,0);
			}
			else
			{
				restTime -= 1;
				usedTime += 1;
				setTime_1(restTime,usedTime);
			}
			
		}, 1000)
	}
	
</script>

