
var agent = navigator.userAgent.toLowerCase();

/*** GESTION DU LAYER RAYON AUCHAN ****/

function setupCatalog(){
        var MyCatalog = document.getElementById('layerCatalog');
        if(MyCatalog != undefined){
                document.getElementById("layerCatalog").className="displayNone";
                var openLay=document.getElementById("openLay");
                addEvent(openLay, "mouseover", openCatalog, false);

                var Catalog=document.getElementById("layerCatalog");
                addEvent(Catalog, "mouseover", openCatalog, true);
                addEvent(Catalog, "mouseout", closeCatalog, true);
        }
}


function openCatalog(){
        document.getElementById("layerCatalog").className="posCatalog";
        return(false);
}

function closeCatalog(){
        document.getElementById("layerCatalog").className="hideCatalog displayNone";
        return(false);
}

/*** FIN GESTION DU LAYER RAYON AUCHAN ****/

//Fonction incr&eacute;mente quantit&eacute; article panier
function inc(objet){
        var inputQuantite = objet.parentNode.getElementsByTagName('INPUT');
   inputQuantite[0].value++;
}

//Fonction d&eacute;cr&eacute;mente quantit&eacute; article panier
function dec(objet){
        var inputQuantite = objet.parentNode.getElementsByTagName('INPUT');
   if (inputQuantite[0].value > 0 ) {
       inputQuantite[0].value--;
   }
}

function inc(objet,inc){
  var inputQuantite = objet.parentNode.getElementsByTagName('INPUT');
  qte = new Number(inputQuantite[0].value);
  qte = qte+inc;
  inputQuantite[0].value = qte;
}

//Fonction d&eacute;cr&eacute;mente quantit&eacute; article panier
function dec(objet,dec){
  var inputQuantite = objet.parentNode.getElementsByTagName('INPUT');
  if (inputQuantite[0].value > dec ) {
    qte = new Number(inputQuantite[0].value);
    qte = qte-dec;
    inputQuantite[0].value = qte;
   }
}

//Fonction d&eacute;cr&eacute;mente quantit&eacute; article panier
function decMinCommande(objet,decrement,min_qte){
  var inputQuantite = objet.parentNode.getElementsByTagName('INPUT');
  if (inputQuantite[0].value >= min_qte+decrement ) {
                return dec(objet,decrement);
   }
}

// Fonction d'ajout au panier par cug (+acces au panier)
function addToCart(cug) {
        if (document.getElementById("qte"+cug) == null){
                qty = 1;
        }
        else{
                qty = document.getElementById("qte"+cug).value;
        }
        window.location.href = "/checkout/checkoutEtape1.jsp?panier=2&cug="+cug+"&qty="+qty;
}

// Fonction d'ajout au panier par cug (+acces au panier) - cas ou ya 2 icones
function addToCart2(cug) {
        if (document.getElementById("qte2_"+cug) == null){
                qty = 1;
        }
        else{
                qty = document.getElementById("qte2_"+cug).value;
        }
        window.location.href = "/checkout/checkoutEtape1.jsp?panier=2&cug="+cug+"&qty="+qty;
}


addLoadListener(setupCatalog);

/* DIGITAS - 02/04/08 : Modifications */
/* BI 11/02 */
jQuery(document).ready(function(){
        checkInputAdressShiping();
        openPopupTicket();
});

function openPopupTicket(){
        var listLinkTicket = jQuery(".linkOpenPopupTicket");
        if (listLinkTicket.length){
                listLinkTicket.click(function(){
                        window.open( this.href , '' , 'top=' + ((screen.height/2)-250) + ' , left=' + ((screen.width/2)-300) + ' , width=600 , height=500 , scrollbars=yes' );
                        return false;
                });
        }
}
/* DIGITAS - 02/04/08 : Fin Modifications */


function checkInputAdressShiping(){
  if(document.forms["FormInscription"])
    if(!document.forms["FormInscription"].elements["memeAdresseNo"].checked)
             jQuery("#ShowLivraison").hide();
        jQuery("#memeAdresseNo").click(function(){
                jQuery("#ShowLivraison").show();
        });
        jQuery("#memeAdresseYes").click(function(){
                jQuery("#ShowLivraison").hide();
        });
}
/* Fin BI 11/02 */


