var search_sqrfootage=0;
var search_location=0;
var search_zoning='commercial';
var search_tab=0;

function tabselect(tab)
{
	$("#tabcontainer .right_tabs").each(function(i){
		$(this).css("visibility","hidden");
	});
	$("#"+tab+" img").css("visibility","visible");

	search_zoning = tab; //set the zone
	search_tab=1;
	get_list();
	search_tab=0;

	return false;
}


function get_list()
{
	search_sqrfootage =$('#sqarefootage').val();
	search_sqrfootage = document.getElementById('sqarefootage')['value'];
	search_location = document.getElementById('location')['value'];

	$.ajax({
		type: "GET",
		url: "availablesearch.php",
		data: "sqrft="+search_sqrfootage+"&loc="+search_location+"&zone="+search_zoning+"&asearch="+search_tab,
		success: function(msg){

				//record the tab location at the front of the html if it is there.

				if(msg.indexOf("~") > 1)
					{
					//display_msg has the text
					var display_msg=msg.substr(msg.indexOf("~")+1);
					//display_msg has the tab
					var display_tab=msg.substring(0,msg.indexOf("~"));

						$("#tabcontainer .right_tabs").each(function(i){
						$(this).css("visibility","hidden");
						});
					$("#"+display_tab+" img").css("visibility","visible");

					search_zoning = display_tab; //set the zone

					}
					else
					{
					display_msg = msg;
					}

				$('#resultcontainer').hide();
				$('#resultcontainer').empty();
				$('#resultcontainer').append(display_msg);
				$('#resultcontainer').show("slow");
				}
			});

}

