function searchAlbuquerqueRealEstate()
{
	var location="";
	var area;

	area = replaceChars(document.searchAlbuquerque.area.value, "gnmh/", "");
	area = replaceChars(area, "abq/", "");
	area = replaceChars(area, "-", " ");

	if(document.searchAlbuquerque.type[0].checked)
	{
		location = replaceChars(document.searchAlbuquerque.area.value, "gnmh", "http://www.great-nm-homes.com/homes");
		location = replaceChars(location, "abq/", "http://www.abq-real-estate.com/houses/");

		if(document.searchAlbuquerque.house_category.value=="new")
		{
			location = location+".htm";
			location = location+"#"+area+" New Homes";
		}
		else if(document.searchAlbuquerque.house_category.value=="recent")
		{
			location = location+".htm";
			location = location+"#"+area+" Recent Listings";
		}
		else
			location = location+"-mls-listings.htm";
	}
	else if(document.searchAlbuquerque.type[1].checked)
	{
		location = replaceChars(document.searchAlbuquerque.area.value, "gnmh", "http://www.great-nm-homes.com/land");
		location = replaceChars(location, "abq/", "http://www.abq-real-estate.com/land/");
		location = location+".htm";
		
		if(document.searchAlbuquerque.land_category.value=="recent")
			location = location+"#"+area+" Recent Listings";
	}

	document.location = location;
}

function oldsearchRioRanchoRealEstate()
{
	var location="";
	var area;

	area = replaceChars(document.searchRioRancho.area.value, "gnmh/", "");
	area = replaceChars(area, "abq/", "");
	area = replaceChars(area, "-", " ");

	if(document.searchRioRancho.type[0].checked)
	{
		location = replaceChars(document.searchRioRancho.area.value, "gnmh", "http://www.great-nm-homes.com/homes");
		location = replaceChars(location, "abq/", "http://www.abq-real-estate.com/houses/");
		
		if(document.searchRioRancho.house_category.value=="new")
		{
			location = location+".htm";
			location = location+"#"+area+" New Homes";
		}
		else if(document.searchRioRancho.house_category.value=="recent")
		{
			location = location+".htm";
			location = location+"#"+area+" Recent Listings";
		}
		else
			location = location+"-mls-listings.htm";
	}
	else if(document.searchRioRancho.type[1].checked)
	{
		location = replaceChars(document.searchRioRancho.area.value, "gnmh", "http://www.great-nm-homes.com/land");
		location = replaceChars(location, "abq/", "http://www.abq-real-estate.com/land/");
		location = location+".htm";
		
		if(document.searchRioRancho.land_category.value=="recent")
			location = location+"#"+area+" Recent Listings";
	}

	document.location = location;
}

function searchRioRanchoRealEstate()
{
	anchorText = replaceChars(document.searchRioRancho.area.value, "gnmh/", "");
	url = replaceChars(document.searchRioRancho.area.value, " ", "-");

	if(document.searchRioRancho.type[0].checked)
	{
		url = replaceChars(url, "gnmh", "http://www.great-nm-homes.com/homes");
		
		if(document.searchRioRancho.house_category.value=="new")
		{
			url = url+".htm";
			url = url+"#"+anchorText+" New Homes";
		}
		else if(document.searchRioRancho.house_category.value=="recent")
		{
			url = url+".htm";
			url = url+"#"+anchorText+" Recent Listings";
		}
		else
			url = url+"-mls-listings.htm";
	}
	else if(document.searchRioRancho.type[1].checked)
	{
		url = replaceChars(url, "gnmh", "http://www.great-nm-homes.com/land");
		url = url+".htm";
		
		if(document.searchRioRancho.land_category.value=="recent")
			url = url+"#"+anchorText+" Recent Listings";
	}

	document.location = url;
}

function searchLosLunasRealEstate()
{
	var location="";
	var area;

	area = replaceChars(document.searchLosLunas.area.value, "nmre/", "");
	area = replaceChars(area, "-", " ");

	if(document.searchLosLunas.type[0].checked)
	{
		location = replaceChars(document.searchLosLunas.area.value, "nmre", "http://www.nm-real-estate.com/houses");
		if(document.searchLosLunas.house_category.value=="new")
		{
			location = location+".htm";
			location = location+"#"+area+" New Homes";
		}
		else if(document.searchLosLunas.house_category.value=="recent")
		{
			location = location+".htm";
			location = location+"#"+area+" Recent Listings";
		}
		else
			location = location+"-mls-listings.htm";

	}
	else if(document.searchLosLunas.type[1].checked)
	{
		location = replaceChars(document.searchLosLunas.area.value, "nmre", "http://www.nm-real-estate.com/land");
		location = location+".htm";
		
		if(document.searchLosLunas.land_category.value=="recent")
			location = location+"#"+area+" Recent Listings";
	}

	document.location = location;
}

function searchEastMountainRealEstate()
{
	anchorText = replaceChars(document.searchEastMountain.area.value, "nmre/", "");
	url = replaceChars(document.searchEastMountain.area.value, " ", "-");

	if(document.searchEastMountain.type[0].checked)
	{
		url = replaceChars(url, "nmre", "http://www.nm-real-estate.com/houses");
		
		if(document.searchEastMountain.house_category.value=="new")
		{
			url = url+".htm";
			url = url+"#"+anchorText+" New Homes";
		}
		else if(document.searchEastMountain.house_category.value=="recent")
		{
			url = url+".htm";
			url = url+"#"+anchorText+" Recent Listings";
		}
		else
			url = url+"-mls-listings.htm";
	}
	else if(document.searchEastMountain.type[1].checked)
	{
		url = replaceChars(url, "nmre", "http://www.nm-real-estate.com/land");
		url = url+".htm";
		
		if(document.searchEastMountain.land_category.value=="recent")
			url = url+"#"+anchorText+" Recent Listings";
	}

	document.location = url;
}

function searchNmCountyRealEstate()
{
	anchorText = replaceChars(document.searchNmCounty.area.value, "nmre/", "");
	url = replaceChars(document.searchNmCounty.area.value, " ", "-");

	if(document.searchNmCounty.type[0].checked)
	{
		url = replaceChars(url, "nmre", "http://www.nm-real-estate.com/houses");
		
		if(document.searchNmCounty.house_category.value=="new")
		{
			url = url+".htm";
			url = url+"#"+anchorText+" New Homes";
		}
		else if(document.searchNmCounty.house_category.value=="recent")
		{
			url = url+".htm";
			url = url+"#"+anchorText+" Recent Listings";
		}
		else
			url = url+"-mls-listings.htm";
	}
	else if(document.searchNmCounty.type[1].checked)
	{
		url = replaceChars(url, "nmre", "http://www.nm-real-estate.com/land");
		url = url+".htm";
		
		if(document.searchNmCounty.land_category.value=="recent")
			url = url+"#"+anchorText+" Recent Listings";
	}

	document.location = url;
}

function replaceChars(input, replaceThis, replaceWith)
{
	temp = "" + input; // temporary holder

	while (temp.indexOf(replaceThis)>-1) 
	{
		pos = temp.indexOf(replaceThis);
		temp = ""+(temp.substring(0, pos)+replaceWith+temp.substring((pos+replaceThis.length), temp.length));
	}
	return temp;
}