/* Layer nav */
var timeoutNav;
function displayLayerNav(event){
        event.preventDefault;
        var parentTab = jQuery(this).parents(".navItem");
        var hoverLayer = false;

        if (jQuery(parentTab).hasClass("active")) {
        	if (event.type == "click") {
        		window.clearTimeout(timeoutNav);
                jQuery(parentTab).removeClass("active");
                /* DIGITAS - 19/10/09 : Ajout */
                if (typeof document.body.style.maxHeight === "undefined") {
                        jQuery(parentTab).find(".navItemFrame").remove();
                }
                /* DIGITAS - 19/10/09 : FIN Ajout */
        	}
        }
        else {
        	var timeDelay = 250;
        	if (event.type == "click") {
        		timeDelay = 0;
        	}
        	window.clearTimeout(timeoutNav);
        	timeoutNav = setTimeout(
        			function() {
        				 jQuery(parentTab).addClass("active");
        	                jQuery(parentTab).siblings().removeClass("active");
        	                /* DIGITAS - 19/10/09 : Ajout */
        	                if (typeof document.body.style.maxHeight === "undefined") {
        	                        jQuery(parentTab).append("<iframe class=\"navItemFrame\"></iframe>");
        	                        jQuery(parentTab).find(".navItemFrame").height(jQuery(this).parents(".navItem").find(".navLayer").height());
        	                }
        	                /* DIGITAS - 19/10/09 : FIN Ajout */
        	                /* DIGITAS - 09/10/09 : Ajout nav layer */
        	                jQuery(parentTab).hover(function(){
        	                },function(){
        	                        jQuery(this).removeClass("active");
        	                        /* DIGITAS - 19/10/09 : Ajout */
        	                        if (typeof document.body.style.maxHeight === "undefined") {
        	                                jQuery(parentTab).find(".navItemFrame").remove();
        	                        }
        	                        /* DIGITAS - 19/10/09 : FIN Ajout */
        	                });
        	                /* DIGITAS - 09/10/09 : FIN Ajout nav layer */
        			},
        			timeDelay
        	);
        }
}


/* roll Push services */
function rollServices(){
        jQuery(this).addClass("active");
        jQuery(this).siblings("li").removeClass("active");
}

/* display footer Tab */
function displayFooterTab(){
        var displayLink = jQuery(this).attr("href").split("#")[1];

        if (jQuery(this).parent().hasClass("active")) {
                jQuery(this).parent().removeClass("active");
                jQuery(this).parents(".footerHeading").removeClass("activedList");
                jQuery("#" + displayLink).hide();
        }
        else {
                jQuery(this).parent().addClass("active");
                jQuery(this).parent().siblings(".active").removeClass("active");
                jQuery(this).parents(".footerHeading").addClass("activedList");
                jQuery("#" + displayLink).show();
                jQuery("#" + displayLink).siblings(".footerDisplay").hide();
        }
        return false;
}

/* Init input value display */
function removeValueField(){
        var inputDefaultValue = jQuery(this).attr("defaultValue");
        if (jQuery(this).attr("value") == inputDefaultValue) {
                jQuery(this).attr("value","");
        }
        jQuery(this).bind("blur", function(){
                if (!jQuery(this).attr("value")) {
                        jQuery(this).attr("value",inputDefaultValue);
                }
        });
}

/* display layer bloc services */
function displayLayerBlocServicesMore(){

        jQuery("#blocServices li").removeClass("active");
        jQuery("#blocServices li div").hide();

        var blockLinkId = this.href.split("#")[1];
        jQuery("#"+blockLinkId).show();
        jQuery(this).parent().addClass("active");

        return false;
}

/* display layer FAQ section */
function displayLayerFaqSection(){
        var parentQuestion = jQuery(this).parents(".faqSection");
        if (parentQuestion.hasClass("active")) {
                parentQuestion.removeClass("active");
                parentQuestion.find(".faqQuestions").hide();
        }
        else {
                parentQuestion.addClass("active");
                parentQuestion.find(".faqQuestions").show();
        }
        return false;
}


/* display layer faq reponses */
function displayLayerFaqResponse(){
        var parentQuestion = jQuery(this).parents(".faqQuestion");
        if (parentQuestion.hasClass("active")) {
                parentQuestion.removeClass("active");
                jQuery(this).siblings(".response").hide();
        }
        else {
                jQuery("#faqQuestions .faqQuestion.active .response").hide();
                jQuery("#faqQuestions .faqQuestion.active").removeClass("active");
                parentQuestion.addClass("active");
                jQuery(this).siblings(".response").show();
        }
        return false;
}

/* checkout layer */
function displayCheckoutLink(){
        if (jQuery(this).hasClass("activeLink")) {
                jQuery(this).removeClass("activeLink");
                jQuery(this).parent().siblings(".headerCheckoutBlock").hide()
        }
        else {
                jQuery(this).addClass("activeLink");
                jQuery(this).parent().siblings(".headerCheckoutBlock").show()
        }
        return false
}

