var defaultOptions = new Array("$50,000",50000,"$100,000",100000,
"$150,000",150000,"$200,000",200000,"$300,000",300000,"$500,000",500000,"$750,000",750000,"$1,000,000",1000000);
var rentalOptions = new Array("$250",250,"$500",500,"$750",750,"$1,000",1000,"$1,500",1500,"$2,000",2000,"$2,500",2500,"$3,000",3000);
var seasonalOptions = new Array("$5,000",5000,"$10,000",10000,
"$15,000",15000,"$20,000",20000,"$25,000",25000,"$30,000",30000,"$40,000",40000,"$50,000",50000);

// don't let the min price be greater than the max price
function SetMinPrice()
{
	// get the min and max prices
	var min_price = parseInt(document.forms["search"].min_price.options[document.forms["search"].min_price.selectedIndex].value);
	var max_price = parseInt(document.forms["search"].max_price.options[document.forms["search"].max_price.selectedIndex].value);
	
	// adjust the max price if the min price is higher
	if(document.forms["search"].max_price.options[document.forms["search"].max_price.selectedIndex].text != "None")
		if(min_price >= max_price)
			document.forms["search"].max_price.selectedIndex = document.forms["search"].min_price.selectedIndex;
}

// don't let the min price be greater than the max price
function SetMaxPrice()
{
	// get the min and max prices
	var min_price = parseInt(document.forms["search"].min_price.options[document.forms["search"].min_price.selectedIndex].value);
	var max_price = parseInt(document.forms["search"].max_price.options[document.forms["search"].max_price.selectedIndex].value);
	
	// adjust the max price if the min price is higher
	if(document.forms["search"].max_price.options[document.forms["search"].max_price.selectedIndex].text != "None")
		if(min_price >= max_price)
			document.forms["search"].min_price.selectedIndex = document.forms["search"].max_price.selectedIndex;
}

// set the options of the min and max price drown down menus
function SetPriceOptions()
{
	// declare variables
	var optionsArray,listing_type;

	// save the selected indexes
	var selectedMinPrice = document.forms["search"].min_price.selectedIndex;
	var selectedMaxPrice = document.forms["search"].max_price.selectedIndex;

	// test if we should set rental options or default options
	listing_type = document.forms["search"].listing_type.options[document.forms["search"].listing_type.selectedIndex].text;
	if(listing_type == "Rental" || listing_type == "Short Term" || listing_type == "Long Term")
		optionsArray = rentalOptions;
	else if(listing_type == "Seasonal")
		optionsArray = seasonalOptions;
	else
		optionsArray = defaultOptions;
	
	// add each of the options to the min and max price menus
	for(i=0; i<optionsArray.length/2; i++)
	{
		document.forms["search"].min_price.options[i+1] = new Option(optionsArray[i*2],optionsArray[i*2+1]);
		document.forms["search"].max_price.options[i] =   new Option(optionsArray[i*2],optionsArray[i*2+1]);
	}
	
	// reset the selected indexes
	if(document.forms["search"].min_price.length > selectedMinPrice)
		document.forms["search"].min_price.selectedIndex = selectedMinPrice;
	if(document.forms["search"].max_price.length > selectedMaxPrice)
		document.forms["search"].max_price.selectedIndex = selectedMaxPrice;
}