$(document).ready(function(){ 
lancerGallery();
});


/*****************************MESSAGE ATTENTE********************************/

function MessageAttente() {
    $.colorbox({
        html: '<div class="MessageAttente">' + $("#myloading").html() + '<br>Chargement en cours. Merci de patienter</div>',
        initialWidth: 50,
        initialHeight: 50,
        width: 200,
        overlayClose: false,
        escKey: false,
        onLoad: function () {
        $('#cboxClose').hide();
        }
    });
}


/****** suivi commande ******/
$(document).ready(function(){          
            $('#suivi-commandes .sc_detail_tab:first').slideToggle('slow').prev('.commande').toggleClass('open');
            $('#suivi-commandes .commande').click(function () {
                if ($(this).next('.sc_detail_tab').is(':hidden')) $('#suivi-commandes .sc_detail_tab:visible').slideToggle('slow').prev().removeClass('open');
                $(this).toggleClass('open').next('.sc_detail_tab').slideToggle('slow');
                return false;
            });
});


/**************pr choix transport*/
function MessageAttente() {

$get('lbl_100').innerHTML = "<div id=DIV_LigneArticleCommentaire></div><div id='DIV2_LigneArticleCommentaire' style='TEXT-ALIGN:CENTER; overflow:hidden'><center><br><br><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);

}




/* colorbox 
--------------------------------*/
function showTextLightbox(largeurBox, hauteurBox, pasDeCroixFermer) {
    $.colorbox({
        html: $('#DIV2_LigneArticleCommentaire').html(),
        maxWidth: '80%', maxHeight: '80%',
        onCleanup: function () { $('#DIV2_LigneArticleCommentaire').remove(); }
    });
}
function hideLightbox() { $.colorbox.close(); }


/* desincription newsletter
--------------------------------*/
$(document).ready(function () { $('.desinscription_newsletter a').colorbox({ iframe: true, innerWidth: 450, innerHeight: 250 }); })


/***************pr configurateur recherche par marque*/


$(document).ready(function(){ 
        var selects = $(".level1ul").find("select").length;
		
				
		if (selects == 0){}
		if (selects == "1"){$('#configurateur').html('<label>Cylindr&eacute;e</label><select disabled="disabled"><option>-- Votre choix --</option></select><label>Mod&egrave;le</label><select  disabled="disabled"><option>-- Votre choix --</option></select><label>Ann&eacute;e</label><select disabled="disabled"><option>-- Votre choix --</option></select>');}
		if (selects == "2"){$('#configurateur').html('<label>Mod&egrave;le</label><select  disabled="disabled"><option>-- Votre choix --</option></select><label>Ann&eacute;e</label><select disabled="disabled"><option>-- Votre choix --</option></select>');}
		if (selects == "3"){$('#configurateur').html('<label>Ann&eacute;e</label><select disabled="disabled"><option>-- Votre choix --</option></select>');}
		if (selects == "4"){}
    });



/***********************/

$(document).ready(function(){ 
        $(document).pngFix(); 
    }); 		

/***********************/

function Affin_ListeDeroulAction(id) {
document.location.href = $('#'+id).val();
}


/******************************* 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($(".bloc_adresse"));
});



/******************************* ONGLETS */
	
	$(document).ready(function(){
			
			$("#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
			
			$(document).ready(function(){
	

			
			var contenuA = $.trim($("#ongletA").text());
			var contenuB = $.trim($("#ongletB").text());
						
							
			if (contenuA ==""){
				$("#ongletA").remove();
				$("#liOngletA").remove();
				$("#liOngletB").addClass("selected");
				$("#liOngletB").children().addClass("selected");
				$("#ongletB").css("display","block");
				}
				
			if (contenuB ==""){
				$("#ongletB").remove();
				$("#liOngletB").remove();
				}
								
				
			if (contenuA =="" && contenuB ==""){
				$("#bloc_DA_onglet2").remove();				
				}
			
			
	});
				
				
			$("#bloc_DA_onglet_menu2").facileTabs({targetElements:".bloc2"});
			$("#bloc_accueil_onglet_menu").facileTabs({targetElements:".bloc"});
			
			});
			
	

    
	
/******************************* CAROUSEL **********************************/
		
	$(document).ready(function(){
				$("#slide_fils").tinycarousel({display: 5} );
				$("#slide_freres").tinycarousel({display: 5} );
				$("#slide_cousins").tinycarousel({display: 5} );
				$("#slide_panier").tinycarousel({display: 5} );
				$("#slide_popup").tinycarousel({display: 5} );
				/*$("#bloc_DA_vignettes").tinycarousel({display: 5} );*/
				$("#bloc_DA_vignettes").tinycarousel({ display: 6, viewport: '#detailArticl_Galr', overview: '#detailArticl_Galr ul' });
				$('#AccueilSlide').tinycarousel({pager: true, display:1, interval:true});
				

			});

	


/******************************* INFOBULLE **********************************/
	
	$(document).ready(function() 
{
   // panier inactif avec taille/couleur
   $('.ajout_panier span[tooltip]').each(function()
   {
      $(this).qtip({
         content: $(this).attr('tooltip'), // Use the tooltip attribute of the element for the content
         style: 'dark' // Give it a crea mstyle to make it stand out
      });
   });
});


/******************************* Compte Identification **********************************/

$(document).ready(function ()
        {
            $('#div_compte_new').hide();
			$('#r_compte_old').attr('checked', 'checked');
        

        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');
            });
		
		});
		
		
		
