var DEBUG="DEBUG";var INFO="INFO";var WARNING="WARNING";var ERROR="ERROR";var Logger=new Class({initialize:function(){this._conteneur=null;this._actif=false;this._filtres=[DEBUG,INFO,WARNING,ERROR];this._colors=new Hash();this._colors.set(DEBUG,"#00cc00");this._colors.set(INFO,"#0000cc");this._colors.set(WARNING,"#fb5c01");this._colors.set(ERROR,"#cc0000");},getConteneur:function(){return this._conteneur;},setConteneur:function(A){this._conteneur=A;},estActif:function(){return this._actif;},setActif:function(A){this._actif=A;},getFiltres:function(){return this._filtres;},setFiltres:function(A){this._filtres=A;},activer:function(A){this.setActif(true);if(null!=A){this.setConteneur(A);}else{this.setConteneur($$("body")[0]);}},desactiver:function(){this.setActif(false);},append:function(A,B){var C="["+A+"] : "+B;if(null==$("__logger")){this.creerCalque();}new Element("div").setHTML(C).setStyles({"color":this._colors.get(A)}).injectInside($("__logger__body"));},creerCalque:function(){var D=new Element("div",{"id":"__logger","events":{"mouseover":function(){D.setOpacity(1);},"mouseout":function(){D.setOpacity(0.2);}}}).setStyles({"border":"solid 1px #000","width":"500px","position":"relative","margin-left":"auto","margin-right":"auto","z-index":2000});var C=new Element("div",{"id":"__logger__top"}).setStyles({"background-color":"#f0f0f0","border-bottom":"solid 1px #808080","text-align":"right","padding":"5px"});var B=new Element("a",{"href":"javascript:;","title":"Fermer","events":{"click":function(){$("__logger").setStyle("display","none");}}}).setHTML("[x]").setStyles({"text-decoration":"none"});var A=new Element("div",{"id":"__logger__body"}).setStyles({"padding":"5px"});B.injectInside(C);C.injectInside(D);A.injectInside(D);D.setOpacity(0.2);D.injectInside(this.getConteneur());},toString:function(){return"Logger[]";}});window._logger=new Logger();function debug(A){if(_logger.estActif()&&_logger.getFiltres().contains(DEBUG)){window._logger.append(DEBUG,A);}}function info(A){if(_logger.estActif()&&_logger.getFiltres().contains(INFO)){window._logger.append(INFO,A);}}function warn(A){if(_logger.estActif()&&_logger.getFiltres().contains(WARNING)){window._logger.append(WARNING,A);}}function error(A){if(_logger.estActif()&&_logger.getFiltres().contains(ERROR)){window._logger.append(ERROR,A);}}function getLogger(){return window._logger;}var AideAuChoix=new Class({initialize:function(){debug(">> com.fr.boulanger.aideauchoix.AideAuChoix.initialize()");this.setBulle(null);this.setDetail(null);this.init();debug("<< com.fr.boulanger.aideauchoix.AideAuChoix.initialize()");},getBulle:function(){return this._bulle;},setBulle:function(A){this._bulle=A;},getDetail:function(){return this._detail;},setDetail:function(A){this._detail=A;},init:function(){debug(">> com.fr.boulanger.aideauchoix.AideAuChoix.init()");var A=this;$$("a.bulle").each(function(C){var B=getCheminJS()+"json_terme_"+C.getProperty("title")+".json";info("url:"+B);A.ancrer(C,B,true);});document.addEvents({"click":function(C){if($("aide_au_choix_Principal")!=null){var B=getAideAuChoix().getDetail();B.supprimer();getAideAuChoix().setDetail(null);}}});debug("<< com.fr.boulanger.aideauchoix.AideAuChoix.init()");},ancrer:function(C,B,D){var A=this;if(D){C.addEvents({"mouseover":function(F){if(null==$("aide_au_choix_BulleInverse")&&null==$("aide_au_choix_Bulle")&&null==$("aide_au_choix_Principal")){var G=new Event(F);var E=new Json.Remote("/webapp/wcs/stores/servlet/JsonView?storeId=10001&catalogId=10001",{method:"get",async:false,onComplete:function(H){A.setBulle(new Bulle(H));A.getBulle().afficher(G.client.x,G.client.y);},onFailure:function(){error("Impossible de charger le fichier : "+B);}}).send(B);}},"mouseout":function(E){if(null!=A.getBulle()){A.getBulle().fireEvent("onMouseOut",E);}},"click":function(G){if(null!=A.getBulle()){var E=A.getBulle().getJson();A.getBulle().fireEvent("onMouseOut",G);var F=getAideAuChoix().getDetail();if(null==F){F=new DetailTerme(E,null);getAideAuChoix().setDetail(F);}else{F.setJson(E);F.supprimer();}F.ajouterHistorique(E.id,E.libelle);F.afficher(0,0);if(G.stopPropagation){G.stopPropagation();}G.cancelBubble=true;}}});}else{C.addEvents({"click":function(G){var H=new Event(G);var E="";var F=new Json.Remote("/webapp/wcs/stores/servlet/JsonView?storeId=10001&catalogId=10001",{method:"get",async:false,onComplete:function(K){A.setBulle(new Bulle(K));E=A.getBulle().getJson();var J=getAideAuChoix().getDetail();var I=J.getHistorique();J.supprimer();J=new DetailTerme(E,null);getAideAuChoix().setDetail(J);J.setHistorique(I);J.ajouterHistorique(E.id,E.libelle);J.afficher(0,0);},onFailure:function(){error("Impossible de charger le fichier : "+B);}}).send(B);}});}}});window._aide=null;var getAideAuChoix=function(){return window._aide;};var setAideAuChoix=function(A){window._aide=A;};var getCheminImage=function(){return window._cheminImage;};var setCheminImage=function(A){window._cheminImage=A;};var getCheminJS=function(){return window._cheminJS;};var setCheminJS=function(A){window._cheminJS=A;};var getCheminVisuel=function(){return window._cheminVisuel;};var setCheminVisuel=function(A){window._cheminVisuel=A;};var getPageRecherche=function(){return window._pageRecherche;};var setPageRecherche=function(A){window._pageRecherche=A;};var CalqueJson=new Class({initialize:function(B,A){debug(">> com.fr.boulanger.aideauchoix.CalqueJson.initialize()");this.setConteneur(null);this.setJson(B);this.setOptions(A);if(this.options.initialize){this.options.initialize.call(this);}debug("<< com.fr.boulanger.aideauchoix.CalqueJson.initialize()");},getConteneur:function(){return this._conteneur;},setConteneur:function(A){this._conteneur=A;},getJson:function(){return this._json;},setJson:function(A){this._json=A;},toString:function(){var A="com.fr.boulanger.aideauchoix.CalqueJson\n[";A+="\tconteneur: "+this._conteneur+"\n";A+="\tjson: "+this._json+"\n";A+="]";return A;},toElement:function(A){debug(">> com.fr.boulanger.aideauchoix.CalqueJson.toElement()");debug("<< com.fr.boulanger.aideauchoix.CalqueJson.toElement()");return null;},afficher:function(A,B){debug(">> com.fr.boulanger.aideauchoix.CalqueJson.afficher()");debug("<< com.fr.boulanger.aideauchoix.CalqueJson.afficher()");}});CalqueJson.implement(new Events);CalqueJson.implement(new Options);var Bulle=CalqueJson.extend({options:{onMouseOut:function(A){debug(">> com.fr.boulanger.aideauchoix.Bulle.onMouseOut()");var E=$(this.getConteneur());if(null!=E){var D=new Event(A);var G=D.client.x;var F=D.client.y+document.documentElement.scrollTop;var I=E.getStyle("top").toInt();var B=E.getStyle("left").toInt();var C=E.getStyle("height").toInt();var H=E.getStyle("width").toInt();info("x:"+G+", y:"+F+", t:"+I+", l:"+B+", t + h:"+(I+C)+", l + w:"+(B+H));if(F<=I||F>=I+C+10||G<=B||G>=B+H){E.remove();getAideAuChoix().setBulle(null);}}debug("<< com.fr.boulanger.aideauchoix.Bulle.onMouseOut()");}},initialize:function(B,A){debug(">> com.fr.boulanger.aideauchoix.Bulle.initialize()");this.parent(B,A);debug("<< com.fr.boulanger.aideauchoix.Bulle.initialize()");},toString:function(){var A="com.fr.boulanger.aideauchoix.Bulle\n[";A+="\tconteneur: "+this._conteneur+"\n";A+="\tjson: "+this._json+"\n";A+="]";return A;},getMaxX:function(){return window.getWidth()-(203+10);},toElement:function(G){debug(">> com.fr.boulanger.aideauchoix.Bulle.toElement()");this.setConteneur((G>=this.getMaxX())?"aide_au_choix_BulleInverse":"aide_au_choix_Bulle");var E=this.getJson().usage;var B=this;var I=new Element("div",{"id":this.getConteneur()}).setOpacity(0);var D=new Element("div",{"class":"aide_au_choix_titre_Bulle"}).setText(this.getJson().libelle);var A=this.decoupageIntelligent(this.epuration(this.getUsage(E)),35,2,"...");var C=new Element("div",{"class":"aide_au_choix_desc"}).setHTML(A);var H=new Element("div",{"class":"aide_au_choix_enSavoirPlus"});var F=new Element("a",{"href":"javascript:;","title":""}).setText("En savoir plus...");F.addEvent("click",function(L){var J=B.getJson();$(B.getConteneur()).remove();getAideAuChoix().setBulle(null);var K=getAideAuChoix().getDetail();if(null==K){K=new DetailTerme(J,null);getAideAuChoix().setDetail(K);}else{K.setJson(J);K.supprimer();}K.ajouterHistorique(J.id,J.libelle);K.afficher(0,0);});I.addEvent("mouseout",function(J){B.fireEvent("onMouseOut",J);});F.injectInside(H);D.injectInside(I);C.injectInside(I);H.injectInside(I);debug("<< com.fr.boulanger.aideauchoix.Bulle.toElement()");return I;},getUsage:function(B){if(B.contains("<a")){var C=0;var A=0;B=B.replace("</a>","");while(-1!=(C=B.indexOf("<a",0))){A=B.indexOf(">",A)+1;info("pos:"+C+", end:"+A);B=B.substring(0,C)+B.substring(A,B.length);}}info("usage modifie:"+B);return B;},epuration:function(B){if(B.contains("<P")){var C=0;var A=0;B=B.replace("</P>","");while(-1!=(C=B.indexOf("<P",0))){A=B.indexOf(">",A)+1;info("pos:"+C+", end:"+A);B=B.substring(0,C)+B.substring(A,B.length);}}info("usage modifie:"+B);return B;},decoupageIntelligent:function(G,D,B,F){var A="";var E=1;var I="";if(G!=""){G=G.replace("  "," ");G=G.replace(" . ",". ");G=G.replace(" , ",", ");var H=G.split(" ");for(var C=0;C<H.length;C++){if((H[C].length+I.length)<=D){I+=H[C];}else{if(E<=B){if(I.length>D){A+=I.substring(0,D);}else{A+=I;}A+="<br/>";E++;}I=H[C];}I+=" ";}if(E<=B){if(I.length>D){A+=I.substring(0,D);A+=" ";A+=F;}else{A+=I;}E++;}}return A;},afficher:function(A,E){debug(">> com.fr.boulanger.aideauchoix.Bulle.afficher()");info("x:"+A+", y:"+E+", scrollTop:"+document.documentElement.scrollTop);if(null==$("aide_au_choix_Bulle")&&null==$("aide_au_choix_BulleInverse")){var B=this;var C=B.toElement(A);var D=E+document.documentElement.scrollTop;C.injectInside($$("body")[0]);C.setStyles({"position":"absolute","left":(A>=B.getMaxX())?A-C.getStyle("width").toInt()+25:A-25,"top":D-C.getStyle("height").toInt()-10});new Fx.Style(C,"opacity",{duration:0}).start(1,1);}debug("<< com.fr.boulanger.aideauchoix.Bulle.afficher()");}});var DetailTerme=CalqueJson.extend({options:{},initialize:function(B,A){debug(">> com.fr.boulanger.aideauchoix.DetailTerme.initialize()");this.parent(B,A);this.setHistorique(new Array());this.setFlagRecherche(false);debug("<< com.fr.boulanger.aideauchoix.DetailTerme.initialize()");},getHistorique:function(){return this._historique;},setHistorique:function(A){this._historique=A;},getFlagRecherche:function(){return this._flagRecherche;},setFlagRecherche:function(A){this._flagRecherche=A;},ajouterHistorique:function(D,B){var A=this.getHistorique();var C=D+":"+B;if(!A.contains(C)){A[A.length]=C;}},toString:function(){var A="com.fr.boulanger.DetailTerme.Bulle\n[";A+="\tconteneur: "+this._conteneur+"\n";A+="\tjson: "+this._json+"\n";A+="\thistorique: "+this._json+"\n\t[";this._historique.each(function(C,B){A+=B+" : "+C;});A+="\t]\n";A+="]";return A;},toElement:function(B){debug(">> com.fr.boulanger.aideauchoix.DetailTerme.toElement()");this.setConteneur("aide_au_choix_Principal");var A=new Element("div",{"id":"aide_au_choix_Principal"}).setOpacity(0);this.creerBlocRecherche().injectInside(A);this.creerBlocPopup().injectInside(A);A.addEvents({"click":function(C){if(C.stopPropagation){C.stopPropagation();}C.cancelBubble=true;}});debug("<< com.fr.boulanger.aideauchoix.DetailTerme.toElement()");return A;},creerBlocRecherche:function(){var N=this;var L=new Element("div",{"class":"aide_au_choix_bkgndHt"});var J=new Element("div",{"class":"aide_au_choix_contenuTitre"});var I=new Element("div",{"class":"aide_au_choix_titre","id":"deplacement"});new Element("img",{"src":getCheminImage()+"/titre-bien-choisir.gif","alt":""}).injectInside(I);I.injectInside(J);var F=new Element("div",{"class":"aide_au_choix_champ"});var M=new Element("table",{"cellpadding":0,"cellspacing":0,"border":0,"class":"aide_au_choix_champtableau"});var K=new Element("tbody");var P=new Element("tr");var H=new Element("td",{"class":"aide_au_choix_coingch"});var E=new Element("td",{"class":"aide_au_choix_milieu"});var O=new Element("input",{"type":"text","id":"rechAAC","class":"aide_au_choix_textebox","value":"rechercher un autre terme"});O.addEvents({"click":function(){if("rechercher un autre terme"==this.value){this.value="";}},"mouseover":function(){N.afficherRecherche();}});O.injectInside(E);var D=new Element("td",{"class":"aide_au_choix_coindt"});H.injectInside(P);E.injectInside(P);D.injectInside(P);P.injectInside(K);K.injectInside(M);M.injectInside(F);F.injectInside(J);var G=new Element("div",{"class":"aide_au_choix_loupe"});var B=new Element("img",{"src":getCheminImage()+"/loupe.gif","alt":"","title":"Cliquez ici pour lancer la recherche"}).injectInside(G);B.addEvents({"mouseover":function(Q){this.setStyle("cursor","pointer");},"mouseout":function(Q){this.setStyle("cursor","default");}});this.creerBlocResultatRecherche(B);G.injectInside(J);var C=new Element("div",{"class":"aide_au_choix_btFermer"});var A=new Element("a",{"href":"javascript:;","title":""});A.addEvent("click",function(){getAideAuChoix().setDetail(null);N.supprimer();});new Element("img",{"src":getCheminImage()+"/bt-fermer.gif","alt":""}).injectInside(A);A.injectInside(C);C.injectInside(J);new Element("div",{"class":"clearLeft"}).injectInside(J);J.injectInside(L);return L;},creerBlocResultatRecherche:function(B){var A=this;B.addEvent("click",function(D){var E=new Event(D);var F=$("conteneurRecherche");if(null!=F){F.remove();}var C=new Json.Remote(getPageRecherche()+"?storeId=10001&catalogId=10001&terme="+$("rechAAC").value,{onComplete:function(U){A.setFlagRecherche(true);var K=new Element("div",{"class":"aide_au_choix_recherche","id":"conteneurRecherche"});K.addEvents({"mouseout":function(X){var d=new Event(X);var Y=window.getWidth();var a=window.getHeight();var f=$(A.getConteneur());var i=d.client.x;var g=d.client.y;var k=(a-399)/2+46;var Z=Y-((Y-579)/2)-67-209;var b=this.getStyle("height").toInt();var j=this.getStyle("width").toInt();if(g<=k||g>=k+b||i<=Z||i>=Z+j){A.masquerRecherche();}}});var P=new Element("table",{"class":"aide_au_choix_tableauRecherche","cellspacing":0,"cellpadding":0,"border":0});var N=new Element("tbody");var Q=U.resultat;var V=Q.length;for(var O=0;O<V;O++){var T=(O==V-1);var R=new Element("tr");var M=new Element("td",{"class":(T)?"aide_au_choix_desctableauRechercheLast":"aide_au_choix_desctableauRecherche"});var J=new Element("div",{"class":(T)?"aide_au_choix_last":""});var S=new Element("a",{"title":Q[O][0],"href":"javascript:;"}).setHTML(Q[O][1]);var I="/webapp/wcs/stores/servlet/JsonView?storeId=10001&catalogId=10001";S.addEvent("click",function(X){var W=new Json.Remote(I,{method:"get",async:false,onComplete:function(Y){A.ajouterHistorique(Y.id,Y.libelle);A.setJson(Y);A.supprimer();A.afficher(0,0);},onFailure:function(){error("Impossible de charger le fichier demandÃ©.");}}).send("termes/"+"json_terme_"+this.getProperty("title")+".json");});S.injectInside(J);J.injectInside(M);M.injectInside(R);R.injectInside(N);}N.injectInside(P);P.injectInside(K);var G=new Element("div",{"class":"aide_au_choix_bordGris"});var H=new Element("a",{"title":"","href":"javascript:;"});var L=new Element("img",{"alt":"Affinez ou pr&eacute;cisez votre recherche ou choisissez parmi les 10 r&eacute;sultats","src":getCheminImage()+"/txt-affinez.gif"});L.injectInside(H);H.injectInside(G);G.injectInside(K);K.injectInside("popupAAC");},onFailure:function(){error("Impossible d'effectuer la recherche demand&eacute;e.");}}).send();});},afficherRecherche:function(){if(!this.getFlagRecherche()){this.setFlagRecherche(true);var A=$("conteneurRecherche");if(null!=A){new Fx.Style(A,"opacity",{duration:500}).start(0,1);}}},masquerRecherche:function(){if(this.getFlagRecherche()){this.setFlagRecherche(false);var A=$("conteneurRecherche");if(null!=A){new Fx.Style(A,"opacity",{duration:500}).start(1,0);}}},creerBlocPopup:function(){var Y=this;var W=this.getJson();var S=new Element("div",{"class":"aide_au_choix_popup","id":"popupAAC"});var R=new Element("div",{"class":"aide_au_choix_ContenuPopup"});var Q=new Element("div",{"class":"aide_au_choix_ContenuGch"});var P=new Element("div",{"class":"aide_au_choix_ContenuGchHt"});var O=new Element("div",{"class":"aide_au_choix_descB"});var M=new Element("div",{"class":"aide_au_choix_titreContenu"}).setHTML(W.libelle);M.injectInside(O);var L=new Element("div").setHTML(W.usage);L.injectInside(O);O.injectInside(P);if(""!=this.getJson().visuel){var K=new Element("div",{"class":"aide_au_choix_zoomproduit"});var V=new Element("div",{"class":"top"});V.setHTML('<img src="'+getCheminVisuel()+"/"+W.visuel+'" width="114px" height="116px" />');var U=new Element("div",{"class":"bottom"});V.injectInside(K);U.injectInside(K);K.injectInside(P);}new Element("div",{"class":"clearBoth"}).injectInside(P);P.injectInside(Q);if(W.profil!=""){var J=new Element("div",{"class":"aide_au_choix_descAvis"}).setHTML("<span>L&rsquo;avis Boulanger : </span>"+W.profil);J.injectInside(Q);}if(W.description!=""){var I=new Element("div",{"class":"aide_au_choix_ContenuGchBas"});var H=new Element("div",{"class":"aide_au_choix_sousTitre"}).setHTML("D&eacute;finition technique :");var G=new Element("div",{"class":"aide_au_choix_descBas"}).setHTML(W.description);H.injectInside(I);G.injectInside(I);I.injectInside(Q);}Q.injectInside(R);var F=new Element("div",{"class":"aide_au_choix_ContenuDt"});var E=new Element("div",{"class":"aide_au_choix_separateur"});var N=getAideAuChoix();if(W.lies.length!=0){var D=new Element("div",{"class":"aide_au_choix_voiraussi"}).setHTML("Voir aussi");var C=new Element("div",{"class":"aide_au_choix_descHtDt"});W.lies.each(function(b){var d=new Element("div",{"class":"espaceBasPetit2"});var Z=new Element("a",{"href":"javascript:;","title":""}).setHTML(b[1]);N.ancrer(Z,getCheminJS()+"json_terme_"+b[0]+".json",false);Z.injectInside(d);d.injectInside(C);});D.injectInside(E);C.injectInside(E);}E.injectInside(F);var B=new Element("div",{"class":"aide_au_choix_descTerme"});if(this.getHistorique().length>1){new Element("div",{"class":"txtnoir"}).setHTML("Derniers termes consult&eacute;s :").injectInside(B);this.getHistorique().each(function(b){var e=b.split(":");if(e[1]!=W.libelle){var f=new Element("div",{"class":"espaceBasPetit3"});var Z=new Element("a",{"href":"javascript:;","title":""}).setHTML(e[1]);N.ancrer(Z,getCheminJS()+"json_terme_"+e[0]+".json",false);Z.injectInside(f);f.injectInside(B);}});}B.injectInside(F);var A=new Element("div",{"class":"aide_au_choix_lienDecouvrir"});var X=new Element("a",{"href":"http://www.boulanger.fr/content/bfr/animation/guides/","title":"Découvrez les guides du bien choisir"});var T=new Element("img",{"src":getCheminImage()+"/lien-decouvrir-guide.gif","alt":"Découvrez les guides du bien choisir"});T.injectInside(X);X.injectInside(A);A.injectInside(F);F.injectInside(R);new Element("div",{"class":"clearBoth"}).injectInside(R);R.injectInside(S);return S;},ancrerContenus:function(){var A=getAideAuChoix();var B=$$(".aide_au_choix_descB .bulle");B.extend($$(".aide_au_choix_descAvis .bulle"));B.extend($$(".aide_au_choix_descBas .bulle"));B.each(function(D){var C=getCheminJS()+"json_terme_"+D.getProperty("title")+".json";info("url:"+C);A.ancrer(D,C);});},afficher:function(A,C){debug(">> com.fr.boulanger.aideauchoix.DetailTerme.afficher()");info("x:"+A+", y:"+C);if(null==$("aide_au_choix_Principal")){var B=this.toElement(A);B.injectInside($$("body")[0]);this.ancrerContenus();B.setStyles({"position":"absolute","left":"64px","top":"342px","margin-left":-290,"margin-top":-200+document.documentElement.scrollTop});this.montrer();}debug("<< com.fr.boulanger.aideauchoix.DetailTerme.afficher()");},supprimer:function(){$(this.getConteneur()).remove();},masquer:function(){new Fx.Style($(this.getConteneur()),"opacity").start(1,0);},montrer:function(){new Fx.Style($(this.getConteneur()),"opacity",{duration:1000}).start(0,1);$(this.getConteneur()).makeDraggable({handle:"deplacement",onStart:function(){this.setOpacity(1);}.bind($(this.getConteneur())),onDrag:function(){}.bind($(this.getConteneur())),onComplete:function(){this.setOpacity(1);}.bind($(this.getConteneur()))});var B=((screen.height)/2)-200;var A=(screen.width)/2;$(this.getConteneur()).setStyles({"position":"absolute","left":A,"top":B,"margin-left":-290,"margin-top":-200+document.documentElement.scrollTop});}});
