$(function(){

function glow(e){

$(e)
			.animate({ backgroundColor: "red" }, 400)
			.animate({ backgroundColor: "white" }, 400)
			.animate({ backgroundColor: "red" }, 400)
			.animate({ backgroundColor: "white" }, 400);



}
		
		$("#form1_submit").click(function(){
		
		var formcontent = $('#contact_form').serialize();
		name = $("#name").val();
		email = $("#email").val();
		spam = $("#spam").val();
		if(name == ''){
		
					glow('#name');
					
					}
	if(email == ''){
	
					glow('#email');
					
					}
						else if(spam != '9'){
					
										glow('#spam');

					
					}
			else{
				$.ajax({
					   
						type: "GET",
						url: templatePath+"scripts/contact_engine.php",
						data: formcontent,
						cache: false,
						
						beforeSend: function(html){
						$("#form1_submit").val('Sending...')
						.attr("disabled", true); 
						},
						
						success: function(html){
						$("#formholder").hide().empty();
						$("#form1_submit").val('Send')
						.attr("disabled", false);
						
						if(html === 'success'){$('#formholder').show().html('Thanks for your comment!');}
						else{$('#formholder').show().html('There appears to have been an error in sending. Please refresh the page and try again.');}
						
						}
				
					});
				
				}
				return false;
		
		});
		
	
		
}); //end function
