//Banners xml format
//<banners>        
//     <banner>   
//          <quote></quote>   <image></image>   <name></name>
//     </banner>
//</banners>

var debug = 0;  
// Anne's note:  zero for de-bugger off;   1 for de-bugger on.    With on, the alerts will then be visible and don't use any returns because that ends the comment!

function loadXML(xmlFile) {  
//Anne's note - this reads in the xml file named in the 'function call' line in html, then creates an object called xmlDoc to store the xml data
	// code for Mozilla, Firefox, Opera, etc.
	if (document.implementation && document.implementation.createDocument)
	{
		if (debug) alert('Loading '+xmlFile);
		xmlDoc = document.implementation.createDocument("", "", null);
		if (debug) alert('xmlDocument created: '+xmlDoc);
		xmlDoc.onload = function() {
			if (debug) alert('Loaded '+xmlFile);
			updateQuote(xmlDoc);   
		}
	}
	// code for IE
	else if (window.ActiveXObject)
	{
		if (debug) alert('Loading '+xmlFile+' for IE');
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		if (debug) alert('xmlDocument created: '+xmlDoc);
		xmlDoc.async=false;
		xmlDoc.onreadystatechange = function () {
			if (xmlDoc.readyState == 4) {
				if (debug) alert('Loaded '+xmlFile);
				updateQuote(xmlDoc);   
// Anne's note:  calling function "updateQuote" - and telling it to use object called xmlDoc
			}
		};             
// Anne's note:  now it's an object called xmlDoc and it can have properties and be manipulated by the js
	}
	else
	{
		return;
	}
	xmlDoc.load(xmlFile);
}

function updateQuote(xmlDoc) {      
// Anne's note - this is the bit that actions the entry into the html page
	if (debug) alert('Updating the page');
	var quoteNo= Math.round(Math.random() * (xmlDoc.getElementsByTagName("banner").length-1));  
// Anne note - creates rand num based on num of elements called Banner it finds, then converts e.g. 1 to 0 (first array number) and length here translates to object number
//	quoteNo = 0;
	if (debug) alert('Using Banner No '+quoteNo);
	document.getElementById("banner").innerHTML = 
// Anne note innerHTML tells it to put it between the tags e.g. p or div and below is what it writes in to the html 
				'<img src="'+xmlDoc.getElementsByTagName("image")[quoteNo].childNodes[0].nodeValue+'" />\n'+
				'<p>'+xmlDoc.getElementsByTagName("quote")[quoteNo].childNodes[0].nodeValue+'</p>\n'+
                        '<h1>'+xmlDoc.getElementsByTagName("name")[quoteNo].childNodes[0].nodeValue+'</h1><div style="clear:both"></div>\n';
				
}