// textScroller.js
// Vertical Text Scroller
// Copyright (c) 2003 Alphalogic. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// This will work on all recent browsers.  This will not work on Netscape 4.x.
// info@alsnet.com



// The height of the scrollerbox (pixels)
var scrollerHeight=76

// The width of the scrollerbox (pixels)
var scrollerWidth=275

// The distance to the left border of the window (pixels)
var scrollerTop=8

// The distance to the top border of the window (pixels)
var scrollerLeft=126

// The padding between the scrollerbox and the text (pixels)
var scrollerPadding=4

// The background-colour of the scrollerbox
var scrollerBGColor="0E2141"

// Font attributes of the title
var titleFace="Arial"
var titleColor="FFFFFF"
var titleSize=1

// Font attributes of the copytext
var copyFace="Arial"
var copyColor="FFFFFF"
var copySize=1

// pause between the messages (milliseconds)
var messagePause=8000

// pause between each scrolling frame (milliseconds)
var framePause=10;

// number of pixels to move between each frame
var step=1;

// Do not edit below this line
var messageLine;
var messageContents;
var contentText = "";
var incHeight=0;
var currentMessage=0;
var timer;
var textWidth = scrollerWidth - 2*scrollerPadding;
var textHeight = scrollerHeight - 2*scrollerPadding;
var firstRun = 0;

function initiate(){
	for (var i=0;i<message.length;i++) {
   	contentText+="<div id='scroll-"+i+"' style='position:absolute;top:"+textHeight+";height:1;overflow:hidden;'>";
		messageLine=message[i];
		messageContents=messageLine.split("|");
		contentText+="<font face='"+titleFace+"' color='"+titleColor+"' size='"+titleSize+"'>"+messageContents[0]+"</font><br><font face='"+copyFace+"' color='"+copyColor+"' size='"+copySize+"'>"+messageContents[1]+"</font>";
      contentText+="</div>";		
	}
	document.getElementById("scrollertext").innerHTML=contentText;
	document.getElementById("scrollerframe").style.overflow='hidden';
	document.getElementById("scrollerframe").style.top=scrollerTop+scrollerPadding;
	document.getElementById("scrollerframe").style.left=scrollerLeft+scrollerPadding;
	document.getElementById("scrollerframe").style.width=textWidth;
	document.getElementById("scrollerframe").style.height=textHeight;
	document.getElementById("scrollerbg").style.top=scrollerTop;
	document.getElementById("scrollerbg").style.left=scrollerLeft;
	document.getElementById("scrollerbg").style.width=scrollerWidth;
	document.getElementById("scrollerbg").style.height=scrollerHeight;
	document.getElementById("scrollerbg").style.backgroundColor = scrollerBGColor;
	scroll();
}


function scroll() {
   if (incHeight<textHeight) {
      incHeight+=step;
      if (incHeight>textHeight) {
         incHeight=textHeight;
      }
      document.getElementById('scroll-'+currentMessage).style.top=textHeight-incHeight;
      document.getElementById('scroll-'+currentMessage).style.height=incHeight;
      if (currentMessage>0) {
         document.getElementById('scroll-'+(currentMessage-1)).style.top=-incHeight;
      } else if (firstRun!=0) {
         document.getElementById('scroll-'+(message.length-1)).style.top=-incHeight;
      }
      timer = setTimeout("scroll()",framePause);
   } else {
      timer = setTimeout("updateMessage()",messagePause);
   }
}


function updateMessage() {
   if (currentMessage==message.length-1) {
      firstRun = 1;
      for (var j=0;j>message.length-1;j++) {
         document.getElementById('scroll-'+j).style.top=textHeight;
         document.getElementById('scroll-'+j).style.height=1;
      }
      currentMessage=0;
   } else {
      currentMessage++;
   }
   incHeight = 0;
   timer = setTimeout("scroll()",framePause);
}

