$(document).ready(function () {



    //***********************************************
    // Gestion du slide pour afficher les formulaires
    //***********************************************

    // Expand Panel
    $("#open").click(function () {
        afficherContactForm();
    });
    $("#popinopen").click(function () {
        $("#open").click();
    });
    $(".popinopen").click(function () {
        $("#open").click();
    });

    // Collapse Panel
    $("#close").click(function () {
        $("div#panel").slideUp("slow");
        $("#panel_header_inscrit").show();
    });
    // Close des résultats d'envoi
    $("#close1").click(function () { $("#close").click(); });
    $("#close2").click(function () { $("#close").click(); });

    // Switch buttons from "Log In | Register" to "Close Panel" on click
    $("#toggle a").click(function () {
        $("#toggle a").toggle();
    });

    //***********************************************
    // Gestion d'affichage des différents formulaires
    //***********************************************

    // Si l'on clique sur les liens picot
    $(".contentpan .contentpanPICTO a").click(function () {
        // cacher tous les formulaires
        $(".contentpan .contentpanBODY").hide();
        // initialiser les images 'off'
        $(".contentpan .imgON").hide();
        $(".contentpan .imgOFF").show();
        // afficher l'image 'on' du click
        $("img" + this.hash + "OFF").hide();
        $("img" + this.hash + "ON").show();
        // afficher le formulaire
        $(this.hash).show();
        this.blur();
        return false;
    });

    // Si l'on clique sur les liens texte du div d'accueil
    $(".contentpan #accueil a").click(function () {
        // cacher tous les formulaires
        $(".contentpan .contentpanBODY").hide();
        // initialiser les images 'off'
        $(".contentpan .imgON").hide();
        $(".contentpan .imgOFF").show();
        // afficher l'image 'on' du click
        $("img" + this.hash + "OFF").hide();
        $("img" + this.hash + "ON").show();
        // afficher le formulaire
        $(this.hash).show();
        this.blur();
        return false;
    });

    //***********************************************
    // Gestion du slide pour afficher le footer
    //***********************************************

    // initialisation
    $("div.footer").hide();
    $("#openfooter").show();
    $("#closefooter").hide();

    // afficher le footer
    $("#openfooter").click(function () {
        $("div.footer").slideDown("slow");
        $("#openfooter").hide();
        $("#closefooter").show();
        return false;
    });

    // cacher le footer
    $("#closefooter").click(function () {
        $("div.footer").slideUp("slow");
        $("#openfooter").show();
        $("#closefooter").hide();
        return false;
    });

});


//***********************************************
// Gestion d'affichage des résultats d'envoi
//***********************************************

function afficherResultForm(id,idresult) {
    $(document).ready(function() {
		// réinitialiser l'affichage des formulaires
        $("#open").click();
        //modif par rapport à la fonction #open click
        $("#panel .contentpan #accueil").hide();
        // afficher l'image ON
        $("img"+id+"OFF").hide();
        $("img"+id+"ON").show();		
        // afficher le résultat du formulaire
        $(idresult).show();
    });
}

function afficherResultError() {
    $(document).ready(function() {
		// réinitialiser l'affichage des formulaires
        $("#open").click();
        //modif par rapport à la fonction #open click
        $("#panel .contentpan #accueil").hide()
        // afficher le résultat du formulaire
        $("#resultError").show();
    });
}

//***********************************************
// Gestion d'affichage du formulaire Boutique
// pour validation n° inscrit et n° commande
//***********************************************

function afficherBoutiqueForm() {
   $(document).ready(function() {
		// réinitialiser l'affichage des formulaires
        $("#open").click();
        //modif par rapport à la fonction #open click
        $("#panel .contentpan #accueil").hide();
        // afficher l'image ON
        $("img#boutiqueOFF").hide();
        $("img#boutiqueON").show();		
        // afficher le résultat du formulaire
        $("#boutique").show();
    });
}

//***********************************************
// Fonctions d'affichage du formulaire de contact
//***********************************************

function afficherContactForm() {
    // réinitialiser l'affichage des formulaires
    $("#panel .contentpan .contentpanBODY").hide();
    $("#panel .contentpan #accueil").show();
    $(".contentpan .imgON").hide();
    $(".contentpan .imgOFF").show();
    $("div#panel").slideDown("slow");
    $("#panel_header_inscrit").hide();
}
function afficherContactFormUrl() {
    afficherContactForm();
     $("#open").hide();
    $("#close").show();
}

