// JavaScript Document
function getWindowWidth() {
	var width = 0
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		width = window.innerWidth;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		width = document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		width = document.body.clientWidth;
	}
	return width;
}
function getWindowHeight() {
	var height = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		height = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		height = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		height = document.body.clientHeight;
	}
	return height;
}
function getElement(psID) { 
   if(document.all) { 
      return document.all[psID]; 
   } else { 
      return document.getElementById(psID); 
   } 
} 
function TextScroller(name, height, width, text, speed) {
	this.data = text.split(/\n/);
	this.speed = speed;
	this.div = null;
	this.pos = 0;
	this.getRows = function getRows() {
		var i;
		var html = "";
		if (this.pos >= this.data.length)
			this.pos = 0;
		var row = this.pos;
		for(i=0; i<20; i++) {
			if (row >= this.data.length)
				row = 0;
			html += this.data[row++] + "<br>";
		}
		return html;
	}
	this.start = function scrollStart() {
		if (document.all) {
			this.div = document.all[name + "-scroller"];
			this.div.style.pixelTop=0;
		} else if (document.getElementById) {
			this.div = document.getElementById(name + "-scroller");
			this.div.style.top = "0px";
		}	
		this.div.innerHTML=this.getRows(); 
		setTimeout(name + ".scrollIt()", this.speed);
	}
	this.scrolling = true;
	this.freeze = function scrollFreeze() {
		this.scrolling = false;
	}
	this.unfreeze = function scrolFreeze() {
		this.scrolling = true;
		setTimeout(name + ".scrollIt()", this.speed);
	}
	this.scrollIt = function scrollIt() {
		if (document.all) {
			if (this.div.style.pixelTop > -15) {
				--this.div.style.pixelTop;
			} else {
				this.div.innerHTML=this.getRows(++this.pos); 
				this.div.style.pixelTop=0;
			}
			if (this.scrolling)
				setTimeout(name + ".scrollIt()", this.speed);
		} else if (document.getElementById) {
			var top = parseInt(this.div.style.top);
			if ( top > -15){
				top--;
				this.div.style.top = top + "px";
			}
			else {
			  	this.div.innerHTML=this.getRows(++this.pos); 
				this.div.style.top = "0px";
			}
			if (this.scrolling)
				setTimeout(name + ".scrollIt()", this.speed*1.5);
		} else
			return;
	}
	var html = "<div class=\"scroller-container\" " 
					+ "style=\"width:" + width + "px; height:" + height + "px;\" "
					+ "onmouseover=\"" + name + ".freeze();\" "
					+ "onmouseout=\"" + name + ".unfreeze()\""
					+ ">\n";
	html += "   <div id=\"" + name + "-scroller\" class=\"scroller\"></div>\n";
	html += "</div>\n";
	document.write(html);
	this.start();
}

function TextTicker(name, height, width, text, speed) {
	this.text = text;
	this.speed = speed;
	this.div = null;
	this.textWidth = 0;
	this.start = function tickStart() {
		if (document.all) {
			this.div = document.all[name + "-ticker"];
			this.div.style.pixelLeft=0;
		} else if (document.getElementById) {
			this.div = document.getElementById(name + "-ticker");
			this.div.style.left = "0px";
		}	
		this.div.innerHTML=this.text;
		this.textWidth = this.div.offsetWidth;
		this.div.innerHTML+=this.text;
		setTimeout(name + ".scrollIt()", this.speed);
	}
	this.scrolling = true;
	this.freeze = function tickFreeze() {
		this.scrolling = false;
	}
	this.unfreeze = function tickUnfreeze() {
		this.scrolling = true;
		setTimeout(name + ".scrollIt()", this.speed);
	}
	this.scrollIt = function tickIt() {
		if (this.textWidth == 0)
			this.textWidth = this.div.offsetWidth / 2;
		if (document.all) {
			var pos = this.div.style.pixelLeft;
			if (pos <= -this.textWidth)
				pos = 0;
			this.div.style.pixelLeft=--pos;
		} else if (document.getElementById) {
			var pos = parseInt(this.div.style.left);
			if (pos <= -this.textWidth)
				pos = 0;
			pos--;
			this.div.style.left = pos + "px";
		} else
			return;
		if (this.scrolling)
			setTimeout(name + ".scrollIt()", this.speed);
	}
	var html = "<div class=\"ticker-container\" " 
					+ "style=\"width:" + width + "px; height:" + height + "px;\" "
					+ "onmouseover=\"" + name + ".freeze();\" "
					+ "onmouseout=\"" + name + ".unfreeze()\""
					+ ">\n";
	html += "   <div id=\"" + name + "-ticker\" class=\"ticker\"></div>\n";
	html += "</div>\n";
	document.write(html);
	this.start();
}


