// Define global variables and arrays
var qI	= 0;
var checker10 = true;
var choice10	= new Array();
var correctans10 	= 0;
var nextq 	= 1;
var quiz10;

function itemReset() {	//resets everything
	qI 	= 0;
	choice10 = new Array();
	correctans10 	= 0;
	nextq	= 1;
	}
	
function busted10() {
	alert('Sorry, you only get one shot at each question.');
	quiz10.history.forward(); 
	quiz10.focus();
	}
	
function book()	{
	parent.location.href='/licensing/learnerdrivers/1464.asp';
	quiz10.document.close();
	}
	
function restart(){
	parent.location.href="/licensing/learnerdrivers/1465.asp"
	quiz10.document.close();
	}

function startquiz10(openStatus, whetherOrNot) {		// Administer the test and record the ans
		
	checker10 = openStatus;
		
	if (whetherOrNot < qI) { 
		busted10(); 
		return; 
		}
	
	if (checker10) { 
		quiz10 = window.open('','QuizOne','width=640,height=480,scrollbars=yes');
		//quiz10.moveTo(150,150);		
		quiz10.focus(); 
		!checker10;
		}
	
	if (qI == qus10.length) { 
		gradeTest10(); 
		return; 
		}
	displayten();
	
	}

function quizten(number,question,optionA,optionB,optionC,ans,img) {    
	this.number = number;
	this.question=question; 
	this.optionA = optionA;
	this.optionB=optionB;    
	this.optionC=optionC; 
	this.ans = ans; 
	this.img = img;  
	return this;
	}
	
function displayten()	{	// display questions
	
	// Write the qusestons and answrs options to the new window
	quiz10.document.clear();
	quiz10.document.open();
	quiz10.document.writeln('<html><head><title>Learners Practice Quiz 10</title>');
	quiz10.document.writeln('<link href="/css/purple.css" rel="stylesheet" type="text/css">');
	quiz10.document.writeln('</head><body bgcolor="\#ffffff\">');
	quiz10.document.writeln('<h3>Question '+ qus10[qI].number +'</h3>');
	quiz10.document.writeln('<table width=\'600\' cellspacing=\'5\'>');
	quiz10.document.writeln('<tr class=\'bg3\'><td align=\'left\' valign=\'top\' colspan=\'3\' height=\"40\">');
	quiz10.document.writeln('<p><b class=\'bodyhdr\'>' +qus10[qI].question+ '</b>');
	quiz10.document.writeln('</td></tr><td width=\'2\'>&nbsp;</td></tr>');
	quiz10.document.writeln('</td></tr><tr><td align=\'left\' valign=\'top\' width=\'35\' height=\'35\'><p>');
	quiz10.document.writeln('A&nbsp;<input type=\'radio\' name=\"answer\" value=\"a\" onClick="opener.choice10[opener.qI - 1] = this.value;\"></p>');
	quiz10.document.writeln('</td><td align=\'left\' valign=\'top\' width=\'340\' height=\'35\'>');	
	quiz10.document.writeln('<p>'+qus10[qI].optionA+'</p>');
	quiz10.document.writeln('</td><td valign=\'top\' width=\'200\'rowspan=\'4\' height=\"200\">');
	quiz10.document.writeln('<img border=\"0\" width=\"200\" height=\"200\" align=\"right\" src=\"'+qus10[qI].img+'\">');
	quiz10.document.writeln('</td></tr><tr><td align=\'left\' valign=\'top\' width=\'35\' height=\'35\'><p>');
	quiz10.document.writeln('B&nbsp;<input type=\'radio\' name=\"answer\" value=\"b\" onClick="opener.choice10[opener.qI - 1] = this.value;\"></p>');
	quiz10.document.writeln('</td><td align=\'left\'valign=\'top\' width=\'340\' height=\'35\'>');
	quiz10.document.writeln('<p>'+qus10[qI].optionB+'</p>');
	quiz10.document.writeln('</td></tr><tr><td align=\'left\' valign=\'top\' width=\'35\' height=\'35\'><p>');
	quiz10.document.writeln('C&nbsp;<input type=\'radio\' name=\"answer\" value=\"c\" onClick="opener.choice10[opener.qI - 1] = this.value;\"></p>');
	quiz10.document.writeln('</td><td align=\'left\' valign=\'top\' width=\'340\' height=\'35\'>');
	quiz10.document.writeln('<p>'+qus10[qI].optionC+'</p>');
	quiz10.document.writeln('</td></tr><tr align=\'left\' valign=\"top\" align=\'left\'><td width=\'30\'height=\'95\'>&nbsp;</td></tr>');
	quiz10.document.writeln('<tr align=\'right\'><td colspan=\'3\'>');
	quiz10.document.writeln('<input type=\'button\' value=\"NEXT QUESTION\" onClick="opener.startquiz10(false,' +nextq+ ')\;">');  
	quiz10.document.writeln('</td></tr></table></body></html>');
	quiz10.document.close();
	// Increment variables for the next question
	qI++;
	nextq++;
	}

