

var GM_horizTxtScrolls =Array();
function HorizTxtScroll(id) {
	this.id =id;	// Id kontenera
	this.O_ctainr =document.getElementById(id);	// Kontener, w którym przesuwa się tekst
	if ( !this.O_ctainr)  return;
	this.O_ctnt =document.getElementById(id + "_ctnt"); // Element z tekstem, który się przesuwa
	if ( !this.O_ctnt)  return;
	GM_horizTxtScrolls[id] =this;

	this.speed=10;	// Szybkość przesuwania [px/s]
	this.ctainrWid =this.O_ctainr.offsetWidth;
	this.ctntWid =this.O_ctnt.offsetWidth;
	this.x =this.ctainrWid;
	this.timerId =null;

	
	this.start =function() {
		this.O_ctnt.style.left =this.x + "px";
		this.O_ctnt.style.visibility ='visible';
		this.ts =(new Date()).valueOf();	// Time stamp
		horizTxtScrollStep(this.id);
	}
		
	this.setSpeed =function(speed) {
		this.speed=speed;	// Szybkość przesuwania [px/s]
	}
	
//	var Xmas = new Date("December 31, 1969 23:00:00")
	//var Xmas = new Date("January 1, 1970 2:00:00")
	//alert(Xmas.valueOf());
}
function horizTxtScrollStep(id) {
	var O_scroll =GM_horizTxtScrolls[id];
	var tsBfor =O_scroll.ts;
	O_scroll.ts =(new Date()).valueOf();
	var time =O_scroll.ts-tsBfor;
	//window.status=time;
	//if (time>0) {
	//	alert(time);
	//	return;
	//}
	
	O_scroll.x -=time*O_scroll.speed/1000;	 // Im większa liczba tutaj tym większe tempo
	if (O_scroll.x<-O_scroll.ctntWid) {
		O_scroll.x =O_scroll.ctainrWid;
	}
	O_scroll.O_ctnt.style.left =Math.round(O_scroll.x) + "px";
	
	if (O_scroll.timerId)  clearTimeout(O_scroll.timerId);
	// Note: Manipulowanie czasem kroku tutaj podawanym jest niewskazane, ze względu na różne rozdzielczości zegara.
	O_scroll.timerId =setTimeout("horizTxtScrollStep('" + id + "')", 1);
	
}



