document.write('<script language="javascript" src="Includes/functions.js"></script>');
function validate()
{
		var formid = document.form.FormID.value;
				
		if(formid == 1) 
		{
			if(!contactfieldreqs()) return false;
		}
		else if(formid == 2)
		{
			if(!contactfieldreqs()) return false;			
		}
		else if(formid == 3)
		{
			if(!contactfieldreqs()) return false;			
		}
		else if(formid == 4)
		{
			if(!contactfieldreqs()) return false;			
		}
		else if(formid == 5)
		{
			if(isEmpty(document.form.hs_address, "Address")) return false;
			if(isEmpty(document.form.hs_town, "Town")) return false;
			if(isEmpty(document.form.hs_state, "State")) return false;			
			if(!name_and_email()) return false;
		}		
		else if(formid == 6)
		{
			if(!name_and_email()) return false;
		}
		else if(formid == 7)
		{
			if(!name_and_email()) return false;
			if(isEmpty(document.form.cf_comments, ""))
			{
				alert('We would love to hear from you!  Please leave us a comment or question.');
				return false;
			}
		}
		else if(formid == 8)
		{
			if(!name_and_email_no_phone()) return false;
			if(!isEmpty(document.form.NLA_CC, "") && !isEmail(document.form.NLA_CC, "CC Email Address"))
				return false;
			if(!isEmpty(document.form.NLA_CC2, "") && !isEmail(document.form.NLA_CC2, "CC2 Email Address"))
				return false;				
		}
		else if(formid == 9)
		{
			if(!name_and_email_no_phone()) return false;
			document.form.cf_comments.value = "Listing #: " + listnum + "<br>" + document.form.cf_comments.value;
		}		
		else if(formid == 10)
		{
			if(!name_and_email()) return false;
			if(isEmpty(document.form.ap_timefr, "From Time"))
				return false;
			if(isEmpty(document.form.ap_timeto, "To Time"))
				return false;				
		}
		else if(formid == 11)
		{
			if(!name_and_email()) return false;
		}
		else if(formid == 14)
		{
			if(isEmpty(document.form.cf_address, "Address")) return false;
			if(isEmpty(document.form.cf_city, "Town")) return false;
			if(isEmpty(document.form.cf_state, "State")) return false;			
			if(!name_and_email()) return false;
		}		
		else if(formid == 15)
		{
			if(isEmpty(document.form.cf_address, "Address")) return false;
			if(isEmpty(document.form.cf_city, "Town")) return false;
			if(isEmpty(document.form.cf_state, "State")) return false;			
			if(!name_and_email()) return false;
		}		
		return true;
}

function contactfieldreqs()
{
	if(isEmpty(document.form.cf_name, "Name") || 
		isEmpty(document.form.cf_method, "Best Method of Contact") ||
		isEmpty(document.form.cf_email, "Email Address"))
		return false;
	if(!isEmail(document.form.cf_email, "Email Address"))
		return false;
	if(!isEmpty(document.form.cf_home, "") && 
		!isPhone(document.form.cf_home, "Home Phone"))
		return false;
	if(!isEmpty(document.form.cf_cell, "") && 
		!isPhone(document.form.cf_cell, "Cell Phone"))
		return false;
	if(!isEmpty(document.form.cf_work, "") && 
		!isPhone(document.form.cf_work, "Work Phone"))
		return false;				
	if(!isEmpty(document.form.cf_email2, "") && 
		!isEmail(document.form.cf_email2, "Contact #2 Email Address"))
		return false;	
		
	return true;
}

function name_and_email()
{
	if(isEmpty(document.form.cf_name, "Name") || 
		isEmpty(document.form.cf_email, "Email Address"))
		return false;
	if(!isEmail(document.form.cf_email, "Email Address"))
		return false;
	if(!isEmpty(document.form.cf_cell, "") && 
		!isPhone(document.form.cf_cell, "Contact Phone"))
		return false;
		
	return true;
}

function name_and_email_no_phone()
{
	if(isEmpty(document.form.cf_name, "Name") || 
		isEmpty(document.form.cf_email, "Email Address"))
		return false;
	if(!isEmail(document.form.cf_email, "Email Address"))
		return false;
		
	return true;
}

function countychanged()
{
	var countyid = document.form.pi_county.value;
	var formid = document.form.FormID.value;
	
	if(formid == 5)
	{
		if(countyid == 1)
		{
		}
		else if(countyid == 2)
		{
		}
		else if(countyid == 999)
		{
			alert('Your request is outside our service area.  Please complete the following' + 
					' and we will process your request to an appropriate marketing specialist.');
			document.location = 'propval_fms.asp';
		}
	}
	else if(formid == 6)
	{
		if(countyid == 999)
		{
			alert('Your request is outside our service area.  Please complete the following' + 
					' and we will process your request to an appropriate marketing specialist.');
			document.location = 'propval_fms.asp';
		}
		else
		{
			document.form.FormID.value = 0;		//So the form is not processed, only the values are read
			document.form.submit();
		}
	}
}

function regionchanged()
{
    document.form.FormID.value = 0;		// So the form is not processed, only the values are read
	document.form.submit();
}