// Osborne 101403 News and events marquee

// Set the functionality of the marquee below.
var altTime  = 5000; // Set the time between message displays (in milliseconds). 
var altSpeed = 1.10;   // Set the transition duration.
var msgTrans =  12;  // Set the number of the transition to apply to the messages.

// Set the style of the marquee below.
var mLeft      = 3;          	// Set the left position of the marquee (in pixels).
var mTop       = 0;         	// Set the top position of the marquee (in pixels).
var mHeight    = 160;        	// Set the height of the marquee (in pixels).
var mWidth     = 150;        	// Set the width of the marquee (in pixels).
var bgColor    = 'transparent';     // Set the marquee's background color.
var brdrWidth  = '0';          	// Set the marquee's border width.
var brdrStyle  = 'none';    	// Set the marquee's border style ('solid', 'dashed', 'dotted', etc.).  Different border styles only work in Netscape 6 and up, and not in Internet Explorer.
var brdrColor  = 'transparent';     	// Set the marquee's border color.
var fontFamily = 'Tahoma';  	// Set the font family.
var fontSize   = 12;         	// Set the font size (in pixels).
var fontStyle  = 'normal';   	// Set the font style ('normal' or 'italic').
var fontWeight = 'normal';     	// Set the font weight ('normal' or 'bold').
var txtDec     = 'none';     	// Set any decorations for the marquee's text.
var fontColor  = 'black';     	// Set the font color.
var msgZIndex  = 1000;       	// Set the z-index of the marquee.  Make sure that the number is bigger than the z-index of what you want it to appear over on the page.


//THIS IS THE CODE THAT CHANGES AS YOUR HEADLINES CHANGE//
// Links and marquee text
var msgArray = new Array();
msgArray[0]= '<a href="/library/about/hours/"><span style="text-decoration:none;text-underline:none;color: #336633;"><b>Open until 11:00 p.m. Sundays through Thursdays</b></a></span>';
msgArray[1]= '<a href="about/newsletters/newsletter7-4.pdf"><span style="text-decoration:none;text-underline:none;color: #336633;"><b>Read the September/October issue of the library newsletter, <i>fyi . . .</i></b></a></span>';
msgArray[2]= '<a href="/library/announce/"><span style="text-decoration:none;text-underline:none;color: #336633;"><b>Take a look at NetLibrary\'s e-book of the month for November!</b></a></span>';
msgArray[3]= '<a href="help/ask/default.asp"><span style="text-decoration:none;text-underline:none;color: #336633;"><b>Need help with your research? Ask a Librarian!</b></a></span>';
msgArray[4]= '<a href="/library/announce/"><span style="text-decoration:none;text-underline:none;color: #336633;"><b>Find flu resources from EBSCO!</b></a></span>';
msgArray[5]= '<a href="/library/announce/"><span style="text-decoration:none;text-underline:none;color: #336633;"><b>Become a fan of ODU Library on Facebook!</b></a></span>';


// Please do not edit below here

var brwsr;
if (navigator.appName == 'Microsoft Internet Explorer')
{
	if (parseInt(navigator.appVersion) >= 3)
		brwsr = 'IE';
	else
		brwsr = null;
}
else if (navigator.appName == 'Netscape')
{
	if (parseInt(navigator.appVersion) >= 5)
		brwsr = 'NS6';
	else if (parseInt(navigator.appVersion) >= 4)
		brwsr = 'NS4';
	else
		brwsr = null;
}
if (brwsr == null)
	brwsr = 'NS6';

function Ret(msgNum)
{
	if (brwsr == 'IE')
		return(document.all['msg' + msgNum]);
	else if (brwsr == 'NS4')
		return(document.layers['msg' + msgNum]);
	else if (brwsr == 'NS6')
		return(document.getElementById('msg' + msgNum));
	else
		return(null);
}

function ShowOrHide(msgNum)
{
	var msgRet;
	if (brwsr == 'IE' || brwsr == 'NS6')
		msgRet = Ret(msgNum).style;
	else
		msgRet = Ret(msgNum);

	if (msgRet.visibility == 'hidden' || msgRet.visibility == 'hide')
	{
		if (brwsr == 'IE')
		{
			msgRet.filter = 'revealTrans(duration=' + altSpeed + ', transition=' + msgTrans + ')';
			Ret(msgNum).filters.revealTrans.apply();
		}
		brwsr == 'NS4' ? msgRet.visibility = 'show' : msgRet.visibility = 'visible';
		if (brwsr == 'IE')
			Ret(msgNum).filters.revealTrans.play();
	}
	else if (msgRet.visibility == 'visible' || msgRet.visibility == 'show')
		brwsr == 'NS4' ? msgRet.visibility = 'hide' : msgRet.visibility = 'hidden';
}

function ShowOrHide2(msgNum)
{
	ShowOrHide(msgNum);
	setTimeout('ShowOrHide(' + msgNum + ')', altTime);
}

function LoopIt()
{
	for (i=0; i<=msgArray.length-1; i++)
		setTimeout('ShowOrHide2(' + i + ')', altTime*i);
}

function BuildMarquee()
{
	var msgBlock = '';
	if (brwsr == 'IE' || brwsr == 'NS6')
	{
		msgBlock += '<div style="height:' + mHeight + 'px; width:' + mWidth + 'px; position:absolute; left:' + mLeft + 'px; top:' + mTop + 'px; background-color:' + bgColor + '; border:' + brdrWidth + 'px ' + brdrStyle + ' ' + brdrColor + '; z-index:' + msgZIndex + ';">\r';
		for (i=0; i<=msgArray.length-1; i++)
		{
			msgBlock += '  <span id="msg' + i + '" style="visibility:hidden; height:' + (mHeight - brdrWidth * 3) + 'px; width:' + (mWidth - brdrWidth * 3) + 'px; position:absolute; left:2px; top:2; font-family:' + fontFamily + '; font-size:' + fontSize + 'px; font-style:' + fontStyle + '; font-weight:' + fontWeight + '; text-decoration:' + txtDec + '; color:' + fontColor + '; z-index:' + (msgZIndex + 1) + '; ">\r'
			+ '    ' + msgArray[i] + '\r'
			+ '  </span>\r';
		} 
		msgBlock += '</div>';
		document.write(msgBlock);
	}
	else if (brwsr == 'NS4')
	{
		var msgBlockNS4 = new Array();
		for (i=0; i<=msgArray.length-1; i++)
		{
			msgBlockNS4[i] = '  <layer bgColor="' + bgColor + '" left="' + mLeft + '" name="msg' + i + '" top="' + mTop + '" visibility="hide" z-index="' + msgZIndex + '">\r'
			+ '    <table bgColor="' + bgColor + '" border="' + brdrWidth + '" borderColor="' + brdrColor + '" cellPadding="2" cellSpacing="0" height="' + mHeight + '" width="' + mWidth + '"><tr><td height="100%" width="100%"><p style="font-family:' + fontFamily + '; font-size:' + fontSize + 'px; font-style:' + fontStyle + '; font-weight:' + fontWeight + '; text-decoration:' + txtDec + '; color:' + fontColor + ';">' + msgArray[i] + '</p></td></tr></table>\r'
			+ '  </layer>\r';
		}

		var arrayStr = '';
		for (j=0; j<=msgBlockNS4.length-1; j++)
			arrayStr += msgBlockNS4[j];
		document.write(arrayStr);
	}
	else
		return(null);
}

BuildMarquee();
if (brwsr == 'NS4')
	setTimeout('LoopIt()', 100);
else
	LoopIt();
setInterval('LoopIt()', altTime*msgArray.length-1);