function slideQuotes(toMove, delay, maxWidth) {
	if (document.getElementById && document.getElementById('quote-bar')) {
		var quoteEl = document.getElementById('quote-bar');
		var currLeft = (quoteEl.style.left) ? parseInt(quoteEl.style.left) : maxWidth;
		currLeft -= toMove;
		/* if (computedWidth <= maxWidth) {
			currLeft = 0;
		} else */ if (Math.abs(currLeft) - computedWidth >= 0) {
			currLeft = maxWidth;
			reloadTicker();
			computedWidth = computeWidth();
		}
		quoteEl.style.left = currLeft + 'px';
		setTimeout('slideQuotes(' + toMove + ', ' + delay + ', ' + maxWidth + ');', delay);
	}
}

function computeWidth() {
	if (document.getElementById && document.getElementById('quote-bar')) {
		var quoteEl = document.getElementById('quote-bar');
		var computedWidth = 0;
		if (document.defaultView && !document.offsetWidth) {
			computedWidth = parseInt(document.defaultView.getComputedStyle(quoteEl, '').getPropertyValue('width'));
		} else if (document.all) {
			computedWidth = parseInt(quoteEl.offsetWidth);
		}
		if (isNaN(computedWidth) || computedWidth <= 0) computedWidth = quoteEl.innerHTML.length * 7;
		return computedWidth;
	}
}

function reloadTicker() {
	var xmlHttp = false;
	if (typeof(window.ActiveXObject) != 'undefined') {
		try {
			xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlHttp = false;
			}
		}
	} else if (typeof(window.XMLHttpRequest) != 'undefined') {
		xmlHttp = new XMLHttpRequest();
	}
	if (xmlHttp) {
		loadTicker(xmlHttp);
	}
}

function loadTicker(xmlHttp) {
	/*
	var months = new Array('January', 'February', 'March', 'April', 'May', 'June',
		'July', 'August', 'September', 'October', 'November', 'December');
	var days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
	var today = new Date();
	var dateString = days[today.getDay()] + ', ' + months[today.getMonth()] + ' ' + today.getDate() + ', ' + today.getFullYear();
	*/
	var tickerContent = '';
	xmlHttp.open('GET', '/usf/generated/ticker-content.asp',true);
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4) {
			var info = xmlHttp.responseText.split('\n');
			delay = parseInt(info[0]);
			for (i = 1; i < info.length - 1; ++i) {
				tickerContent += info[i].replace('\x0D', '') + ' ... ';
			}
			tickerContent = tickerContent.substr(0, tickerContent.length - 5);
			document.getElementById('quote-bar').innerHTML = tickerContent;
		}
	}
	xmlHttp.send(null);
}

function startTicker() {
	computedWidth = computeWidth();
	slideQuotes(2, 50, 750);
}