if (LINE == null) {
  var LINE = {};
}

LINE.forms = {
  setup: function() {
    $("input#LINE_FORM_DELETE").click(function(){
       return confirm("Are you sure you want to delete this item? This action cannot be undone");
    });
  }
}

jQuery(function() {
	/*jQuery.noConflict();*/
	jQuery('body').addClass('dynamic');
	LINE.forms.setup();
});




$(document).ready(function()
{
  /* Keepalive */

	setTimeout(LINE.keepalive.sessionSaver, LINE.keepalive.sessionSaverInterval);

	var options= {
    trimText:true,
    preFieldChangeCallback: function(originalValue) {
        /* console.log("Form field " + $(this).attr("name") + " had starting/saved value of: " + originalValue); */
				LINE.dirtyForm = true;
      },
    dirtyFieldsClass: "alteredField"
	};

	$(".certification-form form").dirtyFields(options);
	$('.submitButton').click(function() { LINE.dirtyForm = false; });
	

});

(function($)
{
  LINE.keepalive =
  {
    sessionSaverUrl: '/ping/',

    sessionSaverInterval: (60000 * 5),

    sessionSaver: function()
    {
      $.post(LINE.keepalive.sessionSaverUrl);
      setTimeout(LINE.keepalive.sessionSaver, LINE.keepalive.sessionSaverInterval);
    }
  };

	LINE.dirtyForm = false;

	window.onbeforeunload = function() {
		if (LINE.dirtyForm) {
			return 'You have made changes on this page that you have not yet saved. If you navigate away from this page you will loose your unsaved changes.\n\nTo save your changes, choose Cancel, then click the save button at the bottom of the page.';
		}
	}
	

})(jQuery);