setUpPage();
function setUpPage(){
	for(suindex = 0;suindex<questionArray.length;suindex++){
		document.write("<div class='exercise_row'><span class='exercise_number'>" + (suindex+1) + " </span><span class='exercise_text'>");
		document.write(questionArray[suindex][0]);
		document.write("</span> <span class='exercise_dropdown'> <select  name=ans" + (suindex+1) + "> ");
		document.write("<option>  </option>");
		document.write("<option>" + questionArray[suindex][1] + "</option>");
		document.write("<option>" + questionArray[suindex][2] + "</option>");
		document.write("<option>" + questionArray[suindex][3] + "</option>");
		document.write("</select></span><span class='exercise_text'>");
		document.write(questionArray[suindex][4]);
		document.write("</span> <span class='exercise_marking'><img src='/images/elt/product_site_graphics/clocktransparent.gif' name='im" + (suindex +1) + "'>");
       	document.write("</span> </div>");
       		
	}
	{
		document.write("<br /><div class='exercise_buttons'><input onClick=checkScore() type=button value='Score' name='button'> <input type=button value='See answers' onClick='reveal()' name='button2'> <input type='reset' onClick='again()' name='reset' value='Start again'></div>");
			}
}

var answerArray = new Array(document.form1.ans1,document.form1.ans2,document.form1.ans3,document.form1.ans4,document.form1.ans5,document.form1.ans6);
var imageArray = new Array(document.images.im1,document.images.im2,document.images.im3,document.images.im4,document.images.im5,document.images.im6);
function checkScore() {
var answerArray = new Array(document.form1.ans1,document.form1.ans2,document.form1.ans3,document.form1.ans4,document.form1.ans5,document.form1.ans6);
var imageArray = new Array(document.images.im1,document.images.im2,document.images.im3,document.images.im4,document.images.im5,document.images.im6);
	if(cheat){
		alert("Please press Start again to try again.")
	}else{
		var score = 0;
		for(csindex = 0;csindex<questionArray.length;csindex++){
			if (answerArray[csindex].selectedIndex == correctArray[csindex]) {
				imageArray[csindex].src="/images/elt/product_site_graphics/clocktick.gif";
				score++;
			} else {
				imageArray[csindex].src="/images/elt/product_site_graphics/clockcross.gif";
			}
		}
		if(score<6){
			alert("Your score is "+score+" / " + questionArray.length + ". Please try again.");
		}else{
			alert("Well done, you scored 6/6.");
		}
	}
}




function reveal() {
var answerArray = new Array(document.form1.ans1,document.form1.ans2,document.form1.ans3,document.form1.ans4,document.form1.ans5,document.form1.ans6);
var imageArray = new Array(document.images.im1,document.images.im2,document.images.im3,document.images.im4,document.images.im5,document.images.im6);
	for(revindex = 0;revindex<questionArray.length;revindex++){
		answerArray[revindex].selectedIndex = correctArray[revindex];
		imageArray[revindex].src="/images/elt/product_site_graphics/clocktransparent.gif";
	}
	cheat = true;
}
function again() {
var answerArray = new Array(document.form1.ans1,document.form1.ans2,document.form1.ans3,document.form1.ans4,document.form1.ans5,document.form1.ans6);
var imageArray = new Array(document.images.im1,document.images.im2,document.images.im3,document.images.im4,document.images.im5,document.images.im6);
	cheat = false;
	for(agindex = 0;agindex<questionArray.length;agindex++){
		answerArray[agindex].selectedIndex = 0;
		imageArray[agindex].src="/images/elt/product_site_graphics/clocktransparent.gif";
	}

}

