function validateApplication() {

   var formIsValid = true;
   var currForm = document.applicationForm;

   if (currForm.firstname.value.length == 0) {
      window.alert('You need to enter a first name');
	  currForm.firstname.focus();
	  formIsValid = false;
	  return false;
   }

   if (currForm.lastname.value.length == 0) {
      window.alert('You need to enter a lastname name');
	  currForm.lastname.focus();
	  formIsValid = false;
	  return false;
   }

   if (currForm.address1.value.length == 0) {
      window.alert('You need to enter a street address.');
	  currForm.address1.focus();
	  formIsValid = false;
	  return false;
   }

   if (currForm.city.value.length == 0) {
      window.alert('You need to enter a city.');
	  currForm.city.focus();
	  formIsValid = false;
	  return false;
   }

	if(currForm.state.value.length == 0) {
      window.alert('You need to select a state.');
	  currForm.state.focus();
	  formIsValid = false;
	  return false;
	}
	
   if (currForm.zip.value.length == 0) {
      window.alert('You need to enter a zip.');
	  currForm.zip.focus();
	  formIsValid = false;
	  return false;
   }	

   if (currForm.country.value.length == 0) {
      window.alert('You need to enter a country.');
	  currForm.country.focus();
	  formIsValid = false;
	  return false;
   }

   if (currForm.phone.value.length == 0) {
      window.alert('You need to enter a phone number.');
	  currForm.phone.focus();
	  formIsValid = false;
	  return false;
   }

   if (currForm.email.value.length == 0) {
      window.alert('You need to enter an email');
	  currForm.email.focus();
	  formIsValid = false;
	  return false;
   }
   
   if (! isValidEmail(currForm.email.value)) {
      window.alert('You need to enter a valid email');
	  currForm.email.focus();
	  formIsValid = false;
	  return false;
   } 
	
   if (currForm.email.value != currForm.email2.value) {
     window.alert('Your email addresses do not match, please retype them.');
	  currForm.email.focus();
	  formIsValid = false;
	  return false;
	}	

   if (currForm.initials.value.length == 0) {
      window.alert('You need to enter your initials');
	  currForm.initials.focus();
	  formIsValid = false;
	  return false;
   }	
	

   currForm.submit();
   return formIsValid;
}

function isValidEmail(email) {

count = 0;
Err = 0;
   
	// #1 Check for invalid characters
	// Create an arroay of invalid characters
	invChars = new Array(" ","#","$","%","!","^","~","'","*","(",")",",","<",">","/","\\");
	// Loop through Array and see if there are any matches, if yes then throw and error.
	   	for(i=0; i<invChars.length; i++) {
	   		if (email.indexOf( invChars[i]) >= 0) {
				Err = 1;
			}
	
		}

	// #2 If passed previous error step  >>> Check the @ symbol (1 instance of the symbol)
	if (Err == 0) {
	// Loop by character through the email string for the @ symbol, count the number of instances
		for ( i=0; i < email.length; i++ ) {
			if (email.charAt(i) == "@") {
				count = count + 1;
			}
		}
		// If there is not 1 instance (0 or more than 1) then throw an error.
		if ( count != 1 ) {
			Err = 2;
		}
	}


	// Split the email string by the @ sign, forming the name portion and the domain portion.
	if ( Err == 0 ) {
	splitEmail = email.split("@");
		emailName = splitEmail[0];
		emailDom = splitEmail[1];

		// #3 Verify minimum characters in name portion (minimum of 1), if not throw an error.
			if ( emailName.length < 1 ) {
				Err = 3;
			}
	
		// #4 Verify there is a . (dot) in the domain portion
			if (emailDom.indexOf(".") < 0) {
				Err = 4;
			} else {
	
		// #5 Verify a minimum of 2 characters before the dot, if not throw an error.
		// First split the domain portion by the . (dot)
			splitDom = emailDom.split(".");
				if ( splitDom[0].length < 2 ) {
					Err = 5;
				}
	
		// #6 Verify a minimum of 2 characters after the dot, if not throw an error.
				if ( splitDom[1].length < 2 ) {
					Err = 6;
				}
			}
	}
	
	// Associate the Err number into the message array for displaying results on the screen.
	ErrMess = ["Passed","Invalid character found.","Problem with the @ symbol.","Problem with the email name.","Missing the dot for the domain name.","Problem with the domain name.","Problem with the domain name extension (.com)."];
	valid = ErrMess[Err];
	return (Err == 0);
}


