function init() 
{questions = new Array()
	answerA = new Array();
	answerB = new Array();
	answerC = new Array();
	answerD = new Array();
	answerE = new Array();
	corrAns = new Array();
	numAns = new Array();
	reference = new Array()
	stat_var = new Array()
	stat_var[0] = 0; stat_var[1] = ""; stat_var[2] = "";

questions[1] = "A sailboat, with sails up, and the engine running has the right of way over all other boats";
numAns[1] = "2"; 
answerA[1] = "True";
answerB[1] = "False";
corrAns[1] = 1;
reference[1] = "If the engine is running, it is considered a power boat."; 

questions[2] = "The right side of a boat is called the ..... side";
numAns[2] = "3"; 
answerA[2] = "Port";
answerB[2] = "Starboard";
answerC[2] = "Lee";
corrAns[2] = 1;
reference[2] = "Study Hint: Starboard and Right have more letters than Port and Left."; 

questions[3] = "What is the most important thing a skipper should know";
numAns[3] = "3"; 
answerA[3] = "Their boat's position";
answerB[3] = "Their radio call sign";
answerC[3] = "Their insurance agent's phone number";
corrAns[3] = 0;
reference[3] = "You need to know your boat's position"; 

questions[4] = "Where must license numbers be displayed on a boat?";
numAns[4] = "5"; 
answerA[4] = "on the transom";
answerB[4] = "at the stern";
answerC[4] = "on any flat surface";
answerD[4] = "on each side of the bow";
answerE[4] = "on your boating ownership document";
corrAns[4] = 3;
reference[4] = "All boats must display license numbers (with a minimum height of 7.5cm) on each side of the bow."; 

questions[5] = "Where must safety equipment be located on a pleasure boat?";
numAns[5] = "4"; 
answerA[5] = "in hanging lockers";
answerB[5] = "under the seats";
answerC[5] = "in the engine compartment";
answerD[5] = "in readily accessible locations";
corrAns[5] = 3;
reference[5] = "in readily accessible locations"; 

questions[6] = "What label must be on every lifejacket or PFD?";
numAns[6] = "4"; 
answerA[6] = "the approval number issued by the DOT, Canada, Canadian Coast Guard or Department of Fisheries and Oceans";
answerB[6] = "the manufacturer's care and cleaning instructions";
answerC[6] = "the approval number issued by Canadian Hydrographic Services";
answerD[6] = "recommendations for proper sizing and use of the device";
corrAns[6] = 0;
reference[6] = "the approval number issued by the DOT, Canada, Canadian Coast Guard or Department of Fisheries and Oceans"; 

questions[7] = "What do a sailboat less than 7m, a rowboat and an anchored boat have in common at night";
numAns[7] = "4"; 
answerA[7] = "they must display red and green sidelights";
answerB[7] = "they must display a white steaming light";
answerC[7] = "they must display an all-around white light";
answerD[7] = "they must display a red or green stern light";
corrAns[7] = 2;
reference[7] = "they must display an all-around white light"; 

questions[8] = "Off a power boat's port bow appears a steady green light with a white light above it.  What action should the power boat take?";
numAns[8] = "4"; 
answerA[8] = "alter course to port";
answerB[8] = "alter course to starboard";
answerC[8] = "slow down and give way";
answerD[8] = "maintain its course and speed";
corrAns[8] = 3;
reference[8] = "maintain its course and speed"; 

questions[9] = "What type of fires is a Class B fire extinguisher designed for?";
numAns[9] = "4"; 
answerA[9] = "wood and paper";
answerB[9] = "oil and gasoline";
answerC[9] = "electrical";
answerD[9] = "fibreglass and plastics";
corrAns[9] = 0;
reference[9] = "Combustible solids, including wood and paper."; 

questions[10] = "What must all pleasure boats between 6m and 12m in length carry if their freeboard exceeds 0.5m?";
numAns[10] = "4"; 
answerA[10] = "a dinghy or liferaft";
answerB[10] = "extra bailers or hand-held pumps";
answerC[10] = "a reboarding device";
answerD[10] = "six fenders";
corrAns[10] = 2;
reference[10] = "a reboarding device"; 

questions[11] = "Where does a magnetic needle point if it is free of local magnetic disturbances?";
numAns[11] = "4"; 
answerA[11] = "true north";
answerB[11] = "magnetic north";
answerC[11] = "apparent north";
answerD[11] = "ship's heading";
corrAns[11] = 1;
reference[11] = "magnetic north"; 

questions[12] = "What is the angular difference between true north and magnetic north called?";
numAns[12] = "4"; 
answerA[12] = "correction";
answerB[12] = "compensation";
answerC[12] = "variation";
answerD[12] = "deviation";
corrAns[12] = 2;
reference[12] = "variation"; 

questions[13] = "What is a lubber's line?";
numAns[13] = "4"; 
answerA[13] = "a line drawn on a boat's deck";
answerB[13] = "a reference line on a compass";
answerC[13] = "a reference line for the position of the helm";
answerD[13] = "a line painted on the hull to show a boat's draft";
corrAns[13] = 1;
reference[13] = "a reference line on a compass"; 

questions[14] = "What kind of line makes a good tow rope?";
numAns[14] = "4"; 
answerA[14] = "nylon";
answerB[14] = "polyester";
answerC[14] = "polypropylene";
answerD[14] = "natural fibre";
corrAns[14] = 2;
reference[14] = "Polypropylene is recommended for use as tow ropes and heaving lines."; 

questions[15] = "What purpose do spring lines serve on a moored boat?";
numAns[15] = "4"; 
answerA[15] = "snug the boat into the dock";
answerB[15] = "reduce fore and aft movement of the boat";
answerC[15] = "give it a nautical look";
answerD[15] = "serve as a backup should the bow or stern lines come undone";
corrAns[15] = 1;
reference[15] = "reduce fore and aft movement of the boat"; 

questions[16] = "Why is it difficult to steer an inboard engine in reverse?";
numAns[16] = "4"; 
answerA[16] = "visibility from the steering station is obscured";
answerB[16] = "a flat transom doesn't cut through the water like a pointed bow";
answerC[16] = "people don't get as much practice going in reverse as forward";
answerD[16] = "the rudder isn't in the discharge current";
corrAns[16] = 3;
reference[16] = "the rudder isn't in the discharge current"; 

questions[17] = "What is the forecast wind speed when a gale warning is issued?";
numAns[17] = "4"; 
answerA[17] = "20 to 33 knots";
answerB[17] = "34 to 47 knots";
answerC[17] = "48 to 63 knots";
answerD[17] = "over 63 knots";
corrAns[17] = 1;
reference[17] = "34 to 47 knots"; 

questions[18] = "Which VHF channel should be monitored for announcements of weather warnings or amended forecasts?";
numAns[18] = "5"; 
answerA[18] = "Channel 10";
answerB[18] = "Channel 12";
answerC[18] = "Channel 16";
answerD[18] = "Channel 17";
answerE[18] = "Scanner should be used to catch all forecasts";
corrAns[18] = 2;
reference[18] = "Channel 16"; 

questions[19] = "Which statement is correct for a north cardinal boy?";
numAns[19] = "4"; 
answerA[19] = "the safest water lies to the south of it";
answerB[19] = "the safest water lies to the west of it";
answerC[19] = "the safest water lies to the east of it";
answerD[19] = "the safest water lies to the north of it";
corrAns[19] = 3;
reference[19] = "the safest water lies to the north of it"; 

questions[20] = "How should you approach a person wh has fallen overboard?";
numAns[20] = "4"; 
answerA[20] = "slowly and in a downwind direction";
answerB[20] = "slowly and in an upwind direction";
answerC[20] = "quickly and in an upwind direction";
answerD[20] = "quickly and in a downwind direction";
corrAns[20] = 1;
reference[20] = "slowly and in an upwind direction"; 

 } 

