function ShowTotal(){
	var iTotal = 0;
	var sCheck = 0;
	var sTestResult = '';

	for (var i=0;i<sAnswer.length;i++){
		if(document.getElementById(sAnswer[i][2]).checked == 1){
			sCheck=1;
		}
	}	
	
	if (sCheck==0){
		window.alert('Xin vui long chon cau tra loi cho phan Trac nghiem!');
		return;
	}		
	
	for (var i=0;i<sQuestion.length;i++){
		iTotal = iTotal + parseFloat(document.getElementById('txt_'+sQuestion[i][1]).value);
	}

	for (var i=0;i<sResult.length;i++){
		if ( parseInt(iTotal) > parseInt(sResult[i][0]) - 1 && parseInt(iTotal) < parseInt(sResult[i][1]) + 1 ){
			sTestResult = '<BR><Table border=0 cellspacing=0 cellpadding=1 width=\"98%\"  bgcolor=\"#999999\" align=center>';
			sTestResult+= '<tr><td><Table border=0 width=\"100%\" bgcolor=\"#D42626\" cellspacing=0 cellpadding=5><tr><td>'
			sTestResult+= '<Font face=Arial size=2 color=\"#FFFFFF\"><b>B&#7841;n &#273;&#432;&#7907;c t&#7893;ng c&#7897;ng <font size=3>'+iTotal+'</font> &#273;i&#7875;m</b></font>';
			sTestResult+= '</td></tr></Table></td></tr>';
			sTestResult+= '<tr><td><Table border=0 width=\"100%\" bgcolor=\"#EBEBEB\" cellspacing=0 cellpadding=5><tr><td>';
			sTestResult+= '<span class=\"clsTestResult\">'+sResult[i][2]+'</span>';
			sTestResult+= '</td></tr></Table>';
			sTestResult+= '</td></tr></Table>'
			document.getElementById("sTotalResult").innerHTML = sTestResult;
		}		
	}	
}

		
function ClearTotal(){
	for (var i=0;i<sQuestion.length;i++){
		document.getElementById('txt_'+sQuestion[i][1]).value = 0;
	}
	for (var i=0;i<sAnswer.length;i++){
			document.getElementById(sAnswer[i][2]).checked = 0;
	}			
	document.getElementById("sTotalResult").innerText = '';
}

		
function ShowTest()
{
	if (sQuestion.length==0)
		return;


	for(var i=0;i<sQuestion.length;i++){
		document.write('<span class="clsTestQuestion">'+unescape(sQuestion[i][0])+'</span>');
		document.write('<input type=hidden value=0 style=\"width:10;\" name=\"txt_'+sQuestion[i][1]+'\">')
		document.write('<Table border=0 cellspacing=0 cellpadding=0>');
			for(var j=0;j<sAnswer.length;j++){
				if (sAnswer[j][1]==sQuestion[i][1]){
					document.write('<tr><td valign=top><input type=\"radio\" id=\"'+sAnswer[j][2]+'\" value=\"'+sAnswer[j][3]+'\" onclick=\"txt_'+sQuestion[i][1]+'.value=this.value\" name=\"'+sQuestion[i][1]+'\"><td>');
					document.write('<td><span class="clsTestAnswer">'+unescape(sAnswer[j][0])+'</span></td></tr>');
				}	
			}
		document.write('</Table>');						
	}
	document.write('<hr size=1 align=center width=\"100%\">')
	document.write('<input type=\"button\" class=\"clsButton\" value=\"K&#7871;t qu&#7843;\" name=\"cmdTotal\" onclick=\"ShowTotal();\"> ');
	document.write('<input type=\"button\" class=\"clsButton\" value=\"Th&#7917; l&#7841;i\" name=\"cmdClear\" onclick=\"ClearTotal();\"><BR>');
	document.write('<Span id=\"sTotalResult\"></Span><BR>');
}
ShowTest();