// JavaScript Document
	
function vScroller(id, w, h, p, b) {
	var _self = this;
	var vScroller_width = w;
	var vScroller_height = h;
	var vScroller_pad = p;
	var vScroller_border = b;
	var mousePause = false;
	var pauseVal = 4;
	var pauseCounter = -77;
	var updateSpeed = 10;
	var scrollSpeed = 4;
	var currentNewsMsg = 0;	
	var vScroller_pauseInt = [];	
	this.pause = pause;
	this.checkLoadVscroll = checkLoadVscroll;
	this.loadvScroller = loadvScroller;
	this.init = init;
	this.move = move;
	this.update = update;
	this.setmousePause = setmousePause;
	
	function setmousePause(b) {
		mousePause = b;
	}
	
	function pause(milliseconds){
		var dt = new Date();
		while ((new Date()) - dt <= milliseconds) { /* Do nothing */
		}
	}
	
	function checkLoadVscroll(){
		//if (window.onLoad)
		var num = document.getElementById('numMsgs');
		var e = document.getElementById("vScrollerContainer");
		if ((num != null) && (e != null)) {
			loadvScroller();
		}
		else {
			setTimeout(_self.checkLoadVscroll, 500);
		}
	}
	
	
	function loadvScroller(){
		vScroller_pauseInt[0] = 0;
		var maxHeight = 0;
		var h = vScroller_height - 2 * vScroller_pad - 2 * vScroller_border;
		var el1 = document.getElementById('numMsgs');
		
		var numMsgs = parseInt(el1.innerHTML);
		
		for (i = 0; i < numMsgs; i++) {
			vScroller_pauseInt[i + 1] = h + vScroller_pauseInt[i];
		}
		
		document.getElementById("vScrollerContainer").style.height = h + 'px';
		update();
		
	}
	
	
	function update(){
		if (pauseCounter > 0) {
			pauseCounter -= updateSpeed;
		}
		else {
			move();
		}
		setTimeout(_self.update, updateSpeed);
	}
	
	function move(){
		if (!mousePause) {
			var e1 = document.getElementById('vScrollerContent');
			var e2 = document.getElementById("vScrollerContainer");
			
			e1.style.top = parseInt(e1.style.top) - scrollSpeed + "px";
			
			var y1 = parseInt(e1.style.top);
			var y2 = parseInt(e2.style.top);
			
			if (y1 < (-1 * vScroller_pauseInt[currentNewsMsg])) {
				currentNewsMsg++;
				pauseCounter = pauseVal * 1000;
			}
			
			if (y1 <= y2 - getHeight(e1.id)) {
				currentNewsMsg = 0;
				pauseCounter = -77;
				e1.style.top = parseInt(e2.style.height) - parseInt(e2.style.top) + "px";
			}
		}
	}
	
	
	
	
	function init(){
		checkLoadVscroll();
	}
}