function gradeTest10() {		// Increment the variables for the last time	
	qI++;
	nextq++;	
	
	for (var i = 0; i < qus10.length; i++) {		// Compare student ans with correct ans
		if (choice10[i] == qus10[i].ans) {
			correctans10++;
			}
		}	
	printResults10();	// Print the test results
	}
	
function printResults10() {		// Print the questions, answer options, and other info
	quiz10.document.clear();
	quiz10.document.open();
	quiz10.document.writeln('<html><head>');
	quiz10.document.writeln('<title>Quiz Ten Results</title>');
	quiz10.document.writeln('<link href="css/purplelocal.css" rel="stylesheet" type="text/css">');
	quiz10.document.writeln('</head><body BGCOLOR=\"WHITE\">');						
	quiz10.document.writeln('<h3>Quiz Results</h3>');						
	quiz10.document.writeln('<p class=\'bodyhdr\'>Your score out of 30 is &nbsp;'+correctans10+'</p>');
	quiz10.document.writeln('<p>Here is how you scored individually for each question:</p><hr>');
	quiz10.document.writeln('<table width=\'600\' cellpadding=\'0\'>');
	
	for (var i = 0; i < qus10.length; i++) {
	
	quiz10.document.writeln('<tr valign=\"top\" align=\'left\'><td height=\'30\' width=\'20\'>');
	quiz10.document.writeln('<p><b>'+qus10[i].number+ '</b></td><td colspan=\'2\'><p>' +qus10[i].question+'</p>');
	quiz10.document.writeln('</td></tr><tr valign=\"top\" align=\'left\'><td height=\'20\'>');
	quiz10.document.writeln('<p>a.</td><td width=\'450\'><p>' +qus10[i].optionA+ '</td>');
	quiz10.document.writeln('<td width=\'100\' rowspan=\'3\'><img border=\"0\" width=\"100\" height=\"100\" src=\"'+qus10[i].img+'\">');
	quiz10.document.writeln('</td></tr><tr valign=\"top\" align=\'left\'><td height=\'20\'>');	
	quiz10.document.writeln('<p>b.</td><td><p>' +qus10[i].optionB+ '</td></tr>');
	quiz10.document.writeln('<tr valign=\"top\" align=\'left\'><td height=\'20\'>');
	quiz10.document.writeln('<p>c.</td><td><p>' +qus10[i].optionC+ '<p>');
	
	// Determine if the student answered each question appropriately, and display accordingly
	if (choice10[i] == qus10[i].ans) {
		quiz10.document.writeln('&nbsp;&nbsp;&nbsp;&nbsp;<b><font color=\"GREEN\">You answered this correctly.  Your answer was:\n' +qus10[i].ans+ '.</font></b>\n</td>');
				}		
		else { 
		quiz10.document.writeln('&nbsp;&nbsp;&nbsp;&nbsp;<b><font color=\"RED\">The correct answer is:\n' +qus10[i].ans+ '\n</font></b>'); 
		}

	quiz10.document.writeln('</td></tr><tr><td colspan=\'3\'><hr></td></tr>');
	}
	i++;	
	quiz10.document.writeln('</table>');
	// Add extra info about the ranking, questions, and application
	quiz10.document.writeln('<p>You can always <a href=# onclick=\'window.close(); opener.restart();\'"><B>retake</B></a> another quiz or go back and read the <a href=# onclick=\'window.close(); opener.book();\'">Drive Safe Book.</a></p><p>Remember to hit refresh or reload to get a new set of questions.');
	quiz10.document.writeln('</body></html>');
	quiz10.document.close();
	}
	
	
