//** Animated Collapsible DIV v2.0- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com.
//** May 24th, 08'- Script rewritten and updated to 2.0.
//** June 4th, 08'- Version 2.01: Bug fix to work with jquery 1.2.6 (which changed the way attr() behaves).
//** March 5th, 09'- Version 2.2, which adds the following:
			//1) ontoggle($, divobj, state) event that fires each time a DIV is expanded/collapsed, including when the page 1st loads
			//2) Ability to expand a DIV via a URL parameter string, ie: index.htm?expanddiv=jason or index.htm?expanddiv=jason,kelly

//** March 9th, 09'- Version 2.2.1: Optimized ontoggle event handler slightly.
//** July 3rd, 09'- Version 2.4, which adds the following:
			//1) You can now insert rel="expand[divid] | collapse[divid] | toggle[divid]" inside arbitrary links to act as DIV togglers
			//2) For image toggler links, you can insert the attributes "data-openimage" and "data-closedimage" to update its image based on the DIV state
var animatedcollapse={divholders:{},divgroups:{},lastactiveingroup:{},preloadimages:[],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){if(typeof a=="object")a=a[0];this.showhide(a,"toggle")},addDiv:function(a,b){this.divholders[a]={id:a,$divref:null,attrs:b};this.divholders[a].getAttr=
function(c){c=new RegExp(c+"=([^,]+)","i");return c.test(this.attrs)&&parseInt(RegExp.$1)!=0?RegExp.$1:null};this.currentid=a;return this},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")){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,d=this.divholders[a].$togglerimage;if(this.divholders[a]&&c.length==1){a={height:b};if(c.attr("fade"))a.opacity=b;c.animate(a,c.attr("speed")?parseInt(c.attr("speed")):500,function(){if(d)d.attr("src",c.css("display")=="none"?d.data("srcs").closed:d.data("srcs").open);if(animatedcollapse.ontoggle)try{animatedcollapse.ontoggle(jQuery,c.get(0),c.css("display"))}catch(f){alert('An error exists inside your "ontoggle" function:\n\n'+f+"\n\nAborting execution of function.")}});
return false}},generatemap:function(){for(var a={},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){animatedcollapse.ontoggle=animatedcollapse.ontoggle||null;var c=animatedcollapse.urlparamselect(),d=a.getCookie("acopendivids"),f=a.getCookie("acgroupswithpersist");if(d!=null)d=d=="nada"?[]:d.split(",");f=f==null||f=="nada"?[]:f.split(",");jQuery.each(a.divholders,function(){this.$divref=b("#"+
this.id);var g=(this.getAttr("persist")||jQuery.inArray(this.getAttr("group"),f)!=-1)&&d!=null?jQuery.inArray(this.id,d)!=-1?"block":"none":this.getAttr("hide")?"none":null;if(c[0]=="all"||jQuery.inArray(this.id,c)!=-1)g="block";else if(c[0]=="none")g="none";this.$divref.css(a.generatemap(["height",this.getAttr("height")],["display",g]));this.$divref.attr(a.generatemap(["groupname",this.getAttr("group")],["fade",this.getAttr("fade")],["speed",this.getAttr("speed")]));if(this.getAttr("group")){var e=
a.divgroups[this.getAttr("group")]||(a.divgroups[this.getAttr("group")]={});e.count=(e.count||0)+1;if(jQuery.inArray(this.id,c)!=-1){e.lastactivedivid=this.id;e.overridepersist=1}if(!e.lastactivedivid&&this.$divref.css("display")!="none"||g=="block"&&typeof e.overridepersist=="undefined")e.lastactivedivid=this.id;this.$divref.css({display:"none"})}});jQuery.each(a.divgroups,function(){this.lastactivedivid&&c[0]!="none"&&a.divholders[this.lastactivedivid].$divref.show()});animatedcollapse.ontoggle&&
jQuery.each(a.divholders,function(){animatedcollapse.ontoggle(jQuery,this.$divref.get(0),this.$divref.css("display"))});var h=b("a[rel]").filter('[rel^="collapse["], [rel^="expand["], [rel^="toggle["]');h.each(function(){this._divids=this.getAttribute("rel").replace(/(^\w+)|(\s+)/g,"").replace(/[\[\]']/g,"");if(this.getElementsByTagName("img").length==1&&a.divholders[this._divids]){animatedcollapse.preloadimage(this.getAttribute("data-openimage"),this.getAttribute("data-closedimage"));$togglerimage=
b(this).find("img").eq(0).data("srcs",{open:this.getAttribute("data-openimage"),closed:this.getAttribute("data-closedimage")});a.divholders[this._divids].$togglerimage=b(this).find("img").eq(0);a.divholders[this._divids].$togglerimage.attr("src",a.divholders[this._divids].$divref.css("display")=="none"?$togglerimage.data("srcs").closed:$togglerimage.data("srcs").open)}b(this).click(function(){var g=this.getAttribute("rel"),e=this._divids==""?[]:this._divids.split(",");if(e.length>0){animatedcollapse[/expand/i.test(g)?
"show":/collapse/i.test(g)?"hide":"toggle"](e);return false}})});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){a=new RegExp(a+
"=[^;]*","i");if(document.cookie.match(a))return document.cookie.match(a)[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=/"},urlparamselect:function(){window.location.search.match(/expanddiv=([\w\-_,]+)/i);return RegExp.$1!=""?RegExp.$1.split(","):[]},preloadimage:function(){for(var a=this.preloadimages,b=0;b<arguments.length;b++)if(arguments[b]&&
arguments[b].length>0){a[a.length]=new Image;a[a.length-1].src=arguments[b]}}};