var xmlHttp;
var xmlDoc = null;

function getQuote()
{
	if (window.ActiveXObject)
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLDOM");
		xmlHttp.async = "false";
		xmlHttp.load("xml/shortquotes.xml");		
		setIERandomQuote();
	} else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
		xmlHttp.onreadystatechange = handleStateChange;
		xmlHttp.open("GET", "xml/shortquotes.xml?timestamp=" + new Date().getTime(), true);
		xmlHttp.send(null);
	}
}

function handleStateChange() {
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			setFFRandomQuote();
		}
	}
}


function setIERandomQuote(browser) {

	xmlDoc = xmlHttp;
	var maxQuotes = xmlDoc.getElementsByTagName("quote").length;
	var randomID = (Math.round(Math.random()*(maxQuotes - 1)));
	var qText = "error";
	var qSignature = "error";

	for (var i = 0; i < maxQuotes; i++) {
		if (randomID == i) {
			qText = xmlDoc.getElementsByTagName("shorttext").item(i).text;
			qSignature = xmlDoc.getElementsByTagName("signature").item(i).text;
		}
	}
	
		document.getElementById("dyQuoteText").innerHTML = qText + "<BR><BR>-&nbsp;" + qSignature;
}

function setFFRandomQuote(browser) {

	xmlDoc = xmlHttp.responseXML;
	var maxQuotes = xmlDoc.getElementsByTagName("quote").length;
	var randomID = (Math.round(Math.random()*(maxQuotes - 1)));
	var qText = "error";
	var qSignature = "error";

	for (var i = 0; i < maxQuotes; i++) {
		if (randomID == i) {
			qText = xmlDoc.getElementsByTagName("shorttext").item(i).firstChild.nodeValue;
			qSignature = xmlDoc.getElementsByTagName("signature").item(i).firstChild.nodeValue;
		}

	}

	document.getElementById("dyQuoteText").innerHTML = qText + "<BR><BR>-&nbsp;" + qSignature;
}