/* 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;
}

}

/* suivi commande
-----------------------------------*/

$(document).ready(function(){
     
    $('.sc_detail').click(function(){
		var $tab1 = $(this).parent().parent().parent().parent('#suivi_commande_liste');
        $tab1.next('.sc_detail_tab').slideToggle('slow');
		return false;
    });
 
});

/* sf hover ie6
-----------------------------------*/

sfHover = function() {
	var sfEls = document.getElementById("bloc_menu_client").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
/*********************************** SO COLISSIMO */

function SoColissimoLiberte() {    SoColissimoRecherche();    return false;}

function SoColissimoRecherche() {
    var adresse = '';
    var typePoints = '';

    if ($('#SoAdresseInput').length > 0) adresse = $('#SoAdresseInput').val();
    if ($('#SoCheckCityssimo:checked').length > 0) typePoints += 'C';
    if ($('#SoCheckPoste:checked').length > 0) typePoints += 'P';
    if ($('#SoCheckCommercant:checked').length > 0) typePoints += 'M';

    $.colorbox({ html: '', initialWidth: 50, initialHeight: 50, maxWidth: '80%', maxHeight: '80%', onComplete: PageMethods.AjaxSoColissimoRecheche(adresse, typePoints, OnSucceeded_SoColissimoRecherche, OnFailed_SoColissimoRecherche) });
}

function SoColissimoCheckMobile() {
    var mobile = $('#SoMobile').val();
    $('#SoMobileErreur').html('&nbsp;');
    var regex = new RegExp(/^(06|07)[0-9]{8}/gi);

    if (mobile.length == 0) {
        $('html, body').animate({ scrollTop: $("#SoColissimoLiberte").offset().top }, 200);
        $('#SoMobileErreur').html('<span class="SoMobileKO">&nbsp; Votre mobile est obligatoire livraison hors domicile ou sur RDV !</span>');
        return false;
    }
    else if (mobile.indexOf('06') != 0 && mobile.indexOf('07') != 0) {
        $('html, body').animate({ scrollTop: $("#SoColissimoLiberte").offset().top }, 200);
        $('#SoMobileErreur').html('<span class="SoMobileKO">&nbsp; Votre mobile doit commencer par 06 ou 07 !</span>');
        return false;
    }
    else if (!regex.test(mobile)) {
        $('html, body').animate({ scrollTop: $("#SoColissimoLiberte").offset().top }, 200);
        $('#SoMobileErreur').html('<span class="SoMobileKO">&nbsp; Votre mobile ne doit contenir que des chiffres !</span>');
        return false;
    }
    else if (mobile.length != 10
            || mobile == '0606060606' || mobile == '0707070707' || mobile == '0600000000' || mobile == '0700000000'
            || mobile == '0611111111' || mobile == '0622222222' || mobile == '0633333333' || mobile == '0644444444'
            || mobile == '0655555555' || mobile == '0677777777' || mobile == '0688888888' || mobile == '0699999999'
            || mobile == '0711111111' || mobile == '0722222222' || mobile == '0733333333' || mobile == '0744444444'
            || mobile == '0755555555' || mobile == '0777777777' || mobile == '0788888888' || mobile == '0799999999'
            || mobile == '0612345678' || mobile == '0712345678') {
        $('html, body').animate({ scrollTop: $("#SoColissimoLiberte").offset().top }, 200);
        $('#SoMobileErreur').html('<span class="SoMobileKO">&nbsp; Votre mobile doit comporter 10 chiffres &agrave; suivre !</span>');
        return false;
    } else {
        $('#SoMobileErreur').html('<span class="SoMobileOK">&nbsp; Votre mobile a &eacute;t&eacute enregistr&eacute;.</span>');
        PageMethods.AjaxSoColissimoEnregistreMobile(mobile, doNothing, doNothing);
        return true;
    }
}
function doNothing(nothing) {
    //alert(nothing);
}

function SoColissimoRechercheCityssimo() {
    if (SoColissimoCheckMobile())
        $.colorbox({ html: '', maxWidth: '90%', maxHeight: '90%', onComplete: PageMethods.AjaxSoColissimoRecheche('', 'C', OnSucceeded_SoColissimoRecherche, OnFailed_SoColissimoRecherche) });
}
function SoColissimoRecherchePoste() {
    if (SoColissimoCheckMobile())
        $.colorbox({ html: '', maxWidth: '90%', maxHeight: '90%', onComplete: PageMethods.AjaxSoColissimoRecheche('', 'P', OnSucceeded_SoColissimoRecherche, OnFailed_SoColissimoRecherche) });
}
function SoColissimoRechercheCommercant() {
    if (SoColissimoCheckMobile())
        $.colorbox({ html: '', maxWidth: '90%', maxHeight: '90%', onComplete: PageMethods.AjaxSoColissimoRecheche('', 'M', OnSucceeded_SoColissimoRecherche, OnFailed_SoColissimoRecherche) });
}

function SoColissimoSelectionneDomicile(isRendezVous) {
    if (isRendezVous == '0' || SoColissimoCheckMobile())
        PageMethods.AjaxSoColissimoSelectionneDomicile(isRendezVous, OnSucceeded_SoColissimoSelectionneDomicile, OnFailed_SoColissimoSelectionneDomicile);
}
function SoColissimoSelectionnePointRetrait(identifiantPoint) { PageMethods.AjaxSoColissimoSelectionnePointRetrait(identifiantPoint, OnSucceeded_SoColissimoSelectionnePointRetrait, OnFailed_SoColissimoSelectionnePointRetrait); }


function OnSucceeded_SoColissimoRecherche(vResult) { $.colorbox({ html: ' ', innerWidth: '900', innerHeight: '735', onComplete: function () { $.colorbox({ html: vResult, innerWidth: '900', innerHeight: '735' }); } }); }
function OnFailed_SoColissimoRecherche(erreur) { $.colorbox({ html: ' Une erreur est survenue, veuillez réessayer' }); }

function OnSucceeded_SoColissimoSelectionnePointRetrait(vResult) { document.location.href = '/panier-confirmation.aspx'; }
function OnFailed_SoColissimoSelectionnePointRetrait(erreur) { document.location.href = '/panier-confirmation.aspx'; }
function OnSucceeded_SoColissimoSelectionneDomicile(vResult) { document.location.href = '/panier-confirmation.aspx'; }
function OnFailed_SoColissimoSelectionneDomicile(erreur) { document.location.href = '/panier-confirmation.aspx'; }
function colorboxFermerVisible() { $('#cboxClose').css({ top: 0, right: 0, 'background-image': 'url(Image/SoColissimo/fermer.gif)', width: 69, 'background-position': '0 0 ' }) }


/************AUTOCOMPLETION*************/
$(document).ready(function () {
    $('#ValeurField0').keydown(function (e) {
        if (e.keyCode == 13) {
            if ($('#autocompletediv li.selected').length) { document.location = $('#autocompletediv li.selected a').attr('href'); }
            else Recherche();
            $('#autocompletediv').hide();
            return false
        }
    }).keyup(function (e) {
        $('body').click(function () { $('#autocompletediv').html(''); });

        if (e.keyCode == 40) {
            var LiSelected = $('#autocompletediv li.selected');
            var TousLi = $('#autocompletediv li');
            var LastLi = $('#autocompletediv li:last-child ');
            var FirstLi = $('#autocompletediv li:first-child ');
            if (TousLi.length) {
                if (LiSelected.length == 0) { FirstLi.addClass("selected"); $('#ValeurField0').val($('#autocompletediv li.selected a').text()); }
                else if (LiSelected == LastLi) { LiSelected.removeClass("selected"); }
                else { LiSelected.removeClass("selected"); LiSelected.next('li').addClass("selected"); $('#ValeurField0').val($('#autocompletediv li.selected a').text()); }
            }
        }
        else if (e.keyCode == 38) {
            var LiSelected = $('#autocompletediv li.selected');
            var TousLi = $('#autocompletediv li');
            var LastLi = $('#autocompletediv li:last-child ');
            var FirstLi = $('#autocompletediv li:first-child ');
            if (TousLi.length) {
                if (LiSelected.length == 0) { LastLi.addClass("selected"); $('#ValeurField0').val($('#autocompletediv li.selected a').text()); }
                else if (LiSelected == FirstLi) { LiSelected.removeClass("selected"); }
                else { LiSelected.removeClass("selected"); LiSelected.prev('li').addClass("selected"); $('#ValeurField0').val($('#autocompletediv li.selected a').text()); }
            }
        }
        else if (e.keyCode == 27) {
            $('#autocompletediv').html('');
        }
        else { AutoComplete(); }
    });
});




