<!--//

	// create the validator
	var v = new Validator();


	// validate the contact form
	function validateForm() {

		/**
		 * I think this can probably be extended to setup observors, etc, 
		 *  - Validator.observe('formsbumit', validator.runAll()
		 *  - Validator.observe('firstname', 'onkeyup', validator.validate(firstname))
		 */
		v.clearAll();
		
		v.validate('name', new Array({type:'required', text:'Please enter your firstname'}));
		v.validate('company', new Array({type:'required', text:'Please enter your company name '}));
		v.validate('email', new Array({type:'required', text: 'Please enter your email address'}, {type:'email', text: 'Your email address is in an invalid format'}));
		v.validate('enquiry', new Array({type:'required', text:'Please enter your enquiry'}));

		// if have any messages
		if(!v.hasMsgs('ERROR')) {
		
			// all good - we validted
			var url = WWW_ROOT + "/contact/form.html";

			// show the spinner
			$('submitSpinner').show();
					
			new Ajax.Request(url, {
				method: 'post',
				parameters: {
					fa: 'ajax_submit', 
					name: $F('name'), 
					company: $F('company'),
					email: $F('email'), 
					phone: $F('phone'), 
					enquiry: $F('enquiry')
				}, 
				
				onSuccess: function (transport) {
					if (transport.responseText == 'OK') {
						$('generalEnquiryForm').hide();
						$('submitRow').hide();
						$('submitSpinner').hide();
						Effect.Appear('contactSuccess', {duration: 0.3, queue: {position: 'end', scope: 'queue'}});
					} else {
						$('submitSpinner').hide();
						Effect.Appear('contactError', {duration: 0.3, queue: {position: 'end', scope: 'queue'}});
					}
				},
					
				onFailure: function () {},				
				onException: function (requestObj, ex) {alert(ex.Message)}
			});	
		}

		// 
		return false;
	}
//-->
