$(function() {
    // gather all the textareas and input fields
    var fields = $("textarea,input[type=text]");
    
    fields.each(function(i) {
        var $me = $(this);
        var $label = $($me.siblings("label")[0]);

        if(!$me.val() || $me.val() === $label.html()) {          
            $me.val($label.html());          
            $me.peekABooField({"class": "editing"});
        } else {          
            $me.addClass("editing");
        }
        $label.hide();
    });

    $("#contact-form").submit(function(e) {
        fields.each(function(i) {
            var $me = $(this);
            var $label = $($me.siblings("label")[0]);

            if($me.val() === $label.html()) {
                $me.val('');
            }            
        });
    });
   
});