var reqString = "* Required";

function validateContactForm(){		
	
	var fname = document.getElementById("fname");
	var lname = document.getElementById("lname");
	var tel = document.getElementById("tel");
	var addy = document.getElementById("address");
	var zip = document.getElementById("zip");
	var email = document.getElementById("email");
	
	var valid = true;
	
	if(fname.value == "" || fname.value == reqString){
		fname.value = reqString;
		fname.focus();
		valid = false;
	}
	if(lname.value == "" || lname.value == reqString){
		lname.value = reqString;
		if(valid) lname.focus();
		valid = false;
	}
	if(tel.value == "" || tel.value == reqString){
		tel.value = reqString;
		if(valid) tel.focus();
		valid = false;
	}
	if(addy.value == "" || addy.value == reqString){
		addy.value = reqString;
		if(valid) addy.focus();
		valid = false;
	}
	if(zip.value == "" || zip.value == reqString){
		zip.value = reqString;
		if(valid) zip.focus();
		valid = false;
	}
	if(!validateEmail(email.value)){
		email.value = reqString;
		if(valid) email.focus();
		valid = false;
	}	
	return valid;		
}
function validateDealerForm(){		
	
	var fname = document.getElementById("fname");
	var lname = document.getElementById("lname");
	var tel = document.getElementById("tel");
	var territory = document.getElementById("territory");

	var email = document.getElementById("email");

	var valid = true;
	
	if(fname.value == "" || fname.value == reqString){
		fname.value = reqString;
		fname.focus();
		valid = false;
	}
	if(lname.value == "" || lname.value == reqString){
		lname.value = reqString;
		if(valid) lname.focus();
		valid = false;
	}
	if(tel.value == "" || tel.value == reqString){
		tel.value = reqString;
		if(valid) tel.focus();
		valid = false;
	}
	if(territory.value == "" || territory.value == reqString){
		territory.value = reqString;
		if(valid) territory.focus();
		valid = false;
	}
	
	if(!validateEmail(email.value)){
		email.value = reqString;
		if(valid) email.focus();
		valid = false;
	}	
	
	return valid;		
}
function validateEmail(email) {
  var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
  return regex.test(email);
}
function clearField(input){
	var val = input.value;
	if(val == reqString){
		input.value = "";
	}
}