// JavaScript Document
// Requires prototype framework v.1.6+

/* -------------------------------------------------------------------
|
|	You may want to add the following rule to your CSS. This will be
|	the style that applies only to your error messages.
|
|	.ajaxForm_error { color: red; }
|
---------------------------------------------------------------------- */

// Modify variables to suit your needs.

// Id of the div or any html element that either the success or error message should appear in.
var messageDiv = 'notify'; 
// ID of the form being submitted
var formId = 'feedback_form'; 
// Path to the form to email script
var scriptPath = 'scripts/formtoemailpro.php'; 

// No need to edit below this line
// ------------------------------------------------------------------------------------------------

function processForm(e) {
		var formValues = $(formId).serialize(true);
		new Ajax.Request(scriptPath, {
						 method: 'post',
						 parameters: formValues,
						 onSuccess: function(transport) {
							var result = transport.responseText;
							if(result.include('Thank you')) {
								$('notify').innerHTML = result;
								formId.reset();
							} else {
								$('notify').innerHTML = '<div class="ajaxForm_error">'+result+'</div>';	
							}
						 }
						 });
		e.stop();
}

document.observe("dom:loaded", function() {
	Event.observe(formId, 'submit', processForm);
									   });