$(function() {
  $('.error').hide();                   // hides error messages 
//  $("input#name").select().focus();     // on load focus on top of contact form 

  $(".button").click(function() 
  {
    var rc = true;
    $('.error').hide();                 
    
    // Validate required feild email 
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      rc = false;
    }
    
    // Validate required feild name - validating this 2nd because I'd prefer to focus on this 	
	  var name = $("input#name").val();
		if (name == "") {
      $("label#name_error").show();
      $("input#name").focus();
      rc = false;
    }
    
    if( rc == true )
		{
		  var weddingdate = $("input#weddingdate").val(); 
		  var dataString = 'name='+ name + '&email=' + email + '&weddingdate=' + weddingdate;
		  //alert (dataString);//return false;          // used for testing 
		  
		  $.ajax({
        type: "POST",
        url: "bin/sendmail_mini.php",
        data: dataString,
        success: function() {
          $('#contactform_mini').html("<div id='message_mini'></div>");
          $('#message_mini').html("<h2>Contact Form Submitted</h2>")
          .append("<p>We will be in touch soon.</p>")
          .hide()
          .fadeIn(1500, function() {
            $('#message_mini').append("<img id='checkmark_mini' src='images/check.png' />");
          });
        }
       });
      rc = false;
    }
    return rc;
	});
});
