// wait for the DOM to be loaded 
jQuery(document).ready(function() { 
	// bind 'myForm' and provide a simple callback function 
	jQuery('#myForm').ajaxForm( { beforeSubmit: validate } );  
	
	function validate(formData, jqForm, options) { 
 
		var form = jqForm[0]; 
		if ( !form.name.value || !form.phone.value || !form.address.value || !form.postcode.value || !form.email.value ) { 
			jQuery(form.name).css({backgroundColor:"#f8eeb6;"});
			jQuery(form.phone).css({backgroundColor:"#f8eeb6;"});
			jQuery(form.address).css({backgroundColor:"#f8eeb6;"});
			jQuery(form.postcode).css({backgroundColor:"#f8eeb6;"});
			jQuery(form.email).css({backgroundColor:"#f8eeb6;"});
			alert('Please enter the required fields.');
			return false; 
		}
		
		jQuery('#myForm').fadeOut(1250,function() {
			jQuery('#thanks').fadeIn(500);
		});
		
		return true;

	}
	
	for (i=0; i < document.forms.length; i++) {
		document.forms[i].reset();
	}
	
}); 