$(document).ready(function(){

	var in_speed 	= 750 ;
	var out_speed	= 500 ;

	$("*[class^='bloc_tag_']").hover(
		function (event) {
			var currentClass = $(this).attr('class');
			var currentId = $(this).attr('id');
			if (event.relatedTarget != null) {
				$("#"+currentId+" .texte_hover").show("slide", { direction: "down" }, in_speed);
				$("#"+currentId+" .bas_hover").show();
			}
		}, function() {
			var currentClass = $(this).attr('class');
			var currentId = $(this).attr('id');
      $("#"+currentId+" .texte_hover").hide("slide", { direction: "down" }, out_speed); 
			$("#"+currentId+" .bas_hover").hide();
		}
	);
	
	$("a.bt_envoi").click(function(){
		var utile = 0; 
		var guide = 0; 
		var comprendre = 0; 
		var questionnaire_id = $("input[name=questionnaire_id]").val();
		var questions_id = $("input[name=questions_id]").val();
		var post_id = $("input[name=post_id]").val();
		var post_titre = $("input[name=post_titre]").val();
		var produit_marque = $("input[name=produit_marque]").val();
		var produit_nom = $("input[name=produit_nom]").val();

		
		if($("#oui_1:checked").val())
		{
			utile = '1';
		}
		else
		{
			if(!($("#non_1:checked").val()))
			{
				utile = '3';
			}
		}		
		
		if($("#oui_2:checked").val())
		{
			guide = '1';
		}
		else
		{
			if(!($("#non_2:checked").val()))
			{
				guide = '3';
			}
		}		
		
		if($("#oui_3:checked").val())
		{
			comprendre = '1';
		}
		else
		{
			if(!($("#non_3:checked").val()))
			{
				comprendre = '3';
			}
		}	

		
		
				
		if( (comprendre != 3) || (guide != 3) || (utile != 3))
		{
		$.post("http://burger.tag-nutrition.fr/wp-content/themes/Tag Nutrition/poll/questionnaire_implement.php", { utile: utile, guide: guide, comprendre: comprendre, questionnaire_id : questionnaire_id, questions_id : questions_id, post_id : post_id, post_titre: post_titre, produit_marque: produit_marque, produit_nom: produit_nom}, //this is JSON that gets posted
		 function(data){
				$("#div_resultats").html(data); 
				$("#div_questionnaire").html("");
				$("#div_questionnaire").fadeOut("slow");
            	$("#div_resultats").fadeIn("slow");
        });
		}
    });

});


function soumetForm(){
	var w = 550;
	var h = 520;
	var wleft = (screen.width - w) / 2;
	var wtop = (screen.height - h) / 2;
	var url = 'http://feedburner.google.com/fb/a/mailverify?uri=TagNutritionTest&loc=fr_FR&email='+document.getElementById("email").value;
	var name = 'popupwindow'
	var win = window.open(url,
		name,
		'width=' + w + ', height=' + h + ', ' +
		'left=' + wleft + ', top=' + wtop + ', '+
		'scrollbars=yes');
	win.moveTo(wleft, wtop);
	win.focus();
	return false;
	}

