// set up the navigation array, and varibales used in populating it

arItems = new Array();
var items1 = 1;
var items2 = 2;

//fucntions used to populate the navigation array

function add1stlevelitem(name,url) {
arItems[items1] = new Array(name,url);
items2 = 2;
items1++;
}

function add2ndlevelitem(name,url,image) {
arItems[items1-1][items2] = new Array(name,url,image);
items2++;
}

//images

arImages = new Array();

arImages[1] = "link.gif";
arImages[2] = "comic.gif";
arImages[3] = "photo.gif";
arImages[4] = "script.gif";
arImages[5] = "newitem.gif";
arImages[6] = "code.gif";

function buildnav(level1name,level2name) {

// Start moving through the array for the main navigation

document.write("<table class='navtable' width='180' border='0' cellpadding='0' cellspacing='0'>");
document.write("<tr>");
document.write("<td><img  src='../images/invisible.gif' width='18' height='1'></td>");
document.write("<td><img  src='../images/invisible.gif' width='18' height='1'></td>");
document.write("<td><img  src='../images/invisible.gif' width='18' height='1'></td>");
document.write("<td><img  src='../images/invisible.gif' width='126' height='1'></td>");
document.write("</tr>");
document.write("<tr>");
document.write("<td><a href='../index.html'><img  src='../images/house.gif' width='18' height='18' border='0'></a></td>");
document.write("<td colspan='3' valign='top'><div class='navdiv'><a href='../index.html' class='navunselected'>&nbsp;www.arthurwyatt.co.uk</span></div></td>");
document.write("</tr>");

for(level1=1; level1<arItems.length; level1++) {


	document.write("<tr>")

	//write the "elbow"
	
	if (level1 == arItems.length-1) {
		document.write("<td valign='top'><img src='../images/L-line.gif' width='18' height='18' alt='' border='0'></td>")
	} else {
		document.write("<td valign='top' background='../images/i-line.gif'><img src='../images/L-line.gif' width='18' height='18' alt='' border='0'></td>")
	}

	if (level1name == arItems[level1][0]) {
		
		
		// Write open folder

		document.write("<td valign='top'>")
		document.write("<a  href='" + arItems[level1][1] + "'>")
		document.write("<img src='../images/openfolder.gif' width='18' height='18' alt='' border='0'></a></td>")
		document.write("<td colspan='2' valign='top'><div class='navdiv'>")
		document.write("<a  href='" + arItems[level1][1] + "' class='navunselected'>")
		document.write(arItems[level1][0])
		document.write("</a></div></td></tr>");
		
		//write contents of folder
		
		for(level2=2; level2<arItems[level1].length; level2++) {
		
			//write the "elbow"
	
			document.write("<tr>");
			
			if (level1 == arItems.length-1) {
				document.write("<td valign='top'><img src='../images/invisible.gif' width='18' height='18' alt='' border='0'></td>")	
					} else {
				document.write("<td valign='top' background='../images/i-line.gif'><img src='../images/invisible.gif' width='18' height='18' alt='' border='0'></td>")
			}
			if (arItems[level1][level2][1] =="#") {
				if (level2 == arItems[level1].length-1) {
					document.write("<td valign='top'></td>")
						} else {
					document.write("<td valign='top' background='../images/i-line.gif'></td>")
				}

			} else {
			
				if (level2 == arItems[level1].length-1) {
					document.write("<td valign='top'><img src='../images/L-line.gif' width='18' height='18' alt='' border='0'></td>")
						} else {
					document.write("<td valign='top' background='../images/i-line.gif'><img src='../images/L-line.gif' width='18' height='18' alt='' border='0'></td>")
				}
			}
		
			if (level2name == arItems[level1][level2][1]  || level2name == arItems[level1][level2][0]) {
				//write subitem selceted
				document.write("<td valign='top'>")
				document.write("<a  href='" + arItems[level1][level2][1] + "'>")
				document.write("<img src='../images/" + arImages[arItems[level1][level2][2]]+ "' width='18' height='18' alt='' border='0'></a></td>")
				document.write("<td><div class='navdiv'>");
				document.write("<a  href='" + arItems[level1][level2][1] + "' class='navselected'>")
				document.write(arItems[level1][level2][0])
				document.write("</a></div></td></tr>");
			} else if (arItems[level1][level2][1] =="#") {
				//write label
				document.write("<td valign='top' colspan='2'>")
				document.write("<div class='navdiv'><img src='../images/invisible.gif' width='1' height='2' alt='' border='0'><br><i>");
				document.write(arItems[level1][level2][0])
				document.write("</i></div></td></tr>");
			} else {
				//write subitem unselected
				document.write("<td valign='top'>")
				document.write("<a  href='" + arItems[level1][level2][1] + "'>")
				document.write("<img src='../images/" + arImages[arItems[level1][level2][2]]+ "' width='18' height='18' alt='' border='0'></a></td>")
				document.write("<td><div class='navdiv'>");
				document.write("<a  href='" + arItems[level1][level2][1] + "' class='navunselected'>")
				document.write(arItems[level1][level2][0])
				document.write("</a></div></td></tr>");		
			}
		}
	
		
	} else {
		//write closed folder
		
		document.write("<td valign='top'>")
		document.write("<a  href='" + arItems[level1][1] + "'>")
		document.write("<img src='../images/closedfolder.gif' width='18' height='18' alt='' border='0'></a></td>")
		document.write("<td colspan='2' valign='top'><div class='navdiv'>")
		document.write("<a  href='" + arItems[level1][1] + "' class='navunselected'>")
		document.write(arItems[level1][0])
		document.write("</a></div></td></tr>");	
	}
	
	
}

document.write("</table>");

}

