function trimAll(sString)
{	while (sString.substring(0,1) == '/')
	{	sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == '/')
	{	sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
var xmlhttp

function loadXMLDoc(url)
{
xmlhttp=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change
  xmlhttp.open("GET",url,true)
  xmlhttp.send(null)
  }
else
  {
  alert("Your browser does not support XMLHTTP.")
  }
}

// Set Nav Variables Here:

// 1st Level 
//Navigation Bar Height
var linkHeight = 18;


// 2nd Level
// Navigation Bar Height
var linkHeight2 = 13;

// Indent
var indent2 = 13;

var dotsWidth = 160;


// 3rd Level
// Navigation Bar Height
var linkHeight3 = 22;
// Indent
var indent3 = 26;


function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
    {   	var navbarHTML = "";
			var navbar = document.getElementById("navbar");
			var directory = trimAll(window.location.pathname);
			if (directory.indexOf('.') > 0)
			{	directory = directory.substring(0, directory.indexOf('.'));
				directory = directory.substring(0, directory.lastIndexOf('/'));
			}
			var location = window.location;
			//alert(location);
			var directory2, directory3;
			var xmlDoc = xmlhttp.responseXML;
			var links = xmlDoc.documentElement.getElementsByTagName("link");
			var folderStructure = directory.split('/');
			for (var i = 0; i < links.length; i++) 
	        {	if ((links[i].getAttribute("title").length > 0) && (links[i].getAttribute("location").length > 0))
		 		{   if (trimAll(links[i].getAttribute("location").toLowerCase()) == folderStructure[0])
					{	navbarHTML = navbarHTML + "<strong>"
					}
					navbarHTML = navbarHTML + "<a href='" + "/" + links[i].getAttribute("location") + "'>"
											+ "<span class='navBox' style='line-height:" + linkHeight + "pt;'>" 
											+ links[i].getAttribute("title") 
											+ "</a></span><br><img src='/template/images/dots.gif' width='" + dotsWidth + "' height='2'><br>"
					if (trimAll(links[i].getAttribute("location").toLowerCase()) == folderStructure[0])
					{	navbarHTML = navbarHTML + "</strong>"
					}
					// Construct 2nd Level
					directory2 = trimAll(links[i].getAttribute("location")).toLowerCase()
					if (directory2 == folderStructure[0])
					{	var subs = links[i].getElementsByTagName("sub1");
						for (var j = 0; j < subs.length; j++) 
		        			{	if (trimAll(subs[j].getAttribute("location").toLowerCase()) == folderStructure[1])
								{	navbarHTML = navbarHTML + "<strong>"
								}
								if (folderStructure.length == 3)
								{	navbarHTML = navbarHTML + "<img src='/template/images/blank.gif' width='" + indent2 + "' height='0'><a href='" 
												+ "../../" + trimAll(subs[j].getAttribute("location")).toLowerCase() + "/'>"
												+ "<span class='navBox2' style='line-height:" + linkHeight2 + "pt;'>" 
												+ subs[j].getAttribute("title") 
												+ "</a></span><br><img src='/template/images/dots.gif' width='" + dotsWidth + "' height='2'><br>"
								}
								else if (folderStructure.length == 2)
								{	navbarHTML = navbarHTML + "<img src='/template/images/blank.gif' width='" + indent2 + "' height='0'><a href='" 
												+ "../" + trimAll(subs[j].getAttribute("location")).toLowerCase() + "/'>"
												+ "<span class='navBox2' style='line-height:" + linkHeight2 + "pt;'>" 
												+ subs[j].getAttribute("title") 
												+ "</a></span><br><img src='/template/images/dots.gif' width='" + dotsWidth + "' height='2'><br>"
								}
								else if (folderStructure.length == 1)
								{	navbarHTML = navbarHTML + "<img src='/template/images/blank.gif' width='" + indent2 + "' height='0'><a href='" 
												+ "./" + trimAll(subs[j].getAttribute("location")).toLowerCase() + "/'>"
												+ "<span class='navBox2' style='line-height:" + linkHeight2 + "pt;'>" 
												+ subs[j].getAttribute("title") 
												+ "</a></span><br><img src='/template/images/dots.gif' width='" + dotsWidth + "' height='2'><br>"
								}
								else
								{	navbarHTML = navbarHTML + "<img src='/template/images/blank.gif' width='" + indent2 + "' height='0'><a href='" 
												+ "/" + trimAll(subs[j].getAttribute("location")).toLowerCase() + "/'>"
												+ "<span class='navBox2' style='line-height:" + linkHeight2 + "pt;'>" 
												+ subs[j].getAttribute("title") 
												+ "</a></span><br><img src='/template/images/dots.gif' width='" + dotsWidth + "' height='2'><br>"
								}
								if (trimAll(subs[j].getAttribute("location").toLowerCase()) == folderStructure[1])
								{	navbarHTML = navbarHTML + "</strong>"
								}
								// Construct 3rd Level
								directory3 = trimAll(subs[j].getAttribute("location")).toLowerCase()
								//alert("directory3: " + directory3 + " folderStructure[1]: " + folderStructure[1])
								if (directory3 == folderStructure[1])
								{	var subs2 = subs[j].getElementsByTagName("sub2");
									for (var k = 0; k < subs2.length; k++) 
				        			{	if (trimAll(subs2[k].getAttribute("location").toLowerCase()) == folderStructure[2])
										{	navbarHTML = navbarHTML + "<strong>"
										}
										if (folderStructure.length == 3) 
										{ navbarHTML = navbarHTML + "<img src='/template/images/blank.gif' width='" + indent3 + "' height='0'><a href='" 
														+ "../" + trimAll(subs2[k].getAttribute("location")).toLowerCase() + "/'>"
														+ "<span class='navBox2' style='line-height:" + linkHeight3 + "pt;'>" 
														+ subs2[k].getAttribute("title") 
														+ "</a></span><br><img src='/template/images/dots.gif' width='" + dotsWidth + "' height='2'><br>"
										}
										else if (folderStructure.length == 2) 
										{ navbarHTML = navbarHTML + "<img src='/template/images/blank.gif' width='" + indent3 + "' height='0'><a href='" 
														+ "./" + trimAll(subs2[k].getAttribute("location")).toLowerCase() + "/'>"
														+ "<span class='navBox2' style='line-height:" + linkHeight3 + "pt;'>" 
														+ subs2[k].getAttribute("title") 
														+ "</a></span><br><img src='/template/images/dots.gif' width='" + dotsWidth + "' height='2'><br>"
										}
										else
										{ 	navbarHTML = navbarHTML + "<img src='/template/images/blank.gif' width='" + indent3 + "' height='0'><a href='" 
														+ "/" + trimAll(subs2[k].getAttribute("location")).toLowerCase() + "/'>"
														+ "<span class='navBox2' style='line-height:" + linkHeight3 + "pt;'>" 
														+ subs2[k].getAttribute("title") 
														+ "</a></span><br><img src='/template/images/dots.gif' width='" + dotsWidth + "' height='2'><br>"
										}
										if (trimAll(subs2[k].getAttribute("location").toLowerCase()) == folderStructure[2])
										{	navbarHTML = navbarHTML + "</strong>"
										}
														
									}
								}					
						}
					}	
								
		 		}

			}
			navbar.innerHTML = navbarHTML + "<br>"
    }
  else
    {
    alert(xmlhttp.status + "Problem retrieving XML data")
    }
  }
}