var qus10 = new Array();
qus10[0] =new quizten	("1","At what age does a person have to wear a seat belt or suitable child restraint?","All ages.","Age 1 year and over.","Age 8 years and over.","a","img/trans.gif","Q57 Restraints ")

qus10[1] =new quizten	("2","Are you allowed to make a \'U\' turn at traffic lights?","Yes.","No, unless there is a \'U\' TURN PERMITTED sign.","Yes, if the traffic lights are not working.","b","img/trans.gif","Q26 Intersections")

qus10[2] =new quizten	("3","What is the speed limit where roads are under construction or repair?","20km/h.","The speed limit shown on the road works sign.","40km/h.","b","img/trans.gif","Q110 Speed")

qus10[3] =new quizten	("4","Does drinking alcohol and driving increase the risk of having a crash?","Yes.","No.","No, providing you drink coffee before you drive.","a","img/trans.gif","Q6 Alcohol")

qus10[4] =new quizten	("5","Do you need to indicate if you are turning from a one-way street into another one-way street?","Yes.","Yes, only if there is a vehicle behind you.","No.","a","img/trans.gif","Q115 Stop & Indicate")

qus10[5] =new quizten	("6","Which of the following statements is correct?","Vehicle Y gives way to both X and Z.","Vehicle X gives way to both Y and Z.","Vehicle Z gives way to both X and Y.","a","img/Q66.gif","Q66 ROW(1)")

qus10[6] =new quizten	("7","Are you allowed to park a vehicle on a pedestrian crossing?","Yes, if no pedestrains are using it.","Yes, if it is a passenger vehicle.","No.","c","img/Q142.gif","Q142	Vulnerable Road Users")

qus10[7] =new quizten	("8","Which is the correct path for the vehicle to take when turning into a two-lane road?","X is the correct path.","Y is the correct path.","Both paths are correct.","c","img/Q50.gif","Q50 Position")

qus10[8] =new quizten	("9","What is the minimum distance a vehicle is allowed to park before a bus stop or pedestrian crossing?","20 metres.","3 metres.","6 metres.","a","img/trans.gif","Q92 Signs & Parking")

qus10[9] =new quizten	("10","Which vehicle must give way?","Vehicle Y.","Neither vehicle has to give way.","Vehicle X.","c","img/Q80.gif","Q80 ROW(2)")

qus10[10] =new quizten	("11","Can medication used for colds or travel sickness affect your driving?","No.","Yes.","No, unless it has been prescribed by a doctor.","b","img/trans.gif","Q8 Alcohol")

qus10[11] =new quizten	("12","Which of the following statements is correct?","All passengers must wear available seat belts or suitable child restraints.","Only passengers over the age of 8 years must wear a seat belt.","Passengers over the age of 65 do not have to wear seat belts.","a","img/trans.gif","Q59 Restraints")

qus10[12] =new quizten	("13","Which of the following statements is correct?","Vehicle X gives way to both Y and Z.","Vehicle Y gives way to both X and Z.","Vehicle Z gives way to both X and Y.","a","img/Q72.gif","Q72 ROW(2)")

qus10[13] =new quizten	("14","Which of the following statements is correct?","Vehicle X must not overtake Y.","Vehicle X may overtake Y, only in a 50km/h area.","Vehicle X may overtake Y.","a","img/Q47.gif","Q47 Position")

