setUpPage();
function setUpPage(){
	for(suindex = 0;suindex<questionArray.length;suindex++){
		document.write("<div style='margin-bottom: 20px'><span class='exercise_number'>" + (suindex+1) + " </span><span class='exercise_text'>");
		document.write(questionArray[suindex][0]);
		document.write("</span><span class='exercise_gapfill'><input size=" + questionArray[suindex][3] + " name=ans" + (suindex+1) + "> </span><span class='exercise_text'>");
              		document.write(questionArray[suindex][2]);
            		document.write("</span><span class='exercise_marking'><img src='/images/elt/product_site_graphics/clocktransparent.gif' name='im" + (suindex +1) + "'></span> </div>");
		
		}
		{
			document.write("<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].value == questionArray[csindex][1]) {
				imageArray[csindex].src="/images/elt/product_site_graphics/clocktick.gif";
				score++;
			} else {
				imageArray[csindex].src="/images/elt/product_site_graphics/clockcross.gif";
			}
		}
		alert("Your score is "+score+" / " + questionArray.length);
	}
}




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].value = questionArray[revindex][1];
		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].value = "";
		imageArray[agindex].src="/images/elt/product_site_graphics/clocktransparent.gif";
	}

}




