	
$(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';
		
		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) {
				hasError = "<ul><li class='list-error'>Please enter your name.</li>";
			}
			
		if(!emailVal) {
					
				if(!hasError)
					{
						hasError = "<ul>";
					}
				hasError += "<li class='list-error'>Please enter your email address.</li>";
			}
			
		if(!bodyVal) {
					
				if(!hasError)
					{
						hasError = "<ul>";
					}
				hasError += "<li class='list-error'>Please enter your query in the space provided.</li>";
			}
			
		if(hasError)
			{
				hasError += "</ul>";
			}
		
		if(hasError == false) {
			
			$('#contact_form').html("<div class='p10t center' style='width: 260px'><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 Harlyn Inn!</b> Your enquiry has been sent and we will contact you shortly to discuss any queries you may have.</i>");		
   					});
		}
		else
			{
				$.prompt("Information Required",hasError);
			}
		
		return false;
	});
	
});
