$(document).ready(function() {
	$('#comment_video').slideUp();
	comment_video_title_first = true;
	$('#comment_video_title').css('cursor', 'pointer').click(function() {
		$(this).css('cursor', 'inherit');
		$(this).find('span').remove();
		if (comment_video_title_first) {
			$('#comment_video').slideDown();
		}
	});
	$("#comment_video").submit(function() {
		comment_pseudo	= $('input[name=comment_pseudo]').val();
		//comment_mail	= $('input[name=comment_mail]').val();
		comment_str		= $('textarea[name=comment_str]').val();
		comment_code	= $('input[name=comment_code]').val();
		if (comment_pseudo.length == 0) {
			alert('Vous n\'avez pas entrer votre pseudo.');
		} else if (comment_str.length == 0) {
			alert('Vous n\'avez entrer aucun message.');
		} else if (comment_str.length < 10) {
			alert('Votre message doit contenir au moins 10 caracteres.');
		} else if (comment_code.length == 0) {
			alert('Vous devez recopier le code qui apparait sur l\'image, merci.');
		} else {
			$('#comment_video_submit').attr('disabled', 'disabled');
			//$.post('/javascript/comment_post.php', {pseudo: comment_pseudo, mail: comment_mail, str: comment_str, code: comment_code, id_video: id_video_value}, function (ajax_response) {
			$.post('/javascript/comment_post.php', {pseudo: comment_pseudo, str: comment_str, code: comment_code, id_video: id_video_value}, function (ajax_response) {
				if (ajax_response == 'CAPTCHA') {
					alert('Le code que vous avez entrer ne correspond a celui de l\'image, merci de reesayer.');
				} else if (ajax_response == 'WAIT') {
					alert('Vous devez attendre 5 minutes avant de pouvoir reposte un commentaire sur le site');
				} else if (ajax_response == 'POSTED') {
					$("#comment_video").html('Votre commentaire &agrave; &eacute;t&eacute; post&eacute; avec succ&egrave;s, merci de votre contribution et bonne visite!');
				} else {
					alert('Une erreur est survenue, veuillez reesayer plutard, merci.');
					alert(ajax_response);
				}
				$('#comment_video_submit').removeAttr('disabled');
			});
		}
		return false;
	});
});