function DDropMenu() {
	this.lists = new Array;

	this.addList = function(list) {
		this.lists.push(list);
	}
}

function DDropList(link, name) {
	this.link = link;
	this.name = name;
	this.links = new Array;

	this.addLink = function(link) {
		this.links.push(link);
	}
}

function DDropLink(link, name) {
	this.link = link;
	this.name = name;
}

window.onload = function() {
		var nav = document.getElementById('navigation');

		var fnMouseOver = function() {
			for (j=0; j<this.childNodes.length; j++) {
				subdiv = this.childNodes[j];
				//if (subdiv.nodeName=='DIV') {
				//	subsubdiv = subdiv.childNodes[0];
				if (subdiv.nodeName=="UL") {
					subdiv.style.display = 'block';
				}
			}
		}

		var fnMouseOut = function() {
			for (j=0; j<this.childNodes.length; j++) {
				subdiv = this.childNodes[j];
				//if (subdiv.nodeName=='DIV') {
				//	subsubdiv = subdiv.childNodes[0];
				if (subdiv.nodeName=="UL") {
					subdiv.style.display = 'none';
				}
			}
		}

		for (var i = 0; i < menu.lists.length; i++) {
			var div = document.createElement('div');
			div.onmouseover = fnMouseOver;
			div.onmouseout = fnMouseOut;
			var link = document.createElement('a');
			link.setAttribute('href',menu.lists[i].link);
			link.setAttribute('id','link'+i);
			link.appendChild(document.createTextNode(menu.lists[i].name));

			if (menu.lists[i].links.length > 0) {
				var ul = document.createElement('ul');
				for (var j = 0; j < menu.lists[i].links.length; j++) {
					var li = document.createElement('li');
					var lnk = document.createElement('a');
					lnk.setAttribute('href', menu.lists[i].links[j].link);
					lnk.appendChild(document.createTextNode(menu.lists[i].links[j].name));
					li.appendChild(lnk);
					ul.appendChild(li);
				}
				div.appendChild(ul);
			}

			div.appendChild(link);
			document.getElementById('navigation').appendChild(div);
		}
	}

var menu = new DDropMenu();
var lstHome = new DDropList('index.html','Home');
menu.addList(lstHome);

var lstProgramme = new DDropList('programme.html','Programme');
menu.addList(lstProgramme);

var lstEvents = new DDropList('#','Other Events');
lstEvents.addLink(new DDropLink('events-local.html','Local'));
lstEvents.addLink(new DDropLink('events-nationwide.html','Nationwide'));
menu.addList(lstEvents);

var lstLinks = new DDropList('#','Links');
lstLinks.addLink(new DDropLink('links-groups.html','BIFG Groups'));
lstLinks.addLink(new DDropLink('links-other.html','Other Links'));
menu.addList(lstLinks);

var lstMiscellaneous = new DDropList('#','Miscellaneous');
lstMiscellaneous.addLink(new DDropLink('miscellaneous-album.html','Album'));
menu.addList(lstMiscellaneous);

var lstAbout = new DDropList('#','About');
lstAbout.addLink(new DDropLink('about-bifg.html','About BIFG'));
lstAbout.addLink(new DDropLink('about-history.html','History'));
menu.addList(lstAbout);

var lstNews = new DDropList('news.html','News');
menu.addList(lstNews);

var lstContact = new DDropList('contact.html','Contact');
menu.addList(lstContact);
