<!-- Random Quote Code -->
var debugMode = false;
var quoteContainer = ""
var xmlFile = "/javascript/quotes.xml";
var xmlDoc;

var current_color=0
var quoteDelay = 20000
var pause_time=9000


function display() {
	window.onerror=null;
	var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
	var ie = (typeof window.ActiveXObject != 'undefined');

	if (moz) {
		xmlDoc = document.implementation.createDocument("", "", null)
		xmlDoc.load(xmlFile);
		xmlDoc.onload = xmlLoadContinue;
		return;
	} else if (ie) {
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async = false;
		while(xmlDoc.readyState != 4) {};
		xmlDoc.load(xmlFile);
	}

	//debugging code
	var err = xmlDoc.parseError;
	if (err.errorCode != 0)
	{
		if(debugMode){
			alert("errorCode: " + xmlDoc.parseError.errorCode + "\n" +
			  "filepos: " + xmlDoc.parseError.filepos + "\n" +
			  "line: " + xmlDoc.parseError.line + "\n" +
			  "linepos: " + xmlDoc.parseError.linepos + "\n" +
			  "reason: " + xmlDoc.parseError.reason + "\n" +
			  "srcText: " + xmlDoc.parseError.srcText + "\n" +
			  "url: " + xmlDoc.parseError.url);
		}
	}
	if(debugMode){alert(xmlDoc.documentElement.xml);}
	xmlLoadContinue();
}

function xmlLoadContinue(){
	window.onerror=null;
	if(debugMode){alert(xmlDoc.documentElement.xml);}
	quoteContainer = xmlDoc.getElementsByTagName("quote");
	nextQuote();
}

function nextQuote() {
	currentQuote = Math.floor(Math.random()* quoteContainer.length)
	//currentQuote = 0
	quote = quoteContainer[currentQuote].firstChild.nodeValue;
	author = quoteContainer[currentQuote].getAttribute("author");
	quoteURL = quoteContainer[currentQuote].getAttribute('url');
	if(quoteURL){textToWrite = "<center>" + quote +"<br />&nbsp;&nbsp;&nbsp;&nbsp;- <em><a href='"+ quoteURL + "' target='_blank'>"+ author + "</a></em></center>";}
	else{textToWrite = "<center>" + quote +"<br />&nbsp;&nbsp;&nbsp;&nbsp;- <em>"+ author + "</em></center>";}

	if(document.all) {
		if(debugMode){alert("thisbrowser=IE");}
		quotewindow.innerHTML = textToWrite;
	}

	if(document.layers) {
		if(debugMode){alert("thisbrowser=NN4");}
		document.quotewindow.document.write(textToWrite);
		document.close();
	}

	if(!document.all && document.getElementById){
		if(debugMode){alert("thisbrowser=NN6");}
		quotewindowlayer = document.getElementById("quotewindow");
		quotewindowlayer.innerHTML = textToWrite;
	}
	setTimeout("nextQuote()",quoteDelay);
}

//code for fade:
var fadecolor= new Array(19);
function fadeColor( fromcol, tocol, fadePortion ) {
    //in the format fadeColour( 'ff0098', 'fe0934', 0.23 )
    var oF = [], oT = [], oP = [];
    var oH = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
    //get the red, green and blue substrings ...
    for( var x = 0; x < 3; x++ ) {
        //... and convert them from hex into decimal ...
        oF[x] = eval( '0x' + fromcol.substring( 2 * x, ( 2 * x ) + 2 ) );
        oT[x] = eval( '0x' + tocol.substring( 2 * x, ( 2 * x ) + 2 ) );
        //... add on the required portion of difference between the two ...
        oP[x] = Math.round( oF[x] + ( ( oT[x] - oF[x] ) * fadePortion ) );
        //... and convert it back into hex ...
        oP[x] = oH[ ( oP[x] - ( oP[x] % 16 ) ) / 16 ] + oH[ oP[x] % 16 ];
    }
    //... and put them back together again as a colour string
    return '#' + oP.join('');
}

for( var y = 0; y < 20; y++ ) {
    //in 10 steps, fade the colour - also see the section on writing with script
   // fadecolor[y]=fadeColor( 'ffffff', '000099', y / 19 );
    fadecolor[y]=fadeColor( '000000', '000000', y / 19 );
	//alert(color[y]);
}

function fadein() {
	if (current_color <= fadecolor.length-1) {
		if(document.all) {
            if(debugMode){alert("thisbrowser=IE");}
			quotewindow.innerHTML = textToWrite;
		}

		if(document.layers) {
           if(debugMode){alert("thisbrowser=NN4");}
			document.quotewindow.document.write(textToWrite);
			document.close();
		}

        if(!document.all && document.getElementById){
            if(debugMode){alert("thisbrowser=NN6");}
            quotewindowlayer = document.getElementById("quotewindow");
            quotewindowlayer.innerHTML = textToWrite;
                }

		current_color++
		var timer=setTimeout("fadein()",50)

	}
	else {
		current_color--
		clearTimeout(timer)
		var intermezzo=setTimeout("fadeout()",pause_time)
	}
}

function fadeout() {
	if (current_color >= 0) {
		if(document.all) {
        //thisbrowser="IE";
			quotewindow.innerHTML = textToWrite;
		}

		if(document.layers) {
        //thisbrowser="NN4";
			document.quotewindow.document.write(textToWrite);
			document.close();
		}
		if(!document.all && document.getElementById){
            //thisbrowser="NN6";
            quotewindowlayer = document.getElementById("quotewindow");
            quotewindowlayer.innerHTML = textToWrite;
                }
		current_color--
		var timer=setTimeout("fadeout()",50)
	}
	else {
		last_quote = currentQuote
		while(currentQuote == last_quote)
		//* Use these 2 lines to step through quotes randomly
			currentQuote = Math.ceil(Math.random() * quote.length-1);
			author = currentQuote

		//* Use these 4 lines to step through quotes sequentially
			//currentQuote++
			//if (currentQuote >= quote.length) {currentQuote=0}
			//author++
			//if (author >= author.length) {author=0}

		current_color++
		clearTimeout(timer)
		var intermezzo=setTimeout("fadein()",1000)
	}
}
<!-- End Random Quote Code -->