function nextQuestion(form) {
	var drillEnd = eval(20 * 1);
	form.howmany.value = drillEnd;
    var i = eval(0);
	if(stat_var[0] == drillEnd) {
		form.question.value = ""; clearChoice(form); form.results.value = "End of Drill.  Your final results are listed below."; stat_var[2] = "end"; } 
	else {
		form.selquestions.selectedIndex = "-1";
		if(stat_var[0] == "0") {
			form.questNo.value = 1; stat_var[0] = 1;}
		else {
			stat_var[0] = stat_var[0] + 1; form.questNo.value = stat_var[0];}
		form.question.value = questions[stat_var[0]];
		for (i= 0; i < form.selquestions.length; i++) { SetOption(form, i); } 
		form.results.value = ""; stat_var[2] = "";
		if(stat_var[1] == "") {
			form.myScore.value = 0; stat_var[1] = 0;}
		else { form.myScore.value = stat_var[1]; } 
	}
}

function SetOption(form, i) { 
	var squ = ""; var sqa = "";
	if (eval(i) > eval(numAns[stat_var[0]] -1 ))
		{ form.selquestions.options[i].text = "      "; }
	else { switch (i) { 
		case 0: 
			squ = "a"; sqa = answerA[stat_var[0]];
			break;
		case 1: 
			squ = "b"; sqa = answerB[stat_var[0]];
			break;
		case 2: 
			squ = "c"; sqa = answerC[stat_var[0]];
			break;
		case 3: 
			squ = "d"; sqa = answerD[stat_var[0]];
			break;
		case 4: 
			squ = "e"; sqa = answerE[stat_var[0]];
			break;
		} 
	form.selquestions.options[i].text = squ + ")  " + sqa;}
}

function checkAnswer(form) {
	var myScore = 0; var curve = 0;
	if(stat_var[2] != "") { 
		switch (stat_var[2]) {
			case "correct":    stat_var[2] == ""; nextQuestion(form); break; 
			case "incorrect":  stat_var[2] = ""; nextQuestion(form); break; 
			case "end":        clearForm(form);  break;
			}
		return; }
	else if(form.selquestions.selectedIndex == corrAns[stat_var[0]]) {
		stat_var[1] = stat_var[1] + eval(1); form.myScore.value = stat_var[1]; 
		form.results.value = "Congratulations!  You are correct.  Click on ''Next Question'' to continue.";stat_var[2] = "correct"; }
	else {
		if (stat_var[0] == "0") { alert('You must click on START DRILL to start the drill.'); } 
	else {
		form.results.value = "Sorry, you are incorrect.  " + reference[stat_var[0]] + "\nClick on ''Next Question'' to continue.";  stat_var[2] = "incorrect"; }
	}
	if (stat_var[0] != "0") { 
		curve = stat_var[1] / stat_var[0]; form.percent.value = parseInt(curve * 100,10);
		if(curve >= 0.9) {form.grade.value = "H"; } 
		else if(curve >= 0.8) {form.grade.value = "P"; } 
		else {form.grade.value = "F"; }
	}
}

function clearChoice(form) { 
	var lp = 0; 
	for (lp = 0; lp < form.selquestions.length; lp++){
		form.selquestions.options[lp].text = " "; }
}

function clearForm(form) { 
	clearChoice(form);stat_var[0] = "0";  form.question.value = "";  form.results.value = "";stat_var[2] = "";  stat_var[1] = "";  form.myScore.value = "";form.percent.value = ""; form.grade.value = "";
}
