function changeAreaLists(arrList,selTxt)
{
	var areaListObj;
	//get get dropdown list object
	areaListObj = document.getElementById("area");

	//get the number of elements in the price range
	var length = areaListObj.length
		//alert(selTxt);
	if(areaListObj.type == "select-multiple")
	{
		for(cnt = 0; cnt < length; cnt++)
		{
			areaListObj.remove(0);
		}

		areaListObj.options[0] = new Option(arrList[0],"");

		for (x = 1; x < arrList.length; x++)
		{
			areaListObj.options[x] = new Option(arrList[x],arrList[x]);
			if (selTxt == arrList[x])
			{
				areaListObj.selectedIndex = x;
			}
		}

	}
}

// change dropdown elements, pass id of dropdown element
// then pass an array of the elements
function changeDropDownElements(arrPriceRangeMin, arrPriceRangeMax)
{

	//get get dropdown list object
	drpdwnObj = document.getElementById("minprice");

	//get the number of elements in the price range
	var length = drpdwnObj.length
	if(drpdwnObj.type == "select-one")
	{
		for(cnt = 0; cnt < length; cnt++)
		{
			drpdwnObj.remove(0);
		}

		for(x in arrPriceRangeMin) 
		{
			drpdwnObj.options[x] = new Option(arrPriceRangeMin[x],arrPriceRangeMin[x]);
		}

	}

	drpdwnObj = document.getElementById("maxprice");

	//get the number of elements in the price range
	length = drpdwnObj.length
	if(drpdwnObj.type == "select-one")
	{

		for(cnt = 0; cnt < length; cnt++)
		{
			drpdwnObj.remove(0);
		}

		for(x in arrPriceRangeMax)
		{
			drpdwnObj.options[x] = new Option(arrPriceRangeMax[x],arrPriceRangeMax[x]);
		}

	}
}

//--------------------------------------------------------------
	// Function to assign initial values to selects.
	function InitSelect(boolCity)
	{
		var objSelectArea = document.getElementById("area");
		if(boolCity)
		{
			objSelectArea.disabled = true;
			var objSelectCity = document.getElementById("city_search");
			//objSelectCity.options[0] = new Option("test", "testval");
			for(i=0;i<intNumCities;i++)
			{
				objSelectCity.options[i+1] = new Option(arrCities[i],arrCities[i]);
			}
		}
		else
		{
			// Add options to area since there are no cities.
			for(i=0;i<arrArea[0].length;i++)
			{
				var strName, strVal;
				var arrTemp = arrArea[0][i].split("^");
                strName = arrTemp[0];
                if(arrTemp[1] != null) {
                    strVal = arrTemp[1];
                }
                else {
                    strVal = arrTemp[0];
                }
                objSelectArea.options[i+1] = new Option(strName,strVal);

				//objSelectArea.options[i+1] = new Option(arrArea[0][i],arrArea[0][i]);
			}
		}

	}
//--------------------------------------------------------------
// Function to toggle values of the area select.

	function ToggleArea(intCity)
	{
		var objSelectArea = document.getElementById("area");
		var strTemp, strVal, strName;

		// Erase current entries.
		for(i=objSelectArea.options.length-1;i>0;i--)
		{
			objSelectArea.options[i] = null;
		}
		if(intCity >= 0)
		{
			objSelectArea.disabled = false;
			for(i=0;i<arrArea[intCity].length;i++)
			{
				strTemp = new String(arrArea[intCity][i]);
				var arrTemp = strTemp.split("^");
				strName = arrTemp[0];
				if(arrTemp[1] != null) {
					strVal = arrTemp[1];
				}
				else {
					strVal = arrTemp[0];
				}
				objSelectArea.options[i+1] = new Option(strName,strVal);
				//objSelectArea.options[i+1] = new Option(arrArea[intCity][i]);
			}
			objSelectArea.focus();
		}
		else
		{
			objSelectArea.selectedIndex = 0;
			objSelectArea.disabled = true;
			document.getElementById("city_search").focus();
		}
	}
//--------------------------------------------------------------


function validate()
{
	var dbg=0;
	var boolReturn = true;
	var strErrMessage = "";

	if(dbg) {
		alert('In validate()');
	}
		// Test for blank first name.
	objVal = document.getElementById("first_name");
	if( objVal.value.length == 0 )
	{
		boolReturn = false;
		strErrMessage += "First Name is a required field\n";
	}

		// Test for blank last name.
	objVal = document.getElementById("lastname");
	if( objVal.value.length == 0 )
	{
		boolReturn = false;
		strErrMessage += "Last Name is a required field\n";
	}

	// Test for blank phone number.
	objVal = document.getElementById("phone");
	if( objVal.value.length == 0 )
	{
		boolReturn = false;
		strErrMessage += "Phone Number is a required field\n";
	}

		// Test for blank email name.
	objVal = document.getElementById("email");

//	(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.emailAddr.value))
//	if( objVal.value.length == 0 )
	if( !(/^\w+([\.\-]\w+)*@\w+([\.\-]\w+)*\.\w{2,4}$/.test(objVal.value)) )
	{
		boolReturn = false;
		strErrMessage += "Email is a required field\n";
	}

		// Test for blank search type.
	objVal = document.getElementById("searchtype");
	if( objVal.value.length == 0 )
	{
		boolReturn = false;
		strErrMessage += "Search Type is a required field\n";
	}


		// Test for blank property type.
	objVal = document.getElementById("type");
	if( objVal.value.length == 0 )
	{
		boolReturn = false;
		strErrMessage += "Property Type is a required field\n";
	}

		// Test for blank area.
	objVal = document.getElementById("area");
	if( objVal.selectedIndex <= 0 )
	{
		boolReturn = false;
		strErrMessage += "Area is a required field\n";
	}

		// Test for blank minimum price.
	objVal = document.getElementById("minprice");
	if( objVal.value.length == 0 )
	{
		boolReturn = false;
		strErrMessage += "Minimum Price is a required field\n";
	}

		// Test for blank maximum price.
	objVal = document.getElementById("maxprice");
	if( objVal.value.length == 0 )
	{
		boolReturn = false;
		strErrMessage += "Maximum Price is a required field\n";
	}


	if(dbg) alert(boolReturn);
	if(!boolReturn) alert(strErrMessage);
	return(boolReturn);

}