$(document).ready(function () {
    
    
    //placeholder attribute fix for old browsers
    if (!Modernizr.input.placeholder) {


        $("input, textarea").each(

        function () {
            if ($(this).val() == "" && $(this).attr("placeholder") != "") {
                $(this).val($(this).attr("placeholder"));
                $(this).focus(function () {
                    if ($(this).val() == $(this).attr("placeholder")) $(this).val("");
                });
                $(this).blur(function () {
                    if ($(this).val() == "") $(this).val($(this).attr("placeholder"));
                });
            }
        });

    }   
    
    
    //form submission
    $("#emailSubmit").click(function(){       
        var email = $("input[name=email]").val();
        console.log("submitting: "+email);        
        
        var showResponse = function(response){
            $("#responseMessage").fadeOut('fast',function(){
                    $("#responseMessage").html(response);
                    $("#responseMessage").fadeIn();
                });
        }
        
        if(email.length < 1 ){
            showResponse("Please fill out the form first.");
            return false;
        }
        
        $.ajax({
            type: "POST",
            data: "email="+email,
            url: "add_email.php",
            context: document.body,
            success: showResponse
        });
        return false;
    });
    

        
});
