/* load an existing document */
try
	{
    	 document_image_list = document.implementation.createDocument("","root",null);
  	}
catch(error)
  	{
  	 try  /* Microsoft insist on being fucktards with Internet Explorer; so I have to do this */
    	 	{
  		 document_image_list = new ActiveXObject("Microsoft.XMLDOM");
    		}
  	 catch(error) 
		{
	        document.write("This page did not load correctly. Here is the error: " + error.message);
	  	}
	}
 	
try
  	{
  	 document_image_list.async = false;
  	 document_image_list.load("../documents/image_list.xml");
        parse_images(document_image_list.getElementsByTagName("*"));
  	}
catch(error) 
	{
	 document.write("This page did not load correctly. Here is the error: " + error.message);
	}


function parse_images(tag_list)
{
 /* I'm going to format and display all the precategorized images, by what else... category */
 var element_counter = 0;
 var indentation = "";
 var image_directory = "";

 /* Get a directory listing and all images that belong inside of that directory.  List the directory and link the images  */
 do
 {
  switch(tag_list[element_counter].nodeName)
  {
   case "image_list":
    element_counter++;  
    break;    
   case "image":
    document.write("<a href=" + tag_list[element_counter].childNodes[0].nodeValue + " target=_blank>" + "<img src=" + tag_list[element_counter].childNodes[0].nodeValue + " /></a> ");
    element_counter++;
    break;
   default:
    if(tag_list[(element_counter + 1)].nodeName !== "image")
    {
    indentation = ""; 
    }
    document.write("<br />" + indentation + tag_list[element_counter].nodeName + "<br />");
    element_counter++;  
    while(tag_list[element_counter].nodeName !== "image")  
    {
     indentation = indentation + ".";
     document.write(indentation + tag_list[element_counter].nodeName + "<br />");
     element_counter++;  
    } 
  }
 }
 while(element_counter < tag_list.length)
}
