var cheat = false;



abArray = ["a","b","c","d"];

setUpPage();


function setUpPage(){

	for(suindex = 0;suindex<questionArray.length;suindex+=2){
		document.write("<tr><td width='30' height='30' valign='top'><img src='/images/elt/product_site_graphics/clocktransparent.gif' name='im" + (suindex+1) + "' width='20' height='20'></td>");
		document.write("<td width='20' valign='top'><b>" + (suindex+1) + "</b></td><td width='240' valign='top'>");
		document.write(questionArray[suindex][0]);

		document.write("</td><td width='30' valign='top'><img src='/images/elt/product_site_graphics/clocktransparent.gif' name='im" + (suindex+2) + "' width='20' height='20'></td>");
		document.write("<td width='20' valign='top'><b>" + (suindex+2) + "</b></td><td width='240' valign='top'>");
		document.write(questionArray[suindex+1][0]);
		document.write("</td></tr>");

		document.write("<tr><td width='30' valign='top'>&nbsp;</td><td valign='top'>&nbsp;</td>");
		document.write("<td>")
		for(inindex = 1;inindex<choices;inindex++){ //<5 = number of choices, change 6 lines below as well.
			document.write("<input type='radio' name='q" + (suindex + 1) + "'>&nbsp;" + questionArray[suindex][inindex] + "<br>");
		}
		document.write("</td><td width='30' valign='top'>&nbsp;</td>");
		document.write("<td width='20' valign='top'><b></b></td><td>");
             		for(inindex = 1;inindex<choices;inindex++){ //
			document.write("<input type='radio' name='q" + (suindex + 2) + "'&nbsp;>" + questionArray[suindex+1][inindex] + "<br>");
		}
		document.write("</td></tr><tr><td height='20'>&nbsp;</td></tr>");
	}
}

var qArray = new Array(document.form1.q1,document.form1.q2,document.form1.q3,document.form1.q4,document.form1.q5,document.form1.q6,document.form1.q7,document.form1.q8);
var imageArray = new Array(document.images.im1,document.images.im2,document.images.im3,document.images.im4,document.images.im5,document.images.im6,document.images.im7,document.images.im8);



function checkAnswers(){
var qArray = new Array(document.form1.q1,document.form1.q2,document.form1.q3,document.form1.q4,document.form1.q5,document.form1.q6,document.form1.q7,document.form1.q8);
var imageArray = new Array(document.images.im1,document.images.im2,document.images.im3,document.images.im4,document.images.im5,document.images.im6,document.images.im7,document.images.im8);
	score = 0;
	if (cheat) {
		alert("Press Play again to try again")
	} else {

		for(qloop=0;qloop<qArray.length;qloop++){

			if (qArray[qloop][ansArray[qloop]-1].checked) {
				score++;
				imageArray[qloop].src="/images/elt/product_site_graphics/clocktick.gif"
			} else {
				imageArray[qloop].src="/images/elt/product_site_graphics/clockcross.gif"
			}
		}
		alert("Your score is " +score+ " / " + qArray.length)
	}
}


function resetTest(){
var qArray = new 
Array(document.form1.q1,document.form1.q2,document.form1.q3,document.form1.q4,document.form1.q5,document.form1.q6,document.form1.q7,document.form1.q8);
var imageArray = new Array(document.images.im1,document.images.im2,document.images.im3,document.images.im4,document.images.im5,document.images.im6,document.images.im7,document.images.im8);
	for(aloop=0;aloop<qArray.length;aloop++){
		imageArray[aloop].src="/images/elt/product_site_graphics/clocktransparent.gif";
		qArray[aloop].checked = false;
	}
	cheat = false;
	score = 0;
}

function seeAnswers(){
var qArray = new 
Array(document.form1.q1,document.form1.q2,document.form1.q3,document.form1.q4,document.form1.q5,document.form1.q6,document.form1.q7,document.form1.q8)
var imageArray = new Array(document.images.im1,document.images.im2,document.images.im3,document.images.im4,document.images.im5,document.images.im6,document.images.im7,document.images.im8)
	cheat = true;
	for(rloop=0;rloop<qArray.length;rloop++){
		qArray[rloop][ansArray[rloop]-1].checked = true;
		imageArray[rloop].src="/images/elt/product_site_graphics/clocktransparent.gif";
	}
}
