function answer(str)
{
	w=window.open("","","status=no, menubar=no, toolbar=no, width=100, height=100")
	w.document.write("<html>"+
						"<meta http-equiv='content-type' content='text/html; charset=windows-1251' />"+
						"<body>Отговор:<br /><b>"+ str+"</b>" +
					   "<form><input type=button value=Close onClick=window.close()></form></body></html>");
}
	
//var trueans = new Array(1, 1, 3, 2, 2, 1, 1, 3, 0, 3);
//var ans = new Array(10);

function clickF(str){
	if(str.length==2){
		var s = str.charAt(0);
		s = parseInt(s);
		ans[s]=parseInt(str.charAt(1));
	}
	else{
		var s = str.substring(0,2);
		s = parseInt(s);
		ans[s]=parseInt(str.charAt(2));
	}
}

function subm(trueans, ans){
	w = window.open("answers.html", "" ,"status=no,menu=no,scrollbars=1,toolbar=no,width=330,height=320");
	w.document.write("<h2 align=center>Резултат</h2>");
	w.document.title="Отговори";
	var br=0;
	for(var i=0;i < trueans.length; i++){
		if(ans[i] != trueans[i]) br++;
	}
	w.document.write("Вашите верни отговори са <b>"+(ans.length-br)+"</b> или " + roundNumber(100*(ans.length-br)/ans.length, 2) + "%.<br />");
	w.document.write("Отогворили сте грешно на <b>"+br+"</b> въпроса.<br />");
	if(br != 0){
		w.document.write("Грешни са следните отговори:<br />");
		for(var i=0;i < trueans.length; i++){
			if(ans[i] != trueans[i]){ w.document.write("<b>"+(i+1)+"</b> &nbsp;&nbsp;&nbsp;&nbsp;");}
		}
	}
	w.document.write("<form><input type=button value=Затвори onClick='self.close()'></form>");
}

function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}
