
//The first script manages the tutorial word problem; a second ssection below manages exercises

function story170(imgName) {
             document [imgName].src = img_default.src;
           
     }

function story171(imgName) {
             document [imgName].src = img_1.src;
           
     }
function story172(imgName) {
             document [imgName].src = img_2.src;
           
     }

function story173(imgName) {
             document [imgName].src = img_3.src;
           
     }

function story174(imgName) {
             document [imgName].src = img_4.src;
           
     }

function story175(imgName) {
             document [imgName].src = img_5.src;

     }

function story176(imgName) {
             document [imgName].src = img_6.src;

     }

function story177(imgName) {
             document [imgName].src = img_7.src;
           
     }


whichbrowser = navigator.appName;          //identify browser
     Ver = parseInt(navigator.appVersion);
      if (whichbrowser == "Netscape" && Ver >= 3 ||  whichbrowser == "Microsoft Internet Explorer" && Ver > 3) version = "3";
      else version = "2";
            
             if (version >= 3) {              // if 3.0, load images 
       
//image to show when highlighted
  
	     img_default = new Image(); 		
             img_default.src = "images/story17.gif";                  
             img_1 = new Image(); 		
             img_1.src = "images/story17a.gif";              
             img_2 = new Image(); 
             img_2.src = "images/story17b.gif";              
             img_3 = new Image(); 		
             img_3.src = "images/story17c.gif";              	
             img_4 = new Image(); 
             img_4.src = "images/story17d.gif";
             img_5 = new Image(); 
             img_5.src = "images/story17e.gif";
             img_6 = new Image(); 
             img_6.src = "images/story17f.gif";
             img_7 = new Image(); 
             img_7.src = "images/story17g.gif";

     }

//*****************************************************

//Starting here is script for the exercises

//This script is one of the first on McFarland website, created in 1998, re-done in early 2001
//Some of the code is "borrowed" from another website and modified for use here

function image_on(imgName) {
	if (version == "3") {
	ActiveImage = eval(imgName + "_active.src");
	document [imgName].src = ActiveImage;
	}
     }

function image_off(imgName) {
	if (version == "3") {
	DefaultImage = eval(imgName + "_default.src");
	document [imgName].src =DefaultImage;
	}
     }



