$(document).ready(function() {
	$('#quick_search label').each(function() {
		id = $(this).attr('for');
		text = $(this).html();
		$('#' + id).defaultvalue(text);
		$(this).hide();
	});
	
	$("#main_nav").superfish().find('ul').bgIframe(); 
	
	payment_range();
});

//Payment Range Function
function payment_range() {
	$('#payment_range_form .calculate').click(function() {
		//Set the estimate variabled
		payment_low = $('#payment_range_form #payment_low').val();
		payment_high = $('#payment_range_form #payment_high').val();
		down_payment = $('#payment_range_form #down_payment').val();
		loan_program = $('#payment_range_form #loan_program').val();
		
		if(payment_low == '' || payment_high == '' || down_payment == '' || loan_program == '') {
			alert('Please fill-in all fields to get an accurate estimate');
		} else {
			//Do your calculations. For now I just repeat the payment entries
			 $('#payment_range_form #payment_low_est').val(payment_low);
			 $('#payment_range_form #payment_high_est').val(payment_high);
		}
		return false;
	});
	
	$('#payment_range_form .clear').click(function() {
		//Clear the estimate form. This is done manually rather
		//than simply with the type="reset" button because that
		//would clear out the entire form. No thank you
		$('#payment_range_form #payment_low').val('');
		$('#payment_range_form #payment_high').val('');
		$('#payment_range_form #down_payment').val('');
		$('#payment_range_form #loan_program').val('');
		$('#payment_range_form #payment_low_est').val('');
		$('#payment_range_form #payment_high_est').val('');
		
		return false;
	});
}

//**************************************************************************************************
// Check if this is a single property request
//**************************************************************************************************
function checkURL()
{
	if (window.location.href.indexOf('#MLSNum')!=-1)
	{
		var url = window.location.href.split('#MLSNum=');
		MLSNum = url[1];
	}
}
