// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

jQuery.ajaxSetup({
    'beforeSend': function(xhr) { xhr.setRequestHeader("Accept", "text/javascript") }
})

jQuery.fn.submitWithAjax = function() {
  this.submit(function() {
    $.post(this.action + ".js", $(this).serialize(), null, "script")
    return false;
  })
  return this;
};

$(function() {
  $("#new_todo").submitWithAjax();
  $("#notice").hide().fadeIn(3000).fadeOut(5000);

  $('.js-warning').remove();
  if ($("#timed-comment-form").length > 0) {
    $.get("/contact/token", function(txt) {
      $("#timed-comment-form").append("<input type=\"hidden\" name=\"ts\" value=\""+txt+"\" />");
    });
  }
});