whichbrowser = navigator.appName;          //identify browser
	Ver = parseInt(navigator.appVersion);

	if (whichbrowser == "Netscape" && Ver >= 3 ||  whichbrowser == "Microsoft Internet Explorer" && Ver > 3) {

	version = "3";
	}

	else version = "2";
       
	if (version == "3") {   // if 3.0, load images

		img_1a_active = new Image(56,130); 
		img_1a_active.src = "congrat.gif"; //image when mouse moves over
		img_1b_active = new Image(56,130); 
		img_1b_active.src = "sorry.gif";   //image when mouse moves over
		img_1c_active = new Image(56,130); 
		img_1c_active.src = "sorry.gif";   //image when mouse moves over

		img_2a_active = new Image(56,130);
		img_2a_active.src = "congrat.gif";
		img_2b_active = new Image(56,130);
		img_2b_active.src = "sorry.gif";
		img_2c_active = new Image(56,130);
		img_2c_active.src = "sorry.gif";

		img_3a_active = new Image(56,130);
		img_3a_active.src = "sorry.gif";
		img_3b_active = new Image(56,130);
		img_3b_active.src = "sorry.gif";
		img_3c_active = new Image(56,130);
		img_3c_active.src = "congrat.gif";

		img_4a_active = new Image(56,130);
		img_4a_active.src = "congrat.gif";
		img_4b_active = new Image(56,130);
		img_4b_active.src = "sorry.gif";
		img_4c_active = new Image(56,130);
		img_4c_active.src = "sorry.gif";

		img_5a_active = new Image(56,130);
		img_5a_active.src = "sorry.gif";   //image when mouse moves over
		img_5b_active = new Image(56,130);
		img_5b_active.src = "sorry.gif";   //image when mouse moves over
		img_5c_active = new Image(56,130);
		img_5c_active.src = "congrat.gif"; //image when mouse moves over

		img_6a_active = new Image(56,130);
		img_6a_active.src = "sorry.gif";
		img_6b_active = new Image(56,130);
		img_6b_active.src = "sorry.gif";
		img_6c_active = new Image(56,130);
		img_6c_active.src = "congrat.gif";

		img_7a_active = new Image(56,130);
		img_7a_active.src = "sorry.gif";
		img_7b_active = new Image(56,130);
		img_7b_active.src = "congrat.gif";
		img_7c_active = new Image(56,130);
		img_7c_active.src = "sorry.gif";

		img_8a_active = new Image(56,130);
		img_8a_active.src = "sorry.gif";
		img_8b_active = new Image(56,130);
		img_8b_active.src = "sorry.gif";
		img_8c_active = new Image(56,130);
		img_8c_active.src = "congrat.gif";

		img_9a_active = new Image(56,130);
		img_9a_active.src = "congrat.gif";
		img_9b_active = new Image(56,130);
		img_9b_active.src = "sorry.gif";
		img_9c_active = new Image(56,130);
		img_9c_active.src = "sorry.gif";

		img_10a_active = new Image(56,130);
		img_10a_active.src = "sorry.gif";
		img_10b_active = new Image(56,130);
		img_10b_active.src = "sorry.gif";
		img_10c_active = new Image(56,130);
		img_10c_active.src = "congrat.gif";

		img_11a_active = new Image(56,130);
		img_11a_active.src = "sorry.gif";   //image when mouse moves over
		img_11b_active = new Image(56,130);
		img_11b_active.src = "congrat.gif"; //image when mouse moves over
		img_11c_active = new Image(56,130);
		img_11c_active.src = "sorry.gif";   //image when mouse moves over


	//images to show when mouse is not over image

		img_1a_default = new Image(56,130);  
		img_1a_default.src = "annuity1.gif";  //default image
		img_1b_default = new Image(56,130); 
		img_1b_default.src = "annuity2.gif";  //default image
		img_1c_default = new Image(56,130);
		img_1c_default.src = "annuity3.gif";  //default image

		img_2a_default = new Image(56,130);
		img_2a_default.src = "annuity1.gif";
		img_2b_default = new Image(56,130);
		img_2b_default.src = "annuity2.gif";
		img_2c_default = new Image(56,130);
		img_2c_default.src = "annuity3.gif";

		img_3a_default = new Image(56,130);
		img_3a_default.src = "annuity1.gif";
		img_3b_default = new Image(56,130);
		img_3b_default.src = "annuity2.gif";
		img_3c_default = new Image(56,130);
		img_3c_default.src = "annuity3.gif";

		img_4a_default = new Image(56,130);
		img_4a_default.src = "annuity1.gif";
		img_4b_default = new Image(56,130);
		img_4b_default.src = "annuity2.gif";
		img_4c_default = new Image(56,130);
		img_4c_default.src = "annuity3.gif";

		img_5a_default = new Image(56,130);
		img_5a_default.src = "annuity1.gif";
		img_5b_default = new Image(56,130);
		img_5b_default.src = "annuity2.gif";
		img_5c_default = new Image(56,130);
		img_5c_default.src = "annuity3.gif";

		img_6a_default = new Image(56,130);
		img_6a_default.src = "annuity1.gif";  //default image
		img_6b_default = new Image(56,130);
		img_6b_default.src = "annuity2.gif";  //default image
		img_6c_default = new Image(56,130);
		img_6c_default.src = "annuity3.gif";  //default image

		img_7a_default = new Image(56,130);
		img_7a_default.src = "annuity1.gif";
		img_7b_default = new Image(56,130);
		img_7b_default.src = "annuity2.gif";
		img_7c_default = new Image(56,130);
		img_7c_default.src = "annuity3.gif";

		img_8a_default = new Image(56,130);
		img_8a_default.src = "annuity1.gif";
		img_8b_default = new Image(56,130);
		img_8b_default.src = "annuity2.gif";
		img_8c_default = new Image(56,130);
		img_8c_default.src = "annuity3.gif";

		img_9a_default = new Image(56,130);
		img_9a_default.src = "annuity1.gif";
		img_9b_default = new Image(56,130);
		img_9b_default.src = "annuity2.gif";
		img_9c_default = new Image(56,130);
		img_9c_default.src = "annuity3.gif";

		img_10a_default = new Image(56,130);
		img_10a_default.src = "annuity1.gif";
		img_10b_default = new Image(56,130);
		img_10b_default.src = "annuity2.gif";
		img_10c_default = new Image(56,130);
		img_10c_default.src = "annuity3.gif";

		img_11a_default = new Image(56,130);
		img_11a_default.src = "annuity1.gif";  //default image
		img_11b_default = new Image(56,130);
		img_11b_default.src = "annuity2.gif";  //default image
		img_11c_default = new Image(56,130);
		img_11c_default.src = "annuity3.gif";  //default image

	if (version == "2") {

		alert ("This page requires either NetScape 3.0+ or Internet Explorer 4.0+!");

	}

}

function test1(form) {

	Ctrl = form.inputbox1;

	if ((Ctrl.value - 269)*(Ctrl.value - 269) < 1.01) {

		return (true);

	} else

		validatePrompt (Ctrl, "Ooops: Your answer to [1] is not OK. Did you round to the nearest dollar?")

		return (false);
}


function test2(form) {

	Ctrl = form.inputbox2;

	if ((Ctrl.value - 192)*(Ctrl.value - 192) < 1.01){

		return (true);

	} else

		validatePrompt (Ctrl, "Ooops: Your answer to [2] is not OK. Did you round to the nearest dollar?")

		return (false);
}

function test3(form) {

	Ctrl = form.inputbox3;

	if (((Ctrl.value - 210293)*(Ctrl.value - 210293) < 0.1) || (Ctrl.value == "210,293") || (Ctrl.value == "210,294")){

		return (true);

	} else

		validatePrompt (Ctrl, "Ooops: Your answer to [3] is not OK. Did you round to the nearest dollar?")

		return (false);
}

