function changecolor(row) {
	 elem = document.getElementById(row);
 	elem.style.backgroundColor = "#cccccc";
	}
	function changecolorout(row) {
	 elem = document.getElementById(row);
 	elem.style.backgroundColor = "transparent";
	}
function stripChar(item) {
item = item.replace(",","");
item = item.replace("$","");
return item;
}

function createGrid() {
var priceoff=0;
	if (document.calculator.trade.value != "") {
	 valueoff = stripChar(document.calculator.trade.value);
	  priceoff=parseInt(valueoff);
	}
	if (document.calculator.down.value != "") {
	 downoff = stripChar(document.calculator.down.value);
	  priceoff= priceoff + parseInt(downoff);
	}
	price=stripChar(document.calculator.price.value);
	price=parseInt(price);
var total = (price - priceoff);
var grid = "";
//alert(price + " " + priceoff);
	if (total>30000) { //use a smaler font
grid = "<TABLE border=0 class=calculatortable2>";
	} else {
	grid = "<TABLE border=0 class=calculatortable>";
	}
grid += "<TR><TD>&nbsp;</TD><TD align=center><strong># of months</strong></TD></TR><TR><TD><strong>A.P.R.</strong></TD><TD><table border=1 cellpadding=6 cellspacing=0><TR class='calculatorhead'><TD align=center >&nbsp;</TD>"; 
     	var monthsarray = new Array(36, 48, 54, 60, 72);
		var interestarray = new Array(1.9, 3.9, 5.9, 7.9, 9.9, 12.9, 15.9, 18.9);
		for (var i=0; i<=4; i++)
		{
		grid += "<TD align=center><B>" + monthsarray[i]+ "</B></TD>";
		}
		grid += "</TR><!--TR id=first onmouseover=changecolor('first'); onmouseout=changecolorout('first');><TD align=center><B>0%</B></TD>"; 
		for (var i=0; i<=4; i++)
{ 
        payment = (total/monthsarray[i]); 

		grid += "<TD align=center>$"+ Math.round(payment) + "</TD>"; 
}
		grid += "</TR-->";
				
		for (p=0; p<=7; p++) 
		{
		grid += "<TR id="+ interestarray[p]+ " onmouseover=changecolor('"+ interestarray[p]+"'); onmouseout=changecolorout('"+ interestarray[p]+"');><TD align=center><B>" + interestarray[p] + "%</B></TD>";	
		for (i=0; i<=4; i++)
{		
        something = Math.pow((1+(interestarray[p]/ 1200)),(monthsarray[i])); 
        payment = ((total * something)*(interestarray[p]/1200)/(something - 1))  ; 

        grid += "<TD align=center>$"+  Math.round(payment) + "</TD>"; 
		}
		
		grid += "</TR>";
		}
		grid += "</TABLE></TD></TR><TR><TD colspan=2><br><b>These calculations are estimates only. <br> Please contact dealer for actual payment information.</b></TD></TR></TABLE>";
			document.getElementById('calcdisplay').innerHTML=grid;
    } 