/* push more display */
function displayPushMore(){
        if (jQuery(this).parents("li").hasClass("activeItem")) {
                jQuery(this).parent().siblings(".itemLayer").hide();
                jQuery(this).parents("li").removeClass("activeItem")
        }
        else {
                jQuery(this).parent().siblings(".itemLayer").show();
                jQuery(this).parents("li").addClass("activeItem");
                jQuery(this).parents("li").siblings(".activeItem").find(".itemLayer").hide();
                jQuery(this).parents("li").siblings(".activeItem").removeClass("activeItem");
        }
        return false;
}

/* Quantity */
function displayLessQuantity(){
        var inputQuantity = jQuery(this).siblings("input[@type=text]");
        var inputValue = parseInt(inputQuantity.attr("value"));

        if (inputValue != 1) {
                inputQuantity.attr("value", inputValue-1);
        }
        return false;
}

function displayMoreQuantity(){
        var inputQuantity = jQuery(this).siblings("input[@type=text]");
        var inputValue = parseInt(inputQuantity.attr("value"));

        inputQuantity.attr("value", inputValue+1);

        return false;
}

/* Tooltip */
function catalogueTooltip(){
        if (typeof document.body.style.maxHeight === "undefined") {
                jQuery(".catalogueTooltip").hover(function(){
                        var tooltipHeight = jQuery(this).find(".displayTooltip").height();
                        jQuery(this).find(".displayTooltip").before("<iframe class=\"tooltipFrame\"></iframe>").show();
                        jQuery(this).find(".tooltipFrame").height(tooltipHeight);
                        jQuery("#contentLift").css("z-index","11");
                }, function(){
                        jQuery(this).find(".displayTooltip").hide();
                        jQuery(this).find(".tooltipFrame").remove();
                        jQuery("#contentLift").css("z-index","0");
                });
        }
        else{
                jQuery(".catalogueTooltip").hover(function(){
                        jQuery("#contentLift").css("z-index","11");
                }, function(){
                        jQuery("#contentLift").css("z-index","0");
                });
        }

}

