
/*  
Script made by Bill Lane © 2002 www.blane.vze.com
This script may be used and changed freely as long as this msg is intact
*/
//The purpose of this script is to scroll news items from bottom to top with the message changing each time.  It is capable of rotating any number of messages as long as the number is stated in this script as totalNumMessages.  Each individual message is comprised of a title, it's message and a link (in the format of title1, title2 ...title200).  Even if you don't need all components of a message it is still important to define all variables just set them equall to " ".
//--------------------------------------------------------------------------------------
//variables that shouldn't be changed
var domType								//tracks which brwoser DOM your using
var posFlag = 5;						//initialisation stage
var looper = 0;
var currentBlock = 1;
var block2move
var windowWidth
var menuShift = (coverWidth - messageWidth)/2
//--------------------------------------------------------------------------------------
//Netscape 7 moves the layers much faster than other browsers.  This sniffer checks for
//this browsers and adjusts variables as required
var ant = navigator.appName.toLowerCase();
var avt = navigator.appVersion.toLowerCase();
var is_N6 = (ant.indexOf("netscape")!=-1) && (avt.charAt(0) > 4);
if(is_N6){timeoutSpeed =NS7timeoutSpeed;messagePause =NS7pause;acc = NS7acc;}
//--------------------------------------------------------------------------------------
function windowResize(){location.reload();}
//--------------------------------------------------------------------------------------
function domTest() {
var domType
if (document.layers){domType = 1;}	//nn4
else if (document.all && !document.getElementById){domType = 2;}	///IE4 
else if (document.getElementById && document.body.style){domType = 3;}	//Standards Compliant
return domType;
}
//--------------------------------------------------------------------------------------
function setupDOM(id){
var domType = domTest()
var layer
switch(domType){
	case 1:layer = document.layers[id];break;
	case 2:layer = document.all[id];break;
	case 3:layer = document.getElementById(id);break;
}
return layer
}
//--------------------------------------------------------------------------------------
function windowWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth - 14;	//adjustment for scrollbars
  } else {
    if( document.documentElement &&
        ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
    } else {
      if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
      }
    }
  }

  return myWidth;
  //window.alert( 'Height = ' + myHeight );
}
//--------------------------------------------------------------------------------------
function posTest(testToRun){
var domType = domTest()
var test
switch (currentBlock){
case 1: block2move = setupDOM("text1"); break; 
case 2: block2move = setupDOM("text2"); break;    
}
switch(domType){
case 1:
	switch(testToRun){
	case 1:if(block2move.top > restPos){test = 1}else{test=0};break;
	case 2:if(block2move.top < topPos + 20){test = 1}else{test=0};break;
	}
break;
case 2:
	switch(testToRun){
	case 1:if(parseInt(block2move.style.top) > restPos){test = 1}else{test=0};break;
	case 2:if(parseInt(block2move.style.top) < topPos + 20){test = 1}else{test=0};break;
	}
break;
case 3:
	switch(testToRun){
	case 1:if(parseInt(block2move.style.top) > restPos){test = 1}else{test=0};break;
	case 2:if(parseInt(block2move.style.top) < topPos + 20){test = 1}else{test=0};break;
	}
break;
}
return test
}//end posTest
//--------------------------------------------------------------------------------------
function writeMessage(thisMessage){
var domType = domTest()
var nextMessage = String(thisMessage)
var content = "<table width='100%' border='0' cellspacing='3' cellpadding='0'><tr><td width='135'><img src='images/spacer.gif' width='135' height='1'></td></tr><tr><td class='scrollTitle' width='135'>" + eval("title" + nextMessage) + "</td></tr><tr><td class='scrollMessage' width='135'>" + eval("message" + nextMessage) + "</td></tr><tr><td class='scrollLink' width='135'><a href=" + eval("link" + nextMessage) +">More Info ...</a>" +"</td></tr></table>";
switch(domType){
case 1:
document.text1.document.open();
document.text1.document.write(content);
document.text1.document.close();
break;
case 2:
block2move.innerHTML = content;
break;
case 3:
block2move.innerHTML = content;
break;
}
}  
//--------------------------------------------------------------------------------------
function moveLayersNS4(){
	var test = 1;
}
//----------------------------------------------------------------------

