function validateFormOnSubmit(theForm) {

var reason = "";
	
	reason += validatePosition(theForm.position);
	reason += validateLocation(theForm.location);
	reason += validateName(theForm.name);
	reason += validateAge(theForm.age);
	reason += validateAddress(theForm.address);
	reason += validateCity(theForm.city);
	reason += validateState(theForm.state);
	reason += validateZip(theForm.zip);
	reason += validatePhone(theForm.phone);
	reason += validateSS(theForm.ss);
	reason += validateDate(theForm.date);
	reason += validateHours(theForm.hours);
	reason += validateCar(theForm.car);
	reason += validateWage(theForm.wage);
	reason += validateGilmore(theForm.gilmore);
	reason += validatePresent(theForm.present);
	reason += validateSmoke(theForm.smoke);
	
      
  	if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
}

  	alert("Your application has been submitted to our Human Resources Department.  Thank you!");
  	return true;
}


function validatePosition(fld) {
var error = "";

	if (fld.value == "") {
	error = "Please indicate the position you are appying for.\n";
}
	return error;
}


function validateLocation(fld) {
	var error = "";

	if (fld.selectedIndex == 0) {
	error = "Please indicate which Gilmore location you are applying for.\n";
}
	return error;
}


function validateName(fld) {
var error = "";

	if (fld.value == "") {
	error = "Please fill in your full name.\n";
}
	return error;
}


function validateAge(fld) {
	var error = "";

	if (fld.selectedIndex == 0) {
	error = "Please indicate if you are 18 or older.\n";
}
	return error;
}


function validateAddress(fld) {
var error = "";

	if (fld.value == "") {
	error = "Please fill in your street address.\n";
}
	return error;
}


function validateCity(fld) {
var error = "";

	if (fld.value == "") {
	error = "Please fill in your city of residence.\n";
}
	return error;
}


function validateState(fld) {
var error = "";

	if (fld.value == "") {
	error = "Please fill in your state of residence.\n";
}
	return error;
}


function validateZip(fld) {
    var error = ""; 

   	if (fld.value == "") {
	error = "Please fill in your zip code.\n";
    
} 	else if (isNaN(fld.value)) {
	error = "The zip code you entered contains illegal characters.\n";
    
}
    return error;
}


function validatePhone(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    

   	if (fld.value == "") {
	error = "Please fill in your phone number.\n";
    
} 	else if (isNaN(stripped)) {
	error = "The phone number you entered contains illegal characters.\n";
    
} 	else if (!(stripped.length == 10)) {
	error = "The phone number you entered is the wrong length. Make sure you included an area code.\n";
}
    return error;
}


function validateSS(fld) {
    var error = "";
    var stripped2 = fld.value.replace(/[\(\)\.\-\ ]/g, '');    

   	if (fld.value == "") {
	error = "Please fill in your social security number.\n";
    
} 	else if (isNaN(stripped2)) {
	error = "The social security number you entered contains illegal characters.\n";
    
} 	else if (!(stripped2.length == 9)) {
	error = "The social security number you entered is the wrong length.\n";
}
    return error;
}


function validateDate(fld) {
var error = "";

	if (fld.value == "") {
	error = "Please indicate the date you could start work.\n";
}
	return error;
}


function validateHours(fld) {
var error = "";

	if (fld.value == "") {
	error = "Please indicate the days and hours you are available to work.\n";
}
	return error;
}


function validateCar(fld) {
var error = "";

	if (fld.value == "") {
	error = "Please indicate your mode of transportation.\n";
}
	return error;
}


function validateWage(fld) {
var error = "";

	if (fld.value == "") {
	error = "Please indicate your expected rate of pay.\n";
}
	return error;
}


function validateGilmore(fld) {
var error = "";

	if (fld.value == "") {
	error = "Please indicate if you have worked for The Gilmore Collection before.\n";
}
	return error;
}


function validatePresent(fld) {
	var error = "";

	if (fld.selectedIndex == 0) {
	error = "Please indicate if we can contact your current employer.\n";
}
	return error;
}


function validateSmoke(fld) {
	var error = "";

	if (fld.selectedIndex == 0) {
	error = "Please indicate whether or not you smoke.\n";
}
	return error;
}





  

// JavaScript Document