// JavaScript Document


function validEmail(email) {
		invalidChars = " /:,;"
		
		if(email == "") {							//can't be null
			return false
		}
		for (i=0; i<invalidChars.length; i++) {		//does it contain invalid characters?
			badChar = invalidChars.charAt(i)
			if (email.indexOf(badChar,0) > -1) {
				return false
			}
		}
		atPos = email.indexOf("@",1)				//there must be 1 @ symbol
		if (atPos == -1) {
			return false
		}
		if (email.indexOf("@",atPos+1) != -1) {		//and only 1 @ symbol
			return false
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) {						//at least 1 "." after the @
			return false
		}
		if (periodPos+3 > email.length) {			//at least 2 characters after "."
			return false
		}
		
		return true
	}


function submitIt(contactForm) {
	
	
		//Check for Celebrity Name
		if (contactForm.celebName.value =="") {
			alert("Please enter the celebrity name.")
			document.contactForm.celebName.focus();
			return false
		}
		
		
		//Check for restaurant
		if (contactForm.restaurant.value =="") {
			alert("Please enter the restaurant.")
			document.contactForm.restaurant.focus();
			return false
		}
		
		//Check for approx date
		if (contactForm.approxDate.value =="") {
			alert("Please enter the approximate date.")
			document.contactForm.approxDate.focus();
			return false
		}
		
		//Check for your name
		if (contactForm.yourName.value =="") {
			alert("Please enter your name.")
			document.contactForm.yourName.focus();
			return false
		}
		
		//Validate email
		if(!validEmail(contactForm.yourEmail.value)) {
			alert("You have entered an invalid email address")
			document.contactForm.yourEmail.focus();
			return false
		}
		

			return true
		}