
<div id="new_style_1" style="display:none;">
<div class="new_tishi">
<layout name="element:doPaperBefore"/>
</div>
</div>
<div id="new_style_2" style="display:block;">
<div class="new_dati">
	<layout name="banks/doPaperFirst" />
	<layout name="banks/doPaperSecond" />
	<layout name="banks/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","");
		});
	});
	
	var restTime = parseInt($("#total_time").attr('value'))*60;
	setTime(restTime,0);
	
});
function saveAnswer(bank_id,answer) {
	$.post("<?php echo U(MODULE_NAME.'/saveAnswer'); ?>",{bank_id:bank_id,answer:answer});
}

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(gourl_type)
{
	var url = "<?php echo U(MODULE_NAME.'/saveAllAnswer'); ?>";
	var gourl_1 = "<?php echo U('menu/showMenu/cd_id/'.$_SESSION['cd_id']); ?>";
	var gourl_2 = "<?php echo U(MODULE_NAME.'/showSelfRecord/showscore/1/come_from/exam/cd_id/'.$_SESSION['cd_id']."/record_id/".$_SESSION['record_id']); ?>";
	if (gourl_type == 1)
	{
		gourl = gourl_1;
	}
	else
	{
		gourl = gourl_2;
	}
	
	$.get(url,function() {
		location.href = gourl;
	});
	
	
}
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(2);
			}
			restTime -= 1;
			usedTime += 1;
			setTime(restTime,usedTime);
		}, 1000)
	}
}
</script>