function aximHowMuchToolCreate(fx_page, fx_params, fx_submit) {
        var var_postdata = '';
    if (fx_submit==true) {
        var_postdata = ajaxGetFormVars(document.getElementById('frmcxaPaymentCal'));
    }
    }

function aximHowMuchToolsPage() {
	ajaxGetData('/axiomfinancial/pages/calculators/how-much-cal/ajax_calculate.cxp?p=s&', "", 'cnxDisplayBox','cnxDisplayBox', 1)

}

function aximHowMuchShow() {
    var var_postdata = ajaxGetFormVars(document.getElementById('frmcxaPaymentCal'));
    ajaxGetData('/axiomfinancial/pages/calculators/how-much-cal/ajax_validate_calculate.cxp?p=s', var_postdata, 'PaymentResults','PaymentResults', 1)
}


function paymentHowMuchCalculate(fx_gross, fx_down, fx_debt, fx_rate, fx_years, fx_propertytax, fx_insurance){

    var loan_life = fx_years;			// years to pay off the loan
    var var_Frequency = 12;			// how many payments a year
    var avg_tax_rate = 0.015;	// the average yearly % for property tax
    var min_PTI = 0.009333333 * loan_life;         // min payment to income
    var max_PTI = 0.011 * loan_life;     // max payment to income
    var min_DTI = 0.012 * loan_life;      // min debt to income
    var max_DTI = 0.012666666 * loan_life;       // max debt to income
    var var_Periods = loan_life * var_Frequency;	// the number of periods (and payments) in the loan
    var var_IntRate = fx_rate;  // interest rate
    var var_MonthlyIncome = fx_gross / var_Frequency;
    var var_MonthlyDebt = fx_debt;
    var var_DownPayment = fx_down;
    var var_PeriodRate = var_IntRate/(var_Frequency * 100);
    var var_TaxInsur = (fx_propertytax + fx_insurance)/12;


    var var_TotalLow = var_MonthlyIncome * min_PTI;
	temp = (var_MonthlyIncome * min_DTI) - var_MonthlyDebt;
	if ( temp < var_TotalLow ) {
		var_TotalLow = temp;
	} 
	var MinPayment = var_TotalLow - var_TaxInsur;
	var var_PrincDenLow = ( Math.pow( 1 + var_PeriodRate, var_Periods ) - 1 ) / ( var_PeriodRate *  Math.pow( 1 + var_PeriodRate, var_Periods ) );
	var var_LoanAmountLow = MinPayment * var_PrincDenLow;
	var var_HousePriceLow = var_LoanAmountLow + var_DownPayment;
	var var_MonthPaymentLow = var_TotalLow - var_TaxInsur
	
	
	var var_TotalHigh = var_MonthlyIncome * max_PTI;
	temp = (var_MonthlyIncome * max_DTI) - var_MonthlyDebt;
	if ( temp < var_TotalHigh ) {
		var_TotalHigh = temp;
	} 
	var MinPayment = var_TotalHigh - var_TaxInsur;
	var var_PrincDenHigh = ( Math.pow( 1 + var_PeriodRate, var_Periods ) - 1 ) / ( var_PeriodRate *  Math.pow( 1 + var_PeriodRate, var_Periods ) );
	var var_LoanAmountHigh = MinPayment * var_PrincDenHigh;
	var var_HousePriceHigh = var_LoanAmountHigh + var_DownPayment;
    var var_MonthPaymentHigh = var_TotalHigh - var_TaxInsur
	

    if (var_IntRate == 0){
	    document.getElementById('Fld_Rates').style.backgroundColor="FEDEDE";
    }
    if (fx_gross == 0){
	    document.getElementById('Fld_Gross').style.backgroundColor="FEDEDE";
    }
   
    document.getElementById('Fld_HousePriceLow').value = var_HousePriceLow.toFixed(2);
    document.getElementById('Fld_LoanAmountLow').value = var_LoanAmountLow.toFixed(2);
    document.getElementById('Fld_MonthPaymentLow').value = var_MonthPaymentLow.toFixed(2);
    document.getElementById('Fld_TaxInsuranceLow').value = var_TaxInsur.toFixed(2);
    document.getElementById('Fld_TotalLow').value = var_TotalLow.toFixed(2);

    document.getElementById('Fld_HousePriceHigh').value = var_HousePriceHigh.toFixed(2);
    document.getElementById('Fld_LoanAmountHigh').value = var_LoanAmountHigh.toFixed(2);
    document.getElementById('Fld_MonthPaymentHigh').value = var_MonthPaymentHigh.toFixed(2);
    document.getElementById('Fld_TaxInsuranceHigh').value = var_TaxInsur.toFixed(2);
    document.getElementById('Fld_TotalHigh').value = var_TotalHigh.toFixed(2);

}


xpsJSPage = 'ran';



