function isValidEmail(strEmail){
  	if(strEmail != ""){
    	validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
   		// search email text for regular exp matches
    	if (strEmail.search(validRegExp) == -1){
      		return 0;
   		} 
     	return 1; 
  	}
}

function checkForm(searchform){
	if (searchform.words.value == ""){
		alert("Please enter some words to search our recipe database for.")
		return false;
	}
}

function changeCat(){
	var current = document.category.categories.selectedIndex;

	if(document.category.categories.options[current].value == -1){
		alert("You must select a real category from the dropdown menu to continue.")
		document.category.categories.focus();
		return false;
	}
}

function changeCuisine(){
	var current = document.cuisine.categories.selectedIndex;

	if(document.cuisine.categories.options[current].value == -1){
		alert("You must select a real cuisine from the dropdown menu to continue.")
		document.cuisine.categories.focus();
		return false;
	}
}

function novalues(addform){
	var goodEmail = addform.email.value
        checkEmail = isValidEmail(goodEmail)
        if(checkEmail == 0){
          alert('A valid e-mail address is required.\nPlease amend and retry');
          document.addform.email.focus();
	  return false;
        }
        
        if (addform.recipename.value == ""){
		alert("You must enter a title in the title field. Your recipe cannot be saved without a title.")
		document.addform.recipename.focus();
		return false;
	}

	if (addform.instructions.value == ""){
		alert("You must enter some cooking instructiona in the instructions field. Without a instructions your recipe cannot be saved.")
		document.addform.instructions.focus();
		return false;
	}
            if (addform.spamImageTheme.value == -1){
		alert("Please select an image theme.")
		document.addform.spamImageTheme.focus();
		return false;
	   }
        
}

function check4name(){
	if(document.catform.catname.value == ""){
		alert("Please enter a name for the category you would like to create")
		document.catform.catname.focus();
		return false;
	}
}