/* 'aide au choix' fake layers */
function initHelpDisplay(){
        var txtObj = {
                initTxt: "R�initialiser les crit�res",
                titleTxtOff: "<strong>Aide au choix :</strong> Choisissez vos produits selon vos crit�res",
                titleTxtOn: "<strong>Aide au choix :</strong> s�lectionnez un ou plusieurs crit�res ci-dessous",
                showTxt: "Afficher l'aide au choix",
                hideTxt: "Fermer l'aide au choix",
                selectedFilterTxt: "crit�res s�lectionn�(s)",
                emptyFilterTxt: "Tous"
        };

        var disabledInput = false;

        // INIT
        jQuery(".searchFormProducts .ligne.last").append("<p class=\"resetHelpSearchFilters\"><a href=\"#\">"+txtObj.initTxt+"</a></p>");
        jQuery(".searchHeadingWording").html(txtObj.titleTxtOn);
        jQuery(".searchHeading").append("<p class=\"searchHeadingActions\"><a href=\"#\">"+txtObj.hideTxt+"</a></p>")
                                                        .addClass("opened");
        jQuery(".searchFormDisplay .selectbox-wrapper") .addClass("active-wrapper")
                                                                                                        /* DIGITAS - 09/10/09 : Suppression de la ligne suivante .before("<input class=\"fakeSelect\" value=\""+txtObj.emptyFilterTxt+"\" />"); */

        // Form Display
        jQuery(".searchHeading").bind("click", function(){
                if (jQuery(this).hasClass("opened")) {
                        jQuery(this).siblings(".searchFormDisplay").hide().end()
                                                .find(".searchHeadingActions a").html(txtObj.showTxt).end()
                                                .removeClass("opened");
                }
                else {
                        jQuery(this).siblings(".searchFormDisplay").show().end()
                                                .find(".searchHeadingActions a").html(txtObj.hideTxt).end()
                                                .addClass("opened");
                }
                return false;
        });

        // Select Display
        jQuery(".searchFormDisplay .fakeSelect").bind("click",function(){
                var layerSibling = jQuery(this).siblings(".selectbox-wrapper");
                if (jQuery(this).parents(".activeStandard").length) {
                        jQuery(this).parents(".standard").removeClass("activeStandard");
                        if (typeof document.body.style.maxHeight === "undefined") {
                                layerSibling.siblings(".selectFrame").remove();
                        }
                }
                else {
                        if (typeof document.body.style.maxHeight === "undefined") {
                                jQuery(".searchFormDisplay .activeStandard .selectFrame").remove();
                        }
                        jQuery(".searchFormDisplay .activeStandard").removeClass("activeStandard");
                        jQuery(this).parents(".standard").addClass("activeStandard");
                        if (typeof document.body.style.maxHeight === "undefined") {
                                var fakeLayerHeight = layerSibling.height();
                                layerSibling.after("<iframe class=\"selectFrame\"></iframe>").show()
                                                        .siblings(".selectFrame").height(fakeLayerHeight);
                        }
                }
        });

        // highlighting
        jQuery(".searchFormDisplay .field")     .hover(function(){
                                                                                jQuery(this).addClass("current");
                                                                                },function(){
                                                                                        jQuery(this).removeClass("current");
                                                                                })

        // value selecting
        jQuery(".searchFormDisplay .field input[type=checkbox]:not([class*=allChoice])").bind("click", function(){

                // selected class display
                if (jQuery(this).is(":checked")) {
                        jQuery(this).parent().addClass("selected");
                        jQuery(this).parents(".standard").find("input.allChoice").removeAttr("checked");/* DIGITAS - 14/10/09 : Ajout */
                }
                else {
                        jQuery(this).parent().removeClass("selected");
                        /* DIGITAS - 14/10/09 : Ajout */
                        if (!jQuery(this).parents(".standard").find("input:checked").length) {
                                jQuery(this).parents(".standard").find("input.allChoice").attr("checked","checked").triggerHandler("click");
                        }
                        /* DIGITAS - 14/10/09 : FIN Ajout */
                }

                // full display
                var uncheckedInput = jQuery(this).parents(".selectbox-wrapper").find("input:not(:checked):not([class*=allChoice])");
                var checkedInputLength = jQuery(this).parents(".selectbox-wrapper").find("input:checked:not([class*=allChoice])").length;

                if (checkedInputLength > 0) {
                        jQuery(this).parents(".standard").addClass("fullStandard");
                }
                else {
                        jQuery(this).parents(".standard").removeClass("fullStandard");
                }
                if ( checkedInputLength >= 3) {
                        uncheckedInput.attr("disabled", "disabled");
                }
                else {
                        uncheckedInput.removeAttr("disabled");
                }
                if (checkedInputLength == 0) {
                        jQuery(this).parents(".standard").find(".fakeSelect").val(txtObj.emptyFilterTxt);
                }
                else {
                        jQuery(this).parents(".standard").find(".fakeSelect").val(checkedInputLength+" "+txtObj.selectedFilterTxt);
                }

                // append value
                if (!jQuery(this).parents(".standard").find(".selectedValues").length) {
                        jQuery(this).parents(".standard").append("<p class=\"selectedValues\"></p>")
                }
                var valueTxt = "";
                jQuery(this).parents(".selectbox-wrapper").find("input:checked:not([class*=allChoice])").each(function(i){
                        if (i > 0) {
                                valueTxt = valueTxt+ ", ";
                        }
                        valueTxt = valueTxt+ jQuery(this).siblings("label").text();
                });
                jQuery(this).parents(".standard").find(".selectedValues").text(valueTxt);

        });

        //  all value selecting
        jQuery(".searchFormDisplay .field input.allChoice").bind("click", function(){

                if (jQuery(this).is(":checked")) {
                        /* DIGITAS - 14/10/09 : Retrait de la ligne suivante :
                                jQuery(this).parents(".standard").addClass("fullStandard");
                         */
                        jQuery(this).parent().addClass("selected")
                                                .parents(".standard").find(".selectedValues").remove().end()
                                                .find(".fakeSelect").val(txtObj.emptyFilterTxt).end()
                                                .find("input:checked:not([class*=allChoice])").parent().removeClass("selected").end()
                                                .removeAttr("checked").end()
                                                /* DIGITAS - 14/10/09 : Remplacement de la ligne suivante
                                                        .find("input[type=checkbox]:not([class*=allChoice])").attr("disabled","disabled");
                                                 */
                                                 .find("input[type=checkbox]:not([class*=allChoice])").removeAttr("disabled");
                                                 /* DIGITAS - 14/10/09 : FIN Remplacement de la ligne */
                }
                else {
                        return false;/* DIGITAS - 14/10/09 : Ajout */
                        /* DIGITAS - 14/10/09 : Retrait des 3 lignes suivantes :
                                jQuery(this).parent().removeClass("selected");
                                jQuery(this).parent().removeClass("selected");
                                jQuery(this).parent().parents(".standard").find("input:disabled:not([class*=allChoice])").removeAttr("disabled");
                        */
                }
                jQuery(this).parents(".standard").removeClass("fullStandard");/* DIGITAS - 14/10/09 : Ajout */
        });


        // Close layer
        jQuery(".searchFormDisplay input").bind("blur", function(){
                if (!jQuery(this).parents(".standard").find(".current").length) {
                        jQuery(this).parents(".standard").removeClass("activeStandard");
                        if (typeof document.body.style.maxHeight === "undefined") {
                                jQuery(this).parents(".standard").find(".selectFrame").remove();
                        }
                }
        })

        // Reset
        jQuery(".searchFormDisplay .resetHelpSearchFilters a").bind("click", function(){
                jQuery(".searchFormDisplay .field input.allChoice").attr("checked","checked");
                jQuery(".searchFormDisplay .field input.allChoice:disabled").removeAttr("disabled");
                jQuery(".searchFormDisplay .field input.allChoice").each(function(){
                        jQuery(this).triggerHandler("click");
                });
                return false;
        });

        // Init
        /* DIGITAS - 09/10/09 : Remplacement des declarations suivants
        jQuery(".searchFormDisplay .field input.allChoice").attr("checked","checked");
        jQuery(".searchFormDisplay .field input.allChoice:disabled").removeAttr("disabled");
        jQuery(".searchFormDisplay .field input.allChoice").each(function(){
                jQuery(this).triggerHandler("click");
        });
        */
        jQuery(".searchFormDisplay .selectbox-wrapper").each(function(){
                 if (jQuery(this).find(".field input:checked").length) {
                        jQuery(this).find(".field input:checked").each(function(){
                                jQuery(this).attr("checked","checked");
                                jQuery(this).triggerHandler("click");
                        });
                 }
                 else {
                        jQuery(this).find(".field input.allChoice").attr("checked","checked");
                        jQuery(this).find(".field input.allChoice:disabled").removeAttr("disabled");
                        jQuery(this).find(".field input.allChoice").each(function(){
                                jQuery(this).triggerHandler("click");
                        });
                 }
        });
        /* DIGITAS - 09/10/09 : FIN Remplacement des declarations */

}

