// buttonAction.js
// Author: Simon, Paul
// JS Dependencies: scriptaculous and prototype.

// When the page loads enable the submit button.
Event.observe(window, 'load', function() {

	// Deal with lack of 'console' object (e.g. IE)
	if(window['console'] === undefined)
        window.console = { log: Prototype.emptyFunction };

	//set all buttons to be enabled
	$$('form input[type="submit"]').each(
	    function(btn) {
		    btn.enable();
		}
	);
	
	// Modify all forms to avoid multiple submits
	$$('form').each(
        function(item) {
	        console.log('Form having submit event added.');
            item.observe('submit', function(event) {
			    console.log('Form submitted. Disabling all submit buttons.');
				$$('form input[type="submit"]').each(
				    function(btn) {
					    btn.disable();
					}
				);
			});
        }
    );
});


