// JavaScript Document
var xmlFile;
function loadCourseDetails(scheduleType)
{
	if (window.XMLHttpRequest && !(window.ActiveXObject))
	{  //Safari
		var xmlhttpWK = new window.XMLHttpRequest();
		xmlhttpWK.open("GET", "xml/course.xml", false);
		xmlhttpWK.send(null);
		xmlFile = xmlhttpWK.responseXML.documentElement;
		getCourses();
	}
	else if (window.ActiveXObject)
	{	//IE
		xmlFile = new ActiveXObject("Microsoft.XMLDOM");
		xmlFile.async = false;
		xmlFile.load("xml/course.xml");
		getCourses();
	}
	else if (navigator.userAgent.indexOf("Chrome") != -1)
	{   //Google Chrome
		var xmlhttp = new window.XMLHttpRequest();
		xmlhttp.open("GET", "xml/course.xml", false);
		xmlhttp.send(null);
		xmlFile = xmlhttp.responseXML.documentElement;
		getCourses();
	}
	else if (document.implementation && document.implementation.createDocument)
	{  //Firefox and others
		xmlFile = document.implementation.createDocument("","",null);
		xmlFile.load("xml/course.xml");
		xmlFile.onload = getCourses;
	}
	else
	{
		alert("This information is not available at this time.");
		return;
	}
	function getCourses()
	{
		if(scheduleType=="Aircraft and Avionics" || scheduleType=="Professional Development" || scheduleType=="Seminars")
		{
			var schdName;
			if (scheduleType=="Aircraft and Avionics")
			{
				schdName = '&nbsp;'+"Aircraft and Avionics Maintenance Training";
			}
			else if (scheduleType=="Professional Development")
			{
				schdName = '&nbsp;'+"Professional Development Training";
			}
			else
			{
				schdName = '&nbsp;'+"Seminars";
			}
			var allTypes = xmlFile.getElementsByTagName("type");
			for (var i=0; i<allTypes.length; i++)
			{
				if (scheduleType == xmlFile.getElementsByTagName("type")[i].firstChild.nodeValue)
				{
					document.getElementById("scheduleDetails").style.display = "block";
					var courseDetails;
					courseDetails = '<table width="845" align="center" border="3" cellspacing="0" cellpadding="1">';
					courseDetails += '<tr>';
					courseDetails += '<td colspan="3"><div align="left" style="background-color:#DDD; color:#00F; font-size: 16px; font-weight:bold;">'+schdName+'</div></td>';
					courseDetails += '</tr>';
					courseDetails += '<tr>';
					courseDetails += '<th scope="col"><div align="center" style="background-color:#DDD; color:#000;">Title</div></th>';
					courseDetails += '<th scope="col"><div align="center" style="background-color:#DDD; color:#000;">Location</div></th>';
					courseDetails += '<th scope="col"><div align="center" style="background-color:#DDD; color:#000;">Date</div></th>';
					courseDetails += '</tr>';
					break;
				}
			}
			var clr = "#FFF";
			for (var j=0; j<allTypes.length; j++)
			{
				if (scheduleType == xmlFile.getElementsByTagName("type")[j].firstChild.nodeValue)
				{
					courseDetails += '<tr>';
					if (xmlFile.getElementsByTagName("title")[j].hasChildNodes()) {
						courseDetails += '<td><div align="center" style="background-color:'+clr+'; color:#000">'+xmlFile.getElementsByTagName("title")[j].firstChild.nodeValue+'</div></td>';
					}
					if (xmlFile.getElementsByTagName("location")[j].hasChildNodes()) {
						courseDetails += '<td><div align="center" style="background-color:'+clr+'; color:#000">'+xmlFile.getElementsByTagName("location")[j].firstChild.nodeValue+'</div></td>';
					}
					if (xmlFile.getElementsByTagName("date")[j].hasChildNodes()) {
						courseDetails += '<td><div align="center" style="background-color:'+clr+'; color:#000">'+xmlFile.getElementsByTagName("date")[j].firstChild.nodeValue+'</div></td>';
					}
					courseDetails += '</tr>';
					if (clr == "#FFF")
					{
						clr = "#CCF";
					}
					else
					{
						clr = "#FFF";
					}
				}
			}
			courseDetails += '</table>';
			document.getElementById("scheduleDetails").innerHTML = courseDetails;
			if (navigator.userAgent.indexOf("MSIE 6") != -1)
			{
				var newHeight = document.getElementById("wrapper").offsetHeight;
				var newFooterPos = newHeight - 34;
				document.getElementById("footer").style.top = newFooterPos+"px";
			}
		}
	}
}
