/* EMAIL FORM VALIDATIONS
*******************************************************************/

/* FORM: REQUEST SHOWING
*******************************************************************/

function validRSForm(request_showing){
	
	var problem = false;  // Flag variable
	var invalidChars = " /:,;"; //The characters don't belong in a valid email address
			
		// Validate the first name
		if (request_showing.first_name.value == ""){
			alert ("Please enter your first name.");
			request_showing.first_name.value = "*** FIRST NAME";
			request_showing.first_name.focus();
			problem = true;
		}
		
		// Validate the last name
		if (request_showing.last_name.value == ""){
			alert ("Please enter your last name.");
			request_showing.last_name.value = "*** LAST NAME";
			request_showing.last_name.focus();
			problem = true;
		}
		
		// Validate the email address
			
			//You must enter something
			if (request_showing.email.value == ""){
				alert("Please enter your email address!");
				request_showing.email.value = "*** EMAIL ADDRESS";
				request_showing.email.focus();
				problem = true;
			}
			
			// There must be something BEFORE the at sign 
			if (request_showing.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 (request_showing.email.value.indexOf("@", 1) == -1){
				alert("No @ sign in email address!");
				problem = true;
			}
			
			// There must be a period somewhere 
			if (request_showing.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 (request_showing.email.value.indexOf(invalidChars.charAt(i), 0) > -1){
					alert("Bad character(s) in email address!", invalidChars.charAt(i), i); 
					problem = true;
				}
			} 
					
		// Validate the phone number
		if (request_showing.phone.value == ""){
			alert ("Please enter your phone number.");
			request_showing.phone.value = "*** PHONE NUMBER";
			request_showing.phone.focus();
			problem = true;
		}
		
		// Validate the best time to call
		if ((request_showing.best_time.selectedIndex == 0) || (request_showing.best_time.value == 0)) {
			alert ("Please select the best time to contact you.");
			problem = true;
		}
		
		// Validate how you heard about RMB
		if ((request_showing.hear_about_RMB.selectedIndex == 0) || (request_showing.hear_about_RMB.value == 0)) {
			alert ("Please select how you heard about RMBI.");
			problem = true;
		}
		
		// return true/false based upon problem
		if(problem){
			return false;
		} else{
			return true;
		}	

};// end of function request showing definition




/* FORM: REQUEST MORE INFO
*******************************************************************/
function validRMIForm(request_more_info){
	
	var problem = false;  // Flag variable
	var invalidChars = " /:,;"; //The characters don't belong in a valid email address
			
		// Validate the first name
		if (request_more_info.first_name.value == ""){
			alert ("Please enter your first name.");
			request_more_info.first_name.value = "*** FIRST NAME";
			request_more_info.first_name.focus();
			problem = true;
		}
		
		// Validate the last name
		if (request_more_info.last_name.value == ""){
			alert ("Please enter your last name.");
			request_more_info.last_name.value = "*** LAST NAME";
			request_more_info.last_name.focus();
			problem = true;
		}
		
		// Validate the email address
			
			//You must enter something
			if (request_more_info.email.value == ""){
				alert("Please enter your email address!");
				request_more_info.email.value = "*** EMAIL ADDRESS";
				request_more_info.email.focus();
				problem = true;
			}
			
			// There must be something BEFORE the at sign 
			if (request_more_info.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 (request_more_info.email.value.indexOf("@", 1) == -1){
				alert("No @ sign in email address!");
				problem = true;
			}
			
			// There must be a period somewhere 
			if (request_more_info.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 (request_more_info.email.value.indexOf(invalidChars.charAt(i), 0) > -1){
					alert("Bad character(s) in email address!", invalidChars.charAt(i), i); 
					problem = true;
				}
			} 
					
		// Validate the phone number
		if (request_more_info.phone.value == ""){
			alert ("Please enter your phone number.");
			request_more_info.phone.value = "*** PHONE NUMBER";
			request_more_info.phone.focus();
			problem = true;
		}
		
		// Validate the best time to call
		if ((request_more_info.best_time.selectedIndex == 0) || (request_more_info.best_time.value == 0)) {
			alert ("Please select the best time to contact you.");
			problem = true;
		}
		
		// Validate how you heard about RMB
		if ((request_more_info.hear_about_RMB.selectedIndex == 0) || (request_more_info.hear_about_RMB.value == 0)) {
			alert ("Please select how you heard about RMBI.");
			problem = true;
		}
		
		// return true/false based upon problem
		if(problem){
			return false;
		} else{
			return true;
		}	

};// end of function request more info definition
	




/* FORM: EMAIL FRIEND
*******************************************************************/
function validEFForm(email_friend){
	
	var problem = false;  // Flag variable
	var invalidChars = " /:,;"; //The characters don't belong in a valid email address
	
		// Validate the recipient's first name
		if (email_friend.recipient_first_name.value == ""){
			alert ("Please enter your friends's first name.");
			email_friend.recipient_first_name.value = "*** FRIEND'S FIRST NAME";
			email_friend.recipient_first_name.focus();
			problem = true;
		}
		
		// Validate the recipient's last name
		if (email_friend.recipient_last_name.value == ""){
			alert ("Please enter your friend's last name.");
			email_friend.recipient_last_name.value = "*** FRIEND'S LAST NAME";
			email_friend.recipient_last_name.focus();
			problem = true;
		}
		
		// Validate the recipient's email address
			
			//You must enter something in recipient's email
			if (email_friend.recipient_email.value == ""){
				alert("Please enter your friend's email address!");
				email_friend.recipient_email.value = "*** FRIEND'S EMAIL ADDRESS";
				email_friend.recipient_email.focus();
				problem = true;
			}
			
			// There must be something BEFORE the at sign in recipient's email 
			if (email_friend.recipient_email.value.indexOf("@", 0) == 0){
				alert("No username in your friend's email address!");
				problem = true;
			}
			
			// There must be an at sign at, or after, the second character in recipient's email
			if (email_friend.recipient_email.value.indexOf("@", 1) == -1){
				alert("No @ sign in your friend's email address!");
				problem = true;
			}
			
			// There must be a period somewhere in recipient's email 
			if (email_friend.recipient_email.value.indexOf(".", 0) == -1){
				alert("No period in your friends email address!");
				problem = true;
			}
			
			// Check for invalid characters in in recipient's email
			for (i=0; i<invalidChars.length; i++){
				if (email_friend.recipient_email.value.indexOf(invalidChars.charAt(i), 0) > -1){
					alert("Bad character(s) in your friend's email address!", invalidChars.charAt(i), i); 
					problem = true;
				}
			} 
				
		// Validate the sender's first name
		if (email_friend.sender_first_name.value == ""){
			alert ("Please enter your first name.");
			email_friend.sender_first_name.value = "*** YOUR FIRST NAME";
			email_friend.sender_first_name.focus();
			problem = true;
		}
		
		// Validate the sender's last name
		if (email_friend.sender_last_name.value == ""){
			alert ("Please enter your last name.");
			email_friend.sender_last_name.value = "*** YOUR LAST NAME";
			email_friend.sender_last_name.focus();
			problem = true;
		}
		
		// Validate the sender's email address
			
			//You must enter something in sender's email
			if (email_friend.sender_email.value == ""){
				alert("Please enter your email address!");
				email_friend.sender_email.value = "*** YOUR EMAIL ADDRESS";
				email_friend.sender_email.focus();
				problem = true;
			}
			
			// There must be something BEFORE the at sign in sender's email 
			if (email_friend.sender_email.value.indexOf("@", 0) == 0){
				alert("No username in your email address!");
				problem = true;
			}
			
			// There must be an at sign at, or after, the second character in sender's email
			if (email_friend.sender_email.value.indexOf("@", 1) == -1){
				alert("No @ sign in your email address!");
				problem = true;
			}
			
			// There must be a period somewhere in sender's email 
			if (email_friend.sender_email.value.indexOf(".", 0) == -1){
				alert("No period in your email address!");
				problem = true;
			}
			
			// Check for invalid characters in in sender's email
			for (i=0; i<invalidChars.length; i++){
				if (email_friend.sender_email.value.indexOf(invalidChars.charAt(i), 0) > -1){
					alert("Bad character(s) in your email address!", invalidChars.charAt(i), i); 
					problem = true;
				}
			} 
		
		// return true/false based upon problem
		if(problem){
			return false;
		} else{
			return true;
		}	
			
};// end of function email friend definition

/* FORM: Contact RMB
*******************************************************************/
function validCRMBForm(contact_RMB){
	
	var problem = false;  // Flag variable
	var invalidChars = " /:,;"; //The characters don't belong in a valid email address
	
		// Validate the first name
		if (contact_RMB.first_name.value == ""){
			alert ("Please enter your first name.");
			contact_RMB.first_name.value = "*** FIRST NAME";
			contact_RMB.first_name.focus();
			problem = true;
		}
		
		// Validate the last name
		if (contact_RMB.last_name.value == ""){
			alert ("Please enter your last name.");
			contact_RMB.last_name.value = "*** LAST NAME";
			contact_RMB.last_name.focus();
			problem = true;
		}
		
		// Validate the email address
			
			//You must enter something
			if (contact_RMB.email.value == ""){
				alert("Please enter your email address!");
				contact_RMB.email.value = "*** EMAIL ADDRESS";
				contact_RMB.email.focus();
				problem = true;
			}
			
			// There must be something BEFORE the at sign 
			if (contact_RMB.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_RMB.email.value.indexOf("@", 1) == -1){
				alert("No @ sign in email address!");
				problem = true;
			}
			
			// There must be a period somewhere 
			if (contact_RMB.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_RMB.email.value.indexOf(invalidChars.charAt(i), 0) > -1){
					alert("Bad character(s) in email address!", invalidChars.charAt(i), i); 
					problem = true;
				}
			} 
					
		// Validate the phone number
		if (contact_RMB.phone.value == ""){
			alert ("Please enter your phone number.");
			contact_RMB.phone.value = "*** PHONE NUMBER";
			contact_RMB.phone.focus();
			problem = true;
		}
		
		// Validate how you heard about RMB
		if ((contact_RMB.hear_about_RMB.selectedIndex == 0) || (contact_RMB.hear_about_RMB.value == 0)) {
			alert ("Please select how you heard about RMBI.");
			problem = true;
		}
		
		// return true/false based upon problem
		if(problem){
			return false;
		} else{
			return true;
		}	
			
};// end of function contact RMB definition

	
/* FORM: redirect to Thank You Pop Up
*******************************************************************/
	
	
	