function Validate(){
	clearFeedback('GOOD');
	clearFeedback('BAD');
	var errors = 0;
	//----------
	//REQUIRED
	//first name
	ele = getFormElementByName("firstName");
	highlightMissingInfo(ele, 0);
	var fnStr = ele.value;
	filter=/^[a-zA-Z\.' ]+$/
	if (!filter.test(fnStr)){
		addFeedback("BAD", "The first name field may only be letters and punctuation.")
		highlightMissingInfo(ele, 1);
		errors++;
	}

	ele = getFormElementByName("lastName");
	highlightMissingInfo(ele, 0);
	var fnStr = ele.value;
	filter=/^[a-zA-Z\.' ]+$/
	if (!filter.test(fnStr)){
		addFeedback("BAD", "The last name field may only be letters and punctuation.")
		highlightMissingInfo(ele, 1);
		errors++;
	}

	//daytime phone
	ele = getFormElementByName("phone2_area");
	highlightMissingInfo(ele, 0);
	var p2AreaStr = ele.value;
	var filter=/^\d{3,3}$/
	if (!filter.test(p2AreaStr)){
		addFeedback("BAD", "The work area code may only contain 3 digits.")
		highlightMissingInfo(ele, 1);
		errors++;
	}

	ele = getFormElementByName("phone2_number1");
	highlightMissingInfo(ele, 0);
	var p2P1Str = ele.value;
	var filter=/^\d{3,3}$/
	if (!filter.test(p2P1Str)){
		addFeedback("BAD", "The work phone number 1 may only contain 3 digits.")
		highlightMissingInfo(ele, 1);
		errors++;
	}

	ele = getFormElementByName("phone2_number2");
	highlightMissingInfo(ele, 0);
	var p2P2Str = ele.value;
	var filter=/^\d{4,4}$/
	if (!filter.test(p2P2Str)){
		addFeedback("BAD", "The work phone number 2 may only contain 4 digits.")
		highlightMissingInfo(ele, 1);
		errors++;
	}

	ele = getFormElementByName("phone2_ext");
	highlightMissingInfo(ele);
	var p2ExtStr = ele.value;
	var filter=/^\d{0,6}$/
	if (!filter.test(p2ExtStr)){
		addFeedback("BAD", "The work phone extension may contain 0 to 6 digits.")
		highlightMissingInfo(ele, 1);
		errors++;
	}

	//email
	ele = getFormElementByName("email");
	highlightMissingInfo(ele, 0);
	var emailStr = ele.value;
	if (!check_email(emailStr)){
		addFeedback("BAD", "The email address is not valid.")
		highlightMissingInfo(ele, 1);
		errors++;
	}

	ele = getFormElementByName("businessName");
	highlightMissingInfo(ele, 0);
	var bnStr = ele.value;
	filter=/^[0-9a-zA-Z\.' ]+$/
	if (!filter.test(bnStr)){
		addFeedback("BAD", "The business name field may only be numbers, letters and punctuation.")
		highlightMissingInfo(ele, 1);
		errors++;
	}

	ele = getFormElementByName("businessLocations");
	highlightMissingInfo(ele, 0);
	var blStr = ele.value;
	filter=/^[0-9]+$/
	if (!filter.test(blStr)){
		addFeedback("BAD", "The business locations field may only be numbers.")
		highlightMissingInfo(ele, 1);
		errors++;
	}

	//SUPPLEMENTAL
	//zipcode
	/*var ele = getFormElementByName("zip1");
	highlightMissingInfo(ele, 0);
	var zipStr = ele.value;
	if (zipStr){
		var filter=/^\d{5}$/
		if (!filter.test(zipStr)){
			addFeedback("BAD", "The zipcode may only contain 5 digits.")
			highlightMissingInfo(ele, 1);
			errors++;
		}
	}*/

	return (errors == 0);
}

function getFormElementByName(name){
	var arr = document.getElementsByName(name);
	return arr[0];
}

function check_email(e) {
	var filter=/^.+@.+\..{2,3}$/

	if (filter.test(e)) return 1;
	return 0;
}


function highlightMissingInfo(ele, force){
	if (ele){
		if (force == 1 || (ele.value == "" && force == "")){
			ele.style.backgroundColor = "#FF8888";
		} else {
			ele.style.backgroundColor = "#FFFFFF";
		}
	}
}

function getFItem(type){
	var fItem = "";
	if (type == "GOOD")	{
		fItem = document.getElementById("positiveFeedback");
	} else if (type == "BAD"){
		fItem = document.getElementById("negativeFeedback");
	}
	return fItem;
}

function addFeedback(type, info){
	var fItem = getFItem(type);
	if (fItem){
		if (fItem.innerHTML){
			fItem.innerHTML+="<br/>"+info;
		}else{
			fItem.innerHTML = info;
		}
	}
}

function clearFeedback(type){
	var fItem = getFItem(type);
	if (fItem){
		fItem.innerHTML = "";
	}
}