// This function is for the menus in the drinks.php file (drinks.php)
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// This function is going to check that the required fields are not empty and the email should be a valid email
// This is used in the Submit Drink Recipe (submit_drink.php)
function checkSubmit( myForm )
{
    // This checks to make sure you add a drink name
    if( myForm.drinkName.value == "" )
	  {
		    alert( "Please Enter A Drink Name!" );
		    myForm.drinkName.focus();
		    myForm.drinkName.select();
		    return false
	  }
		// This checks to make sure you add the ingredients
		if( myForm.ingredients.value == "" )
	  {
		    alert( "Please Enter The Ingredients!" );
		    myForm.ingredients.focus();
		    myForm.ingredients.select();
		    return false
	  }
		// This checks to make sure you add the instructions
		if( myForm.instructions.value == "" )
	  {
		    alert( "Please Enter The Instructions!" );
		    myForm.instructions.focus();
		    myForm.instructions.select();
		    return false
	  }
		// This checks to make sure you add a category
		if( myForm.category.value == "" )
	  {
		    alert( "Please Select A Category!" );
		    myForm.category.focus();		    
		    return false
	  }
		// This checks to make sure you add a glass
		if( myForm.glass.value == "" )
	  {
		    alert( "Please Select A Glass!" );
		    myForm.glass.focus();		   
		    return false
	  }
	  
	  // This is going to check that you answered the question
	  if( myForm.question.value == "" )
	  {
		    alert( "Please Answer the Question!" );
		    myForm.question.focus();
		    myForm.question.select();
		    return false;
	  }	
		
    // This is going to check that the email is a valid email
  	re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	  // If the email address field is not empty make sure it is a valid email
	  if( myForm.email.value != "" )
	  {
		    // If the email address is valid do nothing
		    if( re.test( myForm.email.value ) ) 
		    {
		        // Do nothing
		    }
				else
				{
				    alert( "Invalid Email Address!\n\nExample: user@provider.com\n\nMake sure there are no spaces" );
			      	myForm.email.focus();
			      	myForm.email.select();
			      	return false
				}
	  }	  
		
		// Everything when OK
		return true;
}

// This checks that the form is complete (email_recipe.php)
function checkEmailRecipe( myForm )
{
	// This is going to check that the email is a valid email
  	re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	
	// The email should not be empty
	if( myForm.recipient.value == "" )
	{
		alert( "Please Enter a Recipient's Email!" );
		myForm.recipient.focus();
		myForm.recipient.select();
		return false
	}
	
	// If the email address field is not empty make sure it is a valid email
	if( myForm.recipient.value != "" )
	{
		// If the email address is valid do nothing
		if( re.test( myForm.recipient.value ) ) 
		{
			// Do nothing
		}
		else
		{
			alert( "Invalid Email Address!\n\nExample: user@provider.com\n\nMake sure there are no spaces" );
			myForm.recipient.focus();
			myForm.recipient.select();
			return false
		}
	}	
	  
	// This makes sure there is a sender's name
	if( myForm.name.value == "" )
	{
		    alert( "Please Enter Your Name!" );
		    myForm.name.focus();
		    myForm.name.select();
		    return false
	}
	
	// The email should not be empty  
	if( myForm.email.value == "" )
	{
		alert( "Please Enter Your Email!" );
		myForm.email.focus();
		myForm.email.select();
		return false
	}
	  
	  // If the email address field is not empty make sure it is a valid email
	if( myForm.email.value != "" )
	{	
		// If the email address is valid do nothing
		if( re.test( myForm.email.value ) ) 
		{
			// Do nothing
		}
		else
		{
			alert( "Invalid Email Address!\n\nExample: user@provider.com\n\nMake sure there are no spaces" );
			myForm.email.focus();
			myForm.email.select();
			return false
		}
	}	
	  
	// This is going to check that you answered the question
	if( myForm.question.value == "" )
	{
		alert( "Please Answer the Question!" );
		myForm.question.focus();
		myForm.question.select();
		return false;
	}
	
	// This checks to make sure that the email used in the recipient is not the same as the sender
	if( myForm.recipient.value == myForm.email.value )
	{
		alert( "The Recipient's Email is the same as Your Email!" );
		myForm.email.focus();
		myForm.email.select();
		return false;
	}
	
	// Everything when OK
    return true;
}