/////////////////////////////////////

function CheckJobApp (jobapp) {
	if (isBlank(jobapp.first_name) || isBlank(jobapp.last_name) || isEmail(jobapp.email_address)) {
		return(false)
	}
	else {
		return(true)
	}
}

function CheckContact (contact) {
	if (isBlank(contact.first_name) || isBlank(contact.last_name) || isEmail(contact.email_address) || isBlank(contact.message)) {
		return(false)
	}
	else {
		return(true)
	}
}

/////////////////////////////////////

function isBlank (field) {
	if (field.value == "") {
		alert("You must enter a value in " + field.name)
		return(true)
	}
	else {
		return(false)
	}
}

function isNumber(field) {
	if (isBlank(field)) {
		return(true)
	}
	oneString = field.value;
	for (var i=0; i<oneString.length;i++) {
		var oneChar = oneString.charAt(i);
		if (oneChar < "0" || oneChar > "9") {
			alert(field.name + " must be a number.")
			return(true)
		}
		else {
			return(false)
		}
	}
}

function isEmail(field) {
	var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
	if (!goodEmail) {
		alert("Please enter a valid e-mail address.")
		field.focus()
		field.select()
		return(true)
	}
	else {
		return(false)
	}
}
///////////////

function isSelected (field) {
	if (field.selectedIndex <= 0) {
		alert("You must select a value from the " + field.name + " List")
		return(false)
	}
	else {
		return(true)
	}
}

function isRange(field) {
	if (field.value != "") {
		if (field.value < 0 || field.value > 48) {
			alert("You couldn't possibly have that many " + field.name)
			return(false)
		}
		else {
			return(true)
		}
	}
	else {
		alert ("You must have SOME " + field.name)
		return(false)
	}
}

///////////////////////////////

function CheckFields (guestbook) {
	if (isBlank(guestbook.username) || !isdate(guestbook.dob, true) || !isSelected(guestbook.sex) || !isRange(guestbook.teeth) || isBlank(guestbook.comments))
	{
		alert ("Not all of the information is entered")
		return(false)
	}
	else {
		return(true)
	}
}