	
$(document).ready(function(){
		
	$("DIV.text-box-div INPUT").blur(function(){	
		$(this).parent().removeClass('error-border');
	});
	$("DIV.text-box-div TEXTAREA").blur(function(){	
		$(this).parent().removeClass('error-border');
	});
	
	$('#contact_form #buttons BUTTON').click(function(){	
		
		var form_name = 'contact_form';
		
		$('form#contact_form #error_report').removeClass('success-table');
		$('form#contact_form #error_report').removeClass('error-table');
		
		var nameVal = document.contact_form.name_value_new.value;
		var bodyVal = document.contact_form.body_value_new.value;
		var emailVal = document.contact_form.email_value_new.value;;
		var phoneVal = document.contact_form.phone_value_new.value;
		
		var hasError = false;
			
		if(!nameVal) 
			{
				$("DIV.name-new").addClass('error-border');
				hasError = true;
			}
		else
			{
				$("DIV.name-new").removeClass('error-border');
			}
			
		if(!emailVal) 
			{
				$("DIV.email-new").addClass('error-border');
				hasError = true;
			}
		else
			{
				$("DIV.email-new").removeClass('error-border');
			}
			
		if(!phoneVal) 
			{
				$("DIV.phone-new").addClass('error-border');
				hasError = true;
			}
		else
			{
				$("DIV.phone-new").removeClass('error-border');
			}
			
		
		if(hasError == false) {
			
			$('#contact_form').html("<div class='p10t center' style='width: 300px'><img src='"+ROOT+"/images/loader.gif' alt='Loading' id='loading'></div>");
			
			$.post(ROOT + '/contact_submit.php',
   				{ name_new: nameVal, phone_new: phoneVal, email_new: emailVal, body_new: bodyVal },
   					function(data){
						$('#contact_form').html("<i><b>Thank you for your interest in Family Law in Cornwall!</b> Your enquiry has been sent and we will contact you shortly to discuss any queries you may have.</i>");		
   					});
		};
		
		return false;
	});
	
});
