// Define global variables and arrays
var qI	= 0;
var checker7 = true;
var choice7	= new Array();
var correctans7 	= 0;
var nextq 	= 1;
var quiz7;

function itemReset() {	//resets everything
	qI 	= 0;
	choice7 = new Array();
	correctans7 	= 0;
	nextq	= 1;
	}
	
function busted7() {
	alert('Sorry, you only get one shot at each question.');
	quiz7.history.forward(); 
	quiz7.focus();
	}
	
function book()	{
	parent.location.href='/licensing/learnerdrivers/1464.asp';
	quiz7.document.close();
	}
	
function restart(){
	parent.location.href="/licensing/learnerdrivers/1465.asp"
	quiz7.document.close();
	}

function startquiz7(openStatus, whetherOrNot) {		// Administer the test and record the ans
		
	checker7 = openStatus;
		
	if (whetherOrNot < qI) { 
		busted7(); 
		return; 
		}
	
	if (checker7) { 
		quiz7 = window.open('','QuizOne','width=640,height=480,scrollbars=yes');
		//quiz7.moveTo(150,150);		
		quiz7.focus(); 
		!checker7;
		}
	
	if (qI == qus7.length) { 
		gradeTest7(); 
		return; 
		}
	displayseven();
	}

function quizseven(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 displayseven()	{	// display questions
	
	// Write the qusestons and answrs options to the new window
	quiz7.document.clear();
	quiz7.document.open();
	quiz7.document.writeln('<html><head><title>Learners Practice Quiz 7</title>');
	quiz7.document.writeln('<link href="/css/purple.css" rel="stylesheet" type="text/css">');
	quiz7.document.writeln('</head><body bgcolor="\#ffffff\">');
	quiz7.document.writeln('<h3>Question '+ qus7[qI].number +'</h3>');
	quiz7.document.writeln('<table width=\'600\' cellspacing=\'5\'>');
	quiz7.document.writeln('<tr class=\'bg3\'><td align=\'left\' valign=\'top\' colspan=\'3\' height=\"40\">');
	quiz7.document.writeln('<p><b class=\'bodyhdr\'>' +qus7[qI].question+ '</b>');
	quiz7.document.writeln('</td></tr><td width=\'2\'>&nbsp;</td></tr>');
	quiz7.document.writeln('</td></tr><tr><td align=\'left\' valign=\'top\' width=\'35\' height=\'35\'><p>');
	quiz7.document.writeln('A&nbsp;<input type=\'radio\' name=\"answer\" value=\"a\" onClick="opener.choice7[opener.qI - 1] = this.value;\"></p>');
	quiz7.document.writeln('</td><td align=\'left\' valign=\'top\' width=\'340\' height=\'35\'>');	
	quiz7.document.writeln('<p>'+qus7[qI].optionA+'</p>');
	quiz7.document.writeln('</td><td valign=\'top\' width=\'200\'rowspan=\'4\' height=\"200\">');
	quiz7.document.writeln('<img border=\"0\" width=\"200\" height=\"200\" align=\"right\" src=\"'+qus7[qI].img+'\">');
	quiz7.document.writeln('</td></tr><tr><td align=\'left\' valign=\'top\' width=\'35\' height=\'35\'><p>');
	quiz7.document.writeln('B&nbsp;<input type=\'radio\' name=\"answer\" value=\"b\" onClick="opener.choice7[opener.qI - 1] = this.value;\"></p>');
	quiz7.document.writeln('</td><td align=\'left\'valign=\'top\' width=\'340\' height=\'35\'>');
	quiz7.document.writeln('<p>'+qus7[qI].optionB+'</p>');
	quiz7.document.writeln('</td></tr><tr><td align=\'left\' valign=\'top\' width=\'35\' height=\'35\'><p>');
	quiz7.document.writeln('C&nbsp;<input type=\'radio\' name=\"answer\" value=\"c\" onClick="opener.choice7[opener.qI - 1] = this.value;\"></p>');
	quiz7.document.writeln('</td><td align=\'left\' valign=\'top\' width=\'340\' height=\'35\'>');
	quiz7.document.writeln('<p>'+qus7[qI].optionC+'</p>');
	quiz7.document.writeln('</td></tr><tr align=\'left\' valign=\"top\" align=\'left\'><td width=\'30\'height=\'95\'>&nbsp;</td></tr>');
	quiz7.document.writeln('<tr align=\'right\'><td colspan=\'3\'>');
	quiz7.document.writeln('<input type=\'button\' value=\"NEXT QUESTION\" onClick="opener.startquiz7(false,' +nextq+ ')\;">');  
	quiz7.document.writeln('</td></tr></table></body></html>');
	quiz7.document.close();
	// Increment variables for the next question
	qI++;
	nextq++;
	}

function gradeTest7() {		// Increment the variables for the last time	
	qI++;
	nextq++;	
	
	for (var i = 0; i < qus7.length; i++) {		// Compare student ans with correct ans
		if (choice7[i] == qus7[i].ans) {
			correctans7++;
			}
		}	
	printResults7();	// Print the test results
	}
	
function printResults7() {		// Print the questions, answer options, and other info
	quiz7.document.clear();
	quiz7.document.open();
	quiz7.document.writeln('<html><head>');
	quiz7.document.writeln('<title>Quiz Seven Results</title>');
	quiz7.document.writeln('<link href="css/purplelocal.css" rel="stylesheet" type="text/css">');
	quiz7.document.writeln('</head><body BGCOLOR=\"WHITE\">');						
	quiz7.document.writeln('<h3>Quiz Results</h3>');						
	quiz7.document.writeln('<p class=\'bodyhdr\'>Your score out of 30 is &nbsp;'+correctans7+'</p>');
	quiz7.document.writeln('<p>Here is how you scored individually for each question:</p><hr>');
	quiz7.document.writeln('<table width=\'600\' cellpadding=\'0\'>');
	
	for (var i = 0; i < qus7.length; i++) {
	
	quiz7.document.writeln('<tr valign=\"top\" align=\'left\'><td height=\'30\' width=\'20\'>');
	quiz7.document.writeln('<p><b>'+qus7[i].number+ '</b></td><td colspan=\'2\'><p>' +qus7[i].question+'</p>');
	quiz7.document.writeln('</td></tr><tr valign=\"top\" align=\'left\'><td height=\'20\'>');
	quiz7.document.writeln('<p>a.</td><td width=\'450\'><p>' +qus7[i].optionA+ '</td>');
	quiz7.document.writeln('<td width=\'100\' rowspan=\'3\'><img border=\"0\" width=\"100\" height=\"100\" src=\"'+qus7[i].img+'\">');
	quiz7.document.writeln('</td></tr><tr valign=\"top\" align=\'left\'><td height=\'20\'>');	
	quiz7.document.writeln('<p>b.</td><td><p>' +qus7[i].optionB+ '</td></tr>');
	quiz7.document.writeln('<tr valign=\"top\" align=\'left\'><td height=\'20\'>');
	quiz7.document.writeln('<p>c.</td><td><p>' +qus7[i].optionC+ '<p>');
	
	// Determine if the student answered each question appropriately, and display accordingly
	if (choice7[i] == qus7[i].ans) {
		quiz7.document.writeln('&nbsp;&nbsp;&nbsp;&nbsp;<b><font color=\"GREEN\">You answered this correctly.  Your answer was:\n' +qus7[i].ans+ '.</font></b>\n</td>');
				}		
		else { 
		quiz7.document.writeln('&nbsp;&nbsp;&nbsp;&nbsp;<b><font color=\"RED\">The correct answer is:\n' +qus7[i].ans+ '\n</font></b>'); 
		}

	quiz7.document.writeln('</td></tr><tr><td colspan=\'3\'><hr></td></tr>');
	}
	i++;	
	quiz7.document.writeln('</table>');
	// Add extra info about the ranking, questions, and application
	quiz7.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.');
	quiz7.document.writeln('</body></html>');
	quiz7.document.close();
	}
	
	
var qus7 = new Array();
qus7[0] =new quizseven("1","What should you do when you see this sign?","Slow down and be prepared to stop.","Be prepared to speed up to avoid workmen on the road.","Close your windows to avoid damage from flying objects.","a","img/Q102.gif","Q102 Signs & Parking")

qus7[1] =new quizseven("2","Which vehicle must give way?","Vehicle Y.","Vehicle X.","Neither vehicle has to give way.","a","img/Q61.gif","Q61 ROW(1)")

qus7[2] =new quizseven("3","If you are turning at an intersection where there are no traffic lights and pedestrians are crossing the road, what must you do?","Give way to pedestrians only if you are turning right.","Give way to pedestrians only if you are turning left.","Give way to pedestrians at all times.","c","img/trans.gif","Q148 Vulnerable Road Users")

qus7[3] =new quizseven("4","Which of the following statements is correct?","Vehicle X may overtake Y.","Vehicle X must not overtake Y.","Vehicle X may overtake Y, only in a 50km/h area.","a","img/Q45.gif","Q45 Position")

qus7[4] = new quizseven("5","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")

qus7[5] =new quizseven("6","Which vehicle must give way?","Vehicle Y.","Neither vehicle has to give way.","Vehicle X.","c","img/Q80.gif","Q80 ROW(2)")

qus7[6] = new quizseven("7","Is it an offence not to give way to an emergency vehicle?","Yes, if it is using a siren or flashing lights.","Yes.","No.","a","img/trans.gif","Q16Emergency")

qus7[7] = new quizseven("8","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")

qus7[8] =new quizseven("9","When should you switch your headlights on?","20 minutes after sunset.","15 minutes after sunset.","At sunset.","c","img/trans.gif","Q126 Vehicle")

qus7[9] = new quizseven("10","What should you do when approaching a railway crossing?","Speed up to clear the crossing quickly.","Slow down and be prepared to stop.","Sound your horn.","b","img/trans.gif","Q25 Intersections")

qus7[10] =new quizseven("11","What does the continuous white line dividing the lanes mean?","You are allowed to change lanes if you are turning right.","You are not allowed to change lanes.","You are allowed to change lanes if you are turning left.","b","img/Q33.gif","Q33 Position")

qus7[11] =new quizseven("12","Is a vehicle allowed to cross over a double unbroken white line (as shown in the diagram)?","Yes, if the driver wishes to overtake another vehicle.","No.","Yes, if the driver wishes to make a right-hand turn or a 'U' turn and it is safe and legal to do so.","c","img/Q37.gif","Q37 Position")

qus7[12] =new quizseven("13","Which vehicle must give way?","Neither vehicle has to give way.","Vehicle Y.","Vehicle X.","b","img/Q74.gif","Q74 ROW(2)")

qus7[13] =new quizseven("14","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")

qus7[14] =new quizseven("15","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")

qus7[15] =new quizseven("16","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")

qus7[16] =new quizseven("17","Which vehicle must give way?","Vehicle Y.","Vehicle X.","Neither vehicle has to give way.","b","img/Q64.gif","Q64 ROW(1)")

qus7[17] =new quizseven("18","What area is known as a vehicle driver's blind spot?","The area beside the vehicle that the driver is not looking at.","An area behind or to the side of the vehicle that cannot be seen in the side or rear-view mirrors.","An area which can only be seen in the side or rear-view mirrors.","b","img/trans.gif","Q112 Stop & Indicate")

qus7[18] =new quizseven("19","Which vehicle must give way?","Vehicle Y.","Neither vehicle has to give way.","Vehicle X.","a","img/Q77.gif","Q77 ROW(2)")

qus7[19] =new quizseven("20","What is the meaning of this sign?","No entry for heavy vehicles.","No entry at any time.","No entry during daylight hours.","b","img/Q100.gif","Q100 Signs & Parking")

qus7[20] = new quizseven("21","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")

qus7[21] =new quizseven("22","When approaching a STOP sign that has no line marked on the road, where must you stop?","Next to the STOP sign.","As close to the crossroad as possible without entering it.","Before the STOP sign.","b","img/trans.gif","Q101 Signs & Parking")

qus7[22] =new quizseven("23","What is the speed limit in built-up areas where there are no speed limit signs? ","60km/h.","50km/h.","80km/h.","b","img/trans.gif","Q106 Speed")

qus7[23] =new quizseven("24","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","Q6	ROW(1)")

qus7[24] =new quizseven("25","Which of the following statements is correct?","Passengers in vehicles are less likely to be injured in a crash if they are wearing seat belts.","The nature of injuries in motor vehicle crashes is not related to the wearing of seat belts.","Passengers in rear seats of a vehicle are not required to wear seat belts.","a","img/trans.gif","Q60 Restraints")

qus7[25] =new quizseven("26","Do you need to indicate if you overtake a vehicle on an unmarked two-way road?","Yes, only if there is a vehicle behind you.","No.","Yes.","c","img/trans.gif","Q114 Stop & Indicate")

qus7[26] =new quizseven("27","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/Q41.gif","Q41 Position")

qus7[27] =new quizseven("28","Is it legal for you to drive a motor vehicle at night with only one headlight working?","No.","Yes, if the right-hand headlight is visible.","Yes.","a","img/trans.gif","Q128 Vehicle")

qus7[28] =new quizseven("29","If you are turning at traffic lights and pedestrians are crossing the road, what must you do? ","Give way to pedestrians crossing the road. ","Go if you are turning with a green arrow.","Ease your way through the pedestrians.","a","img/trans.gif","Q147	Vulnerable Road Users")

qus7[29] = new quizseven("30","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")
