// newsletter form.
$(function() {

	$('input.newsletter').css({backgroundColor:"#010101"});
	$('input.newsletter').focus(function() {
		$(this).css({backgroundColor:"#010101"});
	});
	$('input.newsletter').blur(function() {
		$(this).css({backgroundColor:"#010101"});
	});

	// validate and process form.
	$(".sendbutton").click(function() {
    
		var email = $("input#email").val();

		if (email == "") {
			$('input#email').focus(function() {
    		$(this).css({backgroundColor:"#FF0000",color:"#000000"});
    		});
		$("input#email").focus();
		return false;
		}
		
		var dataString = 'email=' + email;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/add2db.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Thanks for Signing Up!</h2>")
        .append("<p>You will now receive our newsletter.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='site_imgs/img_btn_check.png' />");
        });
      }
     });
     
    return false;
	});
	
});

// newsletter form 2
$(function() {

	$('input.newsletter2').css({backgroundColor:"#010101"});
	$('input.newsletter2').focus(function() {
		$(this).css({backgroundColor:"#010101"});
	});
	$('input.newsletter2').blur(function() {
		$(this).css({backgroundColor:"#010101"});
	});

	// validate and process form.
	$(".sendbutton2").click(function() {
    
		var email = $("input#email2").val();

		if (email == "") {
			$('input#email2').focus(function() {
    		$(this).css({backgroundColor:"#FF0000",color:"#000000"});
    		});
		$("input#email2").focus();
		return false;
		}
		
		var dataString = 'email=' + email;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/process.php",
      data: dataString,
      success: function() {
        $('#contact_form2').html("<div id='message2'></div>");
        $('#message2').html("<h2>Thanks for Signing Up!</h2>")
        .append("<p>You're now signed up to my mailing list.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message2').append("<img id='checkmark2' src='site_imgs/img_btn_check.png' />");
        });
      }
     });
     
    return false;
	});
	
});

// newsletter form 3
$(function() {

	$('input.newsletter3').css({backgroundColor:"#010101"});
	$('input.newsletter3').focus(function() {
		$(this).css({backgroundColor:"#010101"});
	});
	$('input.newsletter3').blur(function() {
		$(this).css({backgroundColor:"#010101"});
	});

	// validate and process form.
	$(".sendbutton3").click(function() {
    
		var email = $("input#email3").val();

		if (email == "") {
			$('input#email3').focus(function() {
    		$(this).css({backgroundColor:"#FF0000",color:"#000000"});
    		});
		$("input#email3").focus();
		return false;
		}
		
		var dataString = 'email=' + email;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/add2db.php",
      data: dataString,
      success: function() {
        $('#contact_form3').html("<div id='message3'></div>");
        $('#message3').html("<h2>Thanks for Signing Up!</h2>")
        .append("<p>You will now receive our newsletter.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message3').append("<img id='checkmark3' src='site_imgs/img_btn_check.png' />");
        });
      }
     });
     
    return false;
	});
	
});

runOnLoad(function() {
$("input#email2").select().focus();
});

