var xmlDoc

function loadXML() 
{
	//Code for IE
	if (window.ActiveXObject)
	{
		  xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		  xmlDoc.async=false;
		  xmlDoc.load("visitors.xml");
		  doCall()
	}

	//Code for Mozilla
	else if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc=document.implementation.createDocument("","visitors",null);
		xmlDoc.load("visitors.xml");
		xmlDoc.onload=doCall
	}
	else
	{
		alert('Your browser cannot handle this script');
	}
}

function doCall()
{
	displayXML("2008");
}

function getXML(name, i)
{
	xmlValue = xmlDoc.getElementsByTagName(name)[i].firstChild;

	if (xmlValue != null)
	{
		return xmlValue.data;
	}
	else
	{
		return '';
	}
}

function displayXML(urlYear)
{
	if (urlYear == '')
	{
		urlYear = "2008";
	}
	document.getElementById("visitors").innerHTML = "";
	for(i = 0; i < xmlDoc.getElementsByTagName("visitor").length; i++)
	{
		if (getXML("date", i).indexOf(urlYear) >= 0)
		{
			var newDiv = document.createElement("DIV");
			newDiv.setAttribute("class", "visitor");
			newDiv.style.width = "575px";
			newDiv.style.marginBottom = "6em";
			newDiv.innerHTML = '<img src="images/visitors/' + getXML("image", i) + '" width="100" alt="" class="visitorImg" style="float: right; width: 100px;" />';
			newDiv.innerHTML += '<h3 style="margin-right: 110px; padding: 5px; background-color: #DDD;">' + getXML("name", i) + '<br /><span class="normal">' + getXML("date", i) + '</span></h3>';
			if (getXML("title", i) != '')
			{
				newDiv.innerHTML += getXML("title", i) + '<br />';
			}
			newDiv.innerHTML += getXML("department", i) + '<br />';
			newDiv.innerHTML += getXML("school", i) + '<br />';
			if (getXML("url", i).indexOf("mailto:") >= 0)
				newDiv.innerHTML += '<a href="' + getXML("url", i) + '">' + getXML("url", i).substr(getXML("url", i).indexOf(":")+1) + '<br />';
			else
				newDiv.innerHTML += '<a href="' + getXML("url", i) + '">' + getXML("url", i) + '<br />';
			document.getElementById("visitors").appendChild(newDiv);
		}
	}
	for (j = 2; j < 9; j++)
	{
		document.getElementById("y200" + j).style.textDecoration = "underline";
		document.getElementById("y200" + j).style.color = "#800000";
		document.getElementById("y200" + j).style.fontWeight = "normal";
	}
	document.getElementById("y" + urlYear).style.textDecoration = "none";
	document.getElementById("y" + urlYear).style.color = "black";
	document.getElementById("y" + urlYear).style.fontWeight = "bold";
}
