/* EMAIL FORM VALIDATIONS
*******************************************************************/

/* FORM: CAR RENTAL
*******************************************************************/

function validCRForm(car_rental){
	
	var problem = false;  // Flag variable
	var invalidChars = " /:,;"; //The characters don't belong in a valid email address			
			
		// Validate the first name
		if (car_rental.senders_first_name.value == ""){
			alert ("Please enter your first name.");
			car_rental.senders_first_name.value = "*** FIRST NAME";
			car_rental.senders_first_name.focus();
			problem = true;
		}
		
		// Validate the last name
		if (car_rental.senders_last_name.value == ""){
			alert ("Please enter your last name.");
			car_rental.senders_last_name.value = "*** LAST NAME";
			car_rental.senders_last_name.focus();
			problem = true;
		}
		
				// Validate the pick up time
		if (car_rental.pickuptime.value == ""){
			alert ("Please enter your pick up time.");
			car_rental.pickuptime.value = "*** PICKUP TIME";
			car_rental.pickuptime.focus();
			problem = true;
		}
		
						// Validate the drop time
		if (car_rental.dropofftime.value == ""){
			alert ("Please enter your drop off time.");
			car_rental.dropofftime.value = "*** DROP OFF TIME";
			car_rental.dropofftime.focus();
			problem = true;
		}
		
		
		// Validate the email address
			
			//You must enter something
			if (car_rental.senders_email.value == ""){
				alert("Please enter your email address!");
				car_rental.senders_email.value = "*** EMAIL ADDRESS";
				car_rental.senders_email.focus();
				problem = true;
			}
			
			// There must be something BEFORE the at sign 
			if (car_rental.senders_email.value.indexOf("@", 0) == 0){
				alert("No username in email address!");
				problem = true;
			}
			
			// There must be an at sign at, or after, the second character
			if (car_rental.senders_email.value.indexOf("@", 1) == -1){
				alert("No @ sign in email address!");
				problem = true;
			}
			
			// There must be a period somewhere 
			if (car_rental.senders_email.value.indexOf(".", 0) == -1){
				alert("No period in email address!");
				problem = true;
			}
			
			// Check for invalid characters
			for (i=0; i<invalidChars.length; i++){
				if (car_rental.senders_email.value.indexOf(invalidChars.charAt(i), 0) > -1){
					alert("Bad character(s) in email address!", invalidChars.charAt(i), i); 
					problem = true;
				}
			} 
					
		
		// return true/false based upon problem
		if(problem){
			return false;
		} else{
			return true;
		}	

};// end of function request showing definition



/* FORM: CONTACT US
*******************************************************************/

function validCBForm(contact_Bonaire){
	
	var problem = false;  // Flag variable
	var invalidChars = " /:,;"; //The characters don't belong in a valid email address
			
		// Validate the first name
		if (contact_Bonaire.senders_first_name.value == ""){
			alert ("Please enter your first name.");
			contact_Bonaire.senders_first_name.value = "*** FIRST NAME";
			contact_Bonaire.senders_first_name.focus();
			problem = true;
		}
		
		// Validate the last name
		if (contact_Bonaire.senders_last_name.value == ""){
			alert ("Please enter your last name.");
			contact_Bonaire.senders_last_name.value = "*** LAST NAME";
			contact_Bonaire.senders_last_name.focus();
			problem = true;
		}
		
		// Validate the email address
			
			//You must enter something
			if (contact_Bonaire.senders_email.value == ""){
				alert("Please enter your email address!");
				contact_Bonaire.senders_email.value = "*** EMAIL ADDRESS";
				contact_Bonaire.senders_email.focus();
				problem = true;
			}
			
			// There must be something BEFORE the at sign 
			if (contact_Bonaire.senders_email.value.indexOf("@", 0) == 0){
				alert("No username in email address!");
				problem = true;
			}
			
			// There must be an at sign at, or after, the second character
			if (contact_Bonaire.senders_email.value.indexOf("@", 1) == -1){
				alert("No @ sign in email address!");
				problem = true;
			}
			
			// There must be a period somewhere 
			if (contact_Bonaire.senders_email.value.indexOf(".", 0) == -1){
				alert("No period in email address!");
				problem = true;
			}
			
			// Check for invalid characters
			for (i=0; i<invalidChars.length; i++){
				if (contact_Bonaire.senders_email.value.indexOf(invalidChars.charAt(i), 0) > -1){
					alert("Bad character(s) in email address!", invalidChars.charAt(i), i); 
					problem = true;
				}
			} 
					
		
		// return true/false based upon problem
		if(problem){
			return false;
		} else{
			return true;
		}	

};// end of function request showing definition



