// Copyright Gilbert Saint
function StopScroller(scroll_name, clip_scroll_id, s_width, s_height, s_bg_color) {
	this.name = scroll_name;
	this.clip_scroll = document.getElementById(clip_scroll_id);
	this.width = s_width;
	this.height = s_height;
	this.clip_scroll.style.width = '' + s_width + 'px';
	this.clip_scroll.style.height = '' + s_height + 'px';
	this.clip_scroll.style.display = 'block';
	this.clip_scroll.style.textAlign = 'center';
}
StopScroller.prototype.initScrollText = function(text_id, text_height, pause, dh_pause, h_inc, t_inc) {
	this.text_height = text_height;
	this.text_scroll = document.getElementById(text_id);
	this.otop = getPageTop(this.clip_scroll);
	this.oleft = getPageLeft(this.clip_scroll) - this.width/2;
	this.htop = 0;
	this.pause = pause;
	this.hpause = 0;
	this.dh_pause = dh_pause;
	this.h_inc = h_inc;
	this.t_inc = t_inc;
	this.text_scroll.style.clip = "rect(0px " + this.width + "px " + this.height + "px 0px)";
	this.text_scroll.style.top = '0px';
	this.text_scroll.style.left = '0px';
	this.clip_scroll.style.display = 'block';
	this.text_scroll.style.display = 'block';
	this.scroll();
}
StopScroller.prototype.scroll = function() {
	this.text_scroll.style.top = '' + ( - this.htop) + 'px';
	this.text_scroll.style.clip = "rect(" + this.htop + "px " + this.width + "px " + (this.htop + this.height) + "px 0px)";
	if (this.htop >= (this.text_height - this.height)) {
		this.htop = 0;
		this.hpause = 0;
		setTimeout(this.name+'.scroll()', this.t_inc);
		return;
	}
	else {
		if (this.htop >= this.hpause) {
			this.htop += this.h_inc;
			this.hpause += this.dh_pause;
			setTimeout(this.name+'.scroll()', this.pause);
			return;
		}
		else {
			this.htop += this.h_inc;
			setTimeout(this.name+'.scroll()', this.t_inc);
		}
	}
}
function Scroller(nom, w, clip, t, l, pause, y_inc, t_inc, divText) {
	this.nom = nom;
	this.h = $(divText).getHeight();
	this.w = w;
	this.c = clip;
	this.t = t;
	this.l = l;
	this.pause = pause;
	this.y_inc = y_inc;
	this.t_inc = t_inc;
	this.active = false;
//	this.divPos = divPos;
	this.divText = document.getElementById(divText);
	this.curMoveMax = 0;
}
Scroller.prototype.init = function() {
		divTexte = this.divText.style;
//		divTexte.clip = "rect(0px " + this.w  + "px " + this.c + "px 0px)";
		divTexte.top = ''+this.t + 'px';
		divTexte.left = ''+this.l + 'px';
	divTexte.display = 'block';
	this.active = true;
//	o_block('this.divTexte', prop(this.divTexte));
}


Scroller.prototype.scroll = function(toMove) {
	if (this.active) {
		divTexte = this.divText.style;
//		divTexte.clip = "rect(" + toMove + "px " + (this.w ) + "px " + (toMove + this.c) + "px 0px)";
		divTexte.top = (this.t - toMove) + 'px';
	if ((toMove == 0)  || (toMove >= this.h - this.c)) {
	   toMove += this.y_inc;
	   if (toMove > this.h - this.c) toMove = 0;
		setTimeout(this.nom+".scroll(" + toMove + ")", this.pause);
		return;
	}
	else toMove += this.y_inc;
	}
	setTimeout(this.nom+".scroll(" + toMove + ")", this.t_inc);
}

function ScrollerH(nom, w, clip, t, l, pause, x_inc, t_inc, divText) {
	this.nom = nom;
	this.h = $(divText).getHeight();
	this.w = $(divText).getWidth();
	this.c = clip;
	this.t = t;
	this.l = l;
	this.pause = pause;
	this.x_inc = x_inc;
	this.t_inc = t_inc;
	this.active = false;
//	this.divPos = divPos;
	this.divText = $(divText);
	this.curMoveMax = 0;
}
ScrollerH.prototype.init = function() {
	divTexte = this.divText.style;
	divTexte.top = ''+this.t + 'px';
	divTexte.left = ''+this.l + 'px';
	divTexte.display = 'block';
	this.active = true;
}


ScrollerH.prototype.scroll = function(toMove) {
	if (this.active) {
		divTexte = this.divText.style;
		divTexte.left = (this.l - toMove) + 'px';
		if ((toMove == 0)  || (toMove >= this.w - this.c)) {
		   toMove += this.x_inc;
		   if (toMove > this.w - this.c) toMove = 0;
			setTimeout(this.nom+".scroll(" + toMove + ")", this.pause);
			return;
		}
		else toMove += this.x_inc;
	}
	setTimeout(this.nom+".scroll(" + toMove + ")", this.t_inc);
}
