/*****************************AFFINAGE DETAIL********************************/

function Affin_ListeDeroulAction(id) {
    document.location.href = $('#' + id).val();
}

/*****************************MESSAGE ATTENTE********************************/

function MessageAttente() {

    $get('lbl_100').innerHTML = "<div id=DIV_LigneArticleCommentaire></div><div id='DIV2_LigneArticleCommentaire' style='TEXT-ALIGN:CENTER; overflow:hidden'><center><img border='0' src='Image/WEB/loading.gif' class='ImgLoading100' /><br><br>Chargement en cours<br>Merci de patienter.</center></div>";
    showTextLightbox(150, 150, true);
}

/******************************* COLONNES EGALES */

function hauteurEgale(group) {
    tallest = 0;
    group.each(function () {
        thisHeight = $(this).height();
        if (thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}


Usage:
$(document).ready(function () {
    hauteurEgale($(".column"));
});




/* checked Adresse compte
--------------------------------*/
function CheckAdresse(Adresse1, Adresse2, Adresse3) {
    var mValid = false;
    try {
        if ($('#' + Adresse1).val() != '') { mValid = true; }
        if ($('#' + Adresse2).val() != '') { mValid = true; }
        if ($('#' + Adresse3).val() != '') { mValid = true; }
        return mValid;
    }
    catch (ex) { return false; }
}

/* repositionner titre page
--------------------------------*/
$(document).ready(function () {
    $('#bloc_titre_page').append($('#TitreHead'));
});

/* caroussel popup article
--------------------------------*/
//$("#slide_popup").tinycarousel({ display: 5 }); // VOIR SI CHARGE APRES AJAX


/* Fonction de debugage InfoDev
--------------------------------*/
function InfoDev(message, cumul) { if (!$('#InfoDev').length) { $('BODY').append('<div id="InfoDev" style="position: absolute; top:0; left:0; font-size:15px;"></div>'); } cumul ? $('#InfoDev').append("<br>" + message) : $('#InfoDev').html(message); }


/* lihoverFix
--------------------------------*/
$(document).ready(function () {
$('#bloc_list_article li, .bloc_DA_sell ul li, #menu_Catalogue1 li, #bloc_list_noeuds_fils li').hover(function() { $(this).addClass("sfhover"); }, function() { $(this).removeClass("sfhover"); });
});

/* colorbox
--------------------------------
function showTextLightbox(largeurBox, hauteurBox, pasDeCroixFermer) {
$.colorbox({
html: $('#DIV2_LigneArticleCommentaire').html(),
onCleanup: function() { $('#DIV2_LigneArticleCommentaire').remove(); }
});
}*/

/* mini panier
--------------------------------*/
$(document).ready(function() {
$('#mini_panier').qtip({
        content: $("#mini_panier_detail", this).html(),
        style: { width: { max: 420} },
        position: { corner: { target: 'bottomRight', tooltip: 'topRight' }, adjust: { x: 20, y: -10} },
        hide: { fixed: true }
    });
    $('#bloc_panier_compte').hover(function() { //quand on arrive sur la zone on update le panier au cas ou il a ete rempli
        $('#mini_panier').qtip("api").updateContent($("#mini_panier_detail", this).html());
        if ($("#mini_panier_detail").html().length > 25) { $('#lbl_005').qtip("api").updateWidth(410); }
    });
});


/* Par contexte
--------------------------------*/

$(document).ready(function () {
    var contexte = $("#H_MEM_CONTEXTE").val();
    switch (contexte) {

        case "Accueil": /*############################ CONTEXTE ACCUEIL ###################################*/

            /****** boite a onglets ******/
            $("#bloc_accueil_onglet_menu").facileTabs({ targetElements: ".bloc" });

            /******Caroussel******/
            $('#AccueilSlide').tinycarousel({ pager: true, display: 1, interval: true });

            break;
        case "View": /*############################### CONTEXTE VIEW ######################################*/

            /******Infobule sur bouton panier inactif ou choix taille ******/
            $('.ajout_panier span[tooltip]').each(function () {
                $(this).qtip({
                    content: $(this).attr('tooltip'), // Use the tooltip attribute of the element for the content
                    style: { tip: true, border: { radius: 5 }, name: 'dark' }, // Give it a crea mstyle to make it stand out
                    position: { corner: { tooltip: 'bottomMiddle', target: 'topMiddle'} }
                });
            });

            /****** Boite à onglets ******/

            $("#bloc_DA_onglet_content .bloc div[id^='sub_'] > div[id^='lbl_'] > div[id^='lbl_']").each(function (i) { if ($(this).html().length < 3) { $(this).parent().parent().remove(); } }); //enlever contenus vides
            $("#bloc_DA_onglet_content .bloc").each(function (i) { if ($(this).html().length < 5) { $("#bloc_DA_onglet_menu li:eq(" + i + ")").addClass("delete"); $(this).remove(); } });
            $("#bloc_DA_onglet_menu li.delete").each(function () { $(this).remove(); });
            $("#bloc_DA_onglet_menu").facileTabs({ targetElements: ".bloc" });    //lancer boite à onglets

            /******Caroussel******/
            $("#slide_fils").tinycarousel({ display: 5 });
            $("#slide_freres").tinycarousel({ display: 5 });
            $("#slide_cousins").tinycarousel({ display: 5 });
            //$("#bloc_DA_vignettes").tinycarousel({display: 5} );
            $("#bloc_DA_vignettes").tinycarousel({ display: 3, viewport: '#detailArticl_Galr', overview: '#detailArticl_Galr ul' });

            /****** zoom ICI et zoom XL ******/
            lancerGallery();

            break;
        case "PageStatique": /*####################### CONTEXTE PAGES SATTIQUES ###########################*/

            break
        case "Identification": /*##################### CONTEXTE IDENTIFICATION ############################*/

            /****** suivi commande ******/
            $('.sc_detail').click(function () {
                var $tab1 = $(this).parent().parent().parent().parent('#suivi_commande_liste');
                $tab1.next('.sc_detail_tab').slideToggle('slow');
                return false;
            });
			
			/****** suivi devis ******/
            $('.sd_detail').click(function () {
                var $tab1 = $(this).parent().parent().parent().parent('#suivi_devis_liste');
                $tab1.next('.sd_detail_tab').slideToggle('slow');
                return false;
            });

            /****** sauvegarde panier ******/
            
            $('.sv_detail').click(function () {
                var $tab1 = $(this).parent().parent().parent().parent('#sauvegarde_panier_liste');
                $tab1.next('.sv_detail_tab').slideToggle('slow');
                return false;
            });

            /****** login (nouveau et ancien compte) ******/
            if ($('#r_compte_old').attr('checked') == true) {
                $('#div_compte_new').hide(); $('#a_compte_old').addClass('checked');
            }
            else {
                $('#div_compte_old').hide(); $('#a_compte_new').addClass('checked');
            }

            $('#a_compte_old').click(function () {
                $('#r_compte_old').attr('checked', 'checked');
                $('#r_compte_new').removeAttr('checked');
                $('#a_compte_old').addClass('checked');
                $('#a_compte_new').removeClass('checked');
                $('#div_compte_new').fadeOut('slow');
                $('#div_compte_old').fadeIn('slow');
            });

            $('#a_compte_new').click(function () {
                $('#r_compte_old').removeAttr('checked');
                $('#r_compte_new').attr('checked', 'checked');
                $('#a_compte_old').removeClass('checked');
                $('#a_compte_new').addClass('checked');
                $('#div_compte_old').fadeOut('slow');
                $('#div_compte_new').fadeIn('slow');
            });




            break
        case "AfficheResultatRechercheAvancee": /*#### CONTEXTE RECHERCHE #################################*/

            /******Caroussel******/
            $("#slide_panier").tinycarousel({ display: 5 });


            break
        case "ValidationPanier": /*################### CONTEXTE PANIER ####################################*/

            /******Point Relais Horaires ******/
            $(document).ready(function () {
                $('#gk_listerelais .horaire').each(function (i) {
                    $(this).qtip({
                        content: "<div class='BulleKiala'>" + $('#gk_listerelais p').eq(i).html() + "</div>",
                        show: 'mouseover',
                        hide: 'mouseout',
                        position: { corner: { tooltip: 'bottomMiddle', target: 'topMiddle'} },
                        style: { border: { width: 2, radius: 5, color: '#BAB3B3' }, tip: true, width: '400' }
                    });
                    $(this).click(function () { return false });
                });
            });

            /******Liste point relais Kiala deplacement******/
            $(document).ready(function () {

                if ($('#KIALA')) {

                    $('#grille_kiala').insertAfter('#KIALA');
                }

                if ($('#SOCOLISSIMO')) {
                    $('#info_socolissimo').insertAfter('#SOCOLISSIMO');
                    $('#btn_socolissimo').insertAfter('#SOCOLISSIMO');
                }

            });

            /******Caroussel******/
            $("#slide_panier").tinycarousel({ display: 5 });


            break
        default: /*################################## AUTRES #############################################*/

    }
});


/**************************************************************************/
function OnSucceeded_AjaxAjoutCommentaireWebLigne(result) {
    var Tab = result.split('~#~');
    var mParamRetour = Tab[0];
    var mResult = Tab[1];
    document.getElementById('commentaire_commentaire_' + mParamRetour).innerHTML = mResult;
    document.getElementById('commentaire_modification_' + mParamRetour).style.display = 'none';
    document.getElementById('commentaire_' + mParamRetour).style.display = 'block';
}

function OnFailed_AjaxAjoutCommentaireWebLigne(error) {
    //alert('La méthode Ajax à causé une erreur : ' + error.get_message());
}

function OnSucceeded_AjaxEnvoiMail(result) {
    alert(result);
}

function OnFailed_AjaxEnvoiMail(error) {
    alert(error);
}
