/**
 * accordeon class
 * 2007 09 20
 * Jochen Vandendriessche
 */

function Accordeon(o){
	this.o = $(o);
	this.e = $$('div', 'acca');
	this.t = $$('strong', 'acco');
	this.h = [];
	for (var i = 0;i<this.e.length;i++){
		var extra = false;
		if (i == 0){
			extra = true;
		}
		this.h[i] = new AccordeonAir(this.e[i], extra, this);
		this.t[i].onclick = bind(this.h[i], this.h[i].toggle);
	}
	this.a = 0;
}

Accordeon.prototype={
	
	toggle:function(i){
		for (var i = 0;i<this.h.length;i++){
			if (this.h[i].state === true){
				this.h[i].state = false;
				this.h[i].anim.move();
			}	
		}
	}
	
}

function AccordeonAir(o, s, p, i){
	this.p = p;
	this.o = o;
	this.id = i;
	this.o.style.overflow = 'hidden';
	this.iH = this.o.offsetHeight;
	this.anim = new joinkFX(this.o, 'outCubic', 20, 'height', '0', '' + this.iH, true);
	this.state = s;
	if (s){
		this.anim.move();
	}else{
		this.o.style.height = '0px';
	}

}

AccordeonAir.prototype={

	toggle:function(){
		if (this.state === true){
			this.anim.move();
			this.state = false;
			this.p.toggle();
		}else{
			this.p.toggle();			
			this.state = true;			
			this.anim.move();
		}
	}
	
}

//	document.getElementById rewrite
	function $(id){
		if (document.getElementById(id)){
			return document.getElementById(id);
		}else{
			return null;
		}
	}
	
//	getElementsByTagName rewrite, filter by class
	function $$(t, c){
		
		var e	=	document.getElementsByTagName(t);
		if (c){
			var ne = [];
			for (var i = 0;i<e.length;i++){
				if (e[i].className == c){
					ne.push(e[i]);
				}
			}
			return ne;
		}else{
			return e;
		}
		
	}