var mouseOverDivs;var filterActivated=false;var activatedTyp=new Array();var activatedEinsatz=new Array();var searchTermTyp="";window.addEvent("domready",function(){productDivs=$("magprod_finder").getChildren("div[id^=prodField]");productDivs.each(function(b){if(b.getElement("a[id^=finderProduktLabel]")){var a=b.getElement("a[id^=finderProduktLabel]").rel;b.setStyle("cursor","help");b.addEvent("mouseenter",function(){$("product_"+a).setStyle("display","block");});b.addEvent("mouseleave",function(){$("product_"+a).setStyle("display","none");});}});chooseTypDivs=$("prodTypFields").getChildren("div[id^=typ_]");chooseTypDivs.each(function(a){a.addEvent("click",function(c){var b=this.id.split("_");b=b[b.length-1];this.toggleClass("active");toggleFilter("prodTyp",b,this.hasClass("active"));});});chooseEinsatzDivs=$("prodEinsatzFields").getChildren("div[id^=einsatz_]");chooseEinsatzDivs.each(function(a){a.addEvent("click",function(c){var b=this.id.split("_");b=b[b.length-1];this.toggleClass("active");toggleFilter("prodEinsatz",b,this.hasClass("active"));});});einsatzInfoDivs=$("prodEinsatzFields").getChildren("img[id^=info_einsatz_]");einsatzInfoDivs.each(function(a){a.addEvent("mouseenter",function(){$(a.id+"_text").setStyle("display","block");});a.addEvent("mouseleave",function(){$(a.id+"_text").setStyle("display","none");});});$("resetDiv").addEvent("mousedown",function(){this.removeClass("active");this.addClass("active");});$("resetDiv").addEvent("mouseup",function(){this.removeClass("active");resetFilters();});});function resetFilters(){productDivs=$("magprod_finder").getChildren("div[id^=prodField]");productDivs.each(function(b){childElement=b.getElement("input.prodTyp");if(childElement!==null){if(!b.hasEvent("mouseenter")){var a=b.getElement("a[id^=finderProduktLabel]").rel;b.addEvent("mouseenter",function(){$("product_"+a).setStyle("display","block");});b.addEvent("mouseleave",function(){$("product_"+a).setStyle("display","none");});}if(b.getStyle("opacity")<1){b.tween("opacity",1);}}});activatedTyp=new Array();activatedEinsatz=new Array();chooseTypDivs=$("prodTypFields").getChildren("div[id^=typ_]");chooseTypDivs.each(function(a){if(a.hasClass("disabled")||!a.hasEvent("click")){a.addEvent("click",function(c){var b=this.id.split("_");b=b[b.length-1];this.toggleClass("active");toggleFilter("prodTyp",b,this.hasClass("active"));});a.toggleClass("disabled");}a.removeClass("active");});chooseEinsatzDivs=$("prodEinsatzFields").getChildren("div[id^=einsatz_]");chooseEinsatzDivs.each(function(a){if(a.hasClass("disabled")||!a.hasEvent("click")){a.addEvent("click",function(c){var b=this.id.split("_");b=b[b.length-1];this.toggleClass("active");toggleFilter("prodEinsatz",b,this.hasClass("active"));});a.toggleClass("disabled");}a.removeClass("active");});}function toggleFilter(c,f,b){var d=false;var e=new Array();var a=new Array();chooseTypDivs=$("prodTypFields").getChildren("div[id^=typ_]");d=chooseTypDivs.some(function(g){return g.hasClass("active");});if(!d){chooseEinsatzDivs=$("prodEinsatzFields").getChildren("div[id^=einsatz_]");d=chooseEinsatzDivs.some(function(g){return g.hasClass("active");});}switch(c){case"prodTyp":b?activatedTyp.include(f):activatedTyp.erase(f);searchTermTyp=activatedTyp.join("|");break;case"prodEinsatz":b?activatedEinsatz.include(f):activatedEinsatz.erase(f);break;}if(!d){resetFilters();return true;}else{productDivs=$("magprod_finder").getChildren("div[id^=prodField]");productDivs.each(function(h){prodTypListe=h.getElement("input.prodTyp");prodEinsatzListe=h.getElement("input.prodEinsatz");if(prodTypListe!==null&&prodEinsatzListe!==null){activeTyp=prodTypListe.value.search(searchTermTyp)>=0;activeEinsatz=activatedEinsatz.every(function(i){return prodEinsatzListe.value.search(i)>=0;});active=activeTyp&&activeEinsatz;if(active){if(!h.hasEvent("mouseenter")){var g=h.getElement("a[id^=finderProduktLabel]").rel;h.addEvent("mouseenter",function(){$("product_"+g).setStyle("display","block");});h.addEvent("mouseleave",function(){$("product_"+g).setStyle("display","none");});}if(h.getStyle("opacity")<1){h.tween("opacity",1);}e.include(prodTypListe.value);a.combine(prodEinsatzListe.value.split(","));}else{if(h.hasEvent("mouseenter")){h.removeEvents("mouseenter");h.removeEvents("mouseleave");}if(h.getStyle("opacity")>0){h.tween("opacity",0);}}}});}if(c!="prodTyp"){chooseTypDivs=$("prodTypFields").getChildren("div[id^=typ_]");chooseTypDivs.each(function(g){active=e.some(function(h){return g.id.search(h)!=-1;});if(!active){if(!g.hasClass("disabled")){g.removeEvents("click");g.toggleClass("disabled");}}else{if(g.hasClass("disabled")){g.addEvent("click",function(i){var h=this.id.split("_");h=h[h.length-1];this.toggleClass("active");toggleFilter("prodTyp",h,this.hasClass("active"));});g.toggleClass("disabled");}}});}chooseEinsatzDivs=$("prodEinsatzFields").getChildren("div[id^=einsatz_]");chooseEinsatzDivs.each(function(g){active=a.some(function(h){return g.id.search(h)!=-1;});if(!active){if(!g.hasClass("disabled")){g.removeEvents("click");g.toggleClass("disabled");}}else{if(g.hasClass("disabled")){g.addEvent("click",function(i){var h=this.id.split("_");h=h[h.length-1];this.toggleClass("active");toggleFilter("prodEinsatz",h,this.hasClass("active"));});g.toggleClass("disabled");}}});}

