function randomERProblem(form) { 	var theP1 = Math.round(Math.random()*6+2);  	var theP2 = Math.round(Math.random()*6+2); 	var theP3 = Math.round(Math.random()*(17-theP1-theP2)+1);  	var theP4 = 20 - theP1 - theP2 - theP3; 	var theP1 = Math.round(theP1*5); 	var theP2 = Math.round(theP2*5); 	var theP3 = Math.round(theP3*5); 	var theP4 = Math.round(theP4*5); 	var theR1 = Math.round(Math.random()*80-30); 	var theR2 = Math.round(Math.random()*80-30); 	var theR3 = Math.round(Math.random()*80-30); 	var theR4 = Math.round(Math.random()*80-30); 	if ((theR1 < 0) && (theR2 < 0) && (theR3 < 0) && (theR4 < 0)) { 		theR2 = Math.round(theR2*(-1)); 		theR4 = Math.round(theR4*(-1)); 	}  	form.p1.value="" + theP1; 	form.p2.value="" + theP2; 	form.p3.value="" + theP3; 	form.p4.value="" + theP4; 	form.r1.value="" + theR1; 	form.r2.value="" + theR2; 	form.r3.value="" + theR3; 	form.r4.value="" + theR4; 	form.er.value=""; }  function findER(form) { 	var theP1Str = form.p1.value; 	if (!isPositiveNumber(theP1Str)) { 		return false; 	} 	var theP2Str = form.p2.value; 	if (!isPositiveNumber(theP2Str)) { 		return false; 	} 	var theP3Str = form.p3.value; 	if (!isPositiveNumber(theP3Str)) { 		return false; 	} 	var theP4Str = form.p4.value; 	if (!isPositiveNumber(theP4Str)) { 		return false; 	} 	var theR1Str = form.r1.value; 	if (!isNumber(theR1Str)) { 		return false; 	} 	var theR2Str = form.r2.value; 	if (!isNumber(theR2Str)) { 		return false; 	} 	var theR3Str = form.r3.value; 	if (!isNumber(theR3Str)) { 		return false; 	} 	var theR4Str = form.r4.value; 	if (!isNumber(theR4Str)) { 		return false; 	} 	var theP1 = parseFloat(theP1Str); 	var theP2 = parseFloat(theP2Str); 	var theP3 = parseFloat(theP3Str); 	var theP4 = parseFloat(theP4Str); 	var theR1 = parseFloat(theR1Str); 	var theR2 = parseFloat(theR2Str); 	var theR3 = parseFloat(theR3Str); 	var theR4 = parseFloat(theR4Str); 	if ((theP1 + theP2 + theP3 + theP4) != 100) { 		alert("The sum of the probabilities must equal 100\%"); 		return true; 	} 	var theER = (theP1*theR1 + theP2*theR2 + theP3*theR3 + theP4*theR4)/100; 	form.er.value = "" + Math.round(theER*100)/100; 	return true; }  function helpER(form) { 	var theP1Str = form.p1.value; 	if (!isPositiveNumber(theP1Str)) { 		return false; 	} 	var theP2Str = form.p2.value; 	if (!isPositiveNumber(theP2Str)) { 		return false; 	} 	var theP3Str = form.p3.value; 	if (!isPositiveNumber(theP3Str)) { 		return false; 	} 	var theP4Str = form.p4.value; 	if (!isPositiveNumber(theP4Str)) { 		return false; 	} 	var theR1Str = form.r1.value; 	if (!isNumber(theR1Str)) { 		return false; 	} 	var theR2Str = form.r2.value; 	if (!isNumber(theR2Str)) { 		return false; 	} 	var theR3Str = form.r3.value; 	if (!isNumber(theR3Str)) { 		return false; 	} 	var theR4Str = form.r4.value; 	if (!isNumber(theR4Str)) { 		return false; 	} 	var theP1 = parseFloat(theP1Str); 	var theP2 = parseFloat(theP2Str); 	var theP3 = parseFloat(theP3Str); 	var theP4 = parseFloat(theP4Str); 	var theR1 = parseFloat(theR1Str); 	var theR2 = parseFloat(theR2Str); 	var theR3 = parseFloat(theR3Str); 	var theR4 = parseFloat(theR4Str); 	if ((theP1 + theP2 + theP3 + theP4) != 100) { 		alert("The sum of the probabilities must equal 100\%"); 		return true; 	} 	var theER = (theP1*theR1 + theP2*theR2 + theP3*theR3 + theP4*theR4)/100; 	theER = "" + Math.round(theER*100)/100; 	var theOut = "<html><head><title>Expected Return Help</title></head><body bgcolor='white'>"; 	theOut += "<h3>Expected Return Help</h3>"; 	theOut += "<p>The expected return can be calculated as follows:</p>"; 	theOut += "<p><i>The probabilities are expressed in decimal form.</i></p>"; 	theOut += "<p>E[R] = (" +  Math.round(theP1)/100 + ")(" + Math.round(theR1*100)/100 + ") + "; 	theOut += "(" +  Math.round(theP2)/100 + ")(" + Math.round(theR2*100)/100 + ") + "; 	theOut += "(" +  Math.round(theP3)/100 + ")(" + Math.round(theR3*100)/100 + ") + "; 	theOut += "(" +  Math.round(theP4)/100 + ")(" + Math.round(theR4*100)/100 + ") = " + theER + "\%</p>"; 	theOut += "<p><b>The Expected Return is " + theER + "\%</b></p>"; 	theOut += "<CENTER>";	theOut += "<P><FORM NAME=\"Form1\">";	theOut += "<INPUT TYPE=\"button\" VALUE=\"   OK   \" onClick=\"window.close();\"></FORM></P></CENTER>"; 	theOut += "</body></html>"; 	var newWin = window.open("","","scrollbars,resizable,width=450,height=320"); 	if (newWin != null) { 		newWin.document.write(theOut); 		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 oneChar = inputStr.substring(0,1); 	if (!((oneChar == '-') || ((oneChar >= "0") && (oneChar <= "9")) || (oneChar == "."))) { 		alert("Please make sure that only numbers are input."); 		return false; 	} 	for (var i = 1; i < inputStr.length; i++) { 		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; }