/*
Script slide text 1.0.2
©2009 djm Web sprl
*/

script_slide_txt = function (vIdA, vIdB) {
	
	var obj = this;
	this.pos = 0;
	this.vitesse = 5;	
	
	this.prod_txt = document.getElementById(vIdA);
	this.prod_txt_cache = document.getElementById(vIdB);
	
	this.w_prod_txt = this.prod_txt.offsetWidth;
	this.w_prod_txt_cache = this.prod_txt_cache.offsetWidth;
	
	this.reste = 0;
	
	this.init_class = function() {		
		
		this.prod_txt.onmouseover = function () {	
			//alert (obj.w_prod_txt + ' ' + obj.w_prod_txt_cache);
			if (obj.w_prod_txt<obj.w_prod_txt_cache) {
				obj.reste = (obj.w_prod_txt_cache-obj.w_prod_txt);
				obj.fctmvt();
				}
			}
		
		this.prod_txt.onmouseout = function () {
			if (obj.pos!=0) {
				obj.fctmvtb();
				}
			}
		}
	
	this.timer;
	this.fctmvt = function () {
		if (this.pos<this.reste) {
			clearTimeout(this.timerb);
			this.pos += this.vitesse;
			this.prod_txt_cache.style.left = -(this.pos) + 'px';
			
			this.timer = setTimeout(function() {obj.fctmvt()},20);
			}
			else {
				clearTimeout(this.timer);
				}
		}
		
	this.timerb
	this.fctmvtb = function () {
		if (this.pos>0) {
			clearTimeout(this.timer);
			this.pos -= this.vitesse;
			this.prod_txt_cache.style.left = -(this.pos) + 'px';
			
			this.timerb = setTimeout(function() {obj.fctmvtb()},20);
			}
			else {
				clearTimeout(this.timerb);
				}
		}
	
	return this.init_class();
	
	}
