
			
			
window.addEvent('domready', function() {								
	loadXML();
});

/*************************************************************************/
/*   This loads the XML  for the content on the lower part of homepage   */
/*************************************************************************/
function loadXML()
{
var timestamp = new Date();
var uri = "/fileadmin/_lcu/XML/homepage.xml";

var uniqueURI = uri + (uri.indexOf("?") > 0 ? "&" : "?")+ "timestamp="+ timestamp.getTime();
	try
	{
		if (window.ActiveXObject)
		{
			var errorHappendHere = "Check Browser and security settings";
			xmlDoc2 = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc2.async=false;
			xmlDoc2.onreadystatechange=verify;
			xmlDoc2.load(uniqueURI);
			imageRotator();
		}
		else if(window.XMLHttpRequest)
		{
			var errorHappendHere = "Error handling XMLHttpRequest request";
			var d = new XMLHttpRequest();
			d.open("GET", uniqueURI, false);
			d.send(null);
			xmlDoc2=d.responseXML;
			imageRotator();
		} else {
			var errorHappendHere = "Error.";
			xmlDoc2 = document.implementation.createDocument("","",null);
			xmlDoc2.onreadystatechange=verify;
			xmlDoc2.async=false;
			xmlDoc2.load(uniqueURI);
			xmlDoc2.onload=imageRotator();
		}
	}	
	catch(e)
	{
		//alert(errorHappendHere); 
	}
}

function verify()
{
  // 0 Object is not initialized
  // 1 Loading object is loading data
  // 2 Loaded object has loaded data
  // 3 Data from object can be worked with
  // 4 Object completely initialized
  if (xmlDoc2.readyState != 4)
  {
    return false;
  }
  return true;
}

/*********************************************************************/
/*    This function randomly grabs a photo from the file             */
/*    homepage.xml. It takes the info associated with it             */
/*    and creates innerHTML. All of this is sent to the 			 */
/*    centerColContainer div. This all happnes on page refresh       */
/*********************************************************************/

var imageRotator = function imageRotator()
{
	// create an object with all of the image nodes
	var xmlTopNodes2=xmlDoc2.getElementsByTagName("node")[0].getElementsByTagName("image"); 
	// find out how many top nodes there are
	var numTopNodes2=xmlTopNodes2.length; 
	//randomly choose a photo and the other info that goes with it to display on the homepage from the XML 
	var randomNumber = (Math.floor(Math.random()*numTopNodes2)); //This is a random number between 0 - (numTopNodes2 - 1)
	// get the value of the image source
	var newImage2 = xmlDoc2.getElementsByTagName("node")[0].getElementsByTagName("image")[randomNumber].getElementsByTagName("source")[0].childNodes[0].nodeValue;
	// get the value of the image alt text
	var newAlt2 = xmlDoc2.getElementsByTagName("node")[0].getElementsByTagName("image")[randomNumber].getElementsByTagName("altText")[0].childNodes[0].nodeValue;
	// get the value of the image text
	var newDesc2 = xmlDoc2.getElementsByTagName("node")[0].getElementsByTagName("image")[randomNumber].getElementsByTagName("description")[0].childNodes[0].nodeValue;
	// add the background image
	document.getElementById('centerColContainer').style.backgroundImage="url("+newImage2+")";
	// put everything together and display the text
	document.getElementById('centerColContainer').innerHTML = newDesc2;	
}