SuburbIndex = new Object();

function checkSearchForm()
{
	var suburb = $('Suburb').value;
	var suburbs = $('Suburbs').value;
	if (suburb.length <1 && suburbs.length<1)
	{
		alert("Either enter a street address, suburb, state, postcode or a suburb");
		return false;
	}
	return true;
}

function addOption(id,v,k)
{
	$(id).options[$(id).options.length] = new Option(k,v);
}

function SetPriceOptions(id, rent)
{
	$(id).innerHTML = "";
	addOption(id, 1, 'Any');
	if (rent)
	{
		for (c=1; c<10;c++)
			addOption($(id),c*100,'$'+c*100);
		for (c=5; c<9;c++)
			addOption(id,c*200,'$'+c*200);
		addOption(id,2000,'$2000');
		return;
	}

	for (i=50; i<=950; i+=50)
		addOption(id,i*1000,'$'+i+',000');
	for (i=1; i<=5; i++)
		addOption(id,i*1000000,'$'+i+' mil');
}


function selectSearchType(type)
{
	type = type.toLowerCase();

	var priceFrom = $('PriceLeft');
	var priceTo = $('PriceRight');
	var surroundingSuburbs = $('SurroundingSuburbs');
	priceFrom.options.length = 0;
	priceTo.options.length = 0;
	if(type=='for_rent')
	{
		surroundingSuburbs.checked= true;
		$('listing_pin_agent_rent').className = 'rounded_box darkgrey_on_white';
		$('listing_pin_rented').className = 'rounded_box darkgrey_on_white';
		$('listing_pin_agent').className = 'rounded_box grey_on_white';
		$('listing_pin_sold').className = 'rounded_box grey_on_white';
		$('HomePageSearchForm').action = '/rent/results/map';

		SetPriceOptions('PriceLeft', true);
		SetPriceOptions('PriceRight', true);
	}
	else
	{
		surroundingSuburbs.checked= false;
		$('listing_pin_agent_rent').className = 'rounded_box grey_on_white';
		$('listing_pin_rented').className = 'rounded_box grey_on_white';
		$('listing_pin_agent').className = 'rounded_box darkgrey_on_white';
		$('listing_pin_sold').className = 'rounded_box darkgrey_on_white';
		$('HomePageSearchForm').action = '/buy/results/map';
		SetPriceOptions('PriceLeft', false);
		SetPriceOptions('PriceRight', false);
	}
	priceFrom.options[0].selected = true;
	priceTo.options[priceTo.options.length-1].selected=true;
}

function LoadFlashMap(State)
{
	new Ajax.Updater('flashmap', '/index.htm?Action=flash&BrowseState='+State, {evalScripts: true});
}

function CreateSuburbFilter( Input, Select ) {}
