/*Javascript file 
for writing 
xml event content 
to html pages
Gary Young
April 4, 2008 */


var XML_Events=null; //declare xml as empty variable
if (window.ActiveXObject)	// check if IE browser
{
XML_Events=new ActiveXObject("Microsoft.XMLDOM"); // instantiate new IE xml object if IE browser
}
else if (document.implementation.createDocument) // create new document for Mozilla, NN, Opera, etc.
{
XML_Events=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script'); // if browser are too old
}

if (XML_Events!=null) // if xml is not empty
{ 
XML_Events.async=false; // do not load page before xml loads
XML_Events.load("./xml/events.xml"); // use this source for xml content
				// dynamically write table to page for xml contents
document.write("<table width='250px' style='background-color:transparent;'>");
document.write("<tr>");
document.write("<thead></thead>");
document.write("</tr>");
// first find main element following root element of document
var x=XML_Events.getElementsByTagName("event");
for (e=0;e<x.length;e++) // iterate through event elements "e" adding 1 after each iteration
{ 
//finds name element and all allows for child elements for future development
document.write("<tr>");
document.write("<td colspan='1' align='left'><h5>Performing:");
document.write("</h5></td>");
document.write("<td style='text-align:right'><h5>");
document.write(x[e].getElementsByTagName("name")[0].childNodes[0].nodeValue);
document.write("</h5></td>");
document.write("</tr>");
//finds date element and all allows for child elements for future development
document.write("<tr>");
document.write("<td class='date' width='75px'><h5>Date:</h5></td><td align='right'>");
document.write(x[e].getElementsByTagName("date")[0].childNodes[0].nodeValue); 
document.write("</td>");
document.write("</tr>");
//finds time element and all allows for child elements for future development
document.write("<tr>");
document.write("<td class='last' width='75px'><h5>Time:</h5></td><td align='right'>");
document.write(x[e].getElementsByTagName("time")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");
//finds place element and all allows for child elements for future development
document.write("<tr>");
document.write("<td valign='top' width='75px'><h5>Location:</h5></td><td></td>");
document.write("</tr>");
document.write("<tr >");
document.write("<td colspan='2' width='100%' style='text-indent:.25in'>");
document.write(x[e].getElementsByTagName("place")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");

//finds details element and all allows for child elements for future development
document.write("<tr>");
document.write("<td valign='top' width='75px'><h5>Details:</h5></td><td></td>");
document.write("</tr>");
document.write("<tr >");
document.write("<td colspan='2' width='100%' style='text-indent:.25in'>");
document.write(x[e].getElementsByTagName("details")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");
//finds url element and writes link to page
document.write("<tr>");
document.write("<td class='link' colspan='2' align='center'><a href='");
document.write(x[e].getElementsByTagName("url")[0].childNodes[0].nodeValue);
document.write("' target='_blank' title='Google maps' >Click here for maps and directions.</a></td></td><td  width='175px'>");
document.write("</tr>");
document.write("<tr >");
document.write("<td colspan='2' width='100%' >");
document.write("</td>");
document.write("</tr>");
}
document.write("</table>");
}