var contextHash={};dojo.subscribe("/dojo/hashchange",contextHash,callbackHash);var currentPage;var homePage;var dayofweek=new Array();dayofweek[0]="Dim";dayofweek[1]="Lun";dayofweek[2]="Mar";dayofweek[3]="Mer";dayofweek[4]="Jeu";dayofweek[5]="Ven";dayofweek[6]="Sam";dayofweek[7]="Dim";var hours_=new Array();hours_[0]="14h00<br/>17h30";hours_[1]="16h30<br/>18h30";hours_[2]="17h30<br/>19h30";hours_[3]="18h30<br/>20h30";hours_[4]="19h30<br/>21h30";var curhash="";var deliveryDate,deliveryHour;function autoCartScroller(){var a=dojo.byId("cartContener");var e=dojo.window.getBox();var c=-dojo.position(dojo.body()).y;var d=dojo.position(a);if(c>=d.y+d.h+150){var b=e.h-dojo.marginBox(a).h-50;if(c-dojo.marginBox(a).h>=0){dojo.style(a,{position:"fixed",top:b+"px"})}}else{if(c<e.h){if(dojo.style(a,"position")!="relative"){dojo.style(a,{position:"relative",top:"0"})}}}}function callbackHash(b){autoCartScroller();if(b&&b!=""){var a=dojo.queryToObject(b);a.m=(a.m)?parseFloat(a.m):0;a.f=(a.f)?parseFloat(a.f):0;a.p=(a.p)?parseFloat(a.p):0;a.page=(a.page)?a.page:null;a.title=(a.title)?a.title:null;if(curhash!=b){curhash=b;if(a.m!=0){navSetSel(a.m)}else{if(a.page==null&&a.title==null){a.page="home.php";a.title=""}}displayDispatcher(a.m,a.f,a.p,(a.page)?a.page:null,a.title,(a.cd)?a.cd:false,(a.pb)?a.pb:false,(a.cs)?a.cs:false)}}}var globalQuery;var mouseOverNavAct=false;function initPage(e,h,b,d,g,f,a,c){dataIFSMarket=new dojo.data.ItemFileReadStore({data:null,clearOnClose:true});if(dojo.hash()==""){navSetSel(e);displayDispatcher(e,h,b,d,g,f,true,c)}else{callbackHash(dojo.hash())}cart_json=(dojo.cookie("mm_cart"))?(dojo.cookie("mm_cart")):null;checkSession();checkCart();dojo.query("a").forEach(function(i){dojo.removeAttr(i,"href")});dojo.connect(dijit.byId("searchInput"),"onFocus",function(){dijit.byId("searchInput").set("value"," ")});dojo.connect(dojo.byId("header"),"onmouseover",function(){closeNav()});initNav()}function checkCart(){cart_array=new Array();if(dojo.fromJson(cart_json)){dojo.xhrPost({url:"/bl/commande/checkCart.php",handleAs:"json",content:{mm_cart:cart_json,deliveryMode:deliveryMode,deliveryHour:deliveryHour,deliveryDate:deliveryDate,deliveryPointId:deliveryPointId},handle:function(b,a){if(typeof b=="error"){console.warn("error!",a)}else{if(b=="error"){}else{cart_array=new Array();cart_json=null;dojo.cookie("mm_cart","",{expires:-5});if(b){dojo.forEach(b,function(d,c){if(dojo.byId(d[0])){dojo.byId(d[0]).innerHTML=0}cartWithoutDeliveryCheck(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],d[8])})}delete cart_array}}}})}}function meca_nav(d,c,a){if(!a){a=false}dojo.query("#leftMenu > ul > ul > div[id^='snav'])").forEach(function(e){e.style.display="none"});dojo.query("#leftMenu > ul > ul[id^='nav'])").forEach(function(e){if(e.id){e.getElementsByTagName("li")[0].style.fontWeight="bold"}});if(dojo.byId("snav"+d)){dojo.byId("snav"+d).style.display="block"}if(dojo.byId("nav"+d)){dojo.byId("nav"+d).getElementsByTagName("li")[0].style.fontWeight="bold";if(dojo.byId("snav"+d)){for(var b=0;b<document.getElementById("snav"+d).getElementsByTagName("li").length;b++){document.getElementById("snav"+d).getElementsByTagName("li")[b].style.color="#2b1d10"}}}if(c==0){if(dojo.byId("nav"+d)){majMarche(d)}}else{if(dojo.byId("snav"+c+"_elem")){majMarche(c);dojo.byId("snav"+c+"_elem").getElementsByTagName("li")[0].style.color="#F47E20"}}return false}function changeMarket(d,b,c,a){market_sel_false=d;if(!a){a=false}dojo.byId("commonContainer").style.display="none";dojo.byId("marketContainer").style.display="block";market_sel=d;navSetSel(market_sel_false);if(marketJsonArray[d]){marketJson=marketJsonArray[d];dataIFSMarket.data=marketJson;dataIFSMarket.close();dojo.byId("smallpreloader").style.display="none";dojo.byId("pageCart").style.display="inline"}else{dojo.xhrGet({url:"/data/getMarket_"+d+".data",handleAs:"json",preventCache:true,sync:true,load:function(f,e){marketJson=f;marketJsonArray[d]=marketJson;dataIFSMarket.data=marketJson;dataIFSMarket.close();dojo.byId("smallpreloader").style.display="none";dojo.byId("pageCart").style.display="inline"},error:function(e){console.error("Problem  : ",e)}})}createNav(b,c,a)}function initPageElem(a,b){dojo.query("#"+a+" div").forEach(function(c){if(dijit.byId(c.id)){dijit.byId(c.id).destroyDescendants(0);dijit.byId(c.id).destroy(0)}else{if(dojo.byId(c.id)){dojo.destroy(c.id)}}});dojo.query("#"+a).empty().grab("/pages/"+b,{sync:true}).addCallback(this,function(){dojo.parser.parse(a)})}function displayBox(d,b,c,f,h,g,a,e){homePage=false;dojo.byId("page").style.display="none";dojo.byId("pageCart").style.display="none";dojo.byId("commonContainer").style.display="none";dojo.byId("marketContainer").style.display="none";dojo.byId("smallpreloader").style.display="block";if(!a){a=false}if(e){checkSession()}if(d!=0&&(d!=0||b!=0||c!=0)){dijit.byId("searchInput").set("value","Recherche (ex: tomate...)");if(dojo.byId("cart_divMarket_"+d)&&dojo.byId("cartContent")){dojo.place(dojo.byId("cart_divMarket_"+d),dojo.byId("cartContent"),"first")}dojo.byId("commonContainer").style.display="none";dojo.byId("marketContainer").style.display="block";changeMarket(d,b,c,a)}else{if(f){market_sel=0;navSetSel(0);dojo.byId("road").innerHTML=decodeURI(h);if(g){dojo.byId("marketContainer").style.display="none";dojo.xhrGet({url:"/pages/"+f,preventCache:false,load:function(i){if(dojo.byId("commonContainer")){dojo.query("*",dojo.byId("page")).forEach(function(j){if(dijit.byNode(j)){dijit.byNode(j).destroyRecursive()}});dojo.empty(dojo.byId("page"))}if(dojo.byId("commonContainer")){dojo.query("*",dojo.byId("commonContainer")).forEach(function(j){if(dijit.byNode(j)){dijit.byNode(j).destroyRecursive()}});dojo.empty(dojo.byId("commonContainer"))}dojo.byId("commonContainer").innerHTML=i;dojo.byId("smallpreloader").style.display="none";dojo.byId("pageCart").style.display="block";dojo.parser.parse(dojo.byId("pageCart"));dojo.byId("commonContainer").style.display="block";if(f.match(["recettes.php"])){searchRecipe()}_gaq.push(["_trackPageview","/pages/"+f])}})}else{dojo.forEach(dijit.findWidgets(dojo.byId("page")),function(i){i.destroyRecursive()});dojo.empty("page");if(f=="home.php"){homePage=true}dojo.xhrGet({url:"/pages/"+f,preventCache:false,load:function(i){dojo.query("*",dojo.byId("page")).forEach(function(j){if(dijit.byNode(j)){dijit.byNode(j).destroyRecursive()}});dojo.empty(dojo.byId("page"));if(dojo.byId("commonContainer")){dojo.query("*",dojo.byId("commonContainer")).forEach(function(j){if(dijit.byNode(j)){dijit.byNode(j).destroyRecursive()}});dojo.empty(dojo.byId("commonContainer"))}dojo.byId("page").innerHTML=i;dojo.parser.parse(dojo.byId("page"));dojo.byId("smallpreloader").style.display="none";dojo.byId("page").style.display="block";_gaq.push(["_trackPageview","/pages/"+f])}})}}}}function CutString(b,a){this.tempDiv=document.createElement("div");this.tempDiv.id="TempNodeForTest";this.tempDiv.innerHTML=b;this.charCount=0;this.limit=a}CutString.prototype.cut=function(){var a=document.createElement("div");this.searchEnd(this.tempDiv,a);return a.innerHTML};CutString.prototype.searchEnd=function(f,d){var e;var a;for(var b=0;b<f.childNodes.length;b++){e=f.childNodes[b];if(e.nodeType!=3){a=e.cloneNode(true);d.appendChild(a);if(e.childNodes.length===0){continue}a.innerHTML="";var c=this.searchEnd(e,a);if(c){return c}else{continue}}if(e.nodeValue.length+this.charCount>=this.limit){a=e.cloneNode(true);a.nodeValue=e.nodeValue.substr(0,this.limit-this.charCount);a.nodeValue=a.nodeValue.replace(/\w*$/," ");d.appendChild(a);return true}a=e.cloneNode(true);d.appendChild(a);this.charCount+=e.nodeValue.length}return false};function cutHtmlString(b,c){var a=new CutString(b,c);return a.cut()}function insertEnSavoirPlus(e,d,a,b,c){dojo.byId(e).innerHTML=b}function gAnalytics(b,a){_gaq.push(["_trackPageview",a])}function insertAddThis(f,e,b,d){_gaq.push(["_trackPageview",b]);b="www.mon-marche.fr/"+b;if(!d){d=" addthis_32x32_style"}dojo.byId(f).innerHTML="";var a={facebook:"Facebook",twitter:"Twitter",email:"Email",expanded:"More",google_plusone:"Google +1"};for(var c in a){dojo.byId(f).innerHTML+='<a class="addthis_button_'+c+'" style="float:left" addthis:url="'+b+'" addthis:title="'+e+'"></a>'}dojo.byId(f).innerHTML='<div class="addthis_toolbox addthis_default_style '+d+'" addthis:url="'+b+'" addthis:title="'+e+'">'+dojo.byId(f).innerHTML+"</div>";addthis.toolbox("#"+f);delete addthisElem;delete a}function insertAddThisFooter(e,c,a,b){if(!b){b=" addthis_32x32_style"}var d="";d+='<a class="addthis_button_facebook_like" fb:like:layout="button_count" addthis:url="http://www.facebook.com/pages/mon-marchefr/303890951556" addthis:title="'+c+'"></a>';d+='<a class="addthis_button_tweet" addthis:url="'+a+'" addthis:title="'+c+'"></a>';d+='<a class="addthis_button_google_plusone" g:plusone:size="medium" addthis:url="'+a+'" addthis:title="'+c+'"></a>';d+='<a class="addthis_counter addthis_pill_style" addthis:url="'+a+'" addthis:title="'+c+'"></a>';dojo.byId(e).innerHTML='<div class="addthis_toolbox addthis_default_style '+b+'" addthis:url="'+a+'" addthis:title="'+c+'">'+d+"</div>";addthis.toolbox("#"+e);delete addthisElem}function createNav(b,c,a){dojo.query("#leftMenu > ul").forEach(function(d){dojo.destroy(d.id)});dojo.byId("road").innerHTML=unescape(marketJson.market.name);dojo.byId("detailmarche").style.display="none";dojo.byId("detailfamille").style.display="none";dojo.byId("detail").style.display="none";dojo.byId("detailmarche").style.display="block";dojo.byId("marketDescription").innerHTML=marketJson.market.content_;curMarketText=marketJson.market.content_;insertEnSavoirPlus("marketDescription",marketJson.market.name,marketJson.market.id,marketJson.market.content_,570);dojo.byId("bck").style.background="url(/images/empty.gif) no-repeat 0 0";dojo.query('div[id^="detailMarketFamily"]',dojo.byId("detailmarche")).forEach(function(f,e,d){dojo.destroy(f.id)});dataIFSMarket.fetch({query:{type:"market"},onComplete:function(d){market_number=d.length;dojo.forEach(d,function(i,f){if(i.delivery_modes&deliveryMode||deliveryMode==0){var h=dojo.byId("leftMenu");var g=dojo.create("ul",{id:"nav"+i.id},h);if(d.length>1){dojo.addClass(dojo.create("li",{innerHTML:i.name,onclick:function(j){meca_nav(i.id,0,false);return(false)}},g),"marketNav");virtualMarket=true;if(i.delivery_modes&deliveryMode||deliveryMode==0){var e=dojo.create("div",{id:"detailMarketFamily"+i.id},dojo.byId("detailmarche"));dojo.byId("detailMarketFamily"+i.id).innerHTML="<div style=\"padding:0px;background: url('"+i.img_bg+'\') no-repeat center;width:140px;height:90px;float:left;position:relative;cursor:pointer;" onclick="meca_nav('+i.id+", 0, false);return(false);\"><div style=\"bottom: 0;background-color: #2b1d10;position:absolute;text-align:right;font-size: 18px;line-height: 18px;color: #fff;font-family: 'LLRubberGrotesqueOTFRegular', 'Arial Black', Arial, sans-serif;text-decoration: none;padding: 3px 0px;width:140px;text-transform:lowercase;\">"+i.name+"</div></div>";dojo.style(e,{margin:"5px 5px 0px 0px",styleFloat:((market_number==5&&f==4)?"right":"left")});delete e}}else{virtualMarket=false}family_number=dataIFSMarket.getValues(i,"families").length;dojo.forEach(dataIFSMarket.getValues(i,"families"),function(k,l){if(k.delivery_modes&deliveryMode||deliveryMode==0){var n=dojo.create("ul",{id:"nav"+k.id},g);dojo.addClass(dojo.create("li",{innerHTML:k.name,onclick:function(m){meca_nav(k.id,0,false);return(false)}},n),"familyNav");if(!virtualMarket){var j=dojo.create("div",{id:"detailMarketFamily"+k.id},dojo.byId("detailmarche"));dojo.byId("detailMarketFamily"+k.id).innerHTML="<div style=\"padding:0px;background: url('"+k.img_bg+'\') no-repeat center;width:140px;height:90px;float:left;position:relative;cursor:pointer;" onclick="displayDispatcher('+i.id+", "+k.id+", 0);\"><div style=\"bottom: 0;background-color: #2b1d10;position:absolute;text-align:right;font-size: 18px;line-height: 18px;color: #fff;font-family: 'LLRubberGrotesqueOTFRegular', 'Arial Black', Arial, sans-serif;text-decoration: none;padding: 3px 0px;width:140px;text-transform:lowercase;\">"+k.name+"</div></div>";dojo.style(j,{margin:"5px 5px 0px 0px",styleFloat:((family_number==5&&l==4)?"right":"left")});delete j}var j=dojo.create("div",{id:"snav"+k.id,style:"padding-left:0px;display:none;"},n);dojo.forEach(dataIFSMarket.getValues(k,"products"),function(m){if(m.id!=undefined){if(m.delivery_modes&deliveryMode||deliveryMode==0){var o=dojo.create("div",{id:"snav"+m.id+"_elem",onclick:function(p){meca_nav(k.id,m.id,false);return(false)}},j);season="";if(m.season_int=="1"){season="<strong style='background-color:#fcbe00;height:11px;width:4px;'>&nbsp;</strong> "}if(m.season_int=="2"){season="<strong style='background-color:#557a3b;height:11px;width:4px;'>&nbsp;</strong> "}if(m.season_int=="3"){season="<strong style='background-color:#fcbe00;height:11px;width:4px;'>&nbsp;</strong> "}if(m.season_int=="4"){season="<strong style='background-color:#fc5f00;height:11px;width:4px;'>&nbsp;</strong> "}dojo.addClass(dojo.create("li",{innerHTML:season+m.name},o),"productNav")}}})}})}});meca_nav(b,c,a)},queryOptions:{deep:true}});_gaq.push(["_trackPageview",marketJson.market.directURL])}function navSetSel(b){if(b==undefined){b=0}var a="";dojo.query(".navtop,.navtop_sel").forEach(function(h){if(h.id){if(h.id=="nav_market_"+b){dojo.removeAttr(h.id,"href");dojo.removeClass(h.id,"navtop");dojo.addClass(h.id,"navtop_sel");dojo.attr(h.id,"onclick",function(i){if("m="+b!=curhash){curhash="m="+b;dojo.hash("m="+b)}displayDispatcher(b,0,0,d,g,f,false,false)});dojo.attr(h.id,"ondblclick",function(i){return false});dojo.attr("nav_market_img_"+b,{src:"/images/market_sel.gif"})}else{dojo.removeAttr(h.id,"href");dojo.removeClass(h.id,"navtop_sel");dojo.addClass(h.id,"navtop");var e=(h.id).replace("nav_market_","");if(e=="1100"){var d="market/box.php";var c=1100}else{var c=e;var d=""}var g=markets_array[e];var f=true;dojo.attr(h.id,"onclick",function(i){if("m="+c!=curhash){curhash="m="+c;dojo.hash("m="+c)}displayDispatcher(c,0,0,d,g,f,false,false)});dojo.attr(h.id,"ondblclick",function(i){return false});dojo.attr("nav_market_img_"+e,{src:"/images/market.gif"});delete e;delete g;delete d;delete c;delete f}}})}function majMarche(a){dojo.byId("detailmarche").style.display="none";dojo.byId("detailfamille").style.display="none";dojo.byId("detail").style.display="none";var b;dataIFSMarket.fetch({query:{id:a+""},onItem:function(c,f){b=c;if(b.type[0]=="market"){market_sel_name=dataIFSMarket.getValue(b,"name");market_sel=dataIFSMarket.getValue(b,"id");if(marketJson.market.id!=market_sel){dojo.byId("road").innerHTML=unescape(marketJson.market.name+" > "+market_sel_name)}else{dojo.byId("road").innerHTML=unescape(market_sel_name)}if("m="+market_sel!=curhash){curhash="m="+market_sel;dojo.hash("m="+market_sel)}dojo.byId("detailmarche").style.display="block";dojo.byId("marketDescription").innerHTML=dataIFSMarket.getValue(b,"content");insertEnSavoirPlus("marketDescription",dataIFSMarket.getValue(b,"name"),dataIFSMarket.getValue(b,"id"),dataIFSMarket.getValue(b,"content"),570);dojo.query('div[id^="detailMarketFamily"]',dojo.byId("detailmarche")).forEach(function(i,h,g){dojo.destroy(i.id)});family_number=dataIFSMarket.getValues(b,"families").length;dojo.forEach(dataIFSMarket.getValues(b,"families"),function(h,j){var g=dojo.create("div",{id:"detailMarketFamily"+h.id},dojo.byId("detailmarche"));dojo.byId("detailMarketFamily"+h.id).innerHTML="<div style=\"padding:0px;background: url('"+h.img_bg+'\') no-repeat center;width:140px;height:90px;float:left;position:relative;cursor:pointer;" onclick="displayDispatcher('+marketJson.market.id+", "+h.id+", 0);\"><div style=\"bottom: 0;background-color: #2b1d10;position:absolute;text-align:right;font-size: 18px;line-height: 18px;color:#fff;font-family: 'LLRubberGrotesqueOTFRegular', 'Arial Black', Arial, sans-serif;text-decoration: none;padding: 3px 0px;width:140px;text-transform:lowercase;\">"+h.name+"</div></div>";dojo.style(g,{margin:"5px 5px 0px 0px",styleFloat:((family_number==5&&j==4)?"right":"left")});delete g});return false}else{if(b.type[0]=="product"){function d(g,j){dojo.byId("detail").style.display="block";dojo.byId("bck").style.background="url(/images/empty.gif) no-repeat 0 0";var i=g[0];if(i.img_nav&&i.img_nav!=""){dojo.byId("cadreimage").style.background="url("+i.img_nav+") no-repeat 0 0";dojo.byId("cadreimage").style.display="block"}else{dojo.byId("cadreimage").style.background="url(/images/empty.gif) no-repeat 0 0";dojo.byId("cadreimage").style.display="none"}product_sel_name=dataIFSMarket.getValue(i,"name");product_sel=i.id;family_sel=i.parent;market_sel=i.market;market_sel_name=i.marketname;family_sel_name=i.parentname;if(marketJson.market.id!=market_sel){dojo.byId("road").innerHTML=unescape(marketJson.market.name+" > "+market_sel_name+" > "+family_sel_name)}else{dojo.byId("road").innerHTML=unescape(market_sel_name+" > "+family_sel_name)}if("m="+marketJson.market.id+"&f="+i.parent+"&p="+i.id!=curhash){curhash="m="+marketJson.market.id+"&f="+i.parent+"&p="+i.id;dojo.hash("m="+marketJson.market.id+"&f="+i.parent+"&p="+i.id)}add_name=dataIFSMarket.getValue(i,"add_name");if(add_name!=""){add_name="<div style='font-family: Arial;font-size:14px;'>"+add_name+"</div>"}dojo.byId("titredetail").innerHTML=dataIFSMarket.getValue(i,"name")+add_name;var n="<strong>Disponibilit&eacute; :</strong><br/>";if((i.delivery_modes&1)&&(i.delivery_modes&2)&&(i.delivery_modes&4)){n=n+"Ce produit est livrable quel que soit le mode de livraison (domicile, entreprise, point presse)"}if(!(i.delivery_modes&1)||!(i.delivery_modes&2)||!(i.delivery_modes&4)){var n=n+"Ce produit n'est pas livrable : <br/>";if(!(i.delivery_modes&1)){n=n+"- A domicile, car la zone n'est pas couverte.<br/>"}if(!(i.delivery_modes&2)){n=n+"- En entreprise<br/>"}if(!(i.delivery_modes&4)){n=n+"- En point presse"}if(!(i.delivery_modes&4)||!(i.delivery_modes&2)){n=n+"<br/>car il est soit trop fragile, soit trop encombrant.<br/>"}}dojo.byId("dispoprod").innerHTML=n;infoprodtxt="";curProductText=i.content;dojo.byId("productDescription").innerHTML=i.content;insertEnSavoirPlus("productDescription",i.name,i.id,i.content,570);if(dataIFSMarket.getValue(i,"deliveryException")){var l="<strong style='color: #ff0000'>Pas de livraison les "+dataIFSMarket.getValue(i,"deliveryException").replace(/;/g,", ").replace("1","Lundis").replace("2","Mardis").replace("3","Mercredis").replace("4","Jeudis").replace("5","Vendredis")+".</strong><br/>";infoprodtxt+=l}if(dataIFSMarket.getValue(i,"origin")){infoprodtxt+="<strong>Origine :</strong> "+dataIFSMarket.getValue(i,"origin")+"<br/>"}if(dataIFSMarket.getValue(i,"season")){infoprodtxt+="<strong>Saisonnalit&eacute; actuelle : </strong>"+dataIFSMarket.getValue(i,"season")+"<br/>"}if(dataIFSMarket.getValue(i,"consumetill")!=undefined){var k=dataIFSMarket.getValue(i,"consumetill");var m="";if(unescape(k)!=""&&unescape(k)!="0"){m="<strong>Consommation :</strong> "+k+" jour(s) apr&egrave;s livraison.<br/>"}else{m="<strong>Consommation :</strong> Voir condition sur l'emballage<br/>"}infoprodtxt+=m}if(dataIFSMarket.getValue(i,"nutrition")!=""){var h=dataIFSMarket.getValue(i,"nutrition");h=(h+"").replace(/([^>\r\n]?)(\r\n|\n\r)/g,"$1<br>$2");infoprodtxt+="<strong>Valeur nutritive :</strong><br/> "+h+"<br/>"}dojo.byId("infoprod").innerHTML=infoprodtxt;txt="<table border='0' width='100%' style='padding-top: 0px'>";if(dataIFSMarket.getValue(i,"conditionnings")!=undefined&&dataIFSMarket.getValue(i,"conditionnings")!=""){if(dataIFSMarket.getValues(i,"conditionnings").length>0){dojo.forEach(dataIFSMarket.getValues(i,"conditionnings"),function(r){var o="";var p="";if(r.promo==1){p="<span style='color:#FF0000'>Promo : </span>"}o+="<tr><td align='left' colspan='2'><strong>"+p+r.conditioning+"</strong></td></tr>";o+="<tr><td align='left' height='12'><strong>Prix : "+r.price+" &euro;</strong>";if(r.global_price){o+=" ("+r.global_price+" &euro; / "+r.unity+")"}o+="</td><td align='right' valign='top' nowrap height='12'>";o+="<a onclick='cart(\"spinner_"+r.cond_id+'", -1, "'+r.price+'","'+escape(r.conditioning)+'","'+dataIFSMarket.getValue(i,"id")+'","'+escape(dataIFSMarket.getValue(i,"name"))+'","'+family_sel+'","'+escape(market_sel_name)+'","'+market_sel+"\");return false;'>";o+="<img id='minus_spinner_"+r.cond_id+"' src='/images/bouton_moins_gros.gif' width='16' height='16' alt='' border='0' alt='Supprimer une unit&eacute;' align='top' hspace='2' vspace='1'>";o+="</a>";if(dojo.byId("cart_spinner_"+r.cond_id+"_nb")){var q=dojo.byId("cart_spinner_"+r.cond_id+"_nb").innerHTML}else{var q=0}o+="<span name='spinner_"+r.cond_id+"' id='spinner_"+r.cond_id+"' style='font-size: 1.2em; height: 16px; width: 20px;'>"+q+"</span>";o+="<a onclick='cart(\"spinner_"+r.cond_id+'", 1, "'+r.price+'","'+escape(r.conditioning)+'","'+dataIFSMarket.getValue(i,"id")+'","'+escape(dataIFSMarket.getValue(i,"name"))+'","'+family_sel+'","'+escape(market_sel_name)+'","'+market_sel+"\");return false;'>";o+="<img id='plus_spinner_"+r.cond_id+"' src='/images/bouton_plus_gros.gif' width='16' height='16' alt='' border='0' alt='Ajouter une unit&eacute;' align='top' hspace='2' vspace='1'>";o+="</a>";o+="</td></tr>";delete q;txt+=o})}}else{txt+="<tr><td valign='top' style='padding-top:4px;' colspan='3'>Actuellement non disponible</td></tr>"}txt+="</table>";dojo.byId("texteproduits").innerHTML=txt;dojo.byId("blocRecette").style.display="none";dojo.query("#texterecettes").empty();dojo.byId("similarProducts").style.display="none";dojo.query("#similarProducts").empty();dojo.xhrPost({url:"/data/getSimilarProducts.php",content:{id:a,mm_cart:dojo.toJson(cart_array),root:market_sel,deliveryMode:deliveryMode},handleAs:"json",preventCache:false,sync:false,timeout:2000,load:function(p,o){dojo.forEach(p.recipes,function(s,r){if(r>0){dojo.create("br",null,dojo.byId("texterecettes"))}else{dojo.byId("blocRecette").style.display="block";dojo.query("#texterecettes").empty()}dojo.create("a",{innerHTML:s.name,onclick:function(t){displayRecipe(0,0,0,"/market/recette.php?origin=product&id="+s.id+"&marche="+market_sel+"&categorie="+family_sel+"&produit="+a,"",true,false,false);return(false)}},dojo.byId("texterecettes"))});if(p.similarProd.length>0){dojo.byId("similarProducts").style.display="block";dojo.byId("similarProducts").innerHTML='<div class="subtitle">Les produits couramment associés à cet article</div>'}var q="";dojo.forEach(p.similarProd,function(u,s){if(s%2==0){var t="left;clear: both;"}else{var t="right;"}q+='<div style="padding: 0px 10px 10px 0px;float:'+t+'width:280px;">';q+='<table border="0" cellpadding="0" cellspacing="0" width="100%">';q+="<tr>";q+='	<td valign="top" colspan="2"><span style="margin: 0 0 3px 0;font-size:11px;color: 2b1d10; cursor: pointer; text-decoration: none;" onclick="displayDispatcher('+u.market_id+', 0, 0, null, null, false, false);return false;">'+u.market_name+"</span></td>";q+="</tr>";q+="<tr>";q+='<td colspan="2"><span style="padding: 0px; color: 2b1d10; font-size:12px; font-weight: bold; cursor: pointer; text-decoration: none;" onclick="displayDispatcher('+u.market_id+", "+u.family_id+', 0, null, null, false, false);return false;">'+u.family_name+"</span></td>";q+="</tr>";q+="<tr>";q+='<td colspan="2" height="15" valign="top"><a onclick="displayDispatcher('+u.market_id+", "+u.family_id+", "+u.product_id+', 0, null, null, false, false);return false;" style="cursor: pointer; font-weight: bold;font-size:11px;">'+u.product_name+"</a></td>";q+="</tr>";q+="<tr>";var r="";if(u.product_img!="/images/empty.gif"){q+='<td rowspan="2" style="padding-right: 2px;" valign="top" width="60"><a onclick="displayDispatcher('+u.market_id+", "+u.family_id+", "+u.product_id+', null, null, false, false);return false;" style="cursor: pointer;"><img src="'+u.product_img+'" width="60"></a></td>';q+='<td valign="top">';r=210}else{q+='<td valign="top" colspan="2">';r=270}q+='<table border="0" cellpadding="0" cellspacing="0" width="'+r+'">';q+="<tr>";q+='<td valign="top"><a onclick="displayDispatcher('+u.market_id+", "+u.family_id+", "+u.product_id+', null, null, false, false);return false;">'+u.conditioning+"</a></td>";q+="</tr>";q+="<tr>";q+='<td nowrap="nowrap" valign="top" align="right">';q+='<div><span style="font-weight: bold;">'+u.price+" €</span>&nbsp;<em>("+u.global_price+"&euro;/"+u.unity+")</em></div>";q+='<div><strong>Qté :</strong> <img src="/images/bouton_moins.gif" alt=""  align="top" border="0" height="12" hspace="2" vspace="1" width="12" onclick=\'cart("spinner_'+u.cond_id+'", -1, "'+u.price+'","'+escape(u.conditioning)+'","'+u.product_id+'","'+escape(u.product_name)+'","'+u.family_id+'","'+escape(u.market_name)+'","'+u.market_id+'");return false;\'><span id="similarProductspinner_'+u.cond_id+'">0</span><img src="/images/bouton_plus.gif" alt="" align="top" border="0" height="12" hspace="2" vspace="1" width="12" onclick=\'cart("spinner_'+u.cond_id+'", 1, "'+u.price+'","'+escape(u.conditioning)+'","'+u.product_id+'","'+escape(u.product_name)+'","'+u.family_id+'","'+escape(u.market_name)+'","'+u.market_id+"\");return false;'>";q+="</div>";q+="</td>";q+="</tr>";q+="</table>";q+="</td>";q+="</tr>";q+="</table>";q+="</div>"});dojo.byId("similarProducts").innerHTML+=q},error:function(o){}});insertAddThis("productaddthistoolbox",i.name,i.directURL,"nope")}dataIFSMarket.fetch({query:{id:a+""},onComplete:d,onError:function(g,h){},queryOptions:{deep:true}})}}if(b.type[0]=="family"){function e(g,i){var h=g[0];if(h.parent){market_sel_name=markets_array[h.parent];market_sel=h.parent;family_sel_name=h.name;family_sel=h.id;if(marketJson.market.id!=market_sel){dojo.byId("road").innerHTML=unescape(marketJson.market.name+" > "+market_sel_name+" > "+family_sel_name)}else{dojo.byId("road").innerHTML=unescape(market_sel_name+" > "+family_sel_name)}if("m="+marketJson.market.id+"&f="+family_sel!=curhash){curhash="m="+marketJson.market.id+"&f="+family_sel;dojo.hash("m="+marketJson.market.id+"&f="+family_sel)}dojo.byId("detailfamille").style.display="block";dojo.byId("familyDescription").innerHTML=h.content;insertEnSavoirPlus("familyDescription",h.name,h.id,h.content,570);dojo.query('div[id^="detailMarketFamilyProduct"]',dojo.byId("detailfamille")).forEach(function(l,k,j){dojo.destroy(l.id)});dojo.forEach(dataIFSMarket.getValues(h,"products"),function(j){if(j.id!=undefined){if(j.delivery_modes&deliveryMode||deliveryMode==0){var k=dojo.create("div",{id:"detailMarketFamilyProduct"+j.id},dojo.byId("detailfamille"));dojo.byId("detailMarketFamilyProduct"+j.id).innerHTML="<div style=\"padding:0px;background: url('"+j.img_nav+'\') no-repeat center;width:140px;height:90px;float:left;position:relative;cursor:pointer;" onclick="displayDispatcher('+marketJson.market.id+", "+family_sel+", "+j.id+");\"><div style=\"bottom: 0;background-color: #2b1d10;position:absolute;text-align:right;font-size: 18px;line-height: 18px;color: #fff;font-family: 'LLRubberGrotesqueOTFRegular', 'Arial Black', Arial, sans-serif;text-decoration: none;padding: 3px 0px;width:140px;text-transform:lowercase;\">"+j.name+"</div></div>";dojo.style(k,{margin:"5px 5px 0px 0px",styleFloat:"left"});delete k}}});_gaq.push(["_trackPageview",h.directURL])}}dataIFSMarket.fetch({query:{id:a+""},onComplete:e,onError:function(g,h){},queryOptions:{deep:true}})}return false},onError:function(c,d){console.log("erreur",c)},queryOptions:{deep:true}})}function changeCart(e,f,d,a,c,b,g,i,h){cartWithoutDeliveryCheck(e,f,d,escape(a),c,escape(b),g,escape(i),h);displayDispatcher(0,0,0,"order/step1.php?rnd="+Math.random(),"R&eacute;capitulatif de votre panier",false,true,true);return false}function resetCart(){dojo.empty("cartContent");dojo.style("cartEmpty","display","block");dojo.byId("cartTotal").innerHTML=0;dojo.byId("cartTotalHL").innerHTML=0;cart_array=new Array();cart_json=null;updateTotal()}Array.prototype.in_array=function(a){for(var c=0,b=this.length;c<b;c++){if(this[c]==a){return true}}return false};var cartObjBDSel=null;function selectDeliveryDateHours(a,f,e,d,c){deliveryHour=f;deliveryDate=a;currentDeliveryPrices=e;if(d==1){client.postal_code=c;deliveryPointId=0}else{if(d==2){client.pointDeliveryEnt=c;deliveryPointId=c}else{if(d==4){client.ref_pressDeliveryPoint=c;deliveryPointId=c}}}deliveryMode=parseInt(d);checkSession();var b=dojo.queryToObject(dojo.hash());if(cartObjBDSel!=null){if(cartObjBDSel.spinner_id){cart_array=new Array();if(dojo.fromJson(cart_json)){cart_array=dojo.fromJson(cart_json);dojo.style("cartEmpty","display","none")}else{cart_json=null}cart_array.push(new Array(cartObjBDSel.spinner_id,cartObjBDSel.count,cartObjBDSel.price,cartObjBDSel.conditioning,cartObjBDSel.product_id,cartObjBDSel.product_name,cartObjBDSel.parent_id,cartObjBDSel.root_name,cartObjBDSel.root_id));car_array_cookie=new Array();dojo.forEach(cart_array,function(h,g){car_array_cookie.push(new Array(h[0],h[1],0,0,0,0,0,0,0))});dojo.cookie("mm_cart",dojo.toJson(car_array_cookie),{expires:5,path:"/"});cart_json=dojo.toJson(cart_array)}else{if(cartObjBDSel.length>1){cart_array=new Array();if(dojo.fromJson(cart_json)){cart_array=dojo.fromJson(cart_json);dojo.style("cartEmpty","display","none")}else{cart_json=null}car_array_cookie=new Array();dojo.forEach(cartObjBDSel,function(g){cart_array.push(new Array(g.spinner_id,g.count,g.price,g.conditioning,g.product_id,g.product_name,g.parent_id,g.root_name,g.root_id));dojo.forEach(cart_array,function(j,h){car_array_cookie.push(new Array(j[0],j[1],0,0,0,0,0,0,0))})});dojo.cookie("mm_cart",dojo.toJson(car_array_cookie),{expires:5,path:"/"});cart_json=dojo.toJson(cart_array)}}cartObjBDSel=null}navSetSel(market_sel);checkSession();checkCart();dijit.byId("dialogContentDiv").set("content","<div></div>");dialogContent({content:"<br/><strong>Votre choix de livraison a bien été pris en compte.<br/>Vous retrouverez au bas de votre panier les informations correspondantes que vous pouvez à tout moment modifier.</strong><br/><div style='clear:both;float:right'><a onclick='dijit.byId(\"dialogContentDiv\").hide();' style='font-weight:bold;'>> Continuer mes courses</a></div>",title:"Votre mode de livraison",width:"780",height:"auto",padding:"10px"});setTimeout(function(){if(dijit.byId("dialogContentDiv")){dijit.byId("dialogContentDiv").hide();dijit.byId("dialogContentDiv").destroyDescendants(0);dijit.byId("dialogContentDiv").destroy(0)}else{if(dojo.byId("dialogContentDiv")){dojo.destroy("dialogContentDiv")}}},10000)}function searchPointDelivery(e,c,b,d,a){if((c||e)&&b){dojo.xhrPost({content:{id:e,code:c,type:b},url:"/bl/client/searchPointDelivery.php",handleAs:"json",handle:function(k,o){if(typeof k=="error"){console.warn("error!",o)}else{if(k.testCase=="ok"){dojo.byId(d).innerHTML="";var f=new RegExp("[ ;]+","g");var g=new RegExp("[ :]+","g");var p=k.point.available_days.split(f);planning="<table>\n";var n="";dojo.forEach(k.point.schedule_.split(f),function(s,r){var s=s.split(g);var q=s[0];var i=s[1];if(r==0){planning+="<tr>\n"}if(dayofweek[q]){planning+="<td><strong>"+dayofweek[q]+"<br/>"+i+"</strong></td>\n"}if(r==0){n+="<tr>\n"}if(p[q]==1){if(a){n+="<td align='center' bgcolor='#557a3b' style='color: #FFFFFF;cursor:pointer;' onClick='selectDeliveryDateHours(\""+s[2]+'", 0, "'+k.point.price+'", "'+b+'", "'+k.point.id+"\");'><strong>&nbsp;</strong></td>\n"}else{n+="<td align='center' bgcolor='#557a3b' style='color: #FFFFFF;'><strong>&nbsp;</strong></td>\n"}}else{n+="<td></td>\n"}});planning+="</tr>\n"+n+"</tr>\n";dojo.byId(d).innerHTML+=((a)?"<span><strong>Cliquez sur la case correspondant à la date de livraison souhaitée : </strong><br/>":"")+planning+"<br/>";dojo.byId(d+"Price").innerHTML="<strong>"+k.point.name+"</strong><br />"+k.point.address+"<br />"+k.point.pc+" "+k.point.city+"<br />";var l="";var m=k.point.price.split(f);for(var j=m.length-1;j>=0;j--){var g=new RegExp("[ :]+","g");var h=m[j].split(g);if(h[2]=="0"){h[2]="<strong color='#557a3b'>Livraison gratuite</strong>"}else{h[2]="Participation de "+h[2]+" &euro;"}if(h[1]=="0"){l+=h[2]+" &agrave; partir de  "+h[0]+" &euro;<br>"}else{l+=h[2]+" pour une commande comprise entre "+h[0]+" &euro; et  "+h[1]+" &euro;<br>"}}dojo.byId(d+"Price").innerHTML+="<br/>"+l;dojo.byId(d).innerHTML+="<br/>Les cases vertes correspondent aux jours disponibles<br/><br/>"}else{dojo.byId(d+"Price").innerHTML="";if(b==2){dojo.byId(d).innerHTML="<strong style='color:#ff0000'>Code erroné</strong>"}else{dojo.byId(d).innerHTML=""}}}}})}else{dojo.byId(d).innerHTML="";dojo.byId(d+"Price").innerHTML=""}}function searchHomeDelivery(d,c,a){var b=-1;if(d.length<5||isNaN(parseInt(d))){dojo.byId(c).innerHTML="";dojo.byId(c+"Price").innerHTML="";return false}livraison_txt="";dojo.xhrPost({content:{pcs:d},url:"/bl/client/searchHomeDelivery.php",handleAs:"json",handle:function(j,n){if(typeof j=="error"){console.warn("error!",n)}else{if(j.testCase=="ok"){dojo.empty(c);livraison_txt="";livraison_txt_="";var e=new RegExp("[ ;]+","g");var f=new RegExp("[ :]+","g");var l=j.home.price.split(e);for(var k=l.length-1;k>=0;k--){var f=new RegExp("[ :]+","g");var g=l[k].split(f);if(g[2]=="0"){g[2]="<strong color='#557a3b'>Livraison gratuite</strong>"}else{g[2]="Participation de "+g[2]+" &euro;"}if(g[1]=="0"){livraison_txt+=g[2]+" &agrave; partir de  "+g[0]+" &euro;<br>"}else{livraison_txt+=g[2]+" pour une commande comprise entre "+g[0]+" &euro; et  "+g[1]+" &euro;<br>"}}var p=j.home.schedule.split(e);planning="<table border='0'>\n";var h="";var m="";var o=1;dojo.forEach(hours_,function(i,q){h+="<tr>\n";dojo.forEach(j.home.schedule_.split(e),function(u,t){var u=u.split(f);var s=u[0];var r=u[1];if(t==0&&q==0){h+="<td></td>\n"}if(dayofweek[s]&&q==0){h+="<td><strong>"+dayofweek[s]+"<br/>"+r+"</strong></td>\n"}if(t==0){m+="<td><strong>"+i.replace("<br/>"," - ")+"</strong></td>\n"}if(p.in_array(s+":"+q)){if(a){m+="<td align='center' bgcolor='#557a3b' style='color: #FFFFFF;cursor:pointer;' onClick='selectDeliveryDateHours(\""+u[2]+'", '+q+', "'+j.home.price+'", "'+o+'", "'+d+"\");'><strong>&nbsp;</strong></td>\n"}else{m+="<td align='center' bgcolor='#557a3b' style='color: #FFFFFF;'><strong>&nbsp;</strong></td>\n"}}else{m+="<td></td>\n"}});h+="</tr>\n";m+="</tr>\n"});planning+=h+m;planning+="<tr><td colspan='6'><br/>Les cases vertes correspondent aux horaires disponibles</td></tr>";planning+="</table>";dojo.byId(c).innerHTML="<span>"+((a)?"<strong>Cliquez sur la case correspondant à la date et heure de livraison souhaitées : </strong><br/>":"")+livraison_txt_+planning+"<br/></span>";dojo.byId(c+"Price").innerHTML=livraison_txt}else{livraison_txt="Actuellement nous ne desservons pas votre ville, n'h&eacute;sitez pas &agrave; nous contacter sur <a href='mailto:contact@mon-marche.fr'>contact@mon-marche.fr</a> de fa&ccedil;on &agrave; ce que l'on puisse &eacute;tudier l'insertion de votre ville dans nos tourn&eacute;es.<br>Par avance merci, <br>L'&eacute;quipe Mon-march&eacute;.fr";dojo.byId(c).innerHTML=livraison_txt}}}})}function searchPostalCode(){if(dijit.byId("searchPostalCodeFrm").validate()){client.postal_code=dojo.byId("postalCodeHeader").value;selectDeliveryMode()}}var dropDownPressPoint=false;function selectDeliveryMode(){var a=dojo.cache("mm.delivery.template","deliverySelector.html");dialogContent({html:a,title:"Sélectionnez votre mode de livraison",width:"780",height:"auto"});var b=null;dojo.xhrGet({url:"/data/getDeliveryPressPoint.php",handleAs:"json",load:function(c){b=new dojo.data.ItemFileReadStore({data:c});var d=new dijit.form.FilteringSelect({id:"deliveryPressPointDetailSelector",name:"deliveryPressPointDetailSelector",label:"prettyLabel",searchAttr:"prettyLabel",value:0,required:true,style:"width: 100%;",store:b},"deliveryPressPointDetailSelectorDiv");d.startup();dojo.connect(d,"onChange",function(){searchPointDelivery(this.value,0,4,"deliveryPressPointDetail",true)});if(client.postal_code&&!client.ref_pressDeliveryPoint){b.fetch({query:{postalcode:client.postal_code+""},onComplete:function(f,g){dojo.forEach(f,function(k,j){if(j==0){searchPointDelivery(k.id,"",4,"deliveryPressPointDetail",true);d.set("value",k.id)}});if(!client.ref_pressDeliveryPoint){dojo.byId("deliveryPressPointDetail").innerHTML="<strong>Actuellement aucun point relais n'est ouvert sur votre code postal, pour ouvrir un point relais près de chez vous, demandez lui son accord, puis indiquez nous ses coordonnées</strong><br/>";if(dijit.byId("pressPointSubmissionForm")){dijit.byId("pressPointSubmissionForm").destroyRecursive()}if(dijit.byId("pressPointSubmissionFormClientName")){dijit.byId("pressPointSubmissionFormClientName").destroyRecursive()}if(dijit.byId("pressPointSubmissionFormPressPointName")){dijit.byId("pressPointSubmissionFormPressPointName").destroyRecursive()}if(dijit.byId("pressPointSubmissionFormPressPointAdress")){dijit.byId("pressPointSubmissionFormPressPointAdress").destroyRecursive()}if(dijit.byId("pressPointSubmissionFormPressPointPostalCode")){dijit.byId("pressPointSubmissionFormPressPointPostalCode").destroyRecursive()}if(dijit.byId("pressPointSubmissionFormPressPointCity")){dijit.byId("pressPointSubmissionFormPressPointCity").destroyRecursive()}if(dijit.byId("pressPointSubmissionFormPressPointPhone")){dijit.byId("pressPointSubmissionFormPressPointPhone").destroyRecursive()}if(dijit.byId("pressPointSubmissionFormPressPointButton")){dijit.byId("pressPointSubmissionFormPressPointButton").destroyRecursive()}var h={width:"100%",height:"3px","float":"none",cssFloat:"none",styleFloat:"none",clear:"both"};var e=new dijit.form.Form({method:"post",id:"pressPointSubmissionForm",encType:"multipart/form-data"}).placeAt(dojo.byId("deliveryPressPointDetail"));dojo.create("label",{innerHTML:"Votre nom : ",style:{"float":"left"}},e.domNode);new dijit.form.ValidationTextBox({id:"pressPointSubmissionFormClientName",name:"pressPointSubmissionFormClientName",type:"text",trim:"true",required:"true",placeHolder:"Votre nom",style:{"float":"left"}}).placeAt(e.domNode);dojo.create("div",{style:h},e.domNode);dojo.create("label",{innerHTML:"Le nom de votre marchand journaux ou point relais souhaité : ",style:{"float":"left"}},e.domNode);new dijit.form.ValidationTextBox({id:"pressPointSubmissionFormPressPointName",name:"pressPointSubmissionFormPressPointName",type:"text",trim:"true",required:"true",placeHolder:"Le nom de votre marchand du point relais souhaité",style:{"float":"left"}}).placeAt(e.domNode);dojo.create("div",{style:h},e.domNode);dojo.create("label",{innerHTML:"Son adresse : ",style:{"float":"left"}},e.domNode);new dijit.form.ValidationTextBox({id:"pressPointSubmissionFormPressPointAdress",name:"pressPointSubmissionFormPressPointAdress",type:"text",trim:"true",required:"false",placeHolder:"L'adresse du point relays",style:{"float":"left"}}).placeAt(e.domNode);dojo.create("div",{style:h},e.domNode);dojo.create("label",{innerHTML:"Son code postal et sa ville : ",style:{"float":"left"}},e.domNode);new dijit.form.ValidationTextBox({id:"pressPointSubmissionFormPressPointPostalCode",name:"pressPointSubmissionFormPressPointPostalCode",type:"text",trim:"true",required:"true",invalidMessage:"Le champ doit contenir un code postal",placeHolder:"Code postal",style:{"float":"left"}}).placeAt(e.domNode);dojo.create("div",{innerHTML:" - ",style:{"float":"left"}},e.domNode);new dijit.form.ValidationTextBox({id:"pressPointSubmissionFormPressPointCity",name:"pressPointSubmissionFormPressPointCity",type:"text",trim:"true",required:"false",placeHolder:"Ville",style:{"float":"left"}}).placeAt(e.domNode);dojo.create("div",{style:h},e.domNode);dojo.create("label",{innerHTML:"Téléphone du point relais : ",style:{"float":"left"}},e.domNode);new dijit.form.TextBox({id:"pressPointSubmissionFormPressPointPhone",name:"pressPointSubmissionFormPressPointPhone",type:"text",trim:"true",required:"false",placeHolder:"Téléphone du point relais",style:{"float":"left"}}).placeAt(e.domNode);dojo.create("div",{style:h},e.domNode);new dijit.form.Button({id:"pressPointSubmissionFormPressPointButton",label:"Nous envoyer les informations",style:{cursor:"pointer"},onClick:function(){if(dijit.byId("pressPointSubmissionForm").validate()){var j={form:e.domNode,url:"/bl/client/pressPointSubmit.php",handleAs:"json",load:function(k){if(k=="ok"){dojo.byId("deliveryPressPointDetail").innerHTML="Merci, votre demande d'ajout de point relais a bien été prise en compte."}else{}},error:function(k){console.log(k)}};var i=dojo.xhrPost(j)}}}).placeAt(e.domNode)}},onError:function(e,f){},queryOptions:{deep:true}})}else{if(client.ref_pressDeliveryPoint){searchPointDelivery(client.ref_pressDeliveryPoint,"",4,"deliveryPressPointDetail",true);d.set("value",client.ref_pressDeliveryPoint)}}}});dojo.query(".deliveryHomeSelectorNotLogged").forEach(function(c){if(client==null||client.id==undefined){dojo.style(c,"display","block")}else{dojo.style(c,"display","none")}},client);if(client.postal_code){if(!client.id){dojo.attr(dojo.byId("deliveryCodeHome"),"value",client.postal_code)}searchHomeDelivery(client.postal_code,"deliveryHomeDetail",true)}if(client.ref_company_code){dojo.attr(dojo.byId("deliveryCodeEnt"),"value",client.ref_company_code);searchPointDelivery(client.ref_company,"",2,"deliveryEntDetail",true)}delete a}function cart(e,f,d,a,c,b,g,i,h){if(deliveryMode){cartWithoutDeliveryCheck(e,f,d,a,c,b,g,i,h)}else{cartObjBDSel={spinner_id:e,count:f,price:d,conditioning:a,product_id:c,product_name:b,parent_id:g,root_name:i,root_id:h};selectDeliveryMode()}}function cartMultiple(a){if(deliveryMode){dojo.forEach(a,function(b){cartWithoutDeliveryCheck(b.spinner_id,b.count,b.price,b.conditioning,b.product_id,b.product_name,b.parent_id,b.root_name,b.root_id)})}else{cartObjBDSel=a;selectDeliveryMode()}}function cartWithoutDeliveryCheck(j,k,h,b,f,e,l,q,m){cart_array=new Array();if(dojo.fromJson(cart_json)){cart_array=dojo.fromJson(cart_json);dojo.style("cartEmpty","display","none")}else{resetCart()}if(dojo.byId("cart_"+j+"_nb")){if(parseInt(dojo.byId("cart_"+j+"_nb").innerHTML)+k<0){k=0;dojo.byId("cart_"+j+"_nb").innerHTML=0;if(dojo.byId("resultsCart"+j)){dojo.byId("resultsCart"+j).innerHTML=0}if(dojo.byId(j)){dojo.byId(j).innerHTML=0}if(dojo.byId("similarProduct"+j)){dojo.byId("similarProduct"+j).innerHTML=0}return false}else{if(dojo.byId("resultsCart"+j)){dojo.byId("resultsCart"+j).innerHTML=dojo.number.round(parseFloat(dojo.byId("resultsCart"+j).innerHTML))+k}if(dojo.byId(j)){dojo.byId(j).innerHTML=dojo.number.round(parseFloat(dojo.byId(j).innerHTML))+k}if(dojo.byId("similarProduct"+j)){dojo.byId("similarProduct"+j).innerHTML=dojo.number.round(parseFloat(dojo.byId("similarProduct"+j).innerHTML))+k}}}else{if(k<0){k=0;if(dojo.byId("resultsCart"+j)){dojo.byId("resultsCart"+j).innerHTML=0}if(dojo.byId(j)){dojo.byId(j).innerHTML=0}if(dojo.byId("similarProduct"+j)){dojo.byId("similarProduct"+j).innerHTML=0}return false}else{if(dojo.byId("resultsCart"+j)){dojo.byId("resultsCart"+j).innerHTML=dojo.number.round(parseFloat(dojo.byId("resultsCart"+j).innerHTML))+k}if(dojo.byId(j)){dojo.byId(j).innerHTML=dojo.number.round(parseFloat(dojo.byId(j).innerHTML))+k}if(dojo.byId("similarProduct"+j)){dojo.byId("similarProduct"+j).innerHTML=dojo.number.round(parseFloat(dojo.byId("similarProduct"+j).innerHTML))+k}}}dojo.byId("cartTotal").innerHTML=dojo.number.round(parseFloat(dojo.byId("cartTotal").innerHTML)+dojo.number.round(k*h,2),2);if(dojo.byId("cart_"+j)){if(parseInt(dojo.byId("cart_"+j+"_nb").innerHTML)+k<=0){dojo.byId("cart_divProduct_"+f).removeChild(dojo.byId("cart_"+j));if(dojo.byId("cart_divProduct_"+f).childNodes.length==1){if(dojo.byId("cart_divProduct_"+f)){dojo.byId("cart_divProduct_"+f).parentNode.removeChild(dojo.byId("cart_divProduct_"+f))}if(dojo.byId("cart_divMarket_"+m).childNodes.length==1){if(dojo.byId("cart_divMarket_"+m)){dojo.byId("cart_divMarket_"+m).parentNode.removeChild(dojo.byId("cart_divMarket_"+m))}}}if(cart_array.length>0){dojo.forEach(cart_array,function(t,r,s){if(t&&t[0]==j){s.splice(r,1)}})}}else{dojo.byId("cart_"+j+"_nb").innerHTML=parseInt(dojo.byId("cart_"+j+"_nb").innerHTML)+k;dojo.byId("cart_"+j+"_price").innerHTML=dojo.number.round(parseInt(dojo.byId("cart_"+j+"_nb").innerHTML)*h,2);if(cart_array.length>0){dojo.forEach(cart_array,function(t,r,s){if(t&&t[0]==j){s.splice(r,1)}});cart_array.push(new Array(j,parseInt(dojo.byId("cart_"+j+"_nb").innerHTML),h,b,f,e,l,q,m))}}}else{if(!dojo.byId("cart_divMarket_"+m)){var o=dojo.doc.createElement("div");o.setAttribute("id","cart_divMarket_"+m);o.setAttribute("style","width : 100%; font-weight: bold;");var d="<a onclick='displayDispatcher("+m+", 0, 0, null, null, true, false, false);return false;' style='font-size: 15px; font-family: Arial, sans-serif;font-variant: bold;'>"+unescape(q)+"</a>";o.innerHTML=d;dojo.byId("cartContent").appendChild(o);dojo.place(dojo.byId("cart_divMarket_"+m),dojo.byId("cartContent"),"first");delete o;delete d}else{dojo.place(dojo.byId("cart_divMarket_"+m),dojo.byId("cartContent"),"first")}if(!dojo.byId("cart_divProduct_"+f)){var n=dojo.doc.createElement("div");n.setAttribute("id","cart_divProduct_"+f);n.setAttribute("style","width : 100%; padding: 0; font-size: 11px; font-variant: normal; font-weight: bold;");var g="<a class='nav' onclick='displayDispatcher("+m+", "+l+", "+f+", null, null, true, false, false);return false;' style='font-weight: bold; color:#000000;'>"+unescape(e.replace(/&amp;/g,"&"))+"</a>";n.innerHTML=g;dojo.byId("cart_divMarket_"+m).appendChild(n);dojo.place(dojo.byId("cart_divProduct_"+f),dojo.byId("cart_divMarket_"+m));delete n;delete g}var a=dojo.doc.createElement("div");a.setAttribute("id","cart_"+j);a.setAttribute("style","width : 100%; font-weight: normal; padding: 0 3x; color:#000000;");var c=unescape(b);var p="<div><a onclick='displayDispatcher("+m+", "+l+", "+f+", null, null, true, false, false);return false;' onmouseover=\"this.innerHTML='"+unescape(b).replace(/([\\'])/g,"\\$1")+"';\" onmouseout=\"this.innerHTML='"+c.replace(/([\\'])/g,"\\$1")+"';\" style='color:#000000;'>"+c+"</a></div><div style='float: right'><span id='cart_"+j+"_price' style='font-weight: bold; color:#000000;'>"+dojo.number.round(k*h,2)+"</span> &euro;</div><div style='font-weight: bold; color:#000000;'>Quantit&eacute; : ";p+="<img id='cart_minus_"+j+"' src='/images/bouton_moins.gif' width='12' height='12' alt='' border='0' title='Supprimer une unit&eacute;' alt='Supprimer une unit&eacute;' align='top' hspace='2' vspace='1'>";delete c;p+="<span id='cart_"+j+"_nb' style='font-weight: bold; color:#000000;'>"+k+"</span>";p+="<img id='cart_plus_"+j+"' src='/images/bouton_plus.gif' width='12' height='12' alt='' border='0' title='Ajouter une unit&eacute;' alt='Ajouter une unit&eacute;' align='top' hspace='2' vspace='1'>";p+="</div>";a.innerHTML=p;dojo.byId("cart_divProduct_"+f).appendChild(a);dojo.place(dojo.byId("cart_"+j),dojo.byId("cart_divProduct_"+f));var i=dojo.connect(dojo.byId("cart_minus_"+j),"onclick",function(r){cart(j,-1,h,b,f,e,l,q,m);return(false)});var i=dojo.connect(dojo.byId("cart_plus_"+j),"onclick",function(r){cart(j,1,h,b,f,e,l,q,m);return(false)});if(cart_array.length>0){dojo.forEach(cart_array,function(t,r,s){if(t&&t[0]==j){s.splice(r,1)}})}cart_array.push(new Array(j,parseInt(dojo.byId("cart_"+j+"_nb").innerHTML),h,b,f,e,l,q,m))}if(cart_array.length<=0){dojo.style("cartEmpty","display","block")}else{dojo.style("cartEmpty","display","none")}car_array_cookie=new Array();dojo.forEach(cart_array,function(s,r){car_array_cookie.push(new Array(s[0],s[1],0,0,0,0,0,0,0))});dojo.cookie("mm_cart",dojo.toJson(car_array_cookie),{expires:5,path:"/"});cart_json=dojo.toJson(cart_array);dojo.byId("cartTotalHL").innerHTML=dojo.byId("cartTotal").innerHTML;updateTotal();delete p;delete a;delete i;delete j;delete k;delete h;delete b;delete f;delete e;delete l;delete q;delete m}function updateTotal(){dojo.byId("cartTotalHL").innerHTML=dojo.byId("cartTotal").innerHTML;if(cartPromo&&cartPromo!=null&&cartPromo.length>0){var a=0;dojo.forEach(cartPromo,function(h){if(h[1]<=dojo.number.round(parseFloat(dojo.byId("cartTotalHL").innerHTML))){a+=parseFloat(h[0])}});dojo.byId("cartPromoTotal").innerHTML=a;if(a>0){dojo.byId("cartTotalHL").innerHTML=dojo.number.round(parseFloat(dojo.byId("cartTotalHL").innerHTML)-a,2);dojo.style("cartPromo","display","inline")}else{dojo.style("cartPromo","display","none")}}if(cartFid&&cartFid!=null){dojo.byId("cartFidPercent").innerHTML=0;dojo.byId("cartFidTotal").innerHTML=0;if(cartFidMin<=dojo.number.round(parseFloat(dojo.byId("cartTotalHL").innerHTML))){dojo.byId("cartFidPercent").innerHTML=cartFid;dojo.byId("cartFidTotal").innerHTML=dojo.number.round((parseFloat(dojo.byId("cartTotalHL").innerHTML)*cartFid)/100,2);dojo.byId("cartTotalHL").innerHTML=dojo.number.round(parseFloat(dojo.byId("cartTotalHL").innerHTML)-parseFloat(dojo.byId("cartFidTotal").innerHTML),2);dojo.style("cartFid","display","inline")}else{dojo.style("cartFid","display","none")}}if(cartCredit&&cartCredit!=null){dojo.byId("cartCreditTotal").innerHTML=dojo.number.round(cartCredit,2);if(dojo.number.round(cartCredit,2)<dojo.number.round(parseFloat(dojo.byId("cartTotalHL").innerHTML))){dojo.byId("cartTotalHL").innerHTML=dojo.number.round(parseFloat(dojo.byId("cartTotalHL").innerHTML)-cartCredit,2)}else{dojo.byId("cartTotalHL").innerHTML=0}dojo.style("cartCredit","display","inline")}if(deliveryMode&&deliveryDate!=""&&currentDeliveryPrices!=""&&dojo.number.round(parseFloat(dojo.byId("cartTotal").innerHTML),2)>0){var d=dojo.number.round(parseFloat(dojo.byId("cartTotal").innerHTML),2);var f=new RegExp("[ ;]+","g");var c=new RegExp("[ :]+","g");var g=currentDeliveryPrices.split(f);var e=0;var b=0;dojo.byId("cartDeliveryTax").innerHTML=-1;dojo.every(g,function(j,h){priceElem_=j.split(c);if(h==0){e=dojo.number.round(parseFloat(priceElem_[0]),2)}if(d>=dojo.number.round(parseFloat(priceElem_[0]),2)&&(d<dojo.number.round(parseFloat(priceElem_[1]),2)||dojo.number.round(parseFloat(priceElem_[1]),2)==0)){dojo.byId("cartDeliveryTax").innerHTML=dojo.number.round(parseFloat(priceElem_[2]),2)}if(priceElem_[2]==0){b=dojo.number.round(parseFloat(priceElem_[0]),2)}return true},d);dojo.empty("DeliveryDetail");if(deliveryMode==1){DeliveryDetailText="Livraison à votre domicile<br/> souhaitée pour le "+deliveryDate.substr(8,2)+"/"+deliveryDate.substr(5,2)+"/"+deliveryDate.substr(0,4)+"<br/>entre "+hours_[deliveryHour].replace("<br/>","-")}else{if(deliveryMode==2){DeliveryDetailText="Livraison en entreprise<br/> souhaitée pour le "+deliveryDate.substr(8,2)+"/"+deliveryDate.substr(5,2)+"/"+deliveryDate.substr(0,4)}else{if(deliveryMode==4){DeliveryDetailText="Livraison en point presse<br/> souhaitée pour le "+deliveryDate.substr(8,2)+"/"+deliveryDate.substr(5,2)+"/"+deliveryDate.substr(0,4)}}}if(deliveryMode>0){if(b>0&&d<b){DeliveryDetailText+="<br/><strong>Livraison gratuite dès "+b+"€</strong>"}DeliveryDetailText+="<br/>Modifier votre livraison";dojo.create("div",{innerHTML:DeliveryDetailText,style:{display:"block",cursor:"pointer",textAlign:"center",fontSize:"11px",fontWeight:"bold",color:"#2A1D12",padding:"1px",margin:"4px 0",border:"1px solid #2A1D12",background:"#fefefd"}},dojo.byId("DeliveryDetail"));dojo.attr(dojo.byId("DeliveryDetail"),"onclick",function(h){selectDeliveryMode()})}if(dojo.byId("cartDeliveryTax").innerHTML>=0){dojo.style("cartTotalL","display","inline");dojo.byId("cartDeliveryInfo").innerHTML="";dojo.style("cartDeliveryInfo","display","none");dojo.byId("cartTotalL").innerHTML=dojo.number.round(parseFloat(dojo.byId("cartTotalHL").innerHTML)+parseFloat(dojo.byId("cartDeliveryTax").innerHTML),2);dojo.style("cartDelivery","display","inline");dojo.byId("actionCart").innerHTML="Validez votre panier";dojo.style("actionCart",{display:"block",cursor:"pointer",textAlign:"center",fontSize:"11px",fontWeight:"bold",color:"#2A1D12",padding:"1px",margin:"4px 0",border:"1px solid #2A1D12",background:"#fefefd"});dojo.attr(dojo.byId("actionCart"),"onclick",function(h){displayDispatcher(0,0,0,"order/step1.php?rnd="+Math.random(),decodeURI("Récapitulatif de votre panier"),false,true,true)})}else{dojo.style("cartDelivery","display","none");dojo.style("cartDeliveryInfo","display","inline");dojo.byId("cartDeliveryInfo").innerHTML="<br/><strong style='white-space: nowrap'>Minimum non atteint ("+e+" €)</strong>";dojo.byId("cartDeliveryInfo").innerHTML+="<br/><strong>"+dojo.byId("DeliveryDetail").innerHTML+"</strong>";dojo.attr(dojo.byId("cartDeliveryInfo"),"onclick",function(h){selectDeliveryMode()});dojo.style("actionCart","display","none");dojo.attr(dojo.byId("actionCart"),"onclick",function(h){selectDeliveryMode()});dojo.empty(dojo.byId("actionCart"))}}else{dojo.style("cartDelivery","display","none");dojo.style("actionCart","display","none");dojo.attr(dojo.byId("actionCart"),"onclick",function(h){selectDeliveryMode()});dojo.empty(dojo.byId("actionCart"));if(dojo.number.round(parseFloat(dojo.byId("cartTotal").innerHTML),2)>0){dojo.empty(dojo.byId("cartDeliveryInfo"));dojo.create("div",{innerHTML:"Sélectionner votre date/lieu de livraison",style:{display:"block",cursor:"pointer",textAlign:"center",fontSize:"11px",fontWeight:"bold",color:"#2A1D12",padding:"1px",margin:"4px 0",border:"1px solid #2A1D12",background:"#fefefd"},onclick:function(){selectDeliveryMode()}},dojo.byId("cartDeliveryInfo"));dojo.style("cartDeliveryInfo","display","inline")}}}function userLogin(){if(dijit.byId("frmLogin").validate()){dojo.xhrPost({form:"frmLogin",url:"/bl/client/login.php",handleAs:"json",sync:true,handle:function(b,a){if(typeof b=="error"){console.warn("error!",a)}else{if(b.id==null){dojo.byId("loginError").innerHTML=b}else{dojo.style("subscribe","display","none");dojo.style("logout","display","inline");cartPromo=b.cartPromo;cartFid=b.cartFid;cartCredit=b.cartCredit;if(deliveryMode==1&&client.postal_code!=undefined&&client.postal_code!=b.postal_code){dojo.mixin(client,b);deliveryMode=0;deliveryDate="";deliveryHour="";displayDispatcher(0,0,0,"client/historiquecommandes.php","Votre espace",true,true,false);updateTotal()}else{dojo.mixin(client,b.client);if(b.page=="order/step1.php"){displayDispatcher(0,0,0,"order/step1.php","R&eacute;capitulatif de votre panier",false,true,true)}else{displayDispatcher(0,0,0,"client/historiquecommandes.php","Votre espace",true,true,true);updateTotal()}}}}}})}}function userLogout(){dojo.xhrGet({url:"/bl/client/logout.php",sync:true,handle:function(b,a){if(typeof b=="error"){console.warn("error!",a)}else{dojo.style("subscribe","display","inline");dojo.style("logout","display","none");dojo.style("cartFid","display","none");dojo.style("cartCredit","display","none");dojo.style("cartPromo","display","none");dojo.style("cartDelivery","display","none");cartPromo=null;cartFid=null;cartCredit=null;client=null;client=Object();deliveryMode=0;deliveryHour="";deliveryDate="";currentDeliveryPrices="";deliveryPointId=0;updateTotal();displayDispatcher(0,0,0,"client/login.php","Identification",false,true,true)}}})}function checkSession(){dojo.xhrPost({url:"/bl/client/checkSession.php",handleAs:"json",content:{mm_cart:dojo.toJson(cart_array),deliveryMode:deliveryMode,deliveryHour:deliveryHour,deliveryDate:deliveryDate,deliveryPointId:deliveryPointId},sync:true,handle:function(b,a){if(typeof b=="error"){console.warn("error!",a)}else{if(b!="none"){dojo.style("subscribe","display","none");dojo.style("logout","display","inline");dataObj=b;cartPromo=dataObj.cartPromo;cartFid=dataObj.cartFid;cartCredit=dataObj.cartCredit;client=dataObj;dojo.style("cartDelivery","display","inline");updateTotal()}else{dojo.style("subscribe","display","inline");dojo.style("logout","display","none");dojo.style("cartFid","display","none");dojo.style("cartCredit","display","none");dojo.style("cartPromo","display","none");dojo.style("cartDelivery","display","none");cartPromo=null;cartFid=null;cartCredit=null;updateTotal()}}}})}function searchItem(){if(dijit.byId("searchFrm").validate()){checkSession();dojo.byId("smallpreloader").style.display="block";dojo.byId("page").style.display="none";dojo.byId("pageCart").style.display="none";dojo.byId("marketContainer").style.display="none";dojo.byId("commonContainer").style.display="block";dojo.byId("road").innerHTML=decodeURI("R&eacute;sultats de votre recherche : "+dojo.byId("searchInput").value);dojo.query("*",dojo.byId("commonContainer")).forEach(function(a){if(dijit.byNode(a)){dijit.byNode(a).destroyRecursive()}});dojo.empty(dojo.byId("commonContainer"));dojo.xhrPost({url:"/bl/content/search.php",preventCache:true,form:"searchFrm",handleAs:"json",sync:false,load:function(a){dojo.byId("commonContainer").innerHTML=a.search;dojo.forEach(a.recipes,function(d,b){if(b==0){dojo.create("div",{innerHTML:"Les recettes","class":"title"},dojo.byId("commonContainer"))}var c=new mm.recipe.itemSearchElem({id:a.id+"_"+d.id,name:d.name,CookingMenu:d.CookingMenu,CookingSpec:d.CookingSpec,season:d.season,CookingType:d.CookingType,recipe:d.recipe,elements:d.elements,advise:d.advise,difficulty:d.difficulty,price:d.price,priceNote:d.priceNote,priceAmount:d.priceAmount,totalPrice:d.totalPrice,principalCond:d.principalCond,cooking:d.preparation,preparation:d.preparation,nb_parts:d.nb_parts,menu:d.menu,kcal:d.kcal,proteine:d.proteine,lipide:d.lipide,glucide:d.glucide,origin:d.origin,originInt:d.originInt,img_recipe:d.img_recipe});c.placeAt("commonContainer","last");delete c});dojo.byId("smallpreloader").style.display="none";dojo.byId("pageCart").style.display="block"}})}}function displayRecipe(d,b,c,f,h,g,a,e){dojo.byId("page").style.display="none";dojo.byId("pageCart").style.display="none";dojo.byId("smallpreloader").style.display="block";dojo.byId("road").innerHTML=decodeURI(h);if(!a){a=false}if(e){checkSession()}dojo.byId("marketContainer").style.display="none";dojo.byId("commonContainer").style.display="block";dojo.xhrGet({url:"/pages/"+f,preventCache:true,load:function(i){dojo.byId("smallpreloader").style.display="none";dojo.query("*",dojo.byId("commonContainer")).forEach(function(j){if(dijit.byNode(j)){dijit.byNode(j).destroyRecursive()}});dojo.empty(dojo.byId("commonContainer"));dojo.byId("commonContainer").innerHTML=i;dojo.byId("pageCart").style.display="block";dojo.parser.parse(dojo.byId("commonContainer"));recipeCheckTotal()}})}function searchMenu(a){dojo.xhrPost({content:{menuType:a},url:"/bl/content/searchMenu.php",handleAs:"json",handle:function(c,b){if(typeof c=="error"){console.warn("error!",b)}else{if(c=="error"){console.warn("error!",b)}else{dojo.forEach(dijit.findWidgets(dojo.byId("menuResults")),function(d){d.destroyRecursive()});dojo.empty("menuResults");dojo.style("menuResults","display","block");if(c.length==0){dojo.byId("menuResults").innerHTML="<strong>Aucun résultat</strong>"}else{dojo.byId("menuResults").innerHTML=""}dojo.byId("menuResults").innerHTML="";dojo.forEach(c,function(f,e){if(f.recipes.length>0){var d=dojo.create("div",{innerHTML:"<div class='subtitle'>Menu "+f.menuType+" "+(e+1)+"</div>"},dojo.byId("menuResults"));dojo.forEach(f.recipes,function(h){if(h.length>0){elem=h[0];var g=new mm.recipe.itemSearchElem({id:elem.id,name:elem.name,CookingMenu:elem.CookingMenu,CookingSpec:elem.CookingSpec,season:elem.season,CookingType:elem.CookingType,recipe:elem.recipe,elements:elem.elements,advise:elem.advise,difficulty:elem.difficulty,price:elem.price,priceNote:elem,priceAmount:elem.priceAmount,totalPrice:elem.totalPrice,principalCond:elem.principalCond,cooking:elem.preparation,preparation:elem.preparation,nb_parts:elem.nb_parts,menu:elem.menu,kcal:elem.kcal,proteine:elem.proteine,lipide:elem.lipide,glucide:elem.glucide,origin:elem.origin,originInt:elem.originInt,img_recipe:elem.img_recipe});g.placeAt(d,"last")}delete elem;delete d});delete d}})}}},onError:function(c,b){dojo.byId("message").innerHTML="Une erreur est survenue"}})}function searchRecipe(){if(dijit.byId("formSearchRecipe").validate()){formData=dijit.byId("formSearchRecipe").get("value");dojo.xhrPost({content:formData,url:"/bl/content/searchRecipe.php",handleAs:"json",handle:function(b,a){if(typeof b=="error"){console.warn("error!",a)}else{if(b=="error"){console.warn("Une erreur est survenue",a)}else{dojo.forEach(dijit.findWidgets(dojo.byId("recipeResults")),function(c){c.destroyRecursive()});dojo.empty("recipeResults");dojo.style("recipeResults","display","block");if(b.length==0){dojo.byId("recipeResults").innerHTML="<strong>Aucun résultat</strong>"}else{dojo.byId("recipeResults").innerHTML=""}dojo.forEach(b,function(d){var c=new mm.recipe.itemSearchElem({id:b.id+"_"+d.id,name:d.name,CookingMenu:d.CookingMenu,CookingSpec:d.CookingSpec,season:d.season,CookingType:d.CookingType,recipe:d.recipe,elements:d.elements,advise:d.advise,difficulty:d.difficulty,price:d.price,priceNote:d.priceNote,priceAmount:d.priceAmount,totalPrice:d.totalPrice,principalCond:d.principalCond,cooking:d.preparation,preparation:d.preparation,nb_parts:d.nb_parts,menu:d.menu,kcal:d.kcal,proteine:d.proteine,lipide:d.lipide,glucide:d.glucide,origin:d.origin,originInt:d.originInt,img_recipe:d.img_recipe});c.placeAt("recipeResults","last");delete c})}}},onError:function(b,a){dojo.byId("message").innerHTML="Une erreur est survenue"}})}}dojo.declare("mm.recipe.itemSearchElem",[dijit._Widget,dijit._Templated],{templateString:dojo.cache("mm.recipe","template/recipeSearch.html"),widgetsInTemplate:true,id:"",name:"",menuId:0,CookingMenu:"",CookingSpec:"",season:"",CookingType:"",recipe:"",elements:"",advise:"",difficulty:"",price:"",priceNote:"",priceAmount:"",nb_parts:"",preparation:"",cooking:"",principalCond:"",menu:"",origin:"",originInt:0,img_recipe:"",recipeListSelectNbValue:0,postCreate:function(){dojo.forEach(dijit.findWidgets(dojo.byId("page")),function(e){console.log(e)});var d=this;this.nameNode.innerHTML=this.name;this.CookingMenuNode.innerHTML=this.CookingMenu;if(this.difficulty>0){for(var c=1;c<=this.difficulty;c++){var a=dojo.create("div",{},this.difficultyNode);dojo.create("img",{src:"/images/recettes/toque.gif",align:"left"},a);delete a}}this.priceNode.innerHTML="";if(this.priceNote>0){for(var c=1;c<=this.priceNote;c++){var a=dojo.create("div",{},this.priceNode);dojo.create("img",{src:"/images/recettes/bourse.gif",align:"left"},a);delete a}}if(this.preparation>0){this.preparationNode.innerHTML="<strong>Préparation :</strong> "+((Math.floor(this.preparation/60)>0)?(Math.floor(this.preparation/60>0))+"h ":"")+(this.preparation-Math.floor(this.preparation/60)*60)+"mn"}else{this.preparationNode.innerHTML=""}if(this.cooking>0){this.cookingNode.innerHTML="<strong>Cuisson :</strong> "+((Math.floor(this.cooking/60)>0)?(Math.floor(this.cooking/60>0))+"h ":"")+(this.cooking-Math.floor(this.cooking/60)*60)+"mn"}else{this.cookingNode.innerHTML=""}var b;if(this.originInt==0){b="/images/recettes/logos/mm.gif"}else{if(this.originInt==1){b="/images/recettes/logos/marmiton.gif"}else{if(this.originInt==2){b="/images/recettes/logos/atlantic.gif"}}}dojo.create("img",{src:b,alt:this.origin,align:"left",align:"left",style:"padding-right: 5px;"},this.originNode);delete b},_onClickDetail:function(){if(dojo.style(this.detailRecipeNode,"display")=="none"){dojo.style(this.detailRecipeNode,"display","block");var d=this;var a=this.priceAmount;if(this.img_recipe!=""){dojo.create("img",{src:this.img_recipe,align:"left",width:"220",height:"188",align:"left",style:"padding-right: 5px;"},this.recipeNode,"first")}this.recipeNode.innerHTML+=this.recipe;if(this.advise!=""){this.adviseNode.innerHTML='<div style="font-face:Arial; font-size:16px;font-weight:bold;">Le conseil qui fait la différence</div>'+this.advise}else{this.adviseNode.innerHTML=""}var b=dojo.create("div",{style:{width:"250px"}},this.elementsNode);dojo.forEach(this.elements,function(h){dojo.create("div",{id:"td"+h.recipeElemCondId,innerHTML:"<strong>"+h.recipeElemQty+"x "+h.recipeElemProdName+"</strong><br/>"+h.recipeElemCondName+" : "+h.recipeElemPrice+" €",style:{styleFloat:"left",width:"230px"}},b);var g=dojo.create("div",{style:{styleFloat:"right",width:"15px"},innerHTML:""},b);var f=new dijit.form.CheckBox({name:"checkbox",value:h,checked:true,onChange:function(i){console.log("onChange called with parameter = "+i+", and widget value = "+f.attr("value"));var k=c.value;var j=(dojo.number.round(d.finalPriceNode.innerHTML*100)/100);console.log(parseFloat(h.recipeElemPrice),h.recipeElemQty);if(f.attr("value")){j+=dojo.number.round((parseFloat(h.recipeElemPrice)*h.recipeElemQty)*100*k)/100;a+=dojo.number.round((parseFloat(h.recipeElemPrice)*h.recipeElemQty)*100)/100}else{j-=dojo.number.round((parseFloat(h.recipeElemPrice)*h.recipeElemQty)*100*k)/100;a-=dojo.number.round((parseFloat(h.recipeElemPrice)*h.recipeElemQty)*100)/100}d.finalPriceNode.innerHTML=(dojo.number.round(j*100)/100);delete j;delete k}},g);var g=dojo.create("div",{style:{styleFloat:"none",clear:"both"}},b);delete f;delete g});var e=dojo.create("div",{innerHTML:"<strong>Sélectionner le nombre de convives</strong>",align:"right"},b);d.recipeListSelectNbValue=1;var c=new dijit.form.Select({name:"recipeListSelectNb",options:[{label:d.nb_parts,value:1},{label:d.nb_parts*2,value:2},{label:d.nb_parts*3,value:3},{label:d.nb_parts*4,value:4},{label:d.nb_parts*5,value:5}],onChange:function(){var f=0;var g=this.value;d.recipeListSelectNbValue=this.value;f=dojo.number.round(a*g*100)/100;d.finalPriceNode.innerHTML=dojo.number.round(f*100)/100;delete f;delete g}}).placeAt(e);this.finalPriceNode.innerHTML=this.priceAmount;delete d;delete b}else{dojo.style(this.detailRecipeNode,"display","none");arrayDelDijitDom=new Array(this.elementsNode,this.finalPriceNode,this.recipeNode,this.adviseNode);dojo.forEach(arrayDelDijitDom,function(f){dojo.forEach(dijit.findWidgets(f),function(g){g.destroyRecursive()});dojo.empty(f)})}},_addToCart:function(){var a=this;cartObjBDSel=Array();dojo.query("input:checked",this.detailRecipeNode).forEach(function(b){b=dijit.byId(b.id).attr("value");console.log(a.recipeListSelectNbValue);nObj={spinner_id:b.recipeElemCondId,count:parseFloat(b.recipeElemQty)*parseFloat(a.recipeListSelectNbValue),price:b.recipeElemPrice,conditioning:b.recipeElemCondName,product_id:b.recipeElemProdId,product_name:b.recipeElemProdName,parent_id:b.recipeElemFamilyId,root_name:b.recipeElemMarketName,root_id:b.recipeElemMarketId};cartObjBDSel.push(nObj)});cartMultiple(cartObjBDSel);delete a}});function recipeCheckTotal(){var b=0;dojo.query("#commonContainer input[type=checkbox]:checked").forEach(function(d){b+=parseFloat(dojo.byId("recipeElemQty_"+d.value).value)*dojo.number.round(parseFloat(dojo.byId("recipeElemPrice_"+d.value).value),2)});var c=parseFloat(dojo.byId("proportion").options[dojo.byId("proportion").selectedIndex].value);var a=parseFloat(dojo.byId("nbpersonnes").value);b=c*b;b=Math.round(b*100)/100;dojo.byId("recipeTotal").innerHTML="Soit pour "+(c*a)+" personnes : "+b+" &euro;"}function addRecipe2Cart(){dojo.query("#commonContainer input[type=checkbox]:checked").forEach(function(a){cart("spinner_"+a.value,parseFloat(dojo.byId("recipeElemQty_"+a.value).value)*parseFloat(dojo.byId("proportion").options[dojo.byId("proportion").selectedIndex].value),dojo.byId("recipeElemPrice_"+a.value).value,dojo.byId("recipeElemCondName_"+a.value).value,dojo.byId("recipeElemProdId_"+a.value).value,dojo.byId("recipeElemProdName_"+a.value).value,dojo.byId("recipeElemFamilyId_"+a.value).value,dojo.byId("recipeElemMarketName_"+a.value).value,dojo.byId("recipeElemMarketId_"+a.value).value)})}function displayDispatcher(d,b,c,f,h,g,a,e){closeNav();if((currentPage!=f||f==null)||d!=0){if(parseInt(d)==1100){homePage=false;dojo.byId("page").style.display="none";dojo.byId("pageCart").style.display="none";dojo.byId("marketContainer").style.display="none";dojo.byId("commonContainer").style.display="none";navSetSel(1100);var h=markets_array[1100];dojo.byId("road").innerHTML=decodeURI(h);dojo.byId("page").style.display="none";dojo.byId("pageCart").style.display="none";dojo.byId("smallpreloader").style.display="block";if(!a){a=false}if(e){checkSession()}dojo.byId("marketContainer").style.display="none";dojo.byId("commonContainer").style.display="block";if(!f){f="market/box.php"}dojo.xhrGet({url:"/pages/"+f,preventCache:true,load:function(i){dojo.byId("smallpreloader").style.display="none";dojo.query("*",dojo.byId("commonContainer")).forEach(function(j){if(dijit.byNode(j)){dijit.byNode(j).destroyRecursive()}});dojo.empty(dojo.byId("commonContainer"));dojo.byId("commonContainer").innerHTML=i;dojo.byId("pageCart").style.display="block";dojo.parser.parse(dojo.byId("commonContainer"));boxCheckTotal()}})}else{displayBox(d,b,c,f,encodeURI(h),g,a,e)}}else{}}function boxCheckTotal(){var a=0;dojo.query("#commonContainer input[type=checkbox]:checked").forEach(function(c){a+=parseFloat(dojo.byId("boxElemQty_"+c.value).value)*dojo.number.round(parseFloat(dojo.byId("boxElemPrice_"+c.value).value),2)});var b=parseFloat(dojo.byId("proportion").options[dojo.byId("proportion").selectedIndex].value);a=b*a;a=Math.round(a*100)/100;dojo.byId("boxTotal").innerHTML="Soit "+a+" &euro;"}function addBox2Cart(){dojo.query("#commonContainer input[type=checkbox]:checked").forEach(function(a){cartWithoutDeliveryCheck("spinner_"+a.value,parseFloat(dojo.byId("boxElemQty_"+a.value).value)*parseFloat(dojo.byId("proportion").options[dojo.byId("proportion").selectedIndex].value),dojo.byId("boxElemPrice_"+a.value).value,dojo.byId("boxElemCondName_"+a.value).value,dojo.byId("boxElemProdId_"+a.value).value,dojo.byId("boxElemProdName_"+a.value).value,dojo.byId("boxElemFamilyId_"+a.value).value,dojo.byId("boxElemMarketName_"+a.value).value,dojo.byId("boxElemMarketId_"+a.value).value)})}function addOrder2Cart(){dojo.query("#commonContainer input[type=checkbox]:checked").forEach(function(a){cartWithoutDeliveryCheck("spinner_"+a.value,parseFloat(dojo.byId("orderElemQty_"+a.value).value),dojo.byId("orderElemPrice_"+a.value).value,dojo.byId("orderElemCondName_"+a.value).value,dojo.byId("orderElemProdId_"+a.value).value,dojo.byId("orderElemProdName_"+a.value).value,dojo.byId("orderElemFamilyId_"+a.value).value,dojo.byId("orderElemMarketName_"+a.value).value,dojo.byId("orderElemMarketId_"+a.value).value)})}var comment_="Par exemple : d&eacute;signer un tiers susceptible de r&eacute;ceptionner votre commande, en lieu et place.";function userProfile(){dojo.byId("profileError").innerHTML="";if(dojo.byId("pwd").value!=dojo.byId("pwd_c").value){dojo.byId("pwd_c").value=""}if(dijit.byId("frmProfile").validate()){if(dojo.byId("comment").value==comment_){dojo.byId("comment").value=""}dojo.xhrPost({form:"frmProfile",url:"/bl/client/modify.php",handleAs:"json",handle:function(b,a){if(typeof b=="error"){console.warn("error!",a)}else{if(b=="error"){dojo.byId("profileError").innerHTML="Une erreur est survenue"}else{if(b=="emailError"){dojo.byId("profileError").innerHTML="L'email, que vous avez renseign&eacute;, est d&eacute;jà utilis&eacute;"}else{if(b.id!=null){dojo.mixin(client,b);dojo.byId("profileError").innerHTML="Vos changements ont bien &eacute;t&eacute; pris en compte"}else{dojo.byId("profileError").innerHTML="Une erreur est survenue"}}}}}})}}function userProfileSubscribe(){dojo.byId("profileError").innerHTML="";if(dojo.byId("pwd").value!=dojo.byId("pwd_c").value){dojo.byId("pwd_c").value=""}if(dijit.byId("frmSubscribe").validate()){if(dojo.byId("comment").value==comment_){dojo.byId("comment").value=""}dojo.xhrPost({form:"frmSubscribe",url:"/bl/client/add.php",handleAs:"json",handle:function(b,a){if(typeof b=="error"){console.warn("error!",a)}else{if(b=="error"){dojo.byId("profileError").innerHTML="Une erreur est survenue"}else{if(b=="emailError"){dijit.byId("email").displayMessage();dojo.byId("profileError").innerHTML="L'email, que vous avez renseign&eacute;, est d&eacute;jà utilis&eacute;"}else{dojo.style("subscribe","display","none");dojo.style("logout","display","inline");dojo.mixin(client,b);cartPromo=b.cartPromo;cartFid=b.cartFid;cartCredit=b.cartCredit;displayDispatcher(0,0,0,"client/coordonnees.php","Bienvenue dans votre espace, merci de vérifier votre adresse email (un mail de confirmation vous a été envoyé)",true,true,true)}}}}})}return false}function userGoFather(){dojo.byId("godFatherError").innerHTML="";if(dijit.byId("frmGodFather").validate()){dojo.xhrPost({form:"frmGodFather",url:"/pages/client/parrainage.php",handleAs:"text",preventCache:true,load:function(a){if(typeof a=="error"){console.warn("error!",args);dojo.byId("godFatherError").innerHTML="Une erreur est survenue"}else{dojo.query("*",dojo.byId("commonContainer")).forEach(function(b){if(dijit.byNode(b)){dijit.byNode(b).destroyRecursive()}});dojo.empty(dojo.byId("commonContainer"));dojo.byId("commonContainer").innerHTML=a;dojo.parser.parse(dojo.byId("commonContainer"))}}})}}function Facture(a){var e=screen.height-200;var d=690;var c=(screen.height-e)/2;var b=(screen.width-d)/2;window.open("/facture.php?com_id="+a,"Facture","toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,resizable=yes,top="+c+",left="+b+",width="+d+",height="+e)}function Payement(){if(dijit.byId("cgv").checked){dojo.byId("road").innerHTML=decodeURI("Votre commande est en cours de traitement, merci de patienter");dojo.byId("page").style.display="none";dojo.byId("smallpreloader").style.display="block";dojo.xhrGet({url:"/bl/commande/validatePayement.php",handleAs:"json",preventCache:true,load:function(a){if(a[0]=="paymentOK"){cart_array=new Array();dojo.cookie("mm_cart",dojo.toJson(cart_array),{expires:5,path:"/"});displayDispatcher(0,0,0,"client/historiquecommandes.php","Espace Client > Historique commandes > Votre commande n° "+a[1]+" a bien &eacute;t&eacute; prise en compte, merci",true,true,true)}else{dojo.byId("version").value=a[2];dojo.byId("TPE").value=a[3];dojo.byId("date").value=a[4];dojo.byId("montant").value=a[5]+""+a[6];dojo.byId("reference").value=a[7];dojo.byId("MAC").value=a[8];dojo.byId("url_retour").value=a[9]+""+a[10];dojo.byId("url_retour_ok").value=a[11]+""+a[12];dojo.byId("url_retour_err").value=a[13]+""+a[14];dojo.byId("lgue").value=a[15];dojo.byId("societe").value=a[16];dojo.byId("texte-libre").value=a[17];dojo.byId("PaymentRequest").submit()}}})}else{dojo.byId("payementError").innerHTML="<br/>Vous devez valider nos conditions g&eacute;n&eacute;rales de vente, avant de proceder au paiement."}}function dialogContent(c){if(dijit.byId("dialogContentDiv")){dijit.byId("dialogContentDiv").destroyDescendants(0);dijit.byId("dialogContentDiv").destroy(0)}else{if(dojo.byId("dialogContentDiv")){dojo.destroy("dialogContentDiv")}}dijit._underlay=null;dijit._curFocus=null;dijit._prevFocus=null;if(!c.title){title=""}else{title=c.title}if(!c.html){content=""}else{content=c.html}if(c.div){content=dojo.byId(c.div).innerHTML}if(c.content){content=c.content}if(c.padding){padding=c.padding}else{padding="0"}if(c.width){width="width: "+c.width+"px;"}else{width="width: 600px;"}if(c.height){height="height:"+c.height+"px;"}else{height="height: 300px;"}var b=new dijit.Dialog({id:"dialogContentDiv",title:title,draggable:false,style:"overflow:auto;text-align:left;padding:0 0;margin:0 0;",onHide:function(){dojo.empty(this)},onCancel:function(e){this.destroyDescendants(0);this.destroy(0)}});dojo.query(".dijitDialogTitleBar").style({color:"#ffffff",fontSize:"1.1em",textAlign:"left",border:"1px solid #557a3b",backgroundColor:"#557a3b",backgroundImage:"url('/images/vide.gif')",backgroundRepeat:"no-repeat"});dojo.query(".dijitDialogPaneContent").style({padding:"0",border:"1px solid #557a3b"});if(c.url){content='<div style="'+width+height+"overflow: auto;text-align: center;padding: "+padding+';"><br>Chargement en cours...</div>';dijit.byId("dialogContentDiv").show();var d={url:c.url,handleAs:"text",load:function(e){content='<div style="'+width+height+"overflow: auto;padding: "+padding+';">'+e+"</div>";dijit.byId("dialogContentDiv").set("content",content)},error:function(e){console.log(e)}};var a=dojo.xhrGet(d)}else{content='<div style="'+width+height+"overflow: auto;padding: "+padding+';">'+content+"</div>";dijit.byId("dialogContentDiv").set("content",content);dojo.behavior.apply();dijit.byId("dialogContentDiv").show();dojo.query(".dijitDialogUnderlay").style({background:"#000000"})}}function simplifyContentVisibility(a){if(a==false){dojo.style("simplifyContentOff","display","block");dojo.style("simplifyContentOn","display","none")}else{dojo.style("simplifyContentOff","display","none");dojo.style("simplifyContentOn","display","block")}}function initNav(){var a=dojo.byId("digest");dojo.place(a,dojo.byId("headerTop"),"last");dojo.style(a,{display:"block",padding:"0",margin:"0",width:"986px",zIndex:"501",position:"absolute",backgroundColor:"#fff",border:"#557a3b solid 2px",textAlign:"left",styleFloat:"left",clear:"both"});dojo.query("> a",dojo.byId("nav")).onmouseenter(function(b){dojo.query("> ul",a).style({display:"none"});dojo.style(dojo.byId("openedNav"+(this.id).replace("level_","")),"display","block");dojo.connect(a,"onmouseleave",function(){dojo.query("> ul",dojo.byId("digest")).style({display:"none"})})}).onmouseleave(function(){})}function closeNav(){dojo.query("> ul",dojo.byId("digest")).style({display:"none"})}function seeMoreNav(a){dojo.query(".suiteNavA").style({display:"block"});dojo.query(".suiteNav").style({display:"none"});dojo.style(a.nextSibling,{display:"block"});dojo.style(a,{display:"none"})}var loopSlider=false;function slider(d,c,a){var d=dojo.byId(d);var e=dojo.coords(d);var b=0;dojo.query(">",d).forEach(function(f){dojo.style(f,{top:"0px",width:"230px",height:"auto",textAlign:"center",styleFloat:"left"});b=b+dojo.coords(f).w});if(b>0){dojo.style(d,"width",b+"px")}if(c>0){if(e.l<0){left=Math.round(e.l/c)*c+c}else{left=-(b-c)}}else{if(Math.abs(Math.round(e.l/c)*c+c)<b){left=Math.round(e.l/c)*c+c}else{left=0}}if(a){loopSlider=true}else{loopSlider=false}if(loopSlider){setTimeout(function(f){slider("partnerSlider",c,loopSlider);if(b){dojo.fx.slideTo({node:d,top:e.t,left:left.toString(),unit:"px",duration:1000}).play()}},3000)}else{if(b){dojo.fx.slideTo({node:d,top:0,left:left.toString(),unit:"px",duration:1000}).play()}}}function subscribeNewsletter(){if(dijit.byId("newsletterFrm").validate()){var b={form:dojo.byId("newsletterFrm"),url:"/bl/client/newsletter.php",handleAs:"json",load:function(c){if(c=="ok"){dialogContent({content:"Merci, votre inscription à la newsletter a bien été prise en compte.",title:"Votre inscription à la newsletter",width:"400",height:"auto",padding:"10px"})}else{console.log(c.status)}},error:function(c){console.log(c)}};var a=dojo.xhrPost(b)}};
