jQuery(document).ready(function($) {

	$('form#contactForm').submit(function() {

		$('form#contactForm .error').remove();

		var hasError = false;

		$('.requiredField').each(function() {

			if(jQuery.trim($(this).val()) == '') {

				var labelText = $(this).prev('label').text();

				$(this).parent().append('<span class="error">Please enter your '+labelText+'.</span>');

				hasError = true;

			} else if($(this).hasClass('email')) {

				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

				if(!emailReg.test(jQuery.trim($(this).val()))) {

					var labelText = $(this).prev('label').text();

					$(this).parent().append('<span class="error">You entered an invalid '+labelText+'.</span>');

					hasError = true;

				}

			}

		});

		if(!hasError) {			

			var formInput = $(this).serialize();

			$.post($(this).attr('action'),formInput, function(data){

				$('form#contactForm').slideUp("fast", function() {				   

					$(this).before('<p class="thanks"><strong>Thank you!</strong> Your email message has been sent<br />We will check our email all and We will be in touch soon</p>');
					self.location='contact_form_done.php';

				});

			});

		}

		

		return false;

		

	});

});
