/* CALCULATES VALUES DISPLAYED WHEN COMPUTE IS CLICKED. FIRST CHECKS THAT THERE ARE VALUES IN ALL OF THE FIELDS. THE RESULTS ARE SENT TO THE TEXT BOXES - MAXIMUM MORTGAGE AND MONTHLY PAYMENT */



function calcMax(){



if((document.maxcalc.totinc.value == null || document.maxcalc.totinc.value.length == 0)|| (document.maxcalc.totinc.value < 10000 || document.maxcalc.totinc.value > 1000000)){

fixpro('Annual Family Income\n','Please enter a number between 10000 and 1000000.');return;}





if((document.maxcalc.protax.value == null || document.maxcalc.protax.value.length == 0)|| (document.maxcalc.protax.value < 100 || document.maxcalc.protax.value > 50000)){

fixpro('Annual Property Taxes\n','Please enter a number between 100 and 50000.');return;}



if((document.maxcalc.proheat.value == null || document.maxcalc.proheat.value.length == 0)|| (document.maxcalc.proheat.value < 20 || document.maxcalc.proheat.value > 1500)){

fixpro('Monthly Heating Costs/Condo Fees\n','Please enter a number between 20 and 1500.');return;}



if((document.maxcalc.debt.value == null || document.maxcalc.debt.value.length == 0)|| (document.maxcalc.debt.value < 0 || document.maxcalc.debt.value > 5000)){

fixpro('Monthly Payments for Loans/Credit Cards\n','Please enter a number between 0 and 5000.');return;}



if((document.maxcalc.second.value == null || document.maxcalc.second.value.length == 0)|| (document.maxcalc.second.value < 0 || document.maxcalc.second.value > 5000)){

fixpro('Secondary Financing Payment\n','Please enter a number between 0 and 5000.');return;}



if((document.maxcalc.rate.value == null || document.maxcalc.rate.value.length == 0)|| (document.maxcalc.rate.value < 2 || document.maxcalc.rate.value > 15)){

fixpro('Interest Rate\n','Please enter a number between 2 and 15.');return;}





var RATE = document.maxcalc.rate.value/100;

var income = document.maxcalc.totinc.value;

var tax = document.maxcalc.protax.value;

var heat = document.maxcalc.proheat.value*12;

var debt = document.maxcalc.debt.value*12;

var second = document.maxcalc.second.value*12;

var compound = 2/12;

var monTime = 35 * 12;

var yrRate = RATE/2;

var rdefine    = Math.pow((1.0 + yrRate),compound)-1.0;

var purchcompound = Math.pow((1.0 + rdefine),monTime);





var maxgdsr =.32;

var maxtdsr =.40;





var GDSPAY = (maxgdsr*income) - tax - heat - second;

var TDSPAY = (maxtdsr*income) - tax - heat - second - debt;



var PAYMENT = (GDSPAY<TDSPAY) ? GDSPAY/12 : TDSPAY/12;

var MORTGAGE = (0 +((PAYMENT*(purchcompound-1.0))/rdefine))/purchcompound;





document.maxcalc.amt.value = '$'+roundPen(MORTGAGE);

document.maxcalc.pay.value = '$'+roundPen(PAYMENT);

return;

}





/* OPENS POP UP WINDOW TO DISPLAY HELP MESSAGES IN NETSCAPE 3.0 AND 4.0 */



/*

function winopen(name)

{

var linkit = "help/"+name;

if(versTest() == true || nineTest()==true){	

maxMo=window.open(linkit,'helpscreen','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=250,height=180,outerWidth=300,outerHeight=230');

if(navigator.appName.substring(0,8) == "Netscape")

{maxMo.focus();}

}



else{location.href=linkit;}



}

*/



/*

maxtitle = new StringArray(9);

maxtitle['A'] = 'Total Annual Income';

maxtitle['B'] = 'Annual Property Taxes';

maxtitle['C'] = 'Monthly Heating Costs';

maxtitle['D'] = 'Other Monthly Debt Payments';

maxtitle['E'] = 'Mortgage Term';

maxtitle['F'] = 'Interest Rate';

maxtitle['G'] = 'Special Circumstances';

maxtitle['H'] = 'Second Mortgage Payments';

maxtitle['I'] = 'Maintenance Fees';

*/



/*

function makeImg()

{

if(browTest()==true){

Img = new Image();

Img.src = "images/back_on.gif"; 

document.images.Back_button.src=Img.src;

}

else{}

} 



function clearImg()

{

if(browTest()==true){

OrImg= new Image();

OrImg.src="images/back_off.gif";

document.images.Back_button.src=OrImg.src;

}

else{}

}



function loadImg()

{

if(browTest()==true){

Img = new Image();

Img.src = "images/back_on.gif"

}

else{}

}

*/

