// JavaScript Document

	function ValidateContactForm(){
		var errors = "";
		if($('Name').value.length == 0){
			errors += "Name\n";
		}
		if(!/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test($('Email').value)){
			errors += "Email\n";
		}
		if($('Message').value.length == 0){
			errors += "Message\n";
		}
		
		return errors;
	}

	function SubmitContactForm(){
		var errors = ValidateContactForm();
		if(errors.length == 0){
			var opts = {
			    // Use POST
			    method: 'post',
			    // Send this data
			    postBody: 'name='+$('Name').value+"&email="+$('Email').value+"&company="+$('Company').value+"&phone="+$('Phone').value+"&message="+$('Message').value,
			    // Handle successful response
			    onSuccess: function(t){
				   $('contactFormResult').innerHTML = "Thank you. Your message has been sent successfully. Someone will be in touch soon.<br />";
				   new Effect.Fade('contactFormResult', {duration: 7});
				   new Effect.Highlight('contactFormResult', {duration: 5});
			    },
			    // Handle 404
			    on404: function(t) {
				   alert('Error 404: location "' + t.statusText + '" was not found.');
			    },
			    // Handle other errors
			    onFailure: function(t) {
				   $('contactFormResult').innerHTML = t.status + ' -- ' + t.statusText;
			    }
			}
			new Ajax.Updater("sendContactForm", '/process.php', opts);
		}else{
			alert("Sorry, there was a problem sending your message. Please make sure \nyou have completed the following fields:\n\n"+errors);
		}
	}// JavaScript Document