function validate_phone(phone)
{
		if ( !phone.match(/^[(]?\d{3}[)]?[ -]?\d{3}[ -]?\d{4}$/) )
			return false;
		return true;
}

function validate_zipcode(zip)
{
	if ( !zip.match(/^\d{5}$|^\d{5}-\d{4}$/) )
		return false;
	return true;
}

function validate_email(email)
{
	if(!email.match(/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/))
		return false;
	return true;
}

function IsNumber(strString)
   //  check for valid numeric strings	
{
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult; i++)
   {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1) blnResult = false;
   }
   return blnResult;
}

function validate_quickSearch(formid,iid)
{
	var oform = document.forms[formid];
	if (oform.elements[iid].value != "")
	{
		//oform.submit();
		return true;
	}
	alert ("Please enter MLS number!");
	return false;
}

//Validates search form: city is mandatory
//It is a multiple selection select
function validate_search()
{
	var obj = document.getElementById('city');
	 for (var i=obj.options.length-1; i >= 0;i--)
	 	if (obj.options[i].selected)
			return true;
	
	alert ("Please select at least one city!");
	return false;
}