//Accordian Initializer
function Accordian(d,s,tc){

	var lastActive = null;

	// get all the elements that have id as content
	l=document.getElementById(d).getElementsByTagName('div');
	c=[];
	for(i=0;i<l.length;i++){
		h=l[i].id;
		if(h.substr(h.indexOf('-')+1,h.length)=='content'){c.push(h);}
	}

	//then search through headers
	for(i=0;i<l.length;i++){
		
		h=l[i].id;
		
		if(h.substr(h.indexOf('-')+1,h.length)=='header'){
			
			d=document.getElementById(h.substr(0,h.indexOf('-'))+'-content');
			d.style.display='none';
			d.style.overflow='hidden';
			//d.maxh =sh(d);
			d.s=(s==undefined)? 7 : s;
			h=document.getElementById(h);
			h.tc=tc;
			h.c=c;
			
			// set the onclick function for each header.
			h.onclick = function(){
				
				for(i=0;i<this.c.length;i++){
					
					cn=this.c[i];
					n=cn.substr(0,cn.indexOf('-'));
					h=n+"-header";
					
					dojo.byId(cn).style.display = "none";
					dojo.removeClass(dojo.byId(h), "active");
					
					if(h==this.id) {
						
						if(lastActive != this.id) {
							dojo.byId(cn).style.display = "block";
							dojo.addClass(dojo.byId(h), "active");
						}
						
						if(dojo.byId(cn).style.display == "none") lastActive = null;
						else lastActive = h;
					}
				}
			}
		}
	}
}
