$(function() {
  $('.error').hide();

  $(".button").click(function() {
	// validate and process form
	// first hide any error messages
    $('.error').hide();
	var email = $("input#email").val();
	if (email == "") {
		$("#email_error").show();
		$("input#email").focus();
		return false;
    }
	var dataString = 'email=' + email;
	//alert (dataString);return false;
		
	$.ajax({
      type: "POST",
      url: "inc/newsletter_process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<img id='checkmark' src='images/check.png' style='float:right; margin-top:2px; margin-right:2px' /><h4>Newsletter signup!</h4>")
        .append("<p style='font-size:11px; line-height:14px'>Thank you. Your subscription request will be confirmed to you by email.</p>")
        .hide()
        .fadeIn(1500);
      }
     });
    return false;
	});
	
// POPUP form start
  $('.error').hide();
  $(".popupbutton").click(function() {
	// validate and process form
	// first hide any error messages
    $('.error').hide();
	var popemail = $("input#popemail").val();
	if (popemail == "") {
		$("#popemail_error").show();
		$("input#popemail").focus();
		return false;
    }
	var dataString = 'email=' + popemail;
	//alert (dataString);return false;
		
	$.ajax({
      type: "POST",
      url: "inc/newsletter_process.php",
      data: dataString,
      success: function() {
        $('#popcontact_form').html("<div class='message'></div>");
        $('.message').html("<img id='checkmark' src='images/check.png' style='float:right; margin-top:2px; margin-right:2px' /><h4>Newsletter signup!</h4>")
        .append("<p style='font-size:11px; line-height:14px'>Thank you. Your subscription request will be confirmed to you by email.</p>")
        .hide()
        .fadeIn(1500);
      }
     });
    return false;
	});	
// POPUP form END
	
});


