// JavaScript Document
// author: Tom Walsh
// date: 3/29/2010
// getEvents accepts the name of an XML document with the following schema:
//
//<?xml version="1.0" ?>
//<month Name>
//	<event>
//		<show>Show name</show>
//		<!-- dates format: month ##-## year -->
//		<dates>show dates</dates>
//		<location>show location</location>
//		<url>show or sponsor url</url>
//	</event>
//</month Name>
//
// it reads the XML file then writes a CSS <div class='event'></div>
// back to the page.

function getEvents(sfileName)
{
    var xmlDoc=null;
    if (window.ActiveXObject)
    {   // code for IE
	   xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    }
    else if (document.implementation.createDocument)
    {   // code for Mozilla, Firefox, Opera, etc.
    	xmlDoc=document.implementation.createDocument("","",null);
    }
    else
    {
    	alert('Your browser cannot handle this script');
    }
    if (xmlDoc!=null) 
    {
    	xmlDoc.async=false;
    	xmlDoc.load(sfileName);
        var x=xmlDoc.getElementsByTagName("event");
		
    	// display css begin
    	
    	
        for (var i=0;i<x.length;i++)
    	{
    		document.write("<div class='event'>");
            document.write("<p>");
            document.write(x[i].getElementsByTagName("show")[0].childNodes[0].nodeValue);
            document.write("</p>");
            document.write("<p class='bold'>");
            document.write(x[i].getElementsByTagName("dates")[0].childNodes[0].nodeValue);
            //document.write(" - ");
            document.write("</p>");
            document.write("<p>");
            document.write(x[i].getElementsByTagName("location")[0].childNodes[0].nodeValue);
            document.write("</p>");
            document.write("<p>");
            document.write("<a href='");
            document.write(x[i].getElementsByTagName("url")[0].childNodes[0].nodeValue);
            document.write("'>");
            //document.write(x[i].getElementsByTagName("url")[0].childNodes[0].nodeValue);
            document.write(x[i].getElementsByTagName("show")[0].childNodes[0].nodeValue);
            document.write("</a>");
            document.write("</p>");
            document.write("</div>");
        }	
 	}
}

