	var correctlist=[];
	function testSetUp(){
		var txt="";
	var choicelist=[];
	var feedbacklist=[];
	

	
	
	
	if (window.XMLHttpRequest)
	  {
	  xhttp=new XMLHttpRequest();
	  }
	else
	  {
	  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xhttp.open("GET","cae_reading4.xml",false);
	xhttp.send("");
	xmlDoc=xhttp.responseXML;

	document.getElementById("instructions").innerHTML=xmlDoc.getElementsByTagName("instructions")[0].childNodes[0].nodeValue;
	document.getElementById("title").innerHTML=xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue;
	var x=xmlDoc.getElementsByTagName("item");
	
	document.getElementById("text2").innerHTML=xmlDoc.getElementsByTagName("text2")[0].childNodes[0].nodeValue;
	
	


 var y=xmlDoc.getElementsByTagName("select");
for (i=0;i<y.length;i++)
  {
	  for (j=0;j<4;j++)
	  {
	  choicelist.push(x[i].getElementsByTagName("choice")[j].childNodes[0].nodeValue)  ;
	
				 var feedback=x[i].getElementsByTagName("choice")[j].getAttribute("feedback");
				
			 feedbacklist.push(feedback);
			
			 if (feedback=="Correct"){
			 correctlist.push(j);
			 }
	  }


 
 
  }
  for (i=0;i<x.length-1;i++)
  {
	var choiceA=choicelist[i*4]; 
	var choiceB=choicelist[i*4+1]; 
	var choiceC=choicelist[i*4+2]; 
	var choiceD=choicelist[i*4+3]; 
	
	
  txt=txt+x[i].getElementsByTagName("text")[0].childNodes[0].nodeValue + "<select onclick='clearScores()' name='q"+i+"' id='q"+i+"'><option option value='sel'>Select</option><option value='0'>"+ choiceA+"</option><option option value='1'>"+ choiceB +"</option><option option value='2'>"+ choiceC +"</option><option option value='3'>"+ choiceD +"</option></select><span id='result_" + i + "'><img src='blank.gif' style='border:0' alt='' /></span>" ;

 
 
  }
   txt=txt+x[x.length-1].getElementsByTagName("text")[0].childNodes[0].nodeValue;
	     
		     
	
	document.getElementById("text").innerHTML=txt;
	
}
function clearScores(){
		
		
	for (i=0;i<correctlist.length;i++)
	
		{
			

		
			
			document.getElementById('result_' + i).innerHTML = '<img src="blank.gif" style="border:0" alt="" />';
			
	}
	var scoretext="";
		document.getElementById("score").innerHTML = scoretext;
	}
function checkAnswers(){
		var score=0;
		for (i=0;i<correctlist.length;i++)
		{
		var z="q"+i;
		
		
		
		
		if(document.getElementById(z).value==correctlist[i]){
			score++;
			document.getElementById('result_' + i).innerHTML = '<img src="correct.gif" style="border:0" alt="Correct!" />';
			
		}else{
			document.getElementById('result_' + i).innerHTML = '<img src="incorrect.gif" style="border:0" alt="Incorrect!" />';
			
		}
		}
	
		var scoretext="     Score: "+score+" out of " +correctlist.length;
		document.getElementById("score").innerHTML = scoretext;
	
	}
		
	
	function seeAnswers(){
		
		for (i=0;i<correctlist.length;i++)
		{
		var z="q"+i;
		
		
		document.getElementById(z).value =correctlist[i];
		
		}
		clearScores();
	}
	
	function reset(){
		for (i=0;i<correctlist.length;i++)
		{
		var z="q"+i;
		
		document.getElementById(z).value ='sel';
		}
		clearScores();
	}
