var isArray=function(a){if(a.constructor.toString().indexOf("Array")==-1){return false}else{return true}};var AWVerticalFolding=Class.create();AWVerticalFolding.prototype={initialize:function(c,b,a,d){this.depth=b;this.indy=c;this.collClick=false;this.categories=new Array();this.expand=a;this.uniqId=d;document.observe("dom:loaded",(function(f){if(this.expand){var g=this.getCurrentCategory();if((g!==null)&&(g.parent_id!=0)){var e=this.getCategory(g.parent_id);while(e&&e.category_id){var h=$(this.uniqId+"_collapser_"+e.category_id);h.removeClassName("collapsed");h.addClassName("expanded");this.setChildrenVisibility(e.category_id,"block",true);e=this.getCategory(e.parent_id)}}}}).bind(this))},registerCategory:function(d,e,a,c,f){var b={category_id:d,parent_id:e,parent:a,expanded:c,current:f};this.categories.push(b)},collapser:function(b){this.collClick=true;var d=$(this.uniqId+"_collapser_"+b);if(typeof(d)!="undefined"){if(d.hasClassName("collapsed")){if(this.getCategory(b).parent_id==0){if(!this.indy){var c=this.getAllChildren(0);for(var a=0;a<c.length;a++){var e=$(this.uniqId+"_collapser_"+c[a].category_id);if(e){if(e.hasClassName("expanded")){e.removeClassName("expanded");e.addClassName("collapsed");this.setChildrenVisibility(c[a].category_id,"none");this.getCategory(c[a].category_id).expanded=false}}}}}d.removeClassName("collapsed");d.addClassName("expanded");this.setChildrenVisibility(b,"block");this.getCategory(b).expanded=true}else{d.removeClassName("expanded");d.addClassName("collapsed");this.setChildrenVisibility(b,"none");this.getCategory(b).expanded=false}}},setChildrenVisibility:function(d,e,f){var c=this.getAllChildren(d);if(isArray(c)&&(c.length>0)){for(var b=0;b<c.length;b++){if(typeof(f)=="undefined"){if(c[b].parent){if(((e=="block")&&c[b].expanded)||(e=="none")){this.setChildrenVisibility(c[b].category_id,e)}}else{this.setChildrenVisibility(c[b].category_id,e)}}var a=$(this.uniqId+"_li_category_"+c[b].category_id);if(a){a.style.display=e}}}},getAllChildren:function(c){var b=new Array();for(var a=0;a<this.categories.length;a++){if(this.categories[a].parent_id==c){b.push(this.categories[a])}}return b},getCategory:function(b){for(var a=0;a<this.categories.length;a++){if(this.categories[a].category_id==b){return this.categories[a]}}return null},liClick:function(a){if(!this.collClick){document.location=a}this.collClick=false},getCurrentCategory:function(){for(var a=0;a<this.categories.length;a++){if(this.categories[a].current){return this.categories[a]}}return null}};
