// Define global variables and arrays
var qI	= 0;
var checker9 = true;
var choice9	= new Array();
var correctans9 	= 0;
var nextq 	= 1;
var quiz9;

function itemReset() {	//resets everything
	qI 	= 0;
	choice9 = new Array();
	correctans9 	= 0;
	nextq	= 1;
	}
	
function busted9() {
	alert('Sorry, you only get one shot at each question.');
	quiz9.history.forward(); 
	quiz9.focus();
	}
	
function book()	{
	parent.location.href='/licensing/learnerdrivers/1464.asp';
	quiz9.document.close();
	}
	
function restart(){
	parent.location.href="/licensing/learnerdrivers/1465.asp"
	quiz9.document.close();
	}

function startquiz9(openStatus, whetherOrNot) {		// Administer the test and record the ans
		
	checker9 = openStatus;
		
	if (whetherOrNot < qI) { 
		busted9(); 
		return; 
		}
	
	if (checker9) { 
		quiz9 = window.open('','QuizOne','width=640,height=480,scrollbars=yes');
		//quiz9.moveTo(150,150);		
		quiz9.focus(); 
		!checker9;
		}
	
	if (qI == qus9.length) { 
		gradeTest9(); 
		return; 
		}
	displaynine();
	}

function quiznine(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 displaynine()	{	// display questions
	
	// Write the qusestons and answrs options to the new window
	quiz9.document.clear();
	quiz9.document.open();
	quiz9.document.writeln('<html><head><title>Learners Practice Quiz 9</title>');
	quiz9.document.writeln('<link href="/css/purple.css" rel="stylesheet" type="text/css">');
	quiz9.document.writeln('</head><body bgcolor="\#ffffff\">');
	quiz9.document.writeln('<h3>Question '+ qus9[qI].number +'</h3>');
	quiz9.document.writeln('<table width=\'600\' cellspacing=\'5\'>');
	quiz9.document.writeln('<tr class=\'bg3\'><td align=\'left\' valign=\'top\' colspan=\'3\' height=\"40\">');
	quiz9.document.writeln('<p><b class=\'bodyhdr\'>' +qus9[qI].question+ '</b>');
	quiz9.document.writeln('</td></tr><td width=\'2\'>&nbsp;</td></tr>');
	quiz9.document.writeln('</td></tr><tr><td align=\'left\' valign=\'top\' width=\'35\' height=\'35\'><p>');
	quiz9.document.writeln('A&nbsp;<input type=\'radio\' name=\"answer\" value=\"a\" onClick="opener.choice9[opener.qI - 1] = this.value;\"></p>');
	quiz9.document.writeln('</td><td align=\'left\' valign=\'top\' width=\'340\' height=\'35\'>');	
	quiz9.document.writeln('<p>'+qus9[qI].optionA+'</p>');
	quiz9.document.writeln('</td><td valign=\'top\' width=\'200\'rowspan=\'4\' height=\"200\">');
	quiz9.document.writeln('<img border=\"0\" width=\"200\" height=\"200\" align=\"right\" src=\"'+qus9[qI].img+'\">');
	quiz9.document.writeln('</td></tr><tr><td align=\'left\' valign=\'top\' width=\'35\' height=\'35\'><p>');
	quiz9.document.writeln('B&nbsp;<input type=\'radio\' name=\"answer\" value=\"b\" onClick="opener.choice9[opener.qI - 1] = this.value;\"></p>');
	quiz9.document.writeln('</td><td align=\'left\'valign=\'top\' width=\'340\' height=\'35\'>');
	quiz9.document.writeln('<p>'+qus9[qI].optionB+'</p>');
	quiz9.document.writeln('</td></tr><tr><td align=\'left\' valign=\'top\' width=\'35\' height=\'35\'><p>');
	quiz9.document.writeln('C&nbsp;<input type=\'radio\' name=\"answer\" value=\"c\" onClick="opener.choice9[opener.qI - 1] = this.value;\"></p>');
	quiz9.document.writeln('</td><td align=\'left\' valign=\'top\' width=\'340\' height=\'35\'>');
	quiz9.document.writeln('<p>'+qus9[qI].optionC+'</p>');
	quiz9.document.writeln('</td></tr><tr align=\'left\' valign=\"top\" align=\'left\'><td width=\'30\'height=\'95\'>&nbsp;</td></tr>');
	quiz9.document.writeln('<tr align=\'right\'><td colspan=\'3\'>');
	quiz9.document.writeln('<input type=\'button\' value=\"NEXT QUESTION\" onClick="opener.startquiz9(false,' +nextq+ ')\;">');  
	quiz9.document.writeln('</td></tr></table></body></html>');
	quiz9.document.close();
	// Increment variables for the next question
	qI++;
	nextq++;
	}

function gradeTest9() {		// Increment the variables for the last time	
	qI++;
	nextq++;	
	
	for (var i = 0; i < qus9.length; i++) {		// Compare student ans with correct ans
		if (choice9[i] == qus9[i].ans) {
			correctans9++;
			}
		}	
	printResults9();	// Print the test results
	}
	
function printResults9() {		// Print the questions, answer options, and other info
	quiz9.document.clear();
	quiz9.document.open();
	quiz9.document.writeln('<html><head>');
	quiz9.document.writeln('<title>Quiz Nine Results</title>');
	quiz9.document.writeln('<link href="css/purplelocal.css" rel="stylesheet" type="text/css">');
	quiz9.document.writeln('</head><body BGCOLOR=\"WHITE\">');						
	quiz9.document.writeln('<h3>Quiz Results</h3>');						
	quiz9.document.writeln('<p class=\'bodyhdr\'>Your score out of 30 is &nbsp;'+correctans9+'</p>');
	quiz9.document.writeln('<p>Here is how you scored individually for each question:</p><hr>');
	quiz9.document.writeln('<table width=\'600\' cellpadding=\'0\'>');
	
	for (var i = 0; i < qus9.length; i++) {
	
	quiz9.document.writeln('<tr valign=\"top\" align=\'left\'><td height=\'30\' width=\'20\'>');
	quiz9.document.writeln('<p><b>'+qus9[i].number+ '</b></td><td colspan=\'2\'><p>' +qus9[i].question+'</p>');
	quiz9.document.writeln('</td></tr><tr valign=\"top\" align=\'left\'><td height=\'20\'>');
	quiz9.document.writeln('<p>a.</td><td width=\'450\'><p>' +qus9[i].optionA+ '</td>');
	quiz9.document.writeln('<td width=\'100\' rowspan=\'3\'><img border=\"0\" width=\"100\" height=\"100\" src=\"'+qus9[i].img+'\">');
	quiz9.document.writeln('</td></tr><tr valign=\"top\" align=\'left\'><td height=\'20\'>');	
	quiz9.document.writeln('<p>b.</td><td><p>' +qus9[i].optionB+ '</td></tr>');
	quiz9.document.writeln('<tr valign=\"top\" align=\'left\'><td height=\'20\'>');
	quiz9.document.writeln('<p>c.</td><td><p>' +qus9[i].optionC+ '<p>');
	
	// Determine if the student answered each question appropriately, and display accordingly
	if (choice9[i] == qus9[i].ans) {
		quiz9.document.writeln('&nbsp;&nbsp;&nbsp;&nbsp;<b><font color=\"GREEN\">You answered this correctly.  Your answer was:\n' +qus9[i].ans+ '.</font></b>\n</td>');
				}		
		else { 
		quiz9.document.writeln('&nbsp;&nbsp;&nbsp;&nbsp;<b><font color=\"RED\">The correct answer is:\n' +qus9[i].ans+ '\n</font></b>'); 
		}

	quiz9.document.writeln('</td></tr><tr><td colspan=\'3\'><hr></td></tr>');
	}
	i++;	
	quiz9.document.writeln('</table>');
	// Add extra info about the ranking, questions, and application
	quiz9.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.');
	quiz9.document.writeln('</body></html>');
	quiz9.document.close();
	}
	
	
var qus9 = new Array();
qus9[0] =new quiznine	("1","Which motorcycle is in the car driver's blind spot? ","Motorcycle Z.","Motorcycle Y.","Motorcycle X.","b","img/Q135.gif","Q135	Vulnerable Road Users")

qus9[1] =new quiznine	("2","Which vehicle must give way?","Neither vehicle has to give way.","Vehicle X.","Vehicle Y.","c","img/Q65.gif","	Q65 ROW(1)")

qus9[2] =new quiznine	("3","When is a driver allowed to drive without a seat belt?","When reversing a vehicle.","When aged 65 years and over.","When the driver is pregnant.","a","img/trans.gif","Q58 Restraints ")

qus9[3] =new quiznine	("4","What is the maximum speed vehicles towing a caravan or trailer are allowed to travel?","110km/h.","90km/h.","100km/h.","c","img/trans.gif","Q111 Speed")

qus9[4] =new quiznine	("5","On an unmarked road, what position must your vehicle be if you are not preparing to turn or overtake?","Any position, providing there is no traffic.","Near the centre of the road.","Close to the left-hand side of the road.","c","img/trans.gif","Q48 Position")

qus9[5] =new quiznine	("6","Which vehicle must give way?","Vehicle X.","Neither vehicle has to give way.","Vehicle Y.","c","img/Q73.gif","Q73 ROW(2)")

qus9[6] =new quiznine	("7","About how long does it take an alert driver to react to an emergency?","One tenth of a second.","10 seconds.","At least 1 second.","c","img/trans.gif","Q120 Stop & Indicate")

qus9[7] =new quiznine	("8","What is the best way to control bleeding from a wound?","Apply antiseptic cream to the wound.","Apply direct pressure to the wound.","Cover the wound with a light bandage.","b","img/trans.gif","Q18 Emergency")

qus9[8] =new quiznine	("9","Are you allowed to park a vehicle on a footpath?","No.","Yes, if it is a passenger vehicle.","Yes.","a","img/trans.gif","Q83 Signs & Parking")

qus9[9] =new quiznine	("10","What is the minimum penalty for a provisional driver with a BAC over 0.00%?","A fine.","A fine and issue of demerit points.","A fine and loss of licence.","b","img/trans.gif","Q1 Alcohol")

qus9[10] =new quiznine	("11","Is vehicle X allowed to overtake vehicle Y?","Yes, if it is safe to do so.","No.","It depends on the time of day.","b","img/Q35.gif","Q35 Position")

qus9[11] =new quiznine	("12","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")

qus9[12] =new quiznine	("13","Who must give way?","Vehicle Y.","Neither has to give way.","The cyclist X.","a","img/Q137.gif","Q137 Vulnerable Road Users")

qus9[13] =new quiznine	("14","Which vehicle must give way?","Vehicle Y.","Neither vehicle has to give way.","Vehicle X.","c","img/Q76.gif","Q76 ROW(2)")

qus9[14] =new quiznine	("15","Which of the following statements is correct?","You should not drive if you are tired.","Your level of fatigue will be increased if you make stops on long trips.","You are more likely to become fatigued on short curving roads.","a","img/trans.gif","Q9 Alcohol")

qus9[15] =new quiznine	("16","What is the minimum distance a vehicle is allowed to park from a public letter box?","3 metres.","5 metres.","1 metre.","a","img/trans.gif","Q86 Signs & Parking")

qus9[16] =new quiznine	("17","When approaching traffic lights, what does a green light with a green arrow (as shown in the diagram) mean?","You may turn right only.","You may turn right or drive straight ahead.","You may drive straight ahead only.","b","img/Q29.gif","Q29 Intersections")

qus9[17] =new quiznine	("18","When should you dip your headlights?","When you are within 50 metres of a  vehicle.","When you are within 200 metres of a vehicle.","When you are dazzled by the lights of an on-coming vehicle.","b","img/trans.gif","Q125Vehicle")

qus9[18] =new quiznine	("19","Which of the following statements is correct?","Vehicle X may overtake Y, only in a 60km/h area.","Vehicle X may overtake Y.","Vehicle X must not overtake Y.","b","img/Q46.gif","Q46 Position")

qus9[19] =new quiznine	("20","What is the legal blood alcohol concentration (BAC) for learner and provisional drivers?","0.00%.","0.02%.","0.05%.","a","img/trans.gif","Q2 Alcohol")

qus9[20] =new quiznine	("21","Which vehicle must give way?","Vehicle X.","Vehicle Y.","Neither vehicle has to give way.","a","img/Q62.gif","Q62 ROW(1)")

qus9[21] =new quiznine	("22","What is the safest way to approach an intersection?","Travelling at the speed limit for the area.","Travelling at a speed that will allow you to stop if required.","Looking steadily to the right.","b","img/trans.gif","Q21 Intersections")

qus9[22] =new quiznine	("23","Which of the following is greater?","Your braking distance.","Your stopping distance.","Your reaction distance.","b","img/trans.gif","Q122 Stop & Indicate")

qus9[23] =new quiznine	("24","Which vehicle must give way?","Vehicle X.","Vehicle Y.","Neither vehicle has to give way.","b","img/Q68.gif","Q68 ROW(1)")

qus9[24] =new quiznine	("25","What is the minimum distance a vehicle is allowed to park from an intersection controlled by traffic lights?","	3 metres.","6 metres.","20 metres.","c","img/trans.gif","Q89 Signs & Parking")

qus9[25] =new quiznine	("26","On an unmarked road, what position must your vehicle be before making a left-hand turn?","Any position, providing there is no traffic.","In the centre of the road.","As close to the left-hand side of the road as possible.","c","img/trans.gif","Q52 Position")

qus9[26] =new quiznine	("27","Which of the following statements is correct?","Tyres with no tread are just as safe as tyres with tread as long as the tyre pressure is correct.","Tyre pressure should be checked when the tyres are hot.","Tyre tread must be at least 1.5mm deep over all parts of the tyre that normally come in contact with the road.","c","img/trans.gif","Q127 Vehicle")

qus9[27] =new quiznine	("28","Are people over 65 years of age required to wear a seat belt?","No, if they are passengers.","Yes.","No, if they are driving.","b","img/trans.gif","Q55 Restraints ")

qus9[28] =new quiznine	("29","Which vehicle must give way?","Vehicle Y.","Neither vehicle has to give way.","Vehicle X.","a","img/Q79.gif","Q79 ROW(2)")

qus9[29] =new quiznine	("30","What is the maximum speed learner drivers (L-plates) are allowed to travel?","110km/h.","90km/h.","100km/h.","c","img/trans.gif","Q108 Speed")
