// JavaScript Document
// this function will be for the practice and rehersal details

// need to initialise the variable to be used in all the script functions.
var xmlDoc, xmlObj, xmlhttp;
var x, i, container;
var pTxt = "";
var crlf = "</font><br /><font style=\"font-style: normal; color: #FF0000;\">";

function loadXML(xmlFile) {
	// Load the relevent xml File into the function and verify that it is ready.
	xmlDoc.async="false";
	xmlDoc.onreadystatechange=verify;
	xmlDoc.load(xmlFile);
	xmlObj=xmlDoc.documentElement;
}

function verify() {
	// 0 Object is not initialised
	// 1 Loading object is loading data
	// 2 Loaded object has loaded data
	// 3 Data from Object can be worked with
	// 4 Object is completely initilised
	if(xmlDoc.readyState != 4)
	{
		return false;
	}
}

function displayPractice() {
	// This is where the code will go to output the collected data into the relevent section
	if (window.XMLHttpRequest)
	{// code for IE7+,Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	//loadXML("xml_files/practice.xml");	
	xmlhttp.open("GET", "xml_files/practice.xml",false);
	xmlhttp.send();
	xmlDoc=xmlhttp.responseXML;
	
	x=xmlDoc.getElementsByTagName("session");
	i=0;
	// get the xml data
	day=(x[i].getElementsByTagName("day")[0].childNodes[0].nodeValue);
	date=(x[i].getElementsByTagName("date")[0].childNodes[0].nodeValue);
	pref=(x[i].getElementsByTagName("prefix")[0].childNodes[0].nodeValue);
	mm=(x[i].getElementsByTagName("month")[0].childNodes[0].nodeValue);
	venue=(x[i].getElementsByTagName("venue")[0].childNodes[0].nodeValue);
	ti=(x[i].getElementsByTagName("time")[0].childNodes[0].nodeValue);
	errata=(x[i].getElementsByTagName("errata")[0].childNodes[0].nodeValue);
	// manipulate the output of the xml data
	// need to set up the font style and colours
	pTxt= "<font style=\"font-style: italic; color: #0000CC;\">";
	pTxt=pTxt + "The next practice is on: " + day + " ";
	pTxt=pTxt + date + "<sup>" + pref + "</sup> ";
	pTxt=pTxt + mm + ", ";
	pTxt=pTxt + venue + ", @ ";
	pTxt=pTxt + ti + crlf;
	pTxt=pTxt + errata + "</font>";
	// output the xml data
	container=document.getElementById("showPractice")
	container.innerHTML=pTxt;
}

