var animatedcollapse={divholders:{},divgroups:{},lastactiveingroup:{},show:function(a){if(typeof a=="object"){for(var b=0;b<a.length;b++)this.showhide(a[b],"show")}else this.showhide(a,"show")},hide:function(a){if(typeof a=="object"){for(var b=0;b<a.length;b++)this.showhide(a[b],"hide")}else this.showhide(a,"hide")},toggle:function(a){this.showhide(a,"toggle")},addDiv:function(a,b){this.divholders[a]={id:a,$divref:null,attrs:b};this.divholders[a].getAttr=function(a){var b=new RegExp(a+"=([^,]+)","i");return b.test(this.attrs)&&parseInt(RegExp.$1)!=0?RegExp.$1:null}},showhide:function(a,b){var c=this.divholders[a].$divref;if(this.divholders[a]&&c.length==1){var d=this.divgroups[c.attr("groupname")];if(c.attr("groupname")&&d.count>1&&(b=="show"||b=="toggle"&&c.css("display")=="none")){if(d.lastactivedivid&&d.lastactivedivid!=a)this.slideengine(d.lastactivedivid,"hide");this.slideengine(a,"show");d.lastactivedivid=a}else{this.slideengine(a,b)}}},slideengine:function(a,b){var c=this.divholders[a].$divref;if(this.divholders[a]&&c.length==1){var d={height:b};if(c.attr("fade"))d.opacity=b;c.animate(d,c.attr("speed")?parseInt(c.attr("speed")):500);return false}},generatemap:function(){var a={};for(var b=0;b<arguments.length;b++){if(arguments[b][1]!=null){a[arguments[b][0]]=arguments[b][1]}}return a},init:function(){var a=this;jQuery(document).ready(function(b){var c=a.getCookie("acopendivids");var d=a.getCookie("acgroupswithpersist");if(c!=null)c=c=="nada"?[]:c.split(",");d=d==null||d=="nada"?[]:d.split(",");jQuery.each(a.divholders,function(){this.$divref=b("#"+this.id);if((this.getAttr("persist")||jQuery.inArray(this.getAttr("group"),d)!=-1)&&c!=null){var e=jQuery.inArray(this.id,c)!=-1?"block":"none"}else{var e=this.getAttr("hide")?"none":null}this.$divref.css(a.generatemap(["height",this.getAttr("height")],["display",e]));this.$divref.attr(a.generatemap(["groupname",this.getAttr("group")],["fade",this.getAttr("fade")],["speed",this.getAttr("speed")]));if(this.getAttr("group")){var f=a.divgroups[this.getAttr("group")]||(a.divgroups[this.getAttr("group")]={});f.count=(f.count||0)+1;if(!f.lastactivedivid&&this.$divref.css("display")!="none"||e=="block")f.lastactivedivid=this.id;this.$divref.css({display:"none"})}});jQuery.each(a.divgroups,function(){if(this.lastactivedivid)a.divholders[this.lastactivedivid].$divref.show()});var e=b("*[rel]").filter('[@rel^="collapse-"], [@rel^="expand-"], [@rel^="toggle-"]');var f=/(collapse-)|(expand-)|(toggle-)/;e.each(function(){b(this).click(function(){var b=this.getAttribute("rel");var c=b.replace(f,"");var d=b.indexOf("collapse-")!=-1?"hide":b.indexOf("expand-")!=-1?"show":"toggle";return a.showhide(c,d)})});b(window).bind("unload",function(){a.uninit()})})},uninit:function(){var a="",b="";jQuery.each(this.divholders,function(){if(this.$divref.css("display")!="none"){a+=this.id+","}if(this.getAttr("group")&&this.getAttr("persist"))b+=this.getAttr("group")+","});a=a==""?"nada":a.replace(/,$/,"");b=b==""?"nada":b.replace(/,$/,"");this.setCookie("acopendivids",a);this.setCookie("acgroupswithpersist",b)},getCookie:function(a){var b=new RegExp(a+"=[^;]*","i");if(document.cookie.match(b))return document.cookie.match(b)[0].split("=")[1];return null},setCookie:function(a,b,c){if(typeof c!="undefined"){var d=new Date;d.setDate(d.getDate()+c);document.cookie=a+"="+b+"; path=/; expires="+d.toGMTString()}else document.cookie=a+"="+b+"; path=/"}}
