var UKISA=UKISA||{};UKISA.widget=UKISA.widget||{};UKISA.widget.Accordion=function(a,e,b,h,i){var f,g,d,c;this.log("Accordion init.");f=this;this.context={tree:[],container:null,containerNodes:null,handlerNodes:null,contentNodes:null,nodes:null,handlers:null,contents:null,currentNode:null,currentParentNode:null};this.context.container=a;this.context.containerNodes=e;this.context.handlerNodes=b;this.context.contentNodes=h;c=[];if(typeof YAHOO.util.Anim==="undefined"){this.log("Cannot find yui/build/animation/animation-min.js");c.push("web/yui/build/animation/animation-min.js")}if(typeof YAHOO.util.Selector==="undefined"){this.log("Cannot find yui/build/selector/selector-min.js");c.push("web/yui/build/selector/selector-min.js")}g=function(){f.config={exclusive:false,easing:YAHOO.util.Easing.easeOut,duration:0.3};for(d in i){if(typeof f.config[d]!=="undefined"){f.config[d]=i[d]}}f.init()};if(c.length){if(typeof YAHOO.util.Get==="undefined"){this.log("Cannot find references to YAHOO Anim and/or Selector or Get.")}else{YAHOO.util.Get.script(c,{onSuccess:g})}}else{this.log("All scripts have been found on the page.");g()}};UKISA.widget.Accordion.prototype={init:function(){var e,g,j,f,c,b,k,h,l,d;e=YAHOO.util.Selector.query;j=this;this.log("Node: "+this.context.container+" "+this.context.containerNodes);this.log("Node handler: "+this.context.container+" "+this.context.handlerNodes);this.log("Node content: "+this.context.container+" "+this.context.contentNodes);this.context.nodes=e(this.context.container+" "+this.context.containerNodes);if(!this.context.nodes.length){this.log("There are no containerNodes.");return}this.log("Node count: "+this.context.nodes.length);g=function(q,n){var r,u,t;r=j.context.currentNode;t=function(){var v,w,x,i;if(n.content.length){v=n.content[0];i=0;w=new YAHOO.util.Anim(v);w.duration=j.config.duration;w.method=j.config.easing;if(v.style.display=="none"){v.style.display="block";v.style.height="auto";x=YAHOO.util.Dom.getRegion(v);i=x.bottom-x.top;j.log("Node content height: "+i);v.style.overflow="hidden";v.style.height="0";w.attributes.height={to:i};w.onComplete.subscribe(function(){v.style.height="auto";YAHOO.util.Dom.addClass(n.node,"active");j.context.currentParentNode=n})}else{w.onComplete.subscribe(function(){v.style.display="none";YAHOO.util.Dom.removeClass(n.node,"active");j.context.currentParentNode=null})}w.attributes.height={to:i};w.animate()}};u=function(){var v,w,x,i;if(n.content.length){v=n.content[0];i=0;w=new YAHOO.util.Anim(v);w.duration=j.config.duration;w.method=j.config.easing;if(v.style.display=="none"){v.style.display="block";v.style.height="auto";x=YAHOO.util.Dom.getRegion(v);i=x.bottom-x.top;j.log("Node content height: "+i);v.style.overflow="hidden";v.style.height="0";w.attributes.height={to:i};w.onComplete.subscribe(function(){v.style.height="auto";YAHOO.util.Dom.addClass(n.node,"active");j.context.currentNode=n})}else{w.onComplete.subscribe(function(){v.style.display="none";YAHOO.util.Dom.removeClass(n.node,"active");j.context.currentNode=null})}w.attributes.height={to:i};w.animate()}};if(j.config.exclusive){if(!n.parent){if(!j.context.currentNode||j.context.currentNode.index===n.index){j.log("Toggle a NEW OR SAME node.");u()}else{j.log("Toggle a DIFFERENT node.");d=new YAHOO.util.Anim(j.context.currentNode.content[0]);d.duration=j.config.duration;d.method=j.config.easing;d.attributes.height={to:0};d.onComplete.subscribe(function(){YAHOO.util.Dom.removeClass(j.context.currentNode.node,"active");j.context.currentNode.content[0].style.display="none";u()});d.animate()}}else{if(!j.context.currentParentNode||j.context.currentParentNode.index===n.index){j.log("Toggle a NEW OR SAME parent node.");var s,o,m,p;s=e(j.context.containerNodes,n.node);for(o=0,m=s.length;o<m;o++){YAHOO.util.Dom.removeClass(s[o],"active");p=e(j.context.contentNodes,s[o]);p[0].style.display="none";j.context.currentNode=null}t()}else{j.log("Toggle a DIFFERENT parent node.");d=new YAHOO.util.Anim(j.context.currentParentNode.content[0]);d.duration=j.config.duration;d.method=j.config.easing;d.attributes.height={to:0};d.onComplete.subscribe(function(){var y,w,v,x;y=e(j.context.containerNodes,j.context.currentParentNode.node);for(w=0,v=y.length;w<v;w++){YAHOO.util.Dom.removeClass(y[w],"active");x=e(j.context.contentNodes,y[w]);x[0].style.display="none"}YAHOO.util.Dom.removeClass(j.context.currentParentNode.node,"active");j.context.currentParentNode.content[0].style.display="none";j.context.currentParentNode=null;j.context.currentNode=null;t()});d.animate()}}}else{u()}YAHOO.util.Event.stopEvent(q);return false};for(f=0,c=this.context.nodes.length;f<c;f++){b=this.context.nodes[f];k=e(this.context.handlerNodes,b);h=e(this.context.contentNodes,b);var a=e(this.context.containerNodes,b);if(a.length){this.log("Node has children.")}else{this.log("Node has no children.")}l={index:f,node:b,handler:k,content:h,parent:!!a.length,children:a};YAHOO.util.Event.addListener(k[0],"click",g,l);if(h.length){if(YAHOO.util.Dom.hasClass(b,"active")){h[0].style.display="block";h[0].style.overflow="hidden";h[0].style.height="auto";if(this.config.exclusive){if(a.length){this.context.currentParentNode=l}else{this.context.currentNode=l}}}else{h[0].style.display="none"}}}},log:function(a){if(window.console){console.log(a)}}};