//Email validation Start
function validEmail(email) {
invalidChars = " /:,;"
//checking for an empty text box
	if (email =="") {
		return false
	}
	//checks for invalid characters within the email
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
			if (email.indexOf(badChar, 0) > -1) {
				return false
			}
	}
//checking for "@" symbol
atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false
	}
//checking for unnecessary "@" symbols
	if (email.indexOf("@", atPos+1) != -1) {
		return false
	}
//checking for a period
periodPos = email.indexOf(".",atPos)
	if(periodPos == -1) {
		return false
	}
	//checking for at least two characters after the period
	if (periodPos+3 > email.length) {
		return false;
	}
		return true;
}
//Email validation end
re = /^\(?(\d{3})\)?[\.\-\/ ]?(\d{3})[\.\-\/ ]?(\d{4})$/

function validator(contact_form) {
var name = contact_form.first_name.value;
var project = contact_form.body_area.value;

//validation for name text box
if (name == "") {
	alert ("Please enter your full name");
	contact_form.first_name.focus();
	contact_form.first_name.select();
	return false;
}
//validation for email address
if (!validEmail(contact_form.client_email.value)) {
	alert("Your email address is invalid...");
	contact_form.client_email.focus();
	contact_form.client_email.select();
	return false;
}

//phone correction and validation
validPhone = re.exec(contact_form.phone.value)
if (validPhone) {
  contact_form.phone.value = "(" + validPhone[1] + ") " + validPhone[2] + "-" + validPhone[3]
			}
			else {
				alert(contact_form.phone.value + " isn't a valid US phone number")
				contact_form.phone.focus()
				contact_form.phone.select()
			return false;
			}

//validation for Pull-down menu
theService = contact_form.service_type.selectedIndex
  if (contact_form.service_type.options[theService].value =="") {
  alert("You must select a type of service...");
  return false;
  }
//validation for project description
if (project == "") {
alert ("Describe the type of work you want done...");
contact_form.body_area.select();
contact_form.body_area.focus();
return false;
}
return true;
}

 
function quoteBox(getQuote){
if (getQuote.name.value == "") {
	alert ("Please enter your Name");
	//place blinking cursor
	getQuote.name.focus();
	getQuote.name.select();
	return false;
}
//validation for email address
if (!validEmail(getQuote.client_email.value)) {
	alert("Your email address is invalid...");
	getQuote.client_email.focus();
	getQuote.client_email.select();
	return false;
}
if (getQuote.comments.value == "") {
	alert ("Please summarize your request.");
	//place blinking cursor
	getQuote.name.focus();
	getQuote.name.select();
	return false;
}
return true
}

