// Quote Randomizer

// Edit Style info HERE
var wrapstyle="quotewrap";  // CSS class here
var quotestyle="quotewords";  // CSS class here
var authorstyle="quoteauthor";  // CSS class here
var datestyle="quotedate";  // CSS class here


// DONT EDIT BELOW HERE

function XMLquotes(){
//first some browser sniffing

try{
	xmlDoc=new ActiveXObject("Microsoft.XMLDOM");//Internet Explorer
}
catch(e){
	try{
		xmlDoc=document.implementation.createDocument("","",null);//Firefox, Mozilla, Opera, etc.
		}
	catch(e){
		alert(e.message);//If not a recognized method, error out
		return;
		}
	}
//XML Housekeeping
xmlDoc.async=false;
xmlDoc.load("quotes.xml");
//Finished loading document

var cnt=xmlDoc.getElementsByTagName("quote").length; //Count number of quotes
var num=Math.floor(Math.random()*cnt); //making our random number based on how many quotes we have
var quoteID=xmlDoc.getElementsByTagName("quote")[num]; //variable for quote identifier

//create object for our quote with tests for empty nodes
var thisquote = new Object();
	if(quoteID.getElementsByTagName("words")[0].childNodes.length>0)
thisquote.words=quoteID.getElementsByTagName("words")[0].childNodes[0].nodeValue;
	else thisquote.words="";
	if(quoteID.getElementsByTagName("author")[0].childNodes.length>0)
thisquote.author=quoteID.getElementsByTagName("author")[0].childNodes[0].nodeValue;
	else thisquote.author="";
	if(quoteID.getElementsByTagName("date")[0].childNodes.length>0)
thisquote.date=quoteID.getElementsByTagName("date")[0].childNodes[0].nodeValue;
	else thisquote.date="";

//write out the quote in the div styles specified at the top
document.write('<div class="'+wrapstyle+'"><div class="'+quotestyle+'">'+thisquote.words+'</div><div class="'+authorstyle+'">'+thisquote.author+'</div><div  class="'+datestyle+'">'+thisquote.date+'</div></div>');
}