jMaceria.core.namespace("ui.web.categoryproduct");jMaceria.ui.web.categoryproduct=function(l){var g={};var h={};var e=function(){i();jMaceria.events.common.bind($(window),"handleProductCategoryFilter",d);$(window).bind("hashchange",f);$(".lnkPageNext").live("click",function(m){if(h.numPage<(h.maxPage-1)){h.numPage++;$(window).trigger("handleProductCategoryFilter",h)}return false});$(".lnkPageBack").live("click",function(m){if(h.numPage>0){h.numPage--;$(window).trigger("handleProductCategoryFilter",h)}return false});$(".pageLink").live("click",function(n){var m=$(this).attr("name");h.numPage=m.substring(5,m.length);h.numPage--;$(window).trigger("handleProductCategoryFilter",h);return false});$(".showProductBox").live("click",function(m){h.selShowType="Box";$(window).trigger("handleProductCategoryFilter",h)});$(".showProductRow").live("click",function(m){h.selShowType="Row";$(window).trigger("handleProductCategoryFilter",h)});$(window).trigger("hashchange")};var c=function(m){if(m===undefined||!m){m=h}if(m!==undefined&&m.selShowType=="Row"){$(".showProductRow").css({"font-weight":"bold"});$(".showProductBox").css({"font-weight":"normal"})}else{$(".showProductBox").css({"font-weight":"bold"});$(".showProductRow").css({"font-weight":"normal"})}};var i=function(){h={selShowType:"Box",selShowNumber:"Show6",selFilterShow:"NotSorted",arAttribute:new Array(),arAttributePrice:new Array(),arAttributeBrand:new Array(),numPage:0,maxPage:0};return h};var k=function(n){var m=n.parents(".attributeTreeContainer");var o=$(".attributeTreeParameterName",m);if(o.val()==="brandParam"){if($.inArray(n.attr("id"),h.arAttributeBrand)===-1){h.numPage=0;h.arAttributeBrand.push(n.attr("id"));b(n)}}else{if(o.val()==="priceParam"){if($.inArray(n.attr("id"),h.arAttributePrice)===-1){h.numPage=0;h.arAttributePrice.push(n.attr("id"));b(n)}}else{if($.inArray(n.attr("id"),h.arAttribute)===-1){h.numPage=0;h.arAttribute.push(n.attr("id"));b(n)}}}};var b=function(m){if(m===undefined){return}$(window).trigger("handleProductCategoryFilter",h)};var j=function(){$(".selFilterBy").change(function(m){h.selFilterShow=$(this).val();$(window).trigger("handleProductCategoryFilter",h)});$(".selShowNumber").change(function(m){h.numPage=0;h.selShowNumber=$(this).val();$(window).trigger("handleProductCategoryFilter",h)})};var d=function(m,o){if(o===undefined||!o){var n=$.bbq.pushState(i());return}$.bbq.pushState(o)};var a=function(n){if(n==undefined&&!n){return""}if(!$.isArray(n)){return n}var m="";$.each(n,function(o,p){m=m+p+","});return m};var f=function(p){var n=$.bbq.getState();if(n===undefined||n.selShowNumber===undefined||n.selFilterShow===undefined){n=i()}var m=n.selShowType!==undefined&&n.selShowType==="Row"?"/CategoryProduct/CategoryProductPanelList":"/CategoryProduct/CategoryProductPanel";var o=function(){$("#loader-ajax").hide();c(n);$(".aLinkAttributeButton").each(function(){jMaceria.ui.effect.controller.menu.afficherSousMenu($(this))})};$("#categoryProductPanel").empty();$("#loader-ajax").show();$("#categoryProductPanel").load(m+"?categoryId="+l+"&numPage="+n.numPage+"&filterShowProduct="+n.selShowNumber+"&filterSortedByProduct="+n.selFilterShow+"&attributeItemList="+a(n.arAttribute)+"&brandList="+a(n.arAttributeBrand)+"&priceList="+a(n.arAttributePrice),null,o)};e();g.attributeOnClick=k;g.filterBarEventHandler=j;g.get_currentparams=function(){return h};g.get_attributeliststring=function(){var m="";$.each(h.arAttribute,function(o,p){m=m+p+","});return m};g.set_maxpage=function(m){if(m!==undefined&&m){h.maxPage=m}};return g};(function(D,ae){var aa,W=document.location,Y=Array.prototype.slice,N=decodeURIComponent,ag=D.param,V,ad,S,U=D.bbq=D.bbq||{},T,ac,F,af="hashchange",J="querystring",G="fragment",R="hash",H="elemUrlAttr",Z="href",P="src",X="on"+af in ae,O=/^.*\?|#.*$/g,E=/^.*\#/,L={};function M(a){return typeof a==="string"}function I(a){var b=Y.call(arguments,1);return function(){return a.apply(this,b.concat(Y.call(arguments)))}}function ab(j,b,a,i,f){var d,e,g,c,h;if(i!==aa){g=a.match(j?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);h=g[3]||"";if(f===2&&M(i)){e=i.replace(b,"")}else{c=ad(g[2]);i=M(i)?ad[j?G:J](i):i;e=f===2?i:f===1?D.extend({},i,c):D.extend({},c,i);e=ag(e)}d=g[1]+(j?"#":e||!g[1]?"?":"")+e+h}else{if(a){d=a.replace(b,"")}else{d=j?W[R]?W[Z].replace(b,""):"":W.search.replace(/^\??/,"")}}return d}ag[J]=I(ab,0,O);ag[G]=V=I(ab,1,E);D.deparam=ad=function(a,c){var b={},d={"true":!0,"false":!1,"null":null};D.each(a.replace(/\+/g," ").split("&"),function(j,h){var k=h.split("="),g=N(k[0]),l,f=b,i=0,e=g.split("]["),m=e.length-1;if(/\[/.test(e[0])&&/\]$/.test(e[m])){e[m]=e[m].replace(/\]$/,"");e=e.shift().split("[").concat(e);m=e.length-1}else{m=0}if(k.length===2){l=N(k[1]);if(c){l=l&&!isNaN(l)?+l:l==="undefined"?aa:d[l]!==aa?d[l]:l}if(m){for(;i<=m;i++){g=e[i]===""?f.length:e[i];f=f[g]=i<m?f[g]||(e[i+1]&&isNaN(e[i+1])?{}:[]):l}}else{if(D.isArray(b[g])){b[g].push(l)}else{if(b[g]!==aa){b[g]=[b[g],l]}else{b[g]=l}}}}else{if(g){b[g]=c?aa:""}}});return b};function K(a,b,c,d){if(c===aa||typeof c==="boolean"){d=c;c=ag[a]()}else{c=M(c)?c.replace(b,""):c}return ad(c,d)}ad[J]=I(K,J,O);ad[G]=S=I(K,G,E);D[H]||(D[H]=function(a){return D.extend(L,a)})({a:Z,base:Z,iframe:P,img:P,input:P,form:"action",link:Z,script:P});ac=D[H];function Q(a,d,b,c){if(!M(b)&&typeof b!=="object"){c=b;b=d;d=aa}return this.each(function(){var e=D(this),g=d||ac()[(this.nodeName||"").toLowerCase()]||"",f=g&&e.attr(g)||"";e.attr(g,ag[a](f,b,c))})}D.fn[J]=I(Q,J);D.fn[G]=I(Q,G);U.pushState=T=function(a,b){if(M(a)&&/^#/.test(a)&&b===aa){b=2}var c=a!==aa,d=V(W[Z],c?a:{},c?b:2);W[Z]=d+(/#/.test(d)?"":"#")};U.getState=function(a,b){return a===aa||typeof a==="boolean"?S(a):S(b)[a]};U.pollDelay=100;D.event.special[af]={setup:function(){if(X){return false}F.start()},teardown:function(){if(X){return false}F.stop()},add:function(c,a,b){return function(d){var e=d[G]=V();d.getState=function(f,g){return f===aa||typeof f==="boolean"?ad(e,f):ad(e,g)[f]};c.apply(this,arguments)}}};F=(function(){var e={},a,f,d,b;function c(){var g=D.browser;d=b=function(h){return h};if(g.msie&&g.version<8){f=D("<iframe/>").hide().appendTo("body")[0].contentWindow;b=function(){return f.document.location[R].replace(/^#/,"")};d=function(j,i){if(j!==i){var h=f.document;h.open();h.close();h.location[R]="#"+j}};d(V())}}e.start=function(){if(a){return}var g=V();d||c();(function h(){var j=V(),i=b(g);if(j!==g){d(g=j,i);D(ae).trigger(af)}else{if(i!==g){T("#"+i)}}a=setTimeout(h,U.pollDelay)})()};e.stop=function(){if(!f){a&&clearTimeout(a);a=0}};return e})()})(jQuery,this);
