
// *** health points stuff
theHealthInputBoxStr = "<input type = 'text' size = 20 value = '' name = 'healthInput' onkeypress='{if (event.keyCode==13) parent.middle.processHealthResponse()}'><input type='text' name='d1' style = 'visibility: hidden; width: 1' width = 1>";

var theAnsH1 = "";
var healthLotto = 1;

function dealWithHealthVial() {
doMonomialDeriv()
} // dealWithHealthVial



function doMonomialDeriv () {
if (numHealths <= maxNumHealths) {
	numHealths += 1;

		var theString = "<table><tr><td align = left><class style = '{ font-family: Arial; font-weight: bold; color: blue;font-size: 14px;font-style: italic;}'>Need health?</class><br>";
		var theDegree = pickOne(1,2,3,4,5);
		var theShift = pickOne(0,1,2,3,1/2,1/3,2/3);
		var theMono = createPoly(theDegree, theShift, 2, 'x', 2.1);
		var theMonoFormat = parent.middle.formatPolyTex(theMono, false,true,false);
		var theMonoAns = formatPolyTex(polyDeriv(theMono,-1) , true,true,false);
		theAnsH1 = theMonoAns[0] + "+C";
//alert(theAnsH1);
		theString += "<form name = health1><table cellspacing=0><tr><td><img src = '../../typesetting/SYMB/Smint.gif'></td><td>" + typesetInlineExpression(theMonoFormat[1]) + " <i>dx</i> = </td></tr></table>" + theHealthInputBoxStr + "</form>";
// alert(theString);
		parent.left.document.getElementById("message").innerHTML = theString;
		parent.left.document.health1.healthInput.focus();

	} // if numHealths <= maxNumHealths

} // doFunctionOfxPlusH





function processHealthResponse() {

		var uu = 0;
		var inPut = parent.left.document.health1.healthInput.value;
		try {
			var answerIn = stripSpaces(inPut); 
			if (answerIn == '') uu = 0;
			else {
				h = 2.5;x = 1.73; c = 3.3;
				var HCorrVal = myEval(theAnsH1);
				var HAnsIn = myEval(answerIn); 
				if (Math.abs(HCorrVal - HAnsIn) <= .0005) uu = 1;
				else uu = 6;
				}
			}
		catch(error) {
			uu = 6;
			}

		if (uu == 1) {
			beep(5);
			health += 20;
			writeBottomSmile('Your health has increased by 20 points.',2);	
			showMeters();
			}
		else if (uu == 0) {}
		else writeBottomWrong ("Nope. Sorry. No health points earned. The correct answer was " + theAnsH1.toString());


} // processHealthResponse