qus10[14] =new quizten("15","When are you allowed to sound your vehicle's horn? ","Only when you are travelling outside built-up areas.","Only when it is used as a warning device.","At any time.","b","img/trans.gif","Q129 Vehicle")

qus10[15] =new quizten	("16","When approaching traffic lights, what does a green light with a red arrow mean?","You may go in any direction other than that indicated by the arrow.","You may turn in the direction of the arrow, if it is safe to do so.","Stop, the lights are not working properly.","a","img/trans.gif","Q28 Intersections")

qus10[16] =new quizten	("17","Which vehicle must give way?","Vehicle Y.","Neither vehicle has to give way.","Vehicle X.","c","img/Q76.gif","Q76 ROW(2)")

qus10[17] =new quizten	("18","If a vehicle is overtaking you and there is not enough distance for it to complete the manoeuvre safely, what should you do?","Sound your horn to warn of approaching danger.","Slow down to let the vehicle move in front of you.","Increase your speed to make the passing vehicle fall back behind you.","b","img/trans.gif","Q39 Position")

qus10[18] =new quizten	("19","Should you use high beam or low beam when driving in fog or smoke? ","High beam.","It makes no difference.","Low beam.","c","img/trans.gif","Q131 Vehicle")

qus10[19] =new quizten	("20","Which of the following statements is correct?","Vehicle X gives way to both Y and Z.","Vehicle Z gives way to both X and Y.","Vehicle Y gives way to both X and Z.","c","img/Q67.gif","Q67 ROW(1)")

qus10[20] =new quizten	("21","How do even small amounts of alcohol affect your driving?","By making you think you are driving better than you are.","By helping your driving ability.","By helping your judgement of speed.","a","img/trans.gif","Q4 Alcohol")

qus10[21] =new quizten	("22","What is the reduced speed limit around schools during certain times of the day?","50km/h.","40km/h.","60km/h.","b","img/trans.gif","Q98 Signs & Parking")

qus10[22] =new quizten	("23","What must you do at a children's crossing when a crossing attendant extends this flag?","Stop and do not proceed until the attendant withdraws the sign.","Slow down.","Drive on carefully if no children are on your side of the crossing.","a","img/Q140.gif","Q140 Vulnerable Road Users"	)

qus10[23] =new quizten	("24","When approaching traffic lights, what does a red light with a green arrow (as shown in the diagram) mean?","Stop, until all lights show green.","You may proceed in the direction of the arrow.","Proceed in any direction.","b","img/Q30.gif","Q30 Intersections")

qus10[24] =new quizten	("25","Which motorcycle is in the car driver's blind spot?","Motorcycle X.","Motorcycle Y.","Motorcycle Z.","b","img/Q113.gif","Q113 Stop & Indicate")

qus10[25] =new quizten	("26","Which of the following statements is correct?","It is always safe to travel at the speed limit.","Your travelling speed should be as close to the speed limit as possible.","Travelling at the speed limit is sometimes too fast for the conditions.","c","img/trans.gif","Q109 Speed")

qus10[26] =new quizten	("27","Which of the following should you do before overtaking a long vehicle?","Follow closely behind the vehicle.","Follow far enough behind the vehicle to have a clear view of the road ahead.","Sound your horn.","b","img/trans.gif","Q49 Position")

qus10[27] =new quizten	("28","What is the meaning of this sign?","Turn left at the next street.","Pass on the left of traffic.","Keep to the left of the sign.","c","img/Q95.gif","Q95 Signs & Parking")

qus10[28] =new quizten	("29","What is the first thing you should do when you assist at a crash scene?","Remove occupants from their vehicle. ","Check whether anyone injured is unconscious.","Check for danger.","c","img/trans.gif","Q19Emergency")

qus10[29] =new quizten	("30","Which vehicle must give way?","Neither vehicle has to give way.","Vehicle X.","Vehicle Y.","b","img/Q63.gif","Q63 ROW(1)")
