function randomPProblem(form) {	var theS = (Math.round(Math.random()*2200)) + 700; 	var theNI = (Math.round(Math.random()*(theS - 1100))) + 100;  	var theTA = (Math.round(Math.random()*2000)) + 1000;  	var theTE = (Math.round(Math.random()*(theTA - 800))) + 500;  	form.SInput.value="" + theS;  	form.NIInput.value="" + theNI;  	form.TAInput.value="" + theTA;  	form.TEInput.value="" + theTE;  	form.PMOutput.value=""; 	form.ROAOutput.value=""; 	form.ROEOutput.value=""; }  function findP(form) { 	var theS = form.SInput.value; 	if (!isPositiveNumber(theS)) { 		return false; 	} 	var theNI = form.NIInput.value; 	if (!isNumber(theNI)) { 		return false; 	} 	var theTA = form.TAInput.value; 	if (!isPositiveNumber(theTA)) { 		return false; 	} 	var theTE = form.TEInput.value; 	if (!isPositiveNumber(theTE)) { 		return false; 	} 	var thePM = theNI/theS; 	form.PMOutput.value = "" + Math.round(thePM*10000)/100; 	var theROA = theNI/theTA; 	form.ROAOutput.value = "" + Math.round(theROA*10000)/100; 	var theROE = theNI/theTE; 	form.ROEOutput.value = "" + Math.round(theROE*10000)/100; 	return true; }  function calcPHelp(form) { 	var theS = form.SInput.value; 	if (!isPositiveNumber(theS)) { 		return false; 	} 	var theNI = form.NIInput.value; 	if (!isNumber(theNI)) { 		return false; 	} 	var theTA = form.TAInput.value; 	if (!isPositiveNumber(theTA)) { 		return false; 	} 	var theTE = form.TEInput.value; 	if (!isPositiveNumber(theTE)) { 		return false; 	} 	var thePM = theNI/theS; 	var theAns = "" + Math.round(thePM*10000)/100; 	var theROA = theNI/theTA; 	var theAns1 = "" + Math.round(theROA*10000)/100; 	var theROE = theNI/theTE; 	var theAns2 = "" + Math.round(theROE*10000)/100; 	var theStr = "<HTML><HEAD><TITLE>Profitability Ratio Help</TITLE></HEAD><BODY BGCOLOR=\"white\">"; 	theStr += "<h1>Profit Margin Help</h1>";	theStr += "<P>The <b>Profit Margin</b> is calculated as follows:</P>";	theStr += drawFraction("Profit Margin","Net Income","Sales",theNI,theS,theAns + "\%");	theStr += "<h1>Return on Assets Help</h1>";	theStr += "<P>The <b>Return on Assets</b> is calculated as follows:</P>";	theStr += drawFraction("Return on Assets","Net Income","Total Assets",theNI,theTA,theAns1 + "\%");	theStr += "<h1>Return on Equity Help</h1>";	theStr += "<P>The <b>Return on Equity</b> is calculated as follows:</P>";	theStr += drawFraction("Return on Equity","Net Income","Total Equity",theNI,theTE,theAns2 + "\%");	theStr += "<CENTER>";	theStr += "<P><FORM NAME=\"Form1\">";	theStr += "<INPUT TYPE=\"button\" VALUE=\"   OK   \" onClick=\"window.close();\"></FORM></CENTER>";	theStr += "</P></BODY></HTML>" 	newWin = window.open("","","scrollbars,resizable,width=400,height=450"); 	if (newWin != null) { 		newWin.document.write(theStr); 		newWin.document.close(); 		newWin.focus(); 	} 	return true;}function isPositiveNumber(inputStr) { 	for (var i = 0; i < inputStr.length; i++) { 		var oneChar = inputStr.substring(i,i+1); 		if (((oneChar >= "0") && (oneChar <= "9")) || (oneChar == ".")) { 		 		} else { 			alert("Please make sure that only numbers are input."); 			return false; 		}  	}	return true; }  function isNumber(inputStr) { 	var decFlag = false; 	if (inputStr == ".") { 		alert("Please make sure that only numbers are input."); 		return false; 	} 	for (var i = 0; i < inputStr.length; i++) { 		var oneChar = inputStr.substring(i,i+1); 		if ((i == 0) && (inputStr.length > 1)) {	 		if (((oneChar >= "0") && (oneChar <= "9")) || ((oneChar == ".") && (decFlag == false)) || (oneChar == "-")) {	 			 		} else {	 			alert("Please make sure that only numbers are input.");	 			return false;	 		}	 	} else {	 		if (((oneChar >= "0") && (oneChar <= "9")) || ((oneChar == ".") && (decFlag == false))) {	 			 		} else {	 			alert("Please make sure that only numbers are input.");	 			return false;	 		}	 	}	 	if (oneChar == ".") {	 		decFlag = true;	 	}	 	}	return true; }  function drawFraction(inLHS,inNumFormula,inDenFormula,inNum,inDen,inAnswer) {	var theOut = "<table cellspacing='1' cellpadding='1'><tr>";	theOut += "<td rowspan='3' valign='center'>" + inLHS + "</td>";	theOut += "<td rowspan='3' valign='center'>=</td>";	theOut += "<td valign='center' align='center'>" + inNumFormula + "</td>";	theOut += "<td rowspan='3' valign='center'>=</td>";	theOut += "<td valign='center' align='center'>" + inNum + "</td>";	theOut += "<td rowspan='3' valign='center'>=</td>";	theOut += "<td rowspan='3' valign='center'>" + inAnswer + "</td>";	theOut += "</tr>";	theOut += "<tr>";	theOut += "<td valign='center' align='center'><hr noshade></td>";	theOut += "<td valign='center' align='center'><hr noshade></td>";	theOut += "</tr>";	theOut += "<tr>";	theOut += "<td valign='center' align='center'>" + inDenFormula + "</td>";	theOut += "<td valign='center' align='center'>" + inDen + "</td>";	theOut += "</tr></table>";	return theOut;}function drawSimpleFraction(inNum,inDen) {	var theOut = "<table cellspacing='1' cellpadding='1'>";	theOut += "<tr><td valign='center' align='center'>" + inNum + "</td></tr>";	theOut += "<tr><td valign='center' align='center'><hr noshade></td></tr>";	theOut += "<tr><td valign='center' align='center'>" + inDen + "</td></tr>";	theOut += "</table>";	return theOut;}