/* ! Suggestion Search */
        var hasBeenClosed = false; // to check if the autocompletion layer has already been close once, and avoid re-show it each time

// Init Search Navigation
function initLayerNavigation2 (){

        var serchfile = "/recherche/suggestions.jsp"
        var millisBetween2Search = 0; //GTH
        var timeoutDisplay; //GTH
        var autoCompleteNum = rechercheNbCaractereCompletion;

        var active = 0;
        var showLayer = true;
        var inputSearch = jQuery(".searchInputDisplay2");
        var siblingLayer = jQuery(inputSearch).parent().siblings(".suggestionsLayer2");

        var inputSearchLength = jQuery(".searchInputDisplay2").val().length

        // KEYDOWN
        jQuery(inputSearch).bind("keydown", function(event){
                var myInputLength = event.target.value.length;

                if (myInputLength >= autoCompleteNum) {
                        switch (event.keyCode) {
                                case 38: // up
                                        event.preventDefault();
                                        moveSelect(-1);
                                        break;
                                case 40: // down
                                        event.preventDefault();
                                        moveSelect(1);
                                        break;
                                case 13: // return
                                       /* DIGITAS - 03/12/09 : Retrait de la d�claration suivante :  event.preventDefault(); */
                                        jQuery(siblingLayer).find("li.current a").trigger("click");
                                        jQuery(inputSearch).unbind("blur");
                                        break;
                        }
                }

                inputSearchLength = jQuery(".searchInputDisplay2").val().length

        });

        function launchSearch(event)
        {
                var myInputLength = event.target.value.length;
                var myInputValue = event.target.value;
                if(myInputLength === 0) {
                        showLayer = true;
                        hasBeenClosed = false;
                        jQuery(siblingLayer).slideUp("fast"); // Hide the suggestions box
                } else if(myInputLength >=autoCompleteNum && inputSearchLength != myInputLength && showLayer == true && !hasBeenClosed){
	                    active = 0;
	                    /*
	                     */
                        jQuery.ajax({
                     	   url:  serchfile,
                     	   type: 'POST',
                     	   data: {queryString: ""+myInputValue+""},
                     	   success: function(data) {
                     		   	var BEGIN = "<!-- BEGIN_CODE -->";
                     		   	var END = "<!-- END_CODE -->";
                     		   	var replacement = data.substr(data.indexOf(BEGIN)+BEGIN.length);
                     		    replacement = replacement.substr(0,replacement.indexOf(END));
                                jQuery(siblingLayer).find(".suggestionsLayerContent2").html(replacement);
                                jQuery(siblingLayer).find(".suggestionsLayerContent2").find("li a").click(function(eventClick){                        
                                        eventClick.preventDefault();
                                        var myLinkValue = jQuery(this).find(".heading").text();
                                        event.target.value = myLinkValue;
                                        jQuery(siblingLayer).slideUp("fast");
										jQuery(this).parents("form").submit();
                                });
                                if (jQuery(siblingLayer).find(".suggestionsLayerContent2").find("li").length>0) {
                             	   jQuery(siblingLayer).slideDown("fast"); // Show the suggestions box
                                }else{
                             	   jQuery(siblingLayer).slideUp("fast"); // hide the suggestion box if no result                                 
                                }
                                event.preventDefault();
                                event.stopPropagation();
                     	   },
                     	   error: function (XMLHttpRequest, textStatus, errorThrown) {
                     	      alert(XMLHttpRequest.status);
                     	      alert(XMLHttpRequest.responseText);
                     	   }
                    	});
                }
        }

        // KEYUP
        jQuery(".searchInputDisplay2").bind("keyup", function(event){
                if(timeoutDisplay!=null)
                        clearTimeout(timeoutDisplay);
                //alert("GTH 1 "+clearTimeout);
                timeoutDisplay = setTimeout (function() {launchSearch(event);}, millisBetween2Search );
                //alert("GTH 2 "+clearTimeout);
        });
        jQuery(inputSearch).bind("focus", function(){
        //at focus, bind the blur event, with a timeout to prevent conflict between blur and focus
                jQuery(inputSearch).bind("blur", function(){
                        setTimeout(function(){jQuery(siblingLayer).slideUp("fast");},500);
                });
        });

        function moveSelect(step) {
                var lis = jQuery("li", siblingLayer);
                if (!lis || lis.length == 0) return false;
                active += step;
         //loop through list
                if (active < 0) {
                        active = lis.size();
                } else if (active > lis.size()) {
                        active = 0;
                }
                lis.removeClass("current");
                jQuery(lis[active-1]).addClass("current");
        }



        jQuery(".suggestionsLayer2 .btCloseSearch a").bind("click", function(){
                jQuery(this).parents(".suggestionsLayer2").slideUp("fast");
                showLayer = false;
                hasBeenClosed = true;//set the flag for hiding autocompletion until field will be emptyed again
                jQuery(inputSearch).trigger("focus");
                return false;
        });
}

