// Use these parms to modify the appearance and behavior of the ticker.
topEdge			= 440;	// absolute position (in pixels) of news box from top edge
leftEdge    		= 5;	// absolute position (in pixels) of news box from left edge
boxHeight		= 100;	// height of ticker box
boxWidth		= 220;	// width of ticker box
scrollPause		= 30;	// milliseconds between scrolls
tickerPause 		= 3000;	// milliseconds for ticker to pause after scrolling the event
nextEventPause		= 2000; // milliseconds between current event pause and next event begin to scroll
nextDiv			= -1;	// counter for next div to scroll in ticker
nextEvent		= 0;	// counter for next event to load into div from news array
tickerHeadlines		= null;

function InitTicker(sender, args) {
    if (tickerHeadlines != null && tickerHeadlines.length > 0) {
        // Set the ticker div styles.
        for (var i = 0; i < 2; i++) {
            var div                 = document.getElementById('headline'+i);
            div.style.background    = 'none transparent scroll repeat 0% 0%';
            div.style.fontSize	    = '9pt';
            div.style.height		= boxHeight + 'px';
            div.style.left	    	= leftEdge + 'px';
            div.style.pixelLeft	    = leftEdge;
            div.style.position	    = 'absolute';
            div.style.visibility	= 'hidden';
            div.style.width		    = boxWidth + 'px';
        }

        // Start the ticker.
        ScrollNewHeadline();
    }
}

function ScrollHeadline(divId, clipTop) {
	try {
		// Set the style of the div.
		var newsDiv = document.getElementById(divId).style;
		newsDiv.visibility = 'visible';
		newsDiv.clip = "rect(" + clipTop + "px " + (boxWidth + leftEdge) + "px " + (clipTop + boxHeight) + "px 0px)";
		
		// DOM-compliant browsers use style.top; older IE versions use style.pixelTop.
		newsDiv.top			= (topEdge - clipTop) + 'px';
		newsDiv.pixelTop	= topEdge - clipTop;
	} catch(ex) {}

	// Increment clip top.  This makes it appear to scroll.
	clipTop = (clipTop + 1);

	switch(clipTop) {
		case 0:
			// Pause scrolling.  Load next event (out of view below).
			setTimeout('ScrollNewHeadline()', (tickerPause + nextEventPause));
			setTimeout('ScrollHeadline(\'' + divId + '\', ' + clipTop + ')', tickerPause);
			break;
		case boxHeight - 1:
			// Stop scrolling when totally out of view.
			newsDiv.visible = 'invisible';
			break;
		default:
			// Scroll after brief delay.
			setTimeout('ScrollHeadline(\'' + divId + '\', ' + clipTop + ')', scrollPause);
	}
}

function ScrollNewHeadline() {
	if (tickerHeadlines != undefined && tickerHeadlines != null && tickerHeadlines.length > 0) {
		// Increment the div counter (will be 0 or 1).
		nextDiv = (nextDiv + 1) % 2;
		document.getElementById('headline' + nextDiv).innerHTML = tickerHeadlines[nextEvent];

		// Grab next event from array (acts as a circular queue).
		nextEvent = (nextEvent < (tickerHeadlines.length - 1) ? nextEvent + 1 : 0);

		// Start scrolling the div.
		ScrollHeadline(('headline' + nextDiv), (0 - boxHeight));
	}
}

window.onload = InitTicker;
document.write("<div id=\"headline0\"></div>\n" + "<div id=\"headline1\"></div>\n");