function isEmail (s) {
	if (isEmpty(s)) 
		if (isEmail.arguments.length == 1) return false;
		else return (isEmail.arguments[1] == true);

	if (isWhitespace(s)) return false;

	var i = 1;
	var sLength = s.length;

	while ((i < sLength) && (s.charAt(i) != "@")) {
		i++
	}

	if ((i >= sLength) || (s.charAt(i) != "@")) return false;
	else i += 2;

	while ((i < sLength) && (s.charAt(i) != ".")) {
		i++
	}

	if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
	else return true;
}

function isEmpty(s) {
	return ((s == null) || (s.length == 0));
}

var whitespace = " \t\n\r";
function isWhitespace (s) {
	var i;
	if (isEmpty(s)) return true;
	for (i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if (whitespace.indexOf(c) == -1) return false;
	}
	return true;
}


function submitContact(form){
	if (isWhitespace (form.firstname.value)) {
		alert("Please enter your first name!");
		form.firstname.focus();
		return;
	}
	if (isWhitespace (form.lastname.value)) {
		alert("Please enter your last name!");
		form.lastname.focus();
		return;
	}
	if (isWhitespace (form.phone.value)) {
		alert("Please enter your phone!");
		form.phone.focus();
		return;
	}
	if (form.besttimetocall.selectedIndex == 0) {
		alert("Please select your best time to call!");
		form.besttimetocall.focus();
		return;
	}
	if (isWhitespace (form.comments.value)) {
		alert("Please enter your comments!");
		form.comments.focus();
		return;
	}

	form.action = "contact.php";
	form.submit();
}

function submitOpportunities(form){
	if (isWhitespace (form.firstname.value)) {
		alert("Please enter your first name!");
		form.firstname.focus();
		return;
	}
	if (isWhitespace (form.lastname.value)) {
		alert("Please enter your last name!");
		form.lastname.focus();
		return;
	}
	if (isWhitespace (form.address.value)) {
		alert("Please enter your address!");
		form.address.focus();
		return;
	}
	if (isWhitespace (form.city.value)) {
		alert("Please enter your city!");
		form.city.focus();
		return;
	}
	if (isWhitespace (form.state.value)) {
		alert("Please enter your state!");
		form.state.focus();
		return;
	}
	if (isWhitespace (form.zipcode.value)) {
		alert("Please enter your zipcode!");
		form.zipcode.focus();
		return;
	}
	if (isWhitespace (form.phone.value)) {
		alert("Please enter your phone!");
		form.phone.focus();
		return;
	}
	if (form.currentworkstatus.selectedIndex == 0) {
		alert("Please select your current work status!");
		form.currentworkstatus.focus();
		return;
	}
	if (form.besttimetocall.selectedIndex == 0) {
		alert("Please select your best time to call!");
		form.besttimetocall.focus();
		return;
	}
	if (form.accessmassagechair.selectedIndex == 0) {
		alert("Please select if you have access to a massage chair!");
		form.accessmassagechair.focus();
		return;
	}
	if (form.travelfor.selectedIndex == 0) {
		alert("Please select whait is the distance would you be willing to travel for job!");
		form.travelfor.focus();
		return;
	}
	if (form.liabilityinsurance.selectedIndex == 0) {
		alert("Please select if you have liability insurance!");
		form.liabilityinsurance.focus();
		return;
	}
	if (isWhitespace (form.typofmassagelicence.value)) {
		alert("Please enter your type of massage license that you have!");
		form.typofmassagelicence.focus();
		return;
	}
	if (form.yearsexperience.selectedIndex == 0) {
		alert("Please select your years experience doing chair massage!");
		form.yearsexperience.focus();
		return;
	}
	if (isWhitespace (form.comments.value)) {
		alert("Please enter your comments!");
		form.comments.focus();
		return;
	}

	form.action = "career_opportunities.php";
	form.submit();
}

function submitGetAFreeQuote(form){
	if (isWhitespace (form.companyname.value)) {
		alert("Please enter your comapny name!");
		form.companyname.focus();
		return;
	}
	if (isWhitespace (form.companyprofile.value)) {
		alert("Please enter your company profile!");
		form.companyprofile.focus();
		return;
	}
	if (isWhitespace (form.noofemployees.value)) {
		alert("Please enter number of employees!");
		form.noofemployees.focus();
		return;
	}
	if (isWhitespace (form.contactperson.value)) {
		alert("Please enter your contact person!");
		form.contactperson.focus();
		return;
	}
	if (isWhitespace (form.address.value)) {
		alert("Please enter your address!");
		form.address.focus();
		return;
	}
	if (isWhitespace (form.city.value)) {
		alert("Please enter your city!");
		form.city.focus();
		return;
	}
	if (isWhitespace (form.state.value)) {
		alert("Please enter your state!");
		form.state.focus();
		return;
	}
	if (isWhitespace (form.zipcode.value)) {
		alert("Please enter your zipcode!");
		form.zipcode.focus();
		return;
	}
	if (isWhitespace (form.phone.value)) {
		alert("Please enter your phone!");
		form.phone.focus();
		return;
	}
	if (form.besttimetocall.selectedIndex == 0) {
		alert("Please select your best time to call!");
		form.besttimetocall.focus();
		return;
	}
	if (isWhitespace (form.comments.value)) {
		alert("Please enter your comments!");
		form.comments.focus();
		return;
	}

	form.action = "get_a_free_quote.php";
	form.submit();
}

