<!--


<!-- Create Popup on Body Load Functions -->

closetime = 10; // Close window after __ number of seconds?// 0 = do not close, anything else = number of seconds

function Start(URL, WIDTH, HEIGHT) {
windowprops = "left=50,top=50,width=" + WIDTH + ",height=" + HEIGHT;
preview = window.open(URL, "preview", windowprops);
if (closetime) setTimeout("preview.close();", closetime*1000);
}

function doPopup(URL, WIDTH, HEIGHT) {
url = URL; //url of page
width = WIDTH;  // width of window in pixels
height = HEIGHT; // height of window in pixels
delay = 0;    // time in seconds before popup opens
timer = setTimeout("Start(url, width, height)", delay*1000);
}





/* PAYMENT CALCULATOR FUNCTIONS */

// Define the fIsNumber function
// Allows only numbers to be input
// Called by a text input onkeypress event
function fIsNumber(evt){
	
	// Initialize variables
	var iKeyNum;
	var sKeyChar;
	var iNumCheck;
	
	// IE
	if(window.event){
		iKeyNum = evt.keyCode;
	// Netscape/Firefox/Opera
	}else if(evt.which){
		iKeyNum = evt.which;
	}
	// Get the character that was pressed
	sKeyChar = String.fromCharCode(iKeyNum);
	// Define the valid characters, "\d" means single digits
	iNumCheck = /\d/;
	// Test if the sKeyChar is a Number
	return iNumCheck.test(sKeyChar);
}

// Define the fEstimatePayment function
// Called by changing certain text fields, or by clicking the Recalculate button
function fEstimatePayment(){

	// Define the minimum and maximum terms to be displayed
	var iMinTerm = 24;
	var iMaxTerm = 72;
	var iTerm;
	
	// Define the minimum and maximum percentages to be displayed
	var iMinPercent = 2;
	var iMaxPercent = 14;
	var iPercent;
	
	// Get a reference to the formPayment object
	var x = document.getElementById("formPayment");
	
	// Calculate the principal
	x.elements["fieldPrincipal"].value = x.elements["fieldPrice"].value - x.elements["fieldCash"].value;
	
	// For every term (row)
	for(var i = iMinTerm; i <= iMaxTerm; i+=12){
		// Reset iPercent to the minium percent
		iPercent = iMinPercent;
		// Set iTerm (increments by 12 months everytime)
		iTerm = i;
		// For every percentage (column)
		for(var j = iMinPercent; j <= iMaxPercent; j++){
			// Calculate the field's value
			x.elements["field" + iTerm + "_" + iPercent].value = fCalculateField(x, iTerm, iPercent);
			// Increase the percent
			iPercent++;
		}
	}
}

// Define the fCalculateField function
// Calculates an individual field, based on the term and percentage rates
// Called by fEstimatePayment function
function fCalculateField(x, iTerm, iPercent){
	// Numerator = Principal * (Interest Rate)
	// Denomenator = 1 - (Math.pow((1 + Interest Rate), (0 - Term)))
	iNumerator = x.elements["fieldPrincipal"].value * ((iPercent/100)/12);
	iDenomenator = 1 - (Math.pow((1 + ((iPercent/100)/12)), (0 - iTerm)));
	return Math.round(iNumerator / iDenomenator);
}




<!-- LOADING GRAPHIC -->
function loadingMessage() {
if (document.getElementById) {  // DOM3 = IE5, NS6
document.getElementById('hidepage').style.visibility = 'hidden';
}
else {
if (document.layers) {  // Netscape 4
document.hidepage.visibility = 'hidden';
}
else {  // IE 4
document.all.hidepage.style.visibility = 'hidden';
      }
   }
}

<!-- OPEN CHEAT SHEET -->
function Cheatsheet(){
	url="cheatsheet.php";
	attributes="width=850,height=800,resizable,scrollbars";
	openit=window.open(url,'cheatsheet',attributes);
	openit.focus();
}




// -->



