
mooScrollingText = new Class({
	setOptions: function(options) {
  	this.options = {
         //width: 205,
         width: 10,
         Height: 180,
         step:1,
         delay:10,              
         orientation:'h'
        }
		Object.extend(this.options, options || {});
	},
	initialize: function(el, options){
		
						
		this.setOptions(options);		
		this.ypos = 0;
		
		this.el = el;
		this.el.style.position = 'relative';
		this.textDiv = document.createElement("div");
		this.textDiv.className = 'zone_scroll';
		this.textDiv.innerHTML = this.el.innerHTML;
		this.el.innerHTML = '';

		this.textDiv.style.position = 'relative';
		this.el.appendChild(this.textDiv);		
		this.textDiv.style.top = this.ypos + 'px';

				
		// bouton down
		this.downbtn = document.createElement("div");
		this.el.appendChild(this.downbtn);
		this.downbtn.id = 'downbtn';
		this.downbtn.innerHTML= '<img src="../_mm/scrolldown.gif" />';

		this.downbtn.ref = this;
		this.downbtn.onmouseover = function(){
			this.ref.startscrolling('down');
		}
		this.downbtn.onmouseout = function(){
			this.ref.stopscrolling();
		}	
		
		// bouton up
		this.upbtn = document.createElement("div");
		this.el.appendChild(this.upbtn);
		this.upbtn.id = 'upbtn';
		this.upbtn.innerHTML= '<img src="../_mm/scrollup.gif"/>';

		this.upbtn.ref = this;
		this.upbtn.onmouseover = function(){
			this.ref.startscrolling('up');
		}
		this.upbtn.onmouseout = function(){
			this.ref.stopscrolling();
		}	
		
				
	},
	
	startscrolling: function(direction){
		if(direction == 'down'){
			this.interval = setInterval(this.scrolldown.bind(this), this.options.delay);
		} else {
			this.interval = setInterval(this.scrollup.bind(this), this.options.delay);
		}
	},
	stopscrolling: function(){
		clearInterval(this.interval);
	},
	scrolldown : function(){
		this.ypos += this.options.step;
		if (this.ypos > 0) this.stopscrolling();
		this.textDiv.style.top = this.ypos + 'px';
	},
	scrollup : function(){
		this.ypos -= this.options.step;
		this.textDiv.style.top = this.ypos + 'px';
	}
});



function ini_scrollingtext(){
	var els = document.getElementsByTagName('DIV');
	for (var i=0; i<els.length; i++){
		if (els[i].className == 'text_overflow'){
			var st = new mooScrollingText(els[i], {});
		}
	}
}

