// Regualr Expressions For Form
var fullNameRE = /^\w{1,}([ ])\w{1,}$/;
var emailRE = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
var telephoneRE = /\([0-9]{3}\)[0-9]{3}-[0-9]{4}/;
var phone2 = /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/; 
var phone3 = /^(\d{3})-(\d{3})-(\d{4})$/;
var zipCodeRE = /^(\d{5}-\d{4})|(\d{5})$/;


var regExLookUpTable = new Array();
	regExLookUpTable.push(null);
	regExLookUpTable.push(emailRE);
	regExLookUpTable.push(phone3);

// Setting Up Alerts For User //
var noFillAlertStart = "Please enter a value for the field labeled";
var validationAlertArray = new Array();
	validationAlertArray.push("Please enter valid name address.");
	validationAlertArray.push("Please enter valid email address.");
	validationAlertArray.push("Please enter valid phone number. (i.e. xxx-xxx-xxxx)");

function validate(me){
	
	
	
	pickupL = document.getElementById("additionalInfo");
	var theCurrStyle = pickupL.style.display
	if(theCurrStyle == "block"){
		if(document.reservations.pickupAddress.value == ""){ alert("What is your pickup address?"); return false; }
		if(document.reservations.dropoffAddress.value == ""){ alert("What is your drop off address?"); return false; }
	}
	
	
	
	
	
	var myDate=new Date();
	
	var selectedDate = document.reservations.ReservationDate_day.value;
	var selectedYear = document.reservations.ReservationDate_year.value;
	var selectedMonth = document.reservations.ReservationDate_month.value
	var selectedMonth2 = 0;
	var selectedYear2 = 0;
		if (selectedMonth == "January") {
			selectedMonth2 = 1;
		}
		if (selectedMonth == "February") {
			selectedMonth2 = 2;
		}
		if (selectedMonth == "March") {
			selectedMonth2 = 3;
		}
		if (selectedMonth == "April") {
			selectedMonth2 = 4;
		}
		if (selectedMonth == "May") {
			selectedMonth2 = 5;
		}
		if (selectedMonth == "June") {
			selectedMonth2 = 6;
		}
		if (selectedMonth == "July") {
			selectedMonth2 = 7;
		}
		if (selectedMonth == "August") {
			selectedMonth2 = 8;
		}
		if (selectedMonth == "September") {
			selectedMonth2 = 9;
		}
		if (selectedMonth == "October") {
			selectedMonth2 = 10;
		}
		if (selectedMonth == "November") {
			selectedMonth2 = 11;
		}
		if (selectedMonth == "December") {
			selectedMonth2 = 12;
		}
		
		if (selectedYear == "2007") {
			selectedYear2 = 107;
		}
	
	var theDate = myDate.getDate();
	var theYear = myDate.getYear();
	var theMonth = myDate.getMonth() + 1;
	if (selectedYear2 == theYear) {
			
			if (selectedMonth2 < theMonth) {
				alert("Please select a date that occurs on or after today's");
				return (false);
			}
			
			if (selectedMonth2 == theMonth) {
				if (selectedDate < theDate) {
					alert("Please select a date that occurs on or after today's");
					return (false);
				}
			}
		}
	
	var theTotalElements = 2;
	for (i = 0; i <= theTotalElements; i++) {
		var theElementName = me.elements[i].name;
		var theElementValue = me.elements[i].value;
		var theElementTitle = '"' + me.elements[i].title + '"';
		
		if(theElementValue == "") {
			alert(noFillAlertStart + " " + theElementTitle);
			return(false);
		}else{
			var theRegEx = regExLookUpTable[i];
			if(theRegEx != null){
				alert(theElementValue);
				if(!theRegEx.test(theElementValue)){
					alert(validationAlertArray[i]);
					return(false);
				}
			}
		}
	}

	er = "You must include:\n";
	if (document.reservations.phone.value == "") {er = er + " - Phone Number\n";}
	if (document.reservations.pickup.value == "") {er = er + " - A Pickup Location\n";}
	if (document.reservations.dropoff.value == "") {er = er + " - A Drop Off Location\n";}
	if (document.reservations.ReservationDate_month.value == "") {er = er + " - The Month\n";}
	if (document.reservations.ReservationDate_day.value == "") {er = er + " - The Day\n";}
	if (document.reservations.ReservationDate_year.value == "") {er = er + " - The Year\n";}
	if (document.reservations.ReservationDate_hour.value == "") {er = er + " - The Time\n";}
	if (document.reservations.number.value == "") {er = er + " - Enter the image in the string\n";}
	if (er != "You must include:\n") {
		alert(er);
		return false;
	}
	
	
	
  return(true);
}






/*function validate() {
		er = "You must include:\n";
		if (document.reservations.name.value == "") {er = er + " - Full Name\n";}
		if (document.reservations.email.value == "") {er = er + " - Email Address\n";}
		if (document.reservations.phone.value == "") {er = er + " - Phone Number\n";}
		if (document.reservations.pickup.value == "") {er = er + " - A Pickup Location\n";}
		if (document.reservations.dropoff.value == "") {er = er + " - A Drop Off Location\n";}
		if (document.reservations.ReservationDate_month.value == "") {er = er + " - The Month\n";}
		if (document.reservations.ReservationDate_day.value == "") {er = er + " - The Day\n";}
		if (document.reservations.ReservationDate_year.value == "") {er = er + " - The Year\n";}
		if (document.reservations.ReservationDate_hour.value == "") {er = er + " - The Time\n";}
		if (er != "You must include:\n") {
			alert(er);
			return false;
			}
	}*/

