$(document).ready(function(){    var initKeyword = $('#keyword').val();    menuHover($('#' + selectedMenu));    function menuHover(menu) {        if ($(menu).css('background-position-y') != '') {            $(menu).css('background-position-y', '-47px');        } else {            tmpPos = $(menu).css('background-position').split(' ');            $(menu).css('background-position', tmpPos[0] + ' -47px');        }    }    function menuOut(menu) {        if ($(menu).attr('id') != selectedMenu) {            if ($(menu).css('background-position-y') != '') {                $(menu).css('background-position-y', '0px');            } else {                tmpPos = $(menu).css('background-position').split(' ');                $(menu).css('background-position', tmpPos[0] + ' 0');            }        }    }    $('#menu_container a').hover(function() { menuHover(this); }, function() { menuOut(this); });    $('#home_first_row #recipe').click(function() { document.location.href = 'recette-lapin-' + $(this).attr('rel') + '.php'; });    $('#facebook').click(function() { window.open('http://www.facebook.com/pages/Longueuil-Annexe-QC/Lapin-du-Qu%C3%A9bec/29195354030#!/pages/Longueuil-Annexe-QC/Lapin-du-Qu%C3%A9bec/29195354030'); });    $('#twitter').click(function() { window.open('http://twitter.com/#!/LapinduQuebec'); });    $('#btnSearch').click(function() {        if ($('#btnGoogle').attr('checked')) {            $('#googleSearch').attr('value', $('#searchField').val());            $('#fGoogleSearch').submit();        } else if ($('#btnWebsite').attr('checked')) {            $('#searchq').attr('value', $('#searchField').val());            $('#fSearchTop').submit();        } else{            $('#keyword2').attr('value', $('#searchField').val());            $('#fRecipe2').submit();        }    });	$('#btn-acheter').click(function() {		if($('#region-acheter').val() != '0' || $('#categorie-acheter').val() != '0') {			$('#fRegion').submit();		} else {			alert('Vous devez choisir une catégorie et/ou une région.');			return false;		}	});    $('#btnRecipe').click(function() { $('#fRecipe').submit(); });    $('#do_you_know').nivoSlider({        effect:'sliceDown',        slices:10,        animSpeed:500, //Slide transition speed        pauseTime:4000,        startSlide:0, //Set starting Slide (0 index)        directionNav:false, //Next & Prev        directionNavHide:false, //Only show on hover        controlNav:false, //1,2,3...        controlNavThumbs:false, //Use thumbnails for Control Nav        controlNavThumbsFromRel:false, //Use image rel for thumbs        controlNavThumbsSearch: '.jpg', //Replace this with...        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src        keyboardNav:false, //Use left & right arrows        pauseOnHover:true, //Stop animation while hovering        manualAdvance:false    });    $('.faqlink').click(function() {        if ($(this).html() != 'Afficher les détails') {            $(this).html('Afficher les détails');            $('#answer' + $(this).attr('rel')).fadeTo('slow', 0, function() {                $(this).css('display', 'none')            });        } else {            $(this).html('Cacher les détails');            $('#answer' + $(this).attr('rel')).css('display', '').fadeTo('slow', 1);        }    });    $(".recipe_img").fancybox({		'speedIn'		:	600,		'speedOut'		:	200,		'overlayShow'	:	false,        'titleShow'     :   true,        'titlePosition' :   'over'	});    $('#print_recipe').click(function() { window.open('imprimer-recette-' + $(this).attr('rel') + '.php', 'Impression', 'width=746,height=500,scrollbars=1'); });    $(".appreciation").fancybox({		'width'		    :	370,		'height'		:	250,        'speedIn'		:	600,		'speedOut'		:	200,		'overlayShow'	:	false,        'titleShow'     :   false,        'type'          :   'iframe'	});    $("#send_friend").fancybox({		'width'		    :	640,		'height'		:	410,        'speedIn'		:	600,		'speedOut'		:	200,		'overlayShow'	:	false,        'titleShow'     :   false,        'type'          :   'iframe'	});    $('#btnAppreciation').click(function() {        $.ajax({            type: "POST",            url: "ajax/appreciation.php",            data: {note: $('input:radio[name=appreciation]:checked').val(), id: $('#id').val()},            success: function(msg){                tmp = msg.split('-');                stars = '';                for (i = 1; i <= 5; i++) {                    if (i <= tmp[0]) { stars = stars + '<img src="images/recipes/star-color.png" />'; } else { stars = stars + '<img src="images/recipes/star-grey.png" />'; }                }                parent.$('#appreciation_zone').html(stars + ' <span class="appreciate">(' + tmp[1] + ')</span>');                parent.$.fancybox.close();            }        });    });    $('#btnSendRecipe').click(function() {        if ($('#from_name').val() == '') { $('#from_name').css('border', '#F00 solid 1px'); } else { $('#from_name').css('border', '#5F5F61 solid 1px'); }        if ($('#to_name').val() == '') { $('#to_name').css('border', '#F00 solid 1px'); } else { $('#to_name').css('border', '#5F5F61 solid 1px'); }        if ($('#from_email').val() == '') { $('#from_email').css('border', '#F00 solid 1px'); } else { $('#from_email').css('border', '#5F5F61 solid 1px'); }        if ($('#to_email').val() == '') { $('#to_email').css('border', '#F00 solid 1px'); } else { $('#to_email').css('border', '#5F5F61 solid 1px'); }        if ($('#from_name').val() != '' && $('#to_name').val() != '' && $('#from_email').val() != '' && $('#to_email').val() != '') {            $.ajax({                type: "POST",                url: "ajax/send-recipe.php",                data: {from_name: $('#from_name').val(), to_name: $('#to_name').val(), from_email: $('#from_email').val(), to_email: $('#to_email').val(), link: $('#link').val()},                success: function(msg){                    $('#msg_box').css('display', 'none');                    if (msg == 'ok') { $('#send_ok').css('display', 'block'); } else { $('#send_error').css('display', 'block'); }                }            });        }    });    $('#btnEnvoyerSuggestion').click(function() {        var error = '';        if ($('#votrenom').val() == '') { error = error + '   - Veuillez inscrire votre nom et prénom.\n' }        if ($('#courriel').val() == '') { error = error + '   - Veuillez inscrire votre courriel.\n' }        if ($('#nom_recette').val() == '') { error = error + '   - Veuillez inscrire le nom de votre recette.' }        if (error == '') {            $('#votrenom').attr('name', 'nom');            $('#fSuggestion').submit()        } else {            alert('Avant d\'envoyer votre message :\n' + error)        }    });    $('#btnInscriptionConcours').click(function() {        var error = '';        if ($('#votrenom').val() == '') { error = error + '   - Veuillez inscrire votre nom et prénom.\n' }        if ($('#courriel').val() == '') { error = error + '   - Veuillez inscrire votre courriel.\n' }	    // Vérification si fichier ou texte pour l'envoi de la recette	    if($('#send:checked').val() == 'file') {			if($('#recipe_file').val() == '') {				error = error + '   - Veuillez sélectionner votre fichier de recette.\n';			}	    }	    if($('#send:checked').val() == 'text') {			if($('#commentaires').val() == '') {				error = error + '   - Veuillez inscrire votre recette dans le champ Recette et commentaires.\n';			}	    }        if (error == '') {            $('#votrenom').attr('name', 'nom');            $('#fConcours').attr('action', 'concours_archive.php');            $('#fConcours').submit()        } else {            alert('Avant d\'envoyer votre inscription :\n' + error)        }    });    $('#btnInscriptionMessager').click(function() {        var error = '';        if ($('#votrenom').val() == '') { error = error + '   - Veuillez inscrire votre nom et prénom.' + "\n"; }        if ($('#courriel').val() == '') { error = error + '   - Veuillez inscrire votre courriel.' + "\n"; }        if (error == '') {            $('#votrenom').attr('name', 'nom');            $('#fMessager').submit()        } else {            alert('Avant de vous abonner :\n' + error)        }    });    $('#keyword').focus(function() { if ($(this).val() == initKeyword) { $(this).val(''); } });    $('#keyword').blur(function() { if ($(this).val() == '') { $(this).val(initKeyword); } });    /*** CORRECTIONS LABELS CONVERSION ***/    $('#liter').html('Litre [l]:');    $('#centiliter').html('Centilitre [cl]:');    $('#deciliter').html('Décilitre [dl]:');    $('#milliliter').html('Millilitre [ml]:');    $('form[name*="cat=Volume"] td:eq(10)').html('Baril (US):');    $('form[name*="cat=Area"] td:eq(12)').html('Verge carré [vg<sup>2</sup>]:');    $('#yard').html('Verge [vg]:');});