function moveLayers(){
var domType = domTest()
if(posFlag == 5){
if(menuFixedPos == 0){
windowWidth = windowWidth();
leftPos = windowWidth - coverWidth;
if(leftPos < 465){leftPos = 465;}
menuPos =(windowWidth/2)-230;
if(menuPos < 130){menuPos = 130;}
}
switch(domType){
//initialise start position and state of all layers
case 1:
	leftPos = leftPos - 15;
	block2move = document.layers["topCover"];
	block2move.top = topPos;
	block2move.left = leftPos;
	block2move.height = coverHeight;
	block2move = document.layers["bottomCover"];
	block2move.top = startPos;
	block2move.left = leftPos;
	block2move.height = coverHeight;
	block2move = document.layers["scrollerBg"]; 
	block2move.top = topPos;
	block2move.left = leftPos;
	block2move.height = startPos - topPos + 5;
	/*block2move = document.layers["menu"]; 
	block2move.left = menuPos;
	block2move.top = 54;*/
	block2move = document.layers["text1"];
	block2move.width = 135;
	block2move.top = startPos;
	block2move.left = leftPos + menuShift;
	var response =writeMessage(currentMessage)
break;
case 2:
	block2move = document.all["topCover"]; 
	block2move.style.top = topPos;
	block2move.style.left = leftPos;
	block2move.style.height = coverHeight;
	block2move = document.all["bottomCover"]; 
	block2move.style.top = startPos;
	block2move.style.left = leftPos;
	block2move.style.height = coverHeight;
	block2move = document.getElementById("scrollerBg"); 
	block2move.style.top = topPos;
	block2move.style.left = leftPos;
	block2move.style.height = startPos - topPos + 5;
	/*block2move = document.getElementById("menu"); 
	block2move.style.left = menuPos;*/
	block2move = document.all["text1"]; 
	block2move.style.top = startPos;
	block2move.style.left = leftPos + menuShift;
	var response =writeMessage(currentMessage)
break;
case 3:
	block2move = document.getElementById("topCover"); 
	block2move.style.top = topPos;
	block2move.style.left = leftPos;
	block2move.style.height = coverHeight;
	block2move = document.getElementById("bottomCover"); 
	block2move.style.top = startPos;
	block2move.style.left = leftPos;
	block2move.style.height = coverHeight;
	block2move = document.getElementById("scrollerBg"); 
	block2move.style.top = topPos;
	block2move.style.left = leftPos;
	block2move.style.height = startPos - topPos + 5;
	/*block2move = document.getElementById("menu"); 
	block2move.style.left = menuPos;*/
	block2move = document.getElementById("text1"); 
	block2move.style.top = startPos;
	block2move.style.left = leftPos + menuShift;
	var response =writeMessage(currentMessage)
break;
}
posFlag = 1;
}	//end if posFlag == 5

//set up DOM based on currentBlock var
switch (currentBlock){
case 1: block2move = setupDOM("text1");break; 
case 2: block2move = setupDOM("text2");break;    
}

switch(posFlag){
case 1:	//normal running state pre-rest
	var thisPos = posTest(1)
   	if(thisPos == 1){	//are we below the stopping point
	speed=speed-acc 	//increment speed for accelleration	
	}else{				//are we at or past the stopping point
	posFlag = 0;	//this means the box should wait
	speed = 0;	
	}
break; 
case 0: //layer at the wait point
	looper+=1;
	if(looper >=messagePause){
	posFlag = 2;
	speed=-5;
	}
break;
case 2: //moving again after break
	speed=speed-acc;
	var thisPos = posTest(2)
	if(thisPos == 1){
	if(currentMessage==totalNumMessages){currentMessage = 0;}
	for (var i = 0; i < totalNumMessages; i++) {
	if(currentMessage == i){
	currentMessage = i+1;
	var response =writeMessage(currentMessage)
	break; 
	}  
	} //end for loop
		switch(domType){
	case 1:
	block2move.top = startPos - 20;
	break;
	case 2:
	block2move.style.top = startPos - 20;
	break;
	case 3:
	block2move.style.top = startPos - 20;
	break;
	}
	speed=-1
	looper = 0;
	posFlag = 1;
	}//end if thisPos ==1
break;  
default :posFlag = 0;
}
 
switch (domType){
case 1: block2move.top=block2move.top + speed; break; 
case 2: block2move.style.top = parseInt(block2move.style.top) + speed + "px";break;
case 3: block2move.style.top = parseInt(block2move.style.top) + speed + "px";break;
}	

//setTimeout("moveLayers()",timeoutSpeed)
}
//--------------------------------------------------------------------------------------