function make_inquiry() {
	$("#mortgage_calculator").slideUp("slow");
	$("#make_inquiry").slideDown("slow");
   	document.getElementById('mortgage_calculator').style.display = 'none';
	document.getElementById('make_inquiry').style.display = 'block';
}

function mortgage_calculator() {
	$("#make_inquiry").slideUp("slow");
	$("#mortgage_calculator").slideDown("slow");
   	document.getElementById('mortgage_calculator').style.display = 'block';
	document.getElementById('make_inquiry').style.display = 'none';
}


//Mortgage Calculator Functions
function testmgtform() {
	if (document.mortgage.homevalue.value == 0 || document.mortgage.homevalue.length == 0) {
		alert ("The Price field can't be 0!");
	}
	else if (document.mortgage.interest.value == 0 || document.mortgage.interest.length == 0) {
		alert ("The Interest Rate field can't be 0!");
	}
    else if (document.mortgage.term.value == 0 || document.mortgage.term.length == 0) {
		alert ("The Term field can't be 0!");
	}
	else
		calculatePayment();
}

function calculatePayment() {
	princ = document.mortgage.homevalue.value - document.mortgage.downpayment.value;
    intRate = (document.mortgage.interest.value/100) / 12;
    months = document.mortgage.term.value * 12;
    payments = Math.floor((princ*intRate)/(1-Math.pow(1+intRate,(-1*months)))*100)/100;
  	
	$("#mgt_payments").replaceWith('<h5 id="mgt_payments">Payments: ' + formatCurrency(payments) + '</h5>');
}

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));

	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function disabled() {
	alert("This function has been disabled because this is a sample site.");	
}

