
<!--
function leaveDigits(_str)
{
  var STR="";
  var _exp =/\d+/g;
  var _array;
  while(_array=_exp.exec(_str))
	STR+=_array.join();
	return STR
}	

	
function formatPhone(STR){
	//STR now contains only nums
	if (STR.length < 10) {
	alert("please enter entire phone number including areacode")
	return false
	}
	
	if (STR.length > 10) {
		 alert("please only enter 10 digit phone numbers")
		 return false
	}else{
	var area="";
	var mid="";
	var end="";
	var phonenum="";
	area=STR.substring(0,3);
	mid=STR.substring(3,6);
	end=STR.substring(6,10);
	phonenum=area+"-"+mid+"-"+end;
	return phonenum
	}
	
}
	

//form.fax.value=leaveDigits(form.fax.value)
//form.fax.value=leaveDigits(form.fax.value)



function validEmail(email) {
	invalidChars = " /:,;"
	
	if (email == "") {						// cannot be empty
		return false
	}
	for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)			// there must be one "@" symbol
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {					// and at least one "." after the "@"
		return false
	}
	if (periodPos+3 > email.length)	{		// must be at least 2 characters after the "."
		return false
	}
	return true
}

//FNAME
//LNAME
//zip
function submitIt(form) {




	// make sure they enter a name
	if (form.firstname.value == "") {
		alert("Please enter a first name(s)")
		form.firstname.focus()
		return false
	}

	// make sure they enter a name
	if (form.lastname.value == "") {
		alert("Please enter a last name(s)")
		form.lastname.focus()
		return false
	}
	
	
	var thelen,phone,email,fax;
	fax=form.fax.value;
	phone=form.phone.value;
	email=form.email.value;	
	
	// make sure they enter a way to contact
	if ((phone == "") && (email == "") && (fax == "")) {
		alert("Please provide a fax, phone OR email address")
		form.email.focus()
		return false
	}

	//manipulate fax number
	if (fax != ""){
	var format="";
	format=leaveDigits(fax)
		if (!formatPhone(format)) {	
			form.fax.focus()	
			form.fax.select()	
			return false
		}else{
			form.fax.value=formatPhone(format)
		}
	}

	//manipulate other phone number
	if (phone != ""){
	var format="";
	format=leaveDigits(phone)
		if (!formatPhone(format)) {	
			form.phone.focus()	
			form.phone.select()	
			return false
		}else{
			form.phone.value=formatPhone(format)
		}
	}
	

	
	//check extension
	if (isNaN(form.ext.value)){
			alert("Please enter numbers only in the extension field.")
			form.ext.focus()	
			form.ext.select()
			return false
	}


	
	//if (form.zip.value == "") {
	//	alert("Please enter a zip code")
	//	form.zip.focus()
	//	return false
	//}

	
if ((form.zip.value != "") && (form.international.value == "")) {	
	if (form.zip.value.length < 5) {
		alert("Zip code needs to include 5 digits")
		form.zip.focus()
		return false
	}

	if (form.zip.value.length == 5) {
		if (isNaN(form.zip.value)) {
			alert("[1]Please enter only numbers in your zip code (or use zip+4 format)")
			form.zip.focus()
			return false
		}
		if (!((form.zip.value > 0) && (form.zip.value <= 99999))) {
			alert("[2]Please enter only numbers in your zip code (or use zip+4 format)")
			form.zip.focus()
			return false
		}

		var re = /\+/g;
		var tmp3=form.zip.value;
		var newstr=tmp3.replace(re,"");
		if (newstr.length < 5) {
			alert("[2]Zip code needs to include 5 digits")
			form.zip.focus()
			return false
		}
	}

	if (form.zip.value.length > 5) {
		var tmp2=form.zip.value.substr(6);
		if (tmp2.length != 4) {
			alert("[1]Please enter your zip code in valid zip+4 format")
			form.zip.focus()
			return false
		}
		if (isNaN(tmp2)) {
			alert("[2]Please enter your zip code in valid zip+4 format")
			form.zip.focus()
			return false
		}
		if (form.zip.value.substr(5,1) != "-") {
			alert("[3]Please enter your zip code in valid zip+4 format")
			form.zip.focus()
			return false
		}
	}
}
	// check to see if the email's valid
	if (email != "") {
		if (!validEmail(email)) {
			alert("Invalid email address, address should be in the form youname@yourdomain.com")
			form.email.focus()
			form.email.select()
			return false
		}
	}

//alert("valid, temporarily return false tho");
//return false
	// If we made it to here, everything's valid, so return true
	return true
}
//-->