function Effect(obj){this.obj=document.getElementById(obj)}
Effect.prototype.fade=function(opac,step,onfinish){
	if(onfinish) var onfinish=onfinish
	var style=this.obj.style
	var fade
	var done=false
	var step=step
	var i = 0
	var int=setInterval(next,5)
	if(step==0){modOpac(opac); done=true; return}
	old=style.opacity*100
	if(old<opac) fade=1
	else if(old>opac) fade=2
	else done=true
	function next(){
		if(done){clearInterval(int); if(onfinish) onfinish(); return}
		if(fade==1) modOpac(old+ease(i,1,opac-old,step))
		else modOpac(old-ease(i,1,old-opac,step))
		if(fade==2&&style.opacity*100<=opac+1||fade==1&&style.opacity*100>=opac-1){
			modOpac(opac)
			done = true
		}i++
	}
	function modOpac(opac){
		style.filter="Alpha(Opacity="+opac+")"
		style.opacity=opac/100
		style.MozOpacity=opac/100
	}
}

Effect.prototype.hide=function(){this.obj.style.display="none"}
Effect.prototype.show=function(){this.obj.style.display="block"}




Effect.prototype.height=function(to,speed,onfinish){
	if(onfinish) var onfinish=onfinish
	var int=setInterval(next,5)
	var i=0
	var done=false
	var step=speed
	var resize,old
	var obj=this.obj
	var style=this.obj.style
	var old=obj.offsetHeight
	var to=to
	if(speed==0){
		style.height=to+"px"
		done=true
	}
	if(old<to) resize=1
	else if(old>to) resize=2
 	else done=true
function next(){
		if(done){
			clearInterval(int)
			if(onfinish) onfinish()
			return
		}
		if(resize==1){
			style.height=old+ease(i,1,to-old,speed)+"px"
		}else{
			if(old-ease(i,1,old-to,speed)<0) style.height="0px"; else style.height=old-ease(i,1,old-to,speed)+"px"
		}
		if(resize==2&&obj.offsetHeight<=to||resize==1&&obj.offsetHeight>=to){
			style.height=to+"px"
			done=true
		}i++
	}
}
	

function ease(t,b,c,d){return c*(-Math.pow(2,-10*t/d)+1)+b}


function Accordian(){	
	this.entries = 0
	this.divs = new Array()
}
Accordian.prototype.add = function(obj, activator){
	this.divs.push(new Effect(obj))
	this.entries++
	var act = document.getElementById(activator)
	act.entry = this.entries - 1
	act.accord = this
	act.height = document.getElementById(obj).offsetHeight
	act.onclick = function(){this.accord.gotoDiv(this.entry,this.height); return false;}
	if(this.entries != 1) this.divs[this.entries-1].height(0,25
														   )
}
Accordian.prototype.gotoDiv = function(num,height){
	for(var i=0;i<this.entries;i++){
		this.divs[i].height(0,25)
	}
	this.divs[num].height(height,25)
}


