function isEmpty(str) 
{
	reg = /\S/;
	if (str != "" && reg.test(str)) {
		return false; // if there is any non-whitespace character, string is not empty
	} else {
		return true;
	}
}

function isNumeric(str) {
	reg = /\D+/; // check to make sure there is no non-digit char
	if (reg.test(str)) {
		return false; // if there is a non-digit char, is not numeric
	} else {
		return true;
	}
}

function searchVal(f) {
	if (!isNumeric(f.minBedroomCount.value)) 
	{
		alert("Value must be a number. Please ensure that the Minimum Bedrooms field contains no non-digit characters.");
		f.minBedroomCount.focus();
		return false;
	}
	else if (!isNumeric(f.minAreaCount.value)) 
	{
		alert("Value must be a number. Please ensure that the Minimum Sq. Ft. field contains no non-digit characters.");
		f.minAreaCount.focus();
		return false;
	}
	else if (!isNumeric(f.maxRentCount.value)) 
	{
		alert("Value must be a number. Please ensure that the Maximum Rent field contains no non-digit characters.");
		f.maxRentCount.focus();
		return false;
	}
	else if (f.rid.value=='')
	{
		alert ("Please Select a region where you want to search the property");
		return false;
	}
	else 
	{
		if (f.typeHouse.checked && 
				f.typeDuplex.checked && 
				f.typeApartComp.checked && 
				f.typeApartHouse.checked && 
				f.typeCondo.checked &&
				f.typeRoom.checked &&
				f.typeTown.checked &&
				f.typeStudio.checked && isEmpty(f.minBedroomCount.value) && isEmpty(f.minAreaCount.value) && isEmpty(f.maxRentCount.value) && isEmpty(f.streetNumber.value) && isEmpty(f.street.value) && isEmpty(f.city.value) && isEmpty(f.zip.value) && isEmpty(f.dateLimit.value) && !(f.furnishedSwitch.checked) && !(f.accessibleSwitch.checked) && !(f.subletSwitch.checked))
		{
			f.allSelected.value=true;
		}
		else
		{
			f.allSelected.value=false;
		}
		if (	f.typeHouse.checked || 
				f.typeDuplex.checked || 
				f.typeApartComp.checked || 
				f.typeApartHouse.checked || 
				f.typeCondo.checked ||
				f.typeRoom.checked ||
				f.typeTown.checked ||
				f.typeStudio.checked) 
		{
			return true;
		} else {
			alert ("You must select at least one property type.");
			return false;
		}
	}
	
}
