$(function() {

$(".submit").click(function() {

var nom = $("#nom").val();
var email = $("#email").val();
var com = $("#com").val();
var videoId = $("#videoId").val();
var captcha = $("#captcha").val();
var dataString = 'nom='+ nom + '&email=' + email + '&com=' + com + '&videoId=' + videoId+ '&captcha=' + captcha;
	
		if(nom=='' || com=='' || captcha=='')
		{
			if (nom=='') {
				alert('Entrez votre nom');
				document.getElementById('nom').focus();
				} else
				{
					if (com=='') {
						alert('Entrez votre commentaire');
						document.getElementById('com').focus();
					} else
					{
						if (captcha=='') {
						alert('Entrez le code de securite');
						document.getElementById('captcha').focus();						
						}
					}
				}

		}
	 
	else
	{
	$("#flash").show();
	$("#flash").fadeIn(400).html('<img src="img/loading.gif" align="absmiddle">&nbsp;<span class="loading">Chargement ...</span>');
	$.ajax({
		  type: "POST",
		  url: "commentajax.php",
		  data: dataString,
		  cache: false,
		  success: function(html){
		 
		  	$("ol#update").prepend(html);
			$("ol#update li:first").fadeIn("slow");
		  document.getElementById('email').value='';
		   document.getElementById('nom').value='';
			document.getElementById('com').value='';
			 document.getElementById('captcha').value='';
			$("#nom").focus();
		   img = document.getElementById('imgCaptcha'); 
		   img.src = 'create_image.php?' + Math.random();
		  $("#flash").hide();
		  }
	 });
}
return false;
	});
});
