


function CheckSearchForm()
	{
		if ((document.RecipeSearch.drinkname.value != "") ||
				(document.RecipeSearch.ingredient.options[document.RecipeSearch.ingredient.selectedIndex].text != "") ||
				(document.RecipeSearch.drinktype.options[document.RecipeSearch.drinktype.selectedIndex].text != ""))
			return true;
		else
		{
			alert("Please choose a search criteria");
			return false;
		}
	}
	function CheckBrowseForm()
	{
		if (document.RecipeBrowse.DrinkCat.options[document.RecipeBrowse.DrinkCat.selectedIndex].text != "") {				
			return true;
		}
		else
		{
			alert("Please choose a search criteria");
			return false;
		}
	}

	function validateEmail(email) {
		invalidChars = " /:,;";
		if (email == "") {
			return false;
		}
		// checks for bad characters
		for (i = 0; i < invalidChars.length; i++) {
			badChar = invalidChars.charAt(i);
			if (email.indexOf(badChar,0) != -1) {
				return false;
			}
		}
		//finds position of @ symbol
		atPos = email.indexOf("@",1);
		if (atPos == -1) {
			return false;
		}
		if (email.indexOf("@",atPos + 1) != -1) {
			return false;
		}
		//finds position of . in email
		periodPos = email.indexOf(".",atPos);
		if (periodPos == -1) {
			return false;
		}
		if (periodPos+3 > email.length) {
			return false;
		}
		atSplit = email.split("@");
		beforeAt = atSplit[0];
		afterAt = atSplit[1];
		if (atSplit[0].length == 1) { 
			return false;
		}
		periodSplit = atSplit[1].split(".");
		beforePeriod = periodSplit[0];
		if (beforePeriod.length <=1) {
			return false;
		}
		return true;
	}

	
	function checkForm()
	{
	  if (document.form1.firstname.value == "") {
			alert("Please enter your first name.");
			document.form1.firstname.focus();
			return false;
		} else if (document.form1.lastname.value == "") {
			alert("Please enter your last name.");
			document.form1.lastname.focus();
			return false;
		} else if (document.form1.email.value == "") {
			alert("Please enter a valid e-mail address.");
			document.form1.email.focus();
			return false;
		} else if (!validateEmail(document.form1.email.value)) {
			alert("Please enter a valid e-mail address.");
			document.form1.email.focus();
			return false;
		} else if (document.form1.age.value == "") {
			alert("Please enter your age.");
			document.form1.age.focus();
			return false;
		} else if (document.form1.sex.value == "") {
			alert("Please enter your sex.");
			document.form1.sex.focus();
			return false;
		} else if (document.form1.country.value == "") {
			alert("Please enter a country.");
			document.form1.country.focus();
			return false;
		} else if ((document.form1.where.value == "") && (document.form1.other.value == "")) {
			alert("Please enter a source from which you heard about us.");
			document.form1.where.focus();
			return false;
		} else {
			return true;
		}			
	}