function test4(form) {

	Ctrl = form.inputbox4;

	if ((Ctrl.value - 485)*(Ctrl.value - 485) < 1.01){

		return (true);

	} else

		validatePrompt (Ctrl, "Ooops: Your answer to [4] is not OK. Did you round to the nearest dollar?")

		return (false);
}

function test5(form) {

	Ctrl = form.inputbox5;

	if (((Ctrl.value - 247842)*(Ctrl.value - 247842) < 1.01) || (Ctrl.value == "247,842") || (Ctrl.value == "247,843")){

		return (true);

	} else

		validatePrompt (Ctrl, "Ooops: Your answer to [5] is not OK. Did you round to the nearest dollar?")

		return (false);
}

function test6(form) {

	Ctrl = form.inputbox6;

	if ((Ctrl.value - 333)*(Ctrl.value - 333) < 1.01){

		return (true);

	} else

		validatePrompt (Ctrl, "Ooops: Your answer to [6] is not OK. Did you round to the nearest dollar?")

		return (false);
}

function test7(form) {

	Ctrl = form.inputbox7;

	if (((Ctrl.value - 346496)*(Ctrl.value - 346496) < 1.01) || (Ctrl.value == "346,496") || (Ctrl.value == "346,497")){

		return (true);

	} else

		validatePrompt (Ctrl, "Ooops: Your answer to [7] is not OK. Did you round to the nearest dollar?")

		return (false);
}

function test8(form) {

	Ctrl = form.inputbox8;

	if (((Ctrl.value - 2324)*(Ctrl.value - 2324) < 1.01) || (Ctrl.value == "2,324") || (Ctrl.value == "2,325")){

		return (true);

	} else

		validatePrompt (Ctrl, "Ooops: Your answer to [8] is not OK. Did you round to the nearest dollar?")

		return (false);
}

function test9(form) {

	Ctrl = form.inputbox9;

	if ((Ctrl.value - 119)*(Ctrl.value - 119) < 1.01){

		return (true);

	} else

		validatePrompt (Ctrl, "Ooops: Your answer to [9] is not OK. Did you round to the nearest dollar?")

		return (false);
}

function test10(form) {

	Ctrl = form.inputbox10;

	if (((Ctrl.value - 7894)*(Ctrl.value - 7894) < 1.01) || (Ctrl.value == "7,894") || (Ctrl.value == "7,895")){

		return (true);

	} else

		validatePrompt (Ctrl, "Ooops: Your answer to [10] is not OK. Did you round to the nearest dollar?")

		return (false);
}

function test11(form) {

	Ctrl = form.inputbox11;

	if (((Ctrl.value - 6172)*(Ctrl.value - 6172) < 1.01) || (Ctrl.value == "6,172") || (Ctrl.value == "6,173")){

		return (true);

	} else

		validatePrompt (Ctrl, "Ooops: Your answer to [11] is not OK. Did you round to the nearest dollar?")

		return (false);
}


function runSubmit1 (form, button)  {

	if (!test1(form)) return;

	alert ("Congratulations: Your answer is OK!");

	//document.test.submit();

	return;

}

function runSubmit2 (form, button)  {

	if (!test2(form)) return;

	alert ("Good job: Your answer is perfect!");

	//document.test.submit();

	return;
}

function runSubmit3 (form, button)  {

	if (!test3(form)) return;

	alert ("Great work: Your answer is correct!");

	//document.test.submit();

	return;
}

function runSubmit4 (form, button)  {

	if (!test4(form)) return;

	alert ("Congratulations: Your answer is fine!");

	//document.test.submit();

	return;
}

function runSubmit5 (form, button)  {

	if (!test5(form)) return;

	alert ("Congratulations: great answer!");

	//document.test.submit();

	return;
}

function runSubmit6 (form, button)  {

	if (!test6(form)) return;

	alert ("Congratulations: Prof couldn't have done better himself!");

	//document.test.submit();

	return;
}

function runSubmit7 (form, button)  {

	if (!test7(form)) return;

	alert ("Congratulations and good work: Your answer is correct!");

	//document.test.submit();

	return;
}

function runSubmit8 (form, button)  {

	if (!test8(form)) return;

	alert ("Congratulations: Your answer is fine!");

	//document.test.submit();

	return;
}

function runSubmit9 (form, button)  {

	if (!test9(form)) return;

	alert ("Congratulations: Good work on your correct answer!");

	//document.test.submit();

	return;
}

function runSubmit10 (form, button)  {

	if (!test10(form)) return;

	alert ("Congratulations: Your answer is great! Note that Mrs. Henderson made a profit!");

	//document.test.submit();

	return;
}

function runSubmit11 (form, button)  {

	if (!test11(form)) return;

	alert ("Congratulations: Your answer is perfect!");

	//document.test.submit();

	return;
}


function validatePrompt (Ctrl, PromptStr) {

	alert (PromptStr)

	Ctrl.focus();

	return;

}

function loadDoc() {

	// initial focus; use if needed

	//document.test.inputbox12.focus ();

	return;

}