/* DIGITAS - 14/10/09 : Modification/Ajout searchField */
function removeValueSeardField(){
        var searchFieldDefault = "Rechercher";
        if (jQuery(this).val() == searchFieldDefault) {
                jQuery(this).val("");
        }
        jQuery(this).blur(function(){
                if (jQuery(this).val() == "") {
                        jQuery(this).val(searchFieldDefault);
                }
        });
}
/* DIGITAS - 14/10/09 : FIN Modification/Ajout searchField */

/* Effacement message popup nouveau a paraitre */
function removeValueAlertEmail(){
        var searchFieldDefault = "Votre adresse e-mail";
        if (jQuery(this).val() == searchFieldDefault) {
                jQuery(this).val("");
        }
}

/////////////// DOCUMENT READY INIT //

jQuery(document).ready(function() {

        /*  INIT custom select */
       /* jQuery(".customSelect").selectbox(); DIGITAS - 03/12/09 : Retrait de la d�claration */ 

        /*  INIT Layer nav */
        jQuery("#breadcrumb .displayLink").bind("click", displayLayerNav);
        jQuery("#breadcrumb .displayLink, #breadcrumb .sectionItem").bind("mouseover", displayLayerNav);
        jQuery("#breadcrumb .displayLink, #breadcrumb .sectionItem").bind("mouseout", function() {
        	window.clearTimeout(timeoutNav);
        });

        /* INIT roll Push services */
        jQuery(".cataloguePush .servicesList li").bind("mouseover", rollServices);

        /* INIT display footer Tab */
        jQuery(".footerHeading .footerNavList li:not(.active)").each(function(){
                var blockLinkId = jQuery(this).find("a").attr("href").split("#")[1];
                jQuery("#"+blockLinkId).hide();
        });
        jQuery(".footerHeading .footerNavList li a").bind("click", displayFooterTab);

        /* INIT input value display */

        /* DIGITAS - 14/10/09 : Modification/Ajout searchField */
        jQuery(".inputDefaultDisplay").bind("focus", removeValueField);
       /* jQuery(".searchInputDisplay2").bind("focus", removeValueSeardField); DIGITAS - 03/12/09 : Retrait de la d�claration */
        /* DIGITAS - 14/10/09 : FIN Modification/Ajout searchField */
        
        	/* Effacement message popup nouveau a paraitre */
  				jQuery(".text").bind("focus", removeValueAlertEmail);


        /* INIT display bloc services tabs */
        jQuery("#blocServices li").each(function(){
                var blockLinkId = jQuery(this).find("a").attr("href").split("#")[1];
                jQuery("#"+blockLinkId).hide();
                jQuery(this).removeClass("active");
        });
        /* INIT events bloc services tabs */
        jQuery("#blocServices .blocServicesSeeMore").bind("click", displayLayerBlocServicesMore);

        /* INIT events  faq questions */
        jQuery("#faqQuestions .faqSectionTitleBlock").bind("click", displayLayerFaqSection);
        jQuery("#faqQuestions .faqQuestionTitle").bind("click", displayLayerFaqResponse);
        jQuery("#faqQuestions .faqQuestion .response").hide();
        jQuery("#faqQuestions .faqQuestion.active .response").show();


        /* INIT carousel */
        // HOME horizontal
        var controllerList = jQuery(".homeCarouselController li a");
        var activeItem = 0;
        if (jQuery(".homeCarouselController li.active").length) {
                var activeItem = parseInt(jQuery(".homeCarouselController li.active a").attr("class"))-1;
        }
        jQuery(".homeCarouselContainer").jCarouselLite({
                visible: 1,
                start: activeItem,
                speed:0,/* DIGITAS - 19/10/09 : speed a 0 */
                btnGo:controllerList,
                circular:false,
                afterEnd: function(a) {
                        jQuery(".homeCarouselController li.active").removeClass("active");
                        var indexCurrent = jQuery(".homeCarouselContainer .carouselList > li").index(jQuery(a))+1;
                        jQuery(".homeCarouselController li a."+indexCurrent).parent().addClass("active");
                }
        });
        // HOME verticale
        var varticalControllerList = jQuery(".homeProductListContainer .carouselHeading a");
        var controllerActive = 0;
        var classReg = new RegExp(/^itemDisplay/);

        if (jQuery(".homeProductListContainer .carouselHeading li.active").length) {
                var controllerActive = parseInt(jQuery(".homeProductListContainer .carouselHeading li.active a").attr("class")) - 1;
        }
        else {
                jQuery(".homeProductListContainer .carouselHeading li:first-child").addClass("active");
        }
        jQuery(".homeProductListCarousel").jCarouselLite({
                visible:1,
                vertical:true,
                auto: 2500,/* DIGITAS - 19/10/09 : changement de la valeur */
                speed: 1000,/* DIGITAS - 19/10/09 : changement de la valeur */
                stopAuto: jQuery(".homeProductListCarousel .carouselItem"),
                start: controllerActive,
                btnGoDirect:varticalControllerList, /* DIGITAS - 19/10/09 : remplacer btnGo par btnGoDirect */
                afterEnd: function(a) {
                        var eltClass = jQuery(a).attr("class").split(" ");
                        eltClass = jQuery.grep(eltClass, function(txt){
                                return (classReg.test(txt));
                    });
                        var itemActivated = eltClass[0].split("itemDisplay")[1];
                        jQuery(".homeProductListContainer .carouselHeading li.active").removeClass("active");
                        jQuery(".homeProductListContainer .carouselHeading li a."+itemActivated).parent().addClass("active");

                }
        });

        /*  INIT shop carousel */
        var carouselNum = jQuery(".stdCarouselPush .carouselContainer li").length;

        if (carouselNum > 5) {
                jQuery(".stdCarouselPush .stdCataloguePushTitle").append("<div class=\"carouselController\"><a class=\"prevBt\"><span>Pr�c�dent</span></a><a class=\"nextBt\"><span>Suivant</span></a></div>")
                jQuery(".stdCarouselPush .carouselContainer").jCarouselLite({
                        visible: 5,
                        vertical: true,
                        speed: 1000,
                        scroll: 1,
                        btnNext: ".stdCarouselPush .nextBt",
                        btnPrev: ".stdCarouselPush .prevBt"
                });
        }

        /* INIT checkout layer */
        jQuery(".displayCheckoutLink").bind("click", displayCheckoutLink);
        if (jQuery(".displayCheckoutLink").hasClass("activeLink")) {
                jQuery(".displayCheckoutLink").parent().siblings(".headerCheckoutBlock").show()
        }
        jQuery(".closeCheckoutLayer a").bind("click", function(){
                jQuery(".displayCheckoutLink").trigger("click");
        });

        /* INIT push more display */
        jQuery(".morePushBlock .itemHeading a").bind("click",displayPushMore);
        jQuery(".morePushBlock li[class!=activeItem] .itemHeading").siblings(".itemLayer").hide();

        /* INIT Quantity */
        /* 23092009 : Suppression, car lors de l utilisation de boutons btLess, btMore, btMoinsPdt...
           on appelle explicitement les fonctions inc() et dec () qui prennent bien en compte le pcb lors de l'ajout/suppression
           , l appel ci-dessous ne sert donc plus a rien
  */
        //jQuery(".catalogueQuantityDisplay .btLess, .prodTicket .btMoinsPdt").bind("click", displayLessQuantity);
        //jQuery(".catalogueQuantityDisplay .btMore, .prodTicket .btPlusPdt").bind("click", displayMoreQuantity)

        /* Init Tooltip */
        catalogueTooltip();

        /* Init 'aide au choix' fake layers */
        initHelpDisplay();

        /* INIT comparateur */
        jQuery(".tableCompareChoice .colEmptyCheckbox input").bind("click", function(){
                var checkedNum = jQuery(this).parents(".tableCompareChoice").find(".colEmptyCheckbox input:checkbox:checked").length;
                if (checkedNum >= 4) {
                        jQuery(this).parents(".tableCompareChoice").find(".colEmptyCheckbox input:checkbox:not(:checked)").attr("disabled", "disabled");
                }
                else {
                        jQuery(this).parents(".tableCompareChoice").find(".colEmptyCheckbox input:checkbox:disabled").removeAttr("disabled");
                }
        });

        /* ! INIT Add Search Suggestions */
        initLayerNavigation2();


        /* ! INIT Home news feed */
        if(jQuery("#newsFeedContainer").length){
        		jQuery.ajax({
                type: "GET",
                url: "newsFeed.xml",
                dataType: "xml",
                success: function(xml) {
                    jQuery(xml).find("news").each(function(){
                                        var readingTime = jQuery(this).find("readingtime").text();
                                        var transitionTime = jQuery(this).find("transition").text();
                                        var txtArray = [];
                                        jQuery(this).find("item").each(function(i){
                                                txtArray[i] =jQuery(this).find("content").text();
                                        });
                                        var currentItem = 0;
                                        jQuery("#newsFeedContainer").append("<p class=\"newsFeed\">"+txtArray[currentItem]+"</p>");
                                        window.setInterval(function(){
                                                if (currentItem + 1 == txtArray.length) {
                                                        currentItem = 0;
                                                }
                                                else {
                                                        currentItem = currentItem + 1;
                                                }
                                                jQuery("#newsFeedContainer .newsFeed").fadeOut(transitionTime ,function(){
                                                        jQuery("#newsFeedContainer .newsFeed").html(txtArray[currentItem]);
                                                        jQuery("#newsFeedContainer .newsFeed").fadeIn(transitionTime);
                                                });
                                        }, readingTime);
                    });
                }
            });
        }


        /* DIGITAS - 08/07/09 : Ajouts Espace Photo */
        jQuery(".cataloguePdtContainer .helpDisplayContent").hide();
        jQuery(".cataloguePdtContainer.activeItem .helpDisplayContent").show();

        jQuery(".cataloguePdtContainer .heplpDisplayTitle").bind("click", function(){
                if (jQuery(this).parent().hasClass("activeItem")) {
                        jQuery(this).siblings(".innerCataloguePdt").find(".helpDisplayContent").hide();
                        jQuery(this).parent().removeClass("activeItem")
                }
                else {
                        jQuery(".cataloguePdtContainer.activeItem .helpDisplayContent").hide();
                        jQuery(".cataloguePdtContainer.activeItem .heplpDisplayTitle").removeClass("activeItem");
                        jQuery(this).siblings(".innerCataloguePdt").find(".helpDisplayContent").show();
                        jQuery(this).parent().addClass("activeItem")
                }
        });
        /* DIGITAS - 08/07/09 : FIN Ajouts Espace Photo */

        /* DIGITAS - 13/10/09 : Ajout Newsletter home */
        if (typeof document.body.style.maxHeight === "undefined") {
                jQuery(".homeCustomersNewsletter .customersPart").hover(function(){
                        jQuery(this).find(".customersTooltip").addClass("activeCustomersTooltip");
                },function(){
                        jQuery(this).find(".customersTooltip").removeClass("activeCustomersTooltip");
                });
        }
        /* DIGITAS - 13/10/09 : FIN Ajout Newsletter home */
		if(typeof(hide)!='undefined' && hide != null && hide == 'true'){
			jQuery(".searchHeading").click();
		}

});

/* Repost */
function rePostSearch(){
	var formSearch = jQuery("#FormRechercheRefonte");
	if ("true" == formSearch.attr("repost")) {
		formSearch.submit();
	} else {
		window.location.reload();
	}
}

