﻿document.observe('dom:loaded', function() {
	function sendForm(event){  
	 // we stop the default submit behaviour  
	 Event.stop(event);  
	 var oOptions = {  
		 method: "POST",  
		 parameters: Form.serialize("makeSuggestionForm"),  
		 asynchronous: true,  
		 onFailure: function (oXHR) {  
			 $('suggestionFormContainer').update(oXHR.statusText);  
		 },  
		 onLoading: function (oXHR) {  
			 $('suggestionFormContainer').update('Sending data ... <img src="../../../assets/images/loading_indicator.gif" title="Loading..." alt="Loading..." border="0" />');  
		 },                            
		 onSuccess: function(oXHR) {  
			$('suggestionFormContainer').update(oXHR.responseText);  
		 }                 
	 };  
	 var oRequest = new Ajax.Updater({success: oOptions.onSuccess.bindAsEventListener(oOptions)}, "../../../assets/include/processSuggestion.php", oOptions);             
	}  
	Event.observe('submitSuggestion', 'click', sendForm, false);  
});	
