
function TestValues(fLoanAmt,fPropValue, fLowLoan) {

    if (fLoanAmt < fLowLoan) { 
        alert('Loans must be at least ' + toUSCurrency(fLowLoan) + '. If you require a loan less than that, please contact customer service at 1 (888) 766-1410');
        return false;
    }
        
    fLTV = fLoanAmt / fPropValue;
	var sMessage = "The amount you want to finance is too high for the estimated value of the property (making your Loan To Value or LTV too high). Please call one of our Loan Counselors for optional pricing/programs";

    if (fLoanAmt > 2000000) {
           alert('The amount you want to finance is too high (maximum $2,000,000). Please call one of our Loan Counselors for a rate quote.');
            return false;
 	}
	
	if (fLoanAmt < fLowLoan) {
           alert('The amount you want to finance is too low (minimum ' + toUSCurrency(fLowLoan) + ').');
            return false;
 	}
	
    /*if (fLoanAmt > 1000000 && fLTV > 0.60) {
           alert(sMessage);
            return false;
    
    }else if (fLoanAmt > 750000 && fLTV > 0.70) {
           alert(sMessage);
            return false;  
             
    }else if (fLoanAmt > 650000 && fLTV > 0.75) {
           alert(sMessage);
            return false;  

    }else if (fLoanAmt > 500000 && fLTV > 0.80) {
           alert(sMessage);
            return false;  

    }else if (fLoanAmt > 400000 && fLTV > 0.85) {
           alert(sMessage);
            return false;  
            
    }else if (fLoanAmt > 350000 && fLTV > 0.90) {
           alert(sMessage);
            return false;  
	} else {*/
	
    //if (fLTV > 0.95) {
    //    alert(sMessage);
    //    return false;
    //}
    
    //};
    return true;
}


function toUSCurrency (input)
{
	// Make sure input is a string:
	input += "";

	// Keep original copy of input string:
	var original_input = input;

	// Strip leading dollar sign if necessary:
	if (input . charAt (0) == "$")
		input = input . substring (1, input . length);
	else if
	(
		input . substring (0, 2) == "-$"
	||	input . substring (0, 2) == "+$"
	)
		input = input . charAt (0) + input . substring (2, input . length);

	// Get float value:
	var amount = parseFloat (input);

	// Return unmodified input if we weren't able to convert it:
	if (isNaN (amount))
		return original_input;


	// Express amount in pennies, rounded to the nearest penny:
	amount = Math . round (100 * amount);

	// Prepare to add a US currency prefix:
	var prefix = "$";
	if (amount < 0)
	{
		prefix = "-" + prefix;
		amount = - amount;
	}

	// Convert amount to string and pad with leading zeros if necessary:
	var string;
	if (amount < 10)
		string = "00" + amount;
	else if (amount < 100)
		string = "0" + amount;
	else
		string = "" + amount;

	// Insert prefix:
	string = prefix + string;

	// Insert decimal point before last two digits:
	string =
		string . substring (0, string . length - 2) +
		"." +
		string . substring (string . length - 2, string . length);

	// Return formatted currency string:
	return string;
}

