﻿<!--
	// See important note in function resetMarquee().
	
	var inMarqueeWidth;
	var marqueeWidth;
	var marqueeWidthUnit;
	var marqueeWidthAdjust;
	var defaultMarqueeWidth = 700;
	var marqueeHeight;
	var speedInterval;
	var increment;
	var allowPause;
	var borderWidth;
	var borderColor;
	var borderStyle;
	var backgroundColor;
	var textColor;
	var fontSize;
	var fontWeight;
	var fontFamily;
	var scrollDirection;
	var fontSizeWeightString;
	var dataDiv;
	var counterDiv;
	var pos;
	var dataWidth;
	var intervalID;
	var curWidth;
	var dataSave;
			
	function pauseIt(val)
	{
		///<summary>Tell the marquee to pause, or continue.</summary>
		///<param name="val" type="boolean">true OR false</param>
		if (allowPause == true)
		{
			if (val==true) {increment=0;}
			else {increment = 1;}
		}
	}	
	//============================================================================
	// getObjWidth (objName): get the width (or height) of an object.
	//============================================================================
	function getObjWidth (inData)
	{
		///<summary>Get an object width at runtime using the passed-in data.</summary>
		///<param name="inData" type="string">This data will be put into a div and used to calculate its width.</param>
		///<return type="integer">Returned the width of a div using the passed in data.</return>
		
		// Default to 0, just in case. then try several possibilities.
		var objWidth = 0;
		var tempDiv = document.createElement('div');
		// font info and position must be same as dataDiv.
		if (dataDiv.currentStyle)
		{
			// get font info for dataDiv in IE
			tempDiv.style.fontFamily = dataDiv.currentStyle.fontFamily;
			tempDiv.style.fontStyle = dataDiv.currentStyle.fontStyle;
			tempDiv.style.fontVariant = dataDiv.currentStyle.fontVariant;
		}
		else
		{
			// get font info for dataDiv in Firefox
			var dStyle = document.defaultView.getComputedStyle(dataDiv,null)
			tempDiv.style.fontFamily = dStyle.fontFamily;
			tempDiv.style.fontStyle = dStyle.fontStyle;
			tempDiv.style.fontVariant = dStyle.fontVariant;
		}
		tempDiv.style.fontSize = fontSize + "pt";
		tempDiv.style.fontWeight = fontWeight;
		tempDiv.style.position = "absolute";
		// tempDiv will never actually show.  Still, it is safer to position it
		// extremely far off the visible part of the screen.
		if ((scrollDirection == "ltr") || (scrollDirection == "rtl"))
		{
			tempDiv.style.left = -20000 + "px";
			tempDiv.style.top = -5000 + "px";
			tempDiv.style.height = marqueeHeight + "px";
		}
		else
		{
			tempDiv.style.left = -5000 + "px";
			tempDiv.style.top = -20000 + "px";
			tempDiv.style.width = marqueeWidth + "px";
		}
		tempDiv.innerHTML = inData;
		document.body.appendChild(tempDiv);
		if ((scrollDirection == "ltr") || (scrollDirection == "rtl"))
			objWidth = tempDiv.offsetWidth;
		else
			objWidth = tempDiv.offsetHeight;
		// Remove tempDiv in IE or Firefox
		if (tempDiv.removeNode)
			tempDiv.removeNode(true);
		else
			document.body.removeChild(tempDiv);
		
		return objWidth;
	}
	//============================================================================
	// moveContent(): move the marquee content through the divs.
	//============================================================================
	function moveContent()
	{
		///<summary>Move the content of a div by a number of pixels already specified.</summary>
		switch(scrollDirection)
		{
		case "ltr":
			// this is left-to-right - move 1 pixel to the right
			pos = pos + increment;
			// if moved passed the length of the data, reset.
			if (pos > marqueeWidth)
				{pos = (0-dataWidth);}
			// set the 'left' property of style to the new position.
			dataDiv.style.left = pos + "px";
			break;
		case "ttb":
			// this is top-to-bottom - move 1 pixel to the bottom
			pos = pos + increment;
			if (pos > (marqueeHeight))
				{pos = (0-dataWidth);}
			// set the 'top' property of style to the new position.
			dataDiv.style.top = pos + "px";
			break;
		case "btt":
			// this is bottom-to-top - move 1 pixel to the top
			pos = pos - increment;
			if (pos < (0-dataWidth))
				{pos = marqueeHeight;}
			// set the 'top' property of style to the new position.
			dataDiv.style.top = pos + "px";
			break;
		default:
			// this is right-to-left OR invalid value.
			// move 1 pixel to the left
			pos = pos - increment;
			// if moved passed the legnth of the data, reset.
			if (pos < (0-dataWidth))
				{pos = marqueeWidth;}
			// set the 'left' property of style to the new position.
			dataDiv.style.left = pos + "px";
		}
		// counter may or may not be there.
		if (counterDiv)
			{counterDiv.innerHTML = "pos = " + pos;}
		
		// See note in resetMarquee()
		if 	(!window.onresize)
			window.onresize = resetMarquee;
	}

	//============================================================================
	// resetMarquee(theData): Reset the marquee and restart the timer.
	//============================================================================
	function resetMarquee()
	{
		// IMPORTANT NOTE:	this function is called when window is resized
		//					(window.resize = resetMarquee;).
		//					There is a bug in IE which will cause this
		//					function to be called in an infinite loop.
		//					A workaround is found in function detectRclick() in
		//					rclick.js.
		
		if (curWidth)
		{
			if (intervalID)
			{
				clearInterval(intervalID);
				intervalID = null;
			}
			if (curWidth == getWindowWidth())
				setupMarquee(null);
			else
			{
				curWidth = getWindowWidth();
				if (BrowserDetect.browser == "Firefox")
					setupMarquee(null);
			}
		}
		else
		{
			curWidth = getWindowWidth();
			if (BrowserDetect.browser == "Firefox")
			{
				if (intervalID)
				{
					clearInterval(intervalID);
					intervalID = null;
				}
				setupMarquee(null);
			}
		}
	}
	
	//============================================================================
	// setupMarquee(theData): Setup the marquee and start the timer.
	//============================================================================
	function setupMarquee(inData)
	{
		///<summary>Setup the marquee and start the timer.</summary>
		///<param name="inData" type="string">This data will be put into the marquee and scrolled.</param>

		var min;
		var max;
		var borderTop;
		var tempData;
		var borderDiv;
		var outsideDiv;
		
		// if no data, exit.
		if (!inData)
		{
			if (!dataSave)
				return;
			else
				inData = dataSave;
		}
		else
			dataSave = inData;
		
		// Compute Marquee Width based on incoming parameters.
		marqueeWidthUnit.toLowerCase();
		marqueeWidth = inMarqueeWidth;
		if (marqueeWidthUnit == "percent")
			marqueeWidth = document.body.offsetWidth * marqueeWidth / 100;
		marqueeWidth = marqueeWidth + marqueeWidthAdjust;
		// Just in case rediculous parameters result in too small a size-use default.
		if (marqueeWidth < 50)
			marqueeWidth = defaultMarqueeWidth;
		
		fontSizeWeightString = " font-size: " + fontSize + "pt; font-weight: " + fontWeight + "; ";
		// Write 3 'div's
//		borderTop = (0-(marqueeHeight/2+10));
		borderTop = -20
		if (dataDiv == null)
		{
			document.writeln("<div id='BorderDiv' style='border: "+borderStyle+" "+borderWidth+"px "+borderColor+"; vertical-align: middle; width: "+(marqueeWidth + (borderWidth*2))+"px; padding-left: 2px; padding-right: 2px; background-color: "+backgroundColor+"; position: relative; left: 90px; top: "+borderTop+"px;'>");
			document.writeln("<div id='OutsideDiv' style='background-color: "+backgroundColor+"; overflow:hidden; vertical-align: middle; width: "+marqueeWidth+"px; height: "+marqueeHeight+"px; position: relative;'>");
			document.writeln("<div id='DataDiv' style='width: "+marqueeWidth+"px; height: "+marqueeHeight+"px; position:absolute; vertical-align: middle; left: "+marqueeWidth+"px; color: "+textColor+"; " + fontSizeWeightString + "'  onMouseover='pauseIt("+true+");' onMouseout='pauseIt("+false+");'>");
			document.writeln("</div></div></div>");
			// precautionary code
			scrollDirection.toLowerCase();
			
			// Get elements into variables.
			dataDiv = document.getElementById("DataDiv");
			counterDiv = document.getElementById("CounterDiv");
		}
		else
		{
			borderDiv = document.getElementById("BorderDiv");
			outsideDiv = document.getElementById("OutsideDiv");
			// Re-setup sizes
			borderDiv.style.width = marqueeWidth + (borderWidth*2) + "px";
			outsideDiv.style.width = marqueeWidth + "px";
			outsideDiv.style.height = marqueeHeight + "px";
			dataDiv.style.width = marqueeWidth + "px";
			dataDiv.style.height = marqueeHeight + "px";
		}

		// get the data width
		
		if ((scrollDirection == "ltr") || (scrollDirection == "rtl"))
			{tempData = "<nobr>" + inData + "</nobr>";}
		else
			{tempData = inData;}

		// Width here is either width or height depending on scrollDirection.
		dataWidth = getObjWidth(tempData);
		
		if (!dataWidth)
			{dataWidth = tempData.length;}
		// starting point for text to enter marquee. If home page, start at beginning.
		if (document.location.pathname.toUpperCase().search("/HOME")>-1)
		{
			if (scrollDirection == "ltr")
				{pos = dataWidth;}
			else if  (scrollDirection == "rtl")
				{pos = marqueeWidth;}
			else if  (scrollDirection == "ttb")
				{pos = 0; dataDiv.style.left = 0;}
			else if  (scrollDirection == "btt")
				{pos = marqueeHeight;  dataDiv.style.left = 0;}
		}
		else
		{
			// Generate a random number from -datawidth to +marqueeWidth.
			if ((scrollDirection == "ltr") || (scrollDirection == "rtl"))
			{
				min = 0-dataWidth;
				max = marqueeWidth;
				dataDiv.style.top = 0;
			}
			else if ((scrollDirection == "ttb") || (scrollDirection == "btt"))
			{
				// Generate a random number from -datawidth to +marqueeHeight.
				min = 0-dataWidth;
				max = marqueeHeight;
				dataDiv.style.left = 0;
			}

			pos = Math.floor(Math.random() * (max - min + 1) + min);
			
		}
		// move data into marquee.
		dataDiv.innerHTML = tempData;
		// Start loop to move the content of the marquee.
		intervalID = setInterval("moveContent()", speedInterval);
	}
-->
