<!--

/****

Menu item x level1 	= nx
Menu image x l1		= nxi

Menu x item y l2	= nx_y
Menu x image y l2	= nx_yi

image source		= di/x.gif
image source over	= di/x_over.gif
image source selected	= di/x_sel.gif

****/

var navi = null;

function NaviElement(id, thenavi) {
	this.navi = thenavi;
	this.id = id;
	this.href = null;
	this.selected = false;
	this.element = document.getElementById(this.id);
	this.imageElement = document.getElementById(this.id + 'i');
	this.originalSource = this.imageElement.src;
	this.imageBase = this.imageElement.src.substr(this.navi.host.length);
	this.imageExtension = this.imageBase.substr(this.imageBase.lastIndexOf('.'));
	this.imageBase = this.imageBase.substr(0, this.imageBase.lastIndexOf('.'));

	this.show = function() {
		this.element.style.display = 'inline';
	}

	this.hide = function() {
		this.element.style.display = 'none';
	}

	this.getParent = function() {
		if (this.level == 2) {
			return this.navi.getElement(this.id.substr(0, this.id.indexOf('_')));
		}
	}

	this.setSelected = function(status) {
		if (status) {
			this.imageElement.src = this.imageBase + '_sel' + this.imageExtension;
			this.selected = true;
			if (this.level == 1)
				this.expand();
			else
				this.getParent().expand();
		} else {
			this.imageElement.src = this.originalSource;
			this.selected = false;
			this.contract();
		}
	}

	this.expand = function() {
		for (var x=1; ;x++) {
			var tmp = document.getElementById(this.id + '_' + x);
			if (tmp == undefined)
				break;
			this.navi.getElement(tmp.id).show();
		}
	}

	this.contract = function() {
		for (var x=1; ; x++) {
			var tmp = document.getElementById(this.id + '_' + x);
			if (tmp == undefined)
				break;
			this.navi.getElement(tmp.id).hide();
		}
	}

	this.over = function() {
		if (!this.selected) {
			this.imageElement.src = this.imageBase + '_over' + this.imageExtension;
		}
	}

	this.out = function() {
		if (!this.selected) {
			this.imageElement.src = this.originalSource;
		}
	}

	this.toggle = function() {
		if (!this.selected) {
			if (this.navi.selected != null)
				this.navi.selected.toggle();
			this.setSelected(true);
			this.navi.selected = this;
		} else {
			this.setSelected(false);
			this.navi.selected = null;
		}
		return false;
	}

	if (this.id.indexOf('_') > -1) {
		this.level = 2;
		if (this.id.substr(this.id.indexOf('_')+1) == 1) {
			this.isFirst = true;
			this.imageElement.src = this.originalSource = this.imageBase + '_shadow' + this.imageExtension;
		} else {
			this.isFirst = false;
		}
	} else {
		this.level = 1;
	}

}

function Navigation() {
	this.elementsById = {};
	this.host = null;
	this.url = null;
	this.path = null;
	this.selected = null;

	this.getCurrentPage = function() {
		var path = this.url.substring(this.host.length);
		if (path.indexOf("?") > -1)
			path = path.substring(0, path.indexOf("?"));
		if (path.indexOf("#") > -1)
			path = path.substring(0, path.indexOf("#"));
		if (path == "/")
			path = "/index.html";
		return path;
	}

	this.getElement = function(id) {
		return this.elementsById[id];
	}

	this.initElements = function() {
		this.host = window.location.href.substring(0, window.location.href.indexOf('/', 8));
		this.url = window.location.href;
		this.path = this.getCurrentPage();
		var e = document.getElementsByTagName("div");
		var currentPage = this.getCurrentPage();
		for(var x=0;x<e.length;x++) {
			if(e[x].className=="l1" || e[x].className=="l2") {
				var tmp = new NaviElement(e[x].id, this);
				var hr = e[x].firstChild.getAttribute("href");
				tmp.href = hr;
				if(hr.indexOf("http://")==0)
					hr = hr.substring(this.host.length);
				if (hr == this.path) {
					this.selected = tmp;
				}
				this.elementsById[e[x].id] = tmp;
			}
		}
		if (this.selected != null) 
			this.selected.setSelected(true);
	}

	this.initElements();

	
}

function level1(id) {
	if (navi)
		navi.getElement(id).toggle();
}

function level2(id) {
	if (navi)
		navi.getElement(id).toggle();
}

function setover(id) {
	if (navi)
		navi.getElement(id).over();
}

function setout(id) {
	if (navi)
		navi.getElement(id).out();
}

function selectcurrentpage() {
	setTimeout('navi = new Navigation()', 150);
	//navi = new Navigation();
}


//-->
