function clearCommentErrors(arr, form) {
  $('#dacommentform .error').html('');
  form.find('.submit-post').attr("disabled", "disabled");
};

function processNewComment(data, statusText, xhr, formParam) {
  var form = $('#dacommentform');
  if (!data.errors) {
    $("#comment_form_box").children().slideUp('slow', function() {
      $('#comment_form_box').html("<div class=\"message\">Thank you for your comment.  It will appear on the site in the fullness of time.</div>").slideDown('slow');
    });
  } else {
    $.each(data.errors, function(i, val) {
      var tmp = $('#dacommentform #error_' + i);
      tmp.html(val.join('&nbsp; '));
    });
    form.find('.submit-post').removeAttr("disabled");
  }
};

$(function() {
  var opts = {
    dataType: 'json',
    beforeSubmit: clearCommentErrors,
    type: 'PUT',
    success: processNewComment
  };
  $('#dacommentform').ajaxForm(opts);
});
				
$(document).ready(function() {
  if (!Modernizr.input.placeholder) {
    $("input").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"));
         }
      });
    }
  });
}


});

