/**
 * _ti - id elementu, ktery chci skrolovat
 * _bb - tlacitko zpet
 * _bb - tlacitko dopredu
 */
function SimpleHorizontalScroller (_ti, _bb, _bf) {
	var ref = this, tmp = 0;
	this.ti = SJEL.$(_ti); SJEL.SStyle(this.ti, {overflow: "hidden"});
	this.bb = SJEL.$(_bb);
	this.bf = SJEL.$(_bf);
	this.tii = SJEL.CE("div");
	this.tii.innerHTML = this.ti.innerHTML;
	this.ti.innerHTML = "";
	SJEL.SStyle(this.tii, {position: "absolute"});
	this.ti.appendChild(this.tii);
	if (SJEL.ie == 6) {
		for (var i = 0; i < this.tii.childNodes.length; i++)
			tmp += this.tii.childNodes[0].offsetWidth;
	} else
		tmp = this.tii.offsetWidth;
	this.max = this.ti.offsetWidth - tmp;
	SJEL.SStyle(this.tii, {position: "static", width: tmp + "px"});
		
	this.step = 4;
	this.mt = 0;  // margin-left
	this.bfe = this.bbe = false;
	
	if (this.max >= 0)  // sirka this.ti je vetsi jak vnitrek this.ti
		return;

	SJEL.AddClass(this.bb, "bw_but");
	SJEL.AddClass(this.bf, "fw_but");
	
	this.bfe = true;
	SJEL.AddClass(this.bf, "fw_but_on");

	this.OnButBTimer = function () {
		ref.mt += ref.step;
		if (ref.mt > 0) {
			ref.mt = 0;
			ref.tab.Stop();
			SJEL.RemoveClass(ref.bb, "bw_but_on");
			ref.bbe = false;
		}
		SJEL.SStyle(ref.tii, {marginLeft: ref.mt + "px"});
		if (!ref.bfe) {
			SJEL.AddClass(ref.bf, "fw_but_on");
			ref.bfe = true;
		}
	}

	this.OnButFTimer = function () {
		ref.mt -= ref.step;
		if (ref.mt < ref.max) {
			ref.mt = ref.max;
			ref.taf.Stop();
			SJEL.RemoveClass(ref.bf, "fw_but_on");
			ref.bfe = false;
		}
		SJEL.SStyle(ref.tii, {marginLeft: ref.mt + "px"});
		if (!ref.bbe) {
			SJEL.AddClass(ref.bb, "bw_but_on");
			ref.bbe = true;
		}
	}

	this.tab = new SJEL.Timer(this.OnButBTimer, 500, 25);
	this.tab.SetFps(30);
	this.taf = new SJEL.Timer(this.OnButFTimer, 500, 25);
	this.taf.SetFps(30);
	
	this.bb.onmouseover = function () {
		ref.tab.Start(true);
	}
	this.bb.onmouseout = function () {
		ref.tab.Stop();
	}

	this.bf.onmouseover = function () {
		ref.taf.Start(true);
	}
	this.bf.onmouseout = function () {
		ref.taf.Stop();
	}	
}
