function randomPaybackProblem(form) { 	theCF0 = -1000 - (Math.round(Math.random()*2)*100);  	theCF1 = ((Math.round(Math.random()*5)) + 1)*100; 	theCF2 = ((Math.round(Math.random()*5)) + 1)*100;  	theCF3 = ((Math.round(Math.random()*5)) + 1)*100;  	theCF4 = ((Math.round(Math.random()*5)) + 1)*100;  	theCF5 = ((Math.round(Math.random()*5)) + 1)*100; 	while ((theCF0 + theCF1 + theCF2 + theCF3 + theCF4 + theCF5) < 0) { 		theCF5 += 100; 	}    	form.Year0.value="" + theCF0; 	form.Year1.value="" + theCF1; 	form.Year2.value="" + theCF2; 	form.Year3.value="" + theCF3; 	form.Year4.value="" + theCF4; 	form.Year5.value="" + theCF5; 	form.PaybackOutput.value=""; }  function findPayback(form) { 	theCF0Str = form.Year0.value; 	if (!isNegativeNumber(theCF0Str)) { 		return false; 	} 	theCF1Str = form.Year1.value; 	if (!isPositiveNumber(theCF1Str)) { 		return false; 	} 	theCF2Str = form.Year2.value; 	if (!isPositiveNumber(theCF2Str)) { 		return false; 	} 	theCF3Str = form.Year3.value; 	if (!isPositiveNumber(theCF3Str)) { 		return false; 	} 	theCF4Str = form.Year4.value; 	if (!isPositiveNumber(theCF4Str)) { 		return false; 	} 	theCF5Str = form.Year5.value; 	if (!isPositiveNumber(theCF5Str)) { 		return false; 	} 	theCF0 = parseFloat(theCF0Str); 	theCF1 = parseFloat(theCF1Str); 	theCF2 = parseFloat(theCF2Str); 	theCF3 = parseFloat(theCF3Str); 	theCF4 = parseFloat(theCF4Str); 	theCF5 = parseFloat(theCF5Str); 	var thePayback = 0; 	var theNCF0 = 0; 	var theNCF1 = 0; 	var theNCF2 = 0; 	var theNCF3 = 0; 	var theNCF4 = 0; 	var theNCF5 = 0; 	theNCF0 = theCF0; 	theNCF1 = theNCF0 + theCF1; 	theNCF2 = theNCF1 + theCF2; 	theNCF3 = theNCF2 + theCF3; 	theNCF4 = theNCF3 + theCF4; 	theNCF5 = theNCF4 + theCF5; 	if (theNCF1 >= 0) { 		thePayback = -(theNCF0/theCF1); 	} else if (theNCF2 >= 0) { 		thePayback = 1 - (theNCF1/theCF2); 	} else if (theNCF3 >= 0) { 		thePayback = 2 - (theNCF2/theCF3); 	} else if (theNCF4 >= 0) { 		thePayback = 3 - (theNCF3/theCF4); 	} else if (theNCF5 >= 0) { 		thePayback = 4 - (theNCF4/theCF5); 	} else { 		thePayback = -1; 	} 	if (thePayback > 0) { 		form.PaybackOutput.value = "" + (Math.round(thePayback*100)/100); 	} else { 		form.PaybackOutput.value = "No Payback"; 	}	 	return true; }  function calcPaybackHelp(form) { 	theCF0Str = form.Year0.value; 	if (!isNegativeNumber(theCF0Str)) { 		return false; 	} 	theCF1Str = form.Year1.value; 	if (!isPositiveNumber(theCF1Str)) { 		return false; 	} 	theCF2Str = form.Year2.value; 	if (!isPositiveNumber(theCF2Str)) { 		return false; 	} 	theCF3Str = form.Year3.value; 	if (!isPositiveNumber(theCF3Str)) { 		return false; 	} 	theCF4Str = form.Year4.value; 	if (!isPositiveNumber(theCF4Str)) { 		return false; 	} 	theCF5Str = form.Year5.value; 	if (!isPositiveNumber(theCF5Str)) { 		return false; 	} 	theCF0 = parseFloat(theCF0Str); 	theCF1 = parseFloat(theCF1Str); 	theCF2 = parseFloat(theCF2Str); 	theCF3 = parseFloat(theCF3Str); 	theCF4 = parseFloat(theCF4Str); 	theCF5 = parseFloat(theCF5Str); 	var thePayback = 0; 	var theNCF0 = 0; 	var theNCF1 = 0; 	var theNCF2 = 0; 	var theNCF3 = 0; 	var theNCF4 = 0; 	var theNCF5 = 0; 	theNCF0 = theCF0; 	theNCF1 = theNCF0 + theCF1; 	theNCF2 = theNCF1 + theCF2; 	theNCF3 = theNCF2 + theCF3; 	theNCF4 = theNCF3 + theCF4; 	theNCF5 = theNCF4 + theCF5; 	var theOut2 = "<img src='images/Payback3.gif' alt='' width='286' height='71' border='0'><br>&nbsp;<br>"; 	if (theNCF1 >= 0) { 		thePayback = -(theNCF0/theCF1); 		theOut2 += drawSimpleFraction("Payback = 0 + ",(-theNCF0),theCF1," = " + (Math.round(thePayback*100)/100) + " years"); 	} else if (theNCF2 >= 0) { 		thePayback = 1 - (theNCF1/theCF2); 		theOut2 += drawSimpleFraction("Payback = 1 + ",(-theNCF1),theCF2," = " + (Math.round(thePayback*100)/100) + " years"); 	} else if (theNCF3 >= 0) { 		thePayback = 2 - (theNCF2/theCF3); 		theOut2 += drawSimpleFraction("Payback = 2 + ",(-theNCF2),theCF3," = " + (Math.round(thePayback*100)/100) + " years"); 	} else if (theNCF4 >= 0) { 		thePayback = 3 - (theNCF3/theCF4); 		theOut2 += drawSimpleFraction("Payback = 3 + ",(-theNCF3),theCF4," = " + (Math.round(thePayback*100)/100) + " years"); 	} else if (theNCF5 >= 0) { 		thePayback = 4 - (theNCF4/theCF5); 		theOut2 += drawSimpleFraction("Payback = 4 + ",(-theNCF4),theCF5," = " + (Math.round(thePayback*100)/100) + " years"); 	} else { 		thePayback = -1; 		theOut2 += "There is no Payback"; 	} 	var theOut = "<html><head><title>Payback Help</title></head><body bgcolor='white'>"; 	theOut += "<h3>Payback Help</h3>"; 	theOut += "<table><tr align='center'><td><b>Year</b></td><td><b>Cash Flow</b></td><td><b>Net Cash Flow</b></td></tr>"; 	theOut +="<tr align='center'><td>0</td><td>" + theCF0 + "</td><td>" + theNCF0 + "</td></tr>"; 	theOut +="<tr align='center'><td>1</td><td>" + theCF1 + "</td><td>" + theNCF1 + "</td></tr>"; 	theOut +="<tr align='center'><td>2</td><td>" + theCF2 + "</td><td>" + theNCF2 + "</td></tr>"; 	theOut +="<tr align='center'><td>3</td><td>" + theCF3 + "</td><td>" + theNCF3 + "</td></tr>"; 	theOut +="<tr align='center'><td>4</td><td>" + theCF4 + "</td><td>" + theNCF4 + "</td></tr>"; 	theOut +="<tr align='center'><td>5</td><td>" + theCF5 + "</td><td>" + theNCF5 + "</td></tr></table>"; 	theOut += "<p>" + theOut2 + "</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=400,height=420"); 	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 isNegativeNumber(inputStr) { 	if (inputStr.length < 2) { 		alert("Please input a negative number."); 		return false; 	} 	var oneChar = inputStr.substring(0,1); 	if (oneChar != '-') { 		alert("Please make sure that only negative 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; }  function drawSimpleFraction(inLeft,inNum,inDen,inRight) {	var theOut = "<table cellspacing='1' cellpadding='1'>";	theOut += "<tr><td valign='center' align='right' rowspan='3'>" + inLeft + "</td>";	theOut += "<td valign='center' align='center'>" + inNum + "</td>";	theOut += "<td valign='center' align='left' rowspan='3'>" + inRight + "</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;}
