//=====================================================================================
// project : scroll
// version : 1.0
// author  : Joseph R. Hughes Jr.
// date	   : 06/09/09
// usage   : onload - VTLS.Scroll.init($('thediv'));
//	the div should contain a single ul
//	with the lines of text you wish to display seperated by <li>s
//	the scroller will automatically determine the height of the
//  inner content and scroll until it reaches the last <li>
//  where upon it will loop back to the begining and scroll again.
//=====================================================================================
if (!window['VTLS']) window['VTLS'] = {};
VTLS.Scroll = {
	'start' : 0,
	'end' : 0,
	'speed' : 30,
	'ref' : 0,
	'pos' : 0,
	'interval' : 0,
	'init' : function(el) {
		el.className = 'inner';
		var n = el.getElementsByTagName('ul')[0];
		var l = n.getElementsByTagName('li');
		this.end = 0;
		for (var i = 0; i < l.length; i++)
			this.end += l[i].offsetHeight;
		this.end = (this.end*-1);
		this.start = el.offsetHeight;
		var interval = this.interval = 0;
		var speed = this.speed;
		this.ref = el;
		this.pos = this.start;
		interval = this.interval = setInterval('VTLS.Scroll.go()', speed);
		el.onmouseover = function() {
			clearInterval(interval);
		}
		el.onmouseout = function() {
			interval = this.interval = setInterval('VTLS.Scroll.go()', speed);
		}
	},
	'stop' : function() {
		clearInterval(this.interval);
		this.ref.className = '';
		return false;
	},
	'go' : function() {
		var n = this.ref.getElementsByTagName('ul')[0];		
		n.style.top = this.pos+'px';
		if (this.pos == this.end) this.pos = this.start;
		this.pos--;
	}
}