$(document).ready(function(){
	$("#submit").click(function(){					   				   
		$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		
	
		var user_idVal = $("#user_id").val();
		if(user_idVal == '') {
			$("#user_id").after('<span class="error">user_id.</span>');
			hasError = true;
		}
		
		var vidVal = $("#vid").val();
		if(vidVal == '') {
			$("#vid").after('<span class="error">vid.</span>');
			hasError = true;
		}
		
		var comment_txtVal = $("#comment_txt").val();
		if(comment_txtVal == '') {
			$("#comment_txt").after('<span class="error">You forgot to enter the message.</span>');
			hasError = true;
		}
		
		
		if(hasError == false) {
			$(this).hide();
			$("#sendEmail li.buttons").append('<img src="http://www.defspot.com/ajax-loader.gif" alt="Loading" id="loading" />');
			
			$.post("comment.php",
   				{ vid: vidVal, user_id: user_idVal, comment_txt: comment_txtVal },
   					function(data){
						$("#sendEmail").slideUp("normal", function() {				   
							
							$("#sendEmail").before('Thank you for your comment!');											
						});
   					}
				 );
		}
		
		return false;
	});						   
});