 function Accordion(_bm, _ti, _co) {
	var ref = this, iemfb = null;
	var bm = SJEL.$(_bm);
	this.ti = SJEL.$A(bm, "class", _ti);
	this.co = SJEL.$A(bm, "class", _co);

	this.njs = SJEL.$A(bm, "class", "nojs");
	for (var i = 0; i < this.njs.length; i++) {
		SJEL.RemoveClass(this.njs[i], "nojs");
	}
	
	/*if ((this.ti.length == 0) || (this.co.length == 0) || (this.ti.length != this.co.length)) {
		alert('Accordion error: length of titles or contents is 0 or they have not equal lengths');
		return;
	}*/
	
		for (var i = 0; i < this.ti.length; i++) {
			this.co[i].he = this.co[i].offsetHeight;  // save current height
	
			if ((SJEL.ie == 0) || (SJEL.ie >= 8)) {
				//alert('bitch');
				SJEL.SStyle(this.co[i], {overflow: "hidden"});
			}
	
			if (!SJEL.ClassExists(this.ti[i], "acc_title_active")) {
				this.co[i].vis = false;  // vis = visible
				SJEL.SStyle(this.co[i], {opacity: 0.0, height: "0px"});
			} else {
				this.co[i].vis = true;
				if (SJEL.ie)  // nastavit height pro IE, protoze tam ma normalne auto
					SJEL.SStyle(this.co[i], {opacity: 1.0, height: this.co[i].offsetHeight + "px"});
			}
				
			//SJEL.SStyle(this.ti[i], {cursor: "pointer"});
			this.ti[i].i = i;
			//alert(this.ti[i].className);
			this.ti[i].onclick = function() {
				var j = 0;
				for (j = 0; j < ref.co.length; j++) {
					if (ref.co[j].vis) {
						ref.Hide(j);
						break;
					}
				}
				if (this.i != j)
					ref.Show(this.i);
			}		
		}

	// prasarna jak svina!!!
	this.Init = function () {
		if (this.co[2] != undefined) {
			if (this.co[2].he == 0)
				this.co[2].he += 144;
			else {
				this.co[2].he += 87;
				if (this.co[2].vis)
					SJEL.SStyle(this.co[2], {height: this.co[2].he + "px"});
			}
			alert(this.co[2].he);

			/*if (SJEL.ie == 6) {
				if (!this.co[2].vis)
					SJEL.SStyle(this.co[2], {visibility: "hidden"});
			}*/
		}
	}
	
	this.Show = function (_i) {
		this.co[_i].vis = true;
		SJEL.AddClass(this.ti[_i], "bm_on");
		SJEL.SStyle(this.co[_i], {opacity: 0.0, height: "0px", display: "block"});

		var mo = new SJEL.Morph("easyin");

		mo.Init(this.co[_i], {opacity: 1.0, height: this.co[_i].he + "px"}, 700, 40);
		mo.Morph();
	}
	
	this.Hide = function (_i) {
		this.co[_i].vis = false;
		SJEL.RemoveClass(this.ti[_i], "bm_on");

		var mo = new SJEL.Morph("easyout");
		
		iemfb = this.co[_i];
		mo.OnMorphFinished(function(_el){
			SJEL.SStyle(iemfb, {display: "none"});
		});
		
		mo.Init(this.co[_i], {opacity: 0.0, height: "0px"}, 700, 40);
		mo.Morph();
	}
	
	//this.Init();
}