function CalcLTT(form,i1,i2,ptax,condo,heat,down,l1,l2,l3,l4,l5,l6,mtge)
{
var v5year = 1 + form.iCalcRate.value / 200
var rate = -1 + Math.pow((v5year*v5year),(1/12))
var mtg = 0
var ratio = 0
var dwn = parseInt(down)
var tx = parseInt(ptax)
var cdo = parseInt(condo)
var ht = parseInt(heat)
var gds = ( (parseInt(i1) + parseInt(i2))*.3225 - parseInt(tx) - parseInt(ht) - parseInt(cdo)*6 ) / 12
var tds = ((parseInt(i1) + parseInt(i2))*.4025-parseInt(tx)-parseInt(ht)-parseInt(cdo)*6-parseInt(l1)*12-parseInt(l2)*12-parseInt(l3)*12-parseInt(l4)*12-parseInt(l5)*12-parseInt(l6)*12)/12

if (gds < tds) 
	{
	mtg = gds / (rate/(1-(1/Math.pow((1+rate),300))))
	}
else 
 	{
	mtg = tds / (rate/(1-(1/Math.pow((1+rate),300))))
    	}

ratio = mtg / (mtg + dwn)

if 	(mtg < 0)
	{
	WriteLayer('MA',null,dwn)
	}
else
	{
	if      (ratio > .95)
		{
		WriteLayer('MA',null,Math.round(dwn / .05))
		}
	else if (ratio > .90)
		{
		WriteLayer('MA',null,Math.round((mtg - mtg * 0.0375 + dwn)))
		}
	else if (ratio > .85)
		{
		WriteLayer('MA',null,Math.round((mtg - mtg * 0.025 + dwn)))
		}
	else if (ratio > .80)
		{
		WriteLayer('MA',null,Math.round((mtg - mtg * 0.02 + dwn)))
		}
	else if (ratio > .75)
		{
		WriteLayer('MA',null,Math.round((mtg - mtg * 0.0125 + dwn)))
		}
	else
		{
		WriteLayer('MA',null,Math.round((mtg + dwn)))
	        }
	}
}
function cleanUp(vText,vVal){
		//if(isNaN(vText.value))vText.value=vVal;
		vText.value=replace(vText.value,' ','');
		vText.value=replace(vText.value,'$','');
		vText.value=replace(vText.value,',','');
		if(vText.value=="")vText.value=vVal;
		vText.value = parseInt(vText.value);
		if(isNaN(vText.value))vText.value=vVal;

}