// JavaScript Document
function change_state()
{
	if(document.search_box.state_sg.value != '')
		window.location.href = 'http://www.foreclosurewarehouse.com/listings.php?state_sg='+document.search_box.state_sg.value;
	else
		window.location.href = 'http://www.foreclosurewarehouse.com/listings.php';
}

function change_county()
{
	if(document.search_box.county_name.value != '')
		window.location.href = 'http://www.foreclosurewarehouse.com/lview.php?state_sg='+document.search_box.state_sg.value+'&county_name='+document.search_box.county_name.value;
	else
		window.location.href = 'http://www.foreclosurewarehouse.com/lview.php?state_sg='+document.search_box.state_sg.value;
}

function change_city()
{
	if(document.search_box.city.value != '')
		window.location.href = 'http://www.foreclosurewarehouse.com/lview.php?state_sg='+document.search_box.state_sg.value+'&county_name='+document.search_box.county_name.value+'&city='+document.search_box.city.value;
	else
		window.location.href = 'http://www.foreclosurewarehouse.com/lview.php?state_sg='+document.search_box.state_sg.value+'&county_name='+document.search_box.county_name.value;
}

function change_zipcode()
{
	var pagina;
	if(document.search_box.zipcode.value != '')
	{
		pagina = 'http://www.foreclosurewarehouse.com/lview.php?zipcode='+document.search_box.zipcode.value;
	}
	else
	{
		if(document.search_box.state_sg.value != '')
		{
			pagina = 'http://www.foreclosurewarehouse.com/lview.php?state_sg='+document.search_box.state_sg.value;
			if(document.search_box.county_name.value != '')
			{
				pagina += '&county_name='+document.search_box.county_name.value;
				if(document.search_box.city.value != '')
				{
					pagina += '&city='+document.search_box.city.value;
				}
			}
		}
	}
	window.location.href = pagina;
}

function limit_search(county_name, city, state_sg, property_type, zipcode, miles)
{
	var url, x, i;
	url = '?state_sg='+state_sg+'&county_name='+county_name+'&city='+city+'&property_type='+property_type+'&zipcode='+zipcode+'&miles='+miles;
	if(document.limit_box.min_price.value != 0 || document.limit_box.max_price.value != -1)
		url += '&min_price='+document.limit_box.min_price.value+'&max_price='+document.limit_box.max_price.value;
	if(document.limit_box.beds.value != '')
		url += '&beds='+document.limit_box.beds.value;
	if(document.limit_box.baths.value != '')
		url += '&baths='+document.limit_box.baths.value;
	
	x = document.getElementsByName('property_style[]');
	for(i=0; i<x.length; i++)
		if(x[i].checked == true)
			url += '&property_style[]='+x[i].value;
	
	document.location = url;
}

function order(county_name, city, state_sg, property_type, zipcode, miles, ini, regs_per_page, min_price, max_price, beds, baths)
{
	var x, i, url;
	
	url = '';
	x = document.getElementsByName('property_style[]');
	for(i=0; i<x.length; i++)
		if(x[i].checked == true)
			url += '&property_style[]='+x[i].value;
		
	if(document.order_by.ordem.value == '')
		document.order_by.ordem.value = 'asc';
	if(document.order_by.item.value != '')
		window.location.href = '?county_name='+county_name+'&city='+city+'&state_sg='+state_sg+'&property_type='+property_type+'&zipcode='+zipcode+'&miles='+miles+'&order_by='+document.order_by.item.value+' '+document.order_by.ordem.value+'&ini='+ini+'&regs_per_page='+regs_per_page+'&min_price='+min_price+'&max_price='+max_price+'&beds='+beds+'&baths='+baths+url;
	else
		window.location.href = '?county_name='+county_name+'&city='+city+'&state_sg='+state_sg+'&property_type='+property_type+'&zipcode='+zipcode+'&miles='+miles+'&ini='+ini+'&regs_per_page='+regs_per_page+'&min_price='+min_price+'&max_price='+max_price+'&beds='+beds+'&baths='+baths+url;
}

function change_zipcode2()
{
	if(document.search_box.zipcode.value != '')
	{
		window.location.href = '?zipcode='+document.search_box.zipcode.value;
	}
	
}