var accordion=function(){
	var array=[]; var speed=5; var timer=10;
	return{
		init:function(t,c){
			var s,ds,l,i,y;			
			s=document.getElementById(t);
			y=-1;
			
			ds=s.getElementsByTagName('div'); l=ds.length;
			for(i=0;i<l;i++){
				var d; d=ds[i];
				if (d.className == 'toggler') {
					y++;
					d.onmouseover=new Function("accordion.process(this)");
					d.id = 'toggler'+y+'-toggler';
					if(i==c){d.className += ' selected';}
				}
				else if (d.className == 'element') {
					d.id = 'toggler'+y+'-element';
					array.push('toggler'+y);
					d.maxh=d.offsetHeight;
					d.maxh=110;
					d.style.overflow = 'hidden';
					if(y!=c){
						d.style.display='none';
					}
					else{
						d.style.display='block';
					}
				}
			}
		},
		process:function(d){
			var cl,i; cl=array.length; i=0;
			for(i;i<cl;i++){
				var s,h,c,cd;
				s=array[i]; h=document.getElementById(s+'-toggler');
				c=s+'-element'; cd=document.getElementById(c); 
				
				if (cd) {
					clearInterval(cd.timer);
					
					if (h==d) {
						if (cd.style.display=='none') {
							cd.style.display='block';
							h.className += ' selected';
						}
					} else if (cd.style.display=='block') {
						h.className = h.className.replace(' selected','');
						cd.style.display='none';
					}
				}
				
				/*if (h==d&&cd.style.display=='none') {
					cd.style.display='block';
					h.className += ' selected';
					this.islide(c,1);
				}
				else if ( cd.style.display=='block') {
					h.className = h.className.replace(' selected','');
					this.islide(c,-1);
				}*/
			}
		},
		islide:function(i,d){var c,m; c=document.getElementById(i); m=c.maxh; c.direction=d; c.timer=setInterval("accordion.slide('"+i +"')",timer)},
		slide:function(i){
			var c,m,h,dist; c=document.getElementById(i); m=c.maxh; h=c.offsetHeight;			
			dist=(c.direction==1)?Math.round((m-h)/speed):Math.round(h/speed);
			if(dist<=1){dist=1}
			c.style.height=h+(dist*c.direction)+'px'; c.style.opacity=h/c.maxh; c.style.filter='alpha(opacity='+(h*100/c.maxh)+')';
			if(h<2&&c.direction!=1){
				c.style.display='none'; 
				clearInterval(c.timer);
			}else if(h>(m-2)&&c.direction==1){clearInterval(c.timer)}
		}
};}();