function showOverview()
{
	$("#overview_area").show();
	$("#accounting_area").hide();
	$("#payments_area").hide();
	$("#forms_area").hide();
}
function showAccounting()
{
	$("#overview_area").hide();
	$("#accounting_area").show();
	$("#payments_area").hide();
	$("#forms_area").hide();
}
function showPayments()
{
	$("#overview_area").hide();
	$("#accounting_area").hide();
	$("#payments_area").show();
	$("#forms_area").hide();
}
function showForms()
{
	$("#overview_area").hide();
	$("#accounting_area").hide();
	$("#payments_area").hide();
	$("#forms_area").show();
}

function quickSearch()
{
	$.post(BASE_URL + "?act=property&go=quickSearchProperty",{ search:$("#search_params").val() },function(data) {
		$("#auto_search").show();
		$("#search_content").html(data);
	});
}

function startSearch()
{
	var searchParams = $("#search_field").val();
	//alert(searchParams);
	
	if (searchParams != '')
	{
		// start the search
		$("#auto_search").show();
		$("#search_loading").show();
		$.post(BASE_URL + "?go=property&act=quickSearchProperty&ajax=1",{searchParams:searchParams},
			function(data){
				$("#search_content").html(data);
				$("#search_loading").hide();
			}
		);
	}
	else
	{
		closeSearch();
	}
}

function closeSearch()
{
	$("#auto_search").hide();
	$("#search_loading").hide();
}

function checkABA(s) {

  var i, n, t;
 
  // First, remove any non-numeric characters.
 
  t = "";
  for (i = 0; i < s.length; i++) {
	c = parseInt(s.charAt(i), 10);
	if (c >= 0 && c <= 9)
	  t = t + c;
  }
 
  // Check the length, it should be nine digits.
 
  if (t.length != 9)
	return false;
 
  // Now run through each digit and calculate the total.
 
  n = 0;
  for (i = 0; i < t.length; i += 3) {
	n += parseInt(t.charAt(i),     10) * 3
	  +  parseInt(t.charAt(i + 1), 10) * 7
	  +  parseInt(t.charAt(i + 2), 10);
  }
 
  // If the resulting sum is an even multiple of ten (but not zero),
  // the aba routing number is good.
 
  if (n != 0 && n % 10 == 0)
	return true;
  else
	return false;
}

function validateForm(form)
{
	//alert(form + ' > .validate');
	var error = 'success';
	$(form).find('.validate').each(function (i) {
		if ($(this).hasClass('required'))
		{
			if ($(this).val() == '')
			{
				//alert("Error: " + $(this).attr("fieldName") + " is required.");
				error = $(this).attr("fieldName") + " is required.";
				return;
			}
		}
		if ($(this).hasClass('routing'))
		{
			if (!checkABA($(this).val()))
			{
				error =  'Invalid routing number';
				return;
			}
		}
	});
	
	return error;
}

$(document).ready(function(){
	$("#inner_content").css("height",$(document).height()-$("#banner").height());
	
	$(".defaultText").focus(function(srcc)
	{
		if ($(this).val() == $(this)[0].title)
		{
			$(this).removeClass("defaultTextActive");
			$(this).val("");
		}
	});
	
	$(".defaultText").blur(function()
	{
		if ($(this).val() == "")
		{
			$(this).addClass("defaultTextActive");
			$(this).val($(this)[0].title);
		}
	});
	
	$(".defaultText").blur();
});
