
// banner.js

       onload = startBanner;

       function showMessage(n, show) {
         var whichEl = (NS4) ? eval("message" + n) :
                               eval("message" + n + ".style");
         whichEl.visibility = (show) ? ((NS4) ? "show" : "visible") :
                                       ((NS4) ? "hide" : "hidden");
       }

       function nextMessage() {
         var fromInd = current;
         current = (fromInd == blurbCount - 1) ? 0 : fromInd + 1;
         //current = (fromInd == blurbCount - 1) ? 0 : fromInd - 1;
         scrollBanner(fromInd, current);
       }

       function moveUp() {
         if (NS4) {
           fromEl.top -= increment;
           if (toEl.top - increment <= toElTarget) {
             toEl.top = toElTarget;
             clearInterval(intervalID);
             fromEl.visibility = "hide";
             timeoutID = setTimeout("nextMessage()", pause);
           } else {
             toEl.top -= increment;
           }
         } else {
           fromEl.pixelTop -= increment;
           if (toEl.pixelTop - increment <= toElTarget) {
             toEl.pixelTop = toElTarget;
             clearInterval(intervalID);
             fromEl.visibility = "hidden";
             timeoutID = setTimeout("nextMessage()", pause);
           } else {
             toEl.pixelTop -= increment;
           }
         }
       }

       function scrollBanner(from, to) {
         if (NS4) {
           fromEl = eval("message" + from);
           toEl = eval("message" + to);
           toEl.top = fromEl.top + bannerHeight;
           toElTarget = fromEl.top;
         } else {
           fromEl = eval("message" + from + ".style");
           toEl = eval("message" + to + ".style");
           toEl.pixelTop = fromEl.pixelTop + bannerHeight;
           toElTarget = fromEl.pixelTop;
         }
         showMessage(to, true); // show the upcoming message
         intervalID = setInterval("moveUp()", interval);
       }

       function makeIE() {
         // assign the necessary code to a variable
         var text = '<DIV ID="banner" STYLE="position:absolute;">';
         for (var i = blurbCount - 1; i >= 0; i--) {
           text += '<DIV ID="message' + i + 
                   '" STYLE="position:absolute; text-align:left;"></DIV>';
         }
         text += '</DIV>';

         // insert the code before the end of the document
         document.body.insertAdjacentHTML("BeforeEnd", text);

         // define the main element's properties
         with (banner.style) {
           width = bannerWidth;
           height = bannerHeight;
           clip = "rect(0 " + bannerWidth + " " + bannerHeight + " 0)";
           //backgroundImage = "url(empty.gif)";
           pixelLeft = bannerLeft;
           pixelTop = bannerTop;
         }

         // define the child elements' properties
         for (i = 0; i < blurbCount; i++) {
           with (eval("message" + i + ".style")) {
             visibility = "hidden";
             pixelLeft = leftPadding;
             pixelTop = topPadding;
             width = bannerWidth - leftPadding;
           //backgroundImage = "url(images/sides.gif)";

           }
         }
       }

       function makeNS() {
         // create the main element
         banner = new Layer(bannerWidth);

         // define the main element's properties
         with (banner) {
           clip.right = bannerWidth;
           clip.bottom = bannerHeight;
           document.bgImage = "url(images/sides.gif)";
           left = bannerLeft;
           top = bannerTop;
           visibility = "show";
         }

         // define the child elements' properties
         for (var i = 0; i < blurbCount; i++) {
           // create a child element
           eval("message" + i + " = " + 
                "new Layer(bannerWidth - leftPadding, banner)");
           with(eval("message" + i)) {
             visibility = "hide";
             left = leftPadding;
             top = topPadding;
             //document.bgColor = bannerColor;
           }
         }
       }

       function fillBanner() {
         var whichEl;
         var iStart=0;
	 var rand;
	 if (NS4) {
	   if (bHeadline == true){   //bHeadline set in bannerconfig
	     // The first in the array is always first
	     whichEl = eval("message0");
             whichEl.document.write(ar[0]);
             whichEl.document.close();  
	     iStart = 1;	
	   }
	   //choose the rest of the blurbs randomly
	   unused = new Array();   //an array for blurbs not yet used
	   for (var i=0; i<(ar.length-iStart); i++)
	     unused[i]= i+iStart;  // fill either 1..ar.length-1 or 0..ar.length
           for (var i=iStart; i<blurbCount; i++) {
		//get a random #
	     
	     //rand= Math.round(100* Math.random()) % unused.length;
	      //rand= unused.length -1;
	     rand=0;
	     
	     whichEl = eval("message" + i);
             whichEl.document.write(ar[unused[rand]]); //write random blurb
             whichEl.document.close();

	       //delete the used blurb from "unused" list
	     unused[rand]=unused[unused.length - 1];  //copy last to current
	     unused.length--;     //delete last
	     if (unused.length <1) 
		break;   	//ran out of unused blurbs
           }
         }else {
	   if(bHeadline == true){
		//the first in array is first
             whichEl = eval("message" + 0);
             whichEl.innerHTML = ar[0];
	     iStart=1;
	   }

	  	//choose the rest randomly
	   unused = new Array();   //an array for blurbs not yet used
	   for (var i=0; i<(ar.length-iStart); i++)
	     unused[i]= i+iStart;  // fill either 1..ar.length-1 or 0..ar.length

           for (var i = 0; i < blurbCount; i++) {
		//get a random #
	     
	     //rand= Math.round(100* Math.random()) % unused.length;
	     //rand= unused.length -1;
	     rand=0
             whichEl = eval("message" + i);
             whichEl.innerHTML = ar[unused[rand]];
	       //delete the used blurb from "unused" list
	     unused[rand]=unused[unused.length - 1];  //copy last to current
	     unused.length--;     //delete last
	     if (unused.length <1) 
		break;   	//ran out of unused blurbs
           }
         }
       }

       function startBanner() {
         if (NS4)
           makeNS()
         else
           makeIE();
         fillBanner();
         showMessage(0, true);
         current = 0;
         timeoutID = setTimeout("nextMessage()", pause);
       }


       var NS4 = (document.layers) ? true : false;
       var IE4 = (document.all) ? true : false;
       var interval = 20;
       var increment = 2;
       var pause = 5000;
       var bannerColor = "images/empty.gif";
       var leftPadding = 0;
       var topPadding = 0;
       var maxBlurbCount = 20; //the number of blurbs to show, if array long enough
       var bannerLeft = (NS4) ? 6 : 6;
       var bannerTop = (NS4) ? 25 : 25;
       var bannerWidth = (NS4) ? 141 : 141;
       var bannerHeight = (NS4) ? 66 : 66;
	   
       var bHeadline = false;
