var ajaxForm = {
	
	start: function(){
		
		var forms = $$('form.ajax');
		if (forms.length){
		
			$each(forms, function(ajaxform){
			ajaxform.addEvent('submit', function(e) {
			/**
			 * Prevent the submit event
			 */
			 
			if($defined($(ajaxform.id + '_log')))
			{
 				new Event(e).stop();
 			/**
			 * This empties the log and shows the spinning indicator
			 */
				var log = $(ajaxform.id + '_log').empty().addClass('ajax-loading');
	
			/**
			 * send takes care of encoding and returns the Ajax instance.
			 * onComplete removes the spinner from the log.
			 */
	 
				new Element('input', {
    			'type': 'hidden',
    			'name': 'ajax',
    			'value': '1'
				}).injectInside(ajaxform);

				ajaxform.send({
					update: log,
					onComplete: function() {
					log.removeClass('ajax-loading');
					}
				});
			}
			});
			});
		}
	}
};

window.addEvent('domready', ajaxForm.start.bind(ajaxForm));