// Define global variables and arrays
var qI	= 0;
var checker6 = true;
var choice6	= new Array();
var correctans6 	= 0;
var nextq 	= 1;
var quiz6;

function itemReset() {	//resets everything
	qI 	= 0;
	choice6 = new Array();
	correctans6 	= 0;
	nextq	= 1;
	}
	
function busted6() {
	alert('Sorry, you only get one shot at each question.');
	quiz6.history.forward(); 
	quiz6.focus();
	}
	
function book()	{
	parent.location.href='/licensing/learnerdrivers/1464.asp';
	quiz6.document.close();
	}
	
function restart(){
	parent.location.href="/licensing/learnerdrivers/1465.asp"
	quiz6.document.close();
	}

function startquiz6(openStatus, whetherOrNot) {		// Administer the test and record the ans
		
	checker6 = openStatus;
		
	if (whetherOrNot < qI) { 
		busted6(); 
		return; 
		}
	
	if (checker6) { 
		quiz6 = window.open('','QuizOne','width=640,height=480,scrollbars=yes');
		//quiz6.moveTo(150,150);		
		quiz6.focus(); 
		!checker6;
		}
	
	if (qI == qus6.length) { 
		gradeTest6(); 
		return; 
		}
	displaysix();
	}

function quizsix(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 displaysix()	{	// display questions
			
	// Write the qusestons and answrs options to the new window
	quiz6.document.clear();
	quiz6.document.open();
	quiz6.document.writeln('<html><head><title>Learners Practice Quiz 6</title>');
	quiz6.document.writeln('<link href="/css/purple.css" rel="stylesheet" type="text/css">');
	quiz6.document.writeln('</head><body bgcolor="\#ffffff\">');
	quiz6.document.writeln('<h3>Question '+ qus6[qI].number +'</h3>');
	quiz6.document.writeln('<table width=\'600\' cellspacing=\'5\'>');
	quiz6.document.writeln('<tr class=\'bg3\'><td align=\'left\' valign=\'top\' colspan=\'3\' height=\"40\">');
	quiz6.document.writeln('<p><b class=\'bodyhdr\'>' +qus6[qI].question+ '</b>');
	quiz6.document.writeln('</td></tr><td width=\'2\'>&nbsp;</td></tr>');
	quiz6.document.writeln('</td></tr><tr><td align=\'left\' valign=\'top\' width=\'35\' height=\'35\'><p>');
	quiz6.document.writeln('A&nbsp;<input type=\'radio\' name=\"answer\" value=\"a\" onClick="opener.choice6[opener.qI - 1] = this.value;\"></p>');
	quiz6.document.writeln('</td><td align=\'left\' valign=\'top\' width=\'340\' height=\'35\'>');	
	quiz6.document.writeln('<p>'+qus6[qI].optionA+'</p>');
	quiz6.document.writeln('</td><td valign=\'top\' width=\'200\'rowspan=\'4\' height=\"200\">');
	quiz6.document.writeln('<img border=\"0\" width=\"200\" height=\"200\" align=\"right\" src=\"'+qus6[qI].img+'\">');
	quiz6.document.writeln('</td></tr><tr><td align=\'left\' valign=\'top\' width=\'35\' height=\'35\'><p>');
	quiz6.document.writeln('B&nbsp;<input type=\'radio\' name=\"answer\" value=\"b\" onClick="opener.choice6[opener.qI - 1] = this.value;\"></p>');
	quiz6.document.writeln('</td><td align=\'left\'valign=\'top\' width=\'340\' height=\'35\'>');
	quiz6.document.writeln('<p>'+qus6[qI].optionB+'</p>');
	quiz6.document.writeln('</td></tr><tr><td align=\'left\' valign=\'top\' width=\'35\' height=\'35\'><p>');
	quiz6.document.writeln('C&nbsp;<input type=\'radio\' name=\"answer\" value=\"c\" onClick="opener.choice6[opener.qI - 1] = this.value;\"></p>');
	quiz6.document.writeln('</td><td align=\'left\' valign=\'top\' width=\'340\' height=\'35\'>');
	quiz6.document.writeln('<p>'+qus6[qI].optionC+'</p>');
	quiz6.document.writeln('</td></tr><tr align=\'left\' valign=\"top\" align=\'left\'><td width=\'30\'height=\'95\'>&nbsp;</td></tr>');
	quiz6.document.writeln('<tr align=\'right\'><td colspan=\'3\'>');
	quiz6.document.writeln('<input type=\'button\' value=\"NEXT QUESTION\" onClick="opener.startquiz6(false,' +nextq+ ')\;">');  
	quiz6.document.writeln('</td></tr></table></body></html>');
	quiz6.document.close();
	// Increment variables for the next question
	qI++;
	nextq++;
	}

function gradeTest6() {		// Increment the variables for the last time	
	qI++;
	nextq++;	
	
	for (var i = 0; i < qus6.length; i++) {		// Compare student ans with correct ans
		if (choice6[i] == qus6[i].ans) {
			correctans6++;
			}
		}	
	printResults6();	// Print the test results
	}
	
function printResults6() {		// Print the questions, answer options, and other info
	quiz6.document.clear();
	quiz6.document.open();
	quiz6.document.writeln('<html><head>');
	quiz6.document.writeln('<title>Quiz Six Results</title>');
	quiz6.document.writeln('<link href="css/purplelocal.css" rel="stylesheet" type="text/css">');
	quiz6.document.writeln('</head><body BGCOLOR=\"WHITE\">');						
	quiz6.document.writeln('<h3>Quiz Results</h3>');						
	quiz6.document.writeln('<p class=\'bodyhdr\'>Your score out of 30 is &nbsp;'+correctans6+'</p>');
	quiz6.document.writeln('<p>Here is how you scored individually for each question:</p><hr>');
	quiz6.document.writeln('<table width=\'600\' cellpadding=\'0\'>');
	
	for (var i = 0; i < qus6.length; i++) {
	
	quiz6.document.writeln('<tr valign=\"top\" align=\'left\'><td height=\'30\' width=\'20\'>');
	quiz6.document.writeln('<p><b>'+qus6[i].number+ '</b></td><td colspan=\'2\'><p>' +qus6[i].question+'</p>');
	quiz6.document.writeln('</td></tr><tr valign=\"top\" align=\'left\'><td height=\'20\'>');
	quiz6.document.writeln('<p>a.</td><td width=\'450\'><p>' +qus6[i].optionA+ '</td>');
	quiz6.document.writeln('<td width=\'100\' rowspan=\'3\'><img border=\"0\" width=\"100\" height=\"100\" src=\"'+qus6[i].img+'\">');
	quiz6.document.writeln('</td></tr><tr valign=\"top\" align=\'left\'><td height=\'20\'>');	
	quiz6.document.writeln('<p>b.</td><td><p>' +qus6[i].optionB+ '</td></tr>');
	quiz6.document.writeln('<tr valign=\"top\" align=\'left\'><td height=\'20\'>');
	quiz6.document.writeln('<p>c.</td><td><p>' +qus6[i].optionC+ '<p>');
	
	// Determine if the student answered each question appropriately, and display accordingly
	if (choice6[i] == qus6[i].ans) {
		quiz6.document.writeln('&nbsp;&nbsp;&nbsp;&nbsp;<b><font color=\"GREEN\">You answered this correctly.  Your answer was:\n' +qus6[i].ans+ '.</font></b>\n</td>');
				}		
		else { 
		quiz6.document.writeln('&nbsp;&nbsp;&nbsp;&nbsp;<b><font color=\"RED\">The correct answer is:\n' +qus6[i].ans+ '\n</font></b>'); 
		}

	quiz6.document.writeln('</td></tr><tr><td colspan=\'3\'><hr></td></tr>');
	}
	i++;	
	quiz6.document.writeln('</table>');
	// Add extra info about the ranking, questions, and application
	quiz6.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.');
	quiz6.document.writeln('</body></html>');
	quiz6.document.close();
	}
	
	
var qus6 = new Array();
qus6[0] =new quizsix("1","Which of the following is greater?","Your braking distance.","Your stopping distance.","Your reaction distance.","b","img/trans.gif","Q122 Stop & Indicate")

qus6[1] =new quizsix("2","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")

qus6[2] =new quizsix("3","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 ")

qus6[3] =new quizsix("4","Which vehicle must give way?","Vehicle X.","Neither vehicle has to give way.","Vehicle Y.","c","img/Q73.gif","Q73 ROW(2)")

qus6[4] =new quizsix("5","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)")

qus6[5] = new quizsix("6","Which of the following statements is correct?","Alcohol has no effect on your driving ability.","Alcohol makes you react faster to hazards.","Alcohol makes you react more slowly to hazards.","c","img/trans.gif","Q3 Alcohol")

qus6[6] =new quizsix("7","Who must give way?","The pedestrian Y.","Vehicle X.","Neither has to give way.","b","img/Q146.gif","Q146	Vulnerable Road Users")

qus6[7] = new quizsix("8","What should you do if your brakes fail while you are driving?","Change to a lower gear and gently apply the handbrake.","Switch off the ignition.","Accelerate and sound your horn.","a","img/trans.gif","Q15Emergency")

qus6[8] = new quizsix("9","At a railway crossing, are you allowed to cross if the train has passed, but the lights are still flashing?","Yes.","No.","Yes, unless the crossing has boom gates.","b","img/trans.gif","Q23 Intersections")

qus6[9] = new quizsix("10","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")

qus6[10] = new quizsix("11","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")

qus6[11] =new quizsix("12","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")

qus6[12] =new quizsix("13","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"	)

qus6[13] = new quizsix("14","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")

qus6[14] =new quizsix("15","Which is the correct path for the vehicle to take when turning right at an intersection?","X is the correct path.","Y is the correct path.","Both paths are correct.","a","img/Q51.gif","Q51 Position")

qus6[15] =new quizsix("16","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")

qus6[16] =new quizsix("17","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 ")

qus6[17] =new quizsix("18","Which vehicle must give way?","Neither vehicle has to give way.","Vehicle X.","Vehicle Y.","b","img/Q63.gif","Q63 ROW(1)")

qus6[18] =new quizsix("19","What is the meaning of this sign?","You can only drive in the direction of the arrow.","You cannot go past the arrow.","You can go either way but only in one lane.","a","img/Q99.gif","Q99 Signs & Parking")

qus6[19] =new quizsix("20","Which vehicle must give way?","Vehicle Y.","Neither vehicle has to give way.","Vehicle X.","c","img/Q76.gif","Q76 ROW(2)")

qus6[20] =new quizsix("21","What is the meaning of this sign?","Give way to traffic on the right only.","Stop and give way to all traffic.","Slow down and give way to all traffic travelling along or turning from the intersecting road.","c","img/Q97.gif","Q97 Signs & Parking")

qus6[21] =new quizsix("22","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")

qus6[22] =new quizsix("23","Which vehicle must give way?","Vehicle Y.","Neither vehicle has to give way.","Vehicle X.","a","img/Q79.gif","Q79 ROW(2)")

qus6[23] = new quizsix("24","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")

qus6[24] =new quizsix("25","Which of the following statements is correct?","Your stopping distance is not affected by the condition of your brakes and tyres.","Your stopping distance is not affected by a loose road surface.","Your stopping distance will increase if the road is wet.","c","img/trans.gif","Q123	Stop & Indicate")

qus6[25] =new quizsix("26","How should you apply your brakes when driving in wet weather?","Heavily, to dry the brakes out.","Carefully, to avoid skidding.","Sharply, so that you can grip the road.","b","img/trans.gif","Q134 Vehicle")

qus6[26] =new quizsix("27","If you are dazzled by another vehicle's headlights, what should you do?","Put your lights on highbeam.","Keep left and look over the top of the approaching vehicle.","Slow down, look left and if you cannot see, pull over and stop.","c","img/trans.gif","Q124 Vehicle")

qus6[27] =new quizsix("28","Who must give way?","The pedestrian X.","Vehicle Y.","Neither has to give way.","b","img/Q145.gif","Q145	Vulnerable Road Users")

qus6[28] =new quizsix("29","In which order should the vehicles proceed?","Vehicle X, then Y, then Z.","Vehicle Z, then Y, then X.","Vehicle X, then Z, then Y.","b","img/Q69.gif","Q69 ROW(1)")

qus6[29] =new quizsix("30","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")