function CSubmenu(sm)
{
	this.child = [];
	this.parent = null;
	this.anchor = null;
	this.pl = null;

	if (document.all)
		this.ref = document.all[sm];
	else if (document.getElementById)
		this.ref = document.getElementById(sm);
	else if (document.layers)
		this.ref = document.layers[sm];
}
function CMenu(vn)
{
	this.loaded = false;
	this.varName = vn;
	this.menus = [];
	this.names = [];
	this.timerID = null;
	this.pause = 200;
	this.focus = null;

	this.addSubmenu = function func(sm, anchor, p)
	{
		var osm = new CSubmenu(sm);
		var c = this.menus.length;
		this.menus[c] = osm;
		this.names[sm] = osm;
		if (p)
		{
			p = this.names[p];
			p.child[p.child.length] = osm;
			osm.parent = p;
		}
		if (document.getElementById && document.getElementById(anchor) != null)
			osm.anchor = document.getElementById(anchor);
		else if (document.layers)
		{
			if (document.anchors[anchor] != null)
				osm.anchor = document.anchors[anchor];
			else
			{
				for (var i = 0; i < document.layers.length; i++)
				{
					if (document.layers[i].document.anchors[anchor] != null)
					{
						osm.anchor = document.layers[i].document.anchors[anchor];
						osm.pl = document.layers[i];
					}
				}
			}
		}
		else if (document.all && document.all[anchor] != null)
			osm.anchor = document.all[anchor];
	}
	this.getLeftByPage = function func0(el)
	{
		var o = el.offsetLeft;
		while ((el = el.offsetParent) != null)
			o += el.offsetLeft;
		return o;
	} // getLeftByPage(el)
	this.getTopByPage = function func1(el)
	{
		var o = el.offsetTop;
		while ((el = el.offsetParent) != null)
			o += el.offsetTop;
		return o;
	} // getTopByPage(el)
	this.getElementPos = function func4(el)
	{
		var p = new Object();
		p.x = 0;
		p.y = 0;
		if (document.all || document.getElementById)
		{
			p.x = this.getLeftByPage(el);
			p.y = this.getTopByPage(el);
		}
		else if (document.layers)
		{
			p.x = el.x;
			p.y = el.y;
		}
		return p;
	} // getElementPos(el)
	this.hideTree = function func5(sm)
	{
		var c = sm.child.length;
		for (var i = 0; i < c; i++)
			this.hideTree(sm.child[i]);
		this.hide(sm.ref);
	} // hideTree(sm)
	this.hideAll = function func6(sm)
	{
		var ar;
		if (sm)
			ar = sm.child;
		else
			ar = this.menus;
		var c = ar.length;
		for (var i = 0; i < c; i++)
			this.hide(ar[i].ref);
	} // hideAll(sm)
	this.hide = function func7(sm)
	{
		if (document.all || document.getElementById)
			sm.style.visibility = 'hidden';
		else if (document.layers)
			sm.visibility = 'hidden';
	} // hide(sm)
	this.delayHide = function func8(f)
	{
		if (f)
		{
			if (this.timerID != null)
			{
				this.timerID = null;
				this.hideAll();
			}
		}
		else
		{
			this.focus = null;
			this.timerID = window.setTimeout(this.varName + '.delayHide(true)', this.pause);
		}
	} // delayHide(f)
	this.show = function func9(sm)
	{
		if (!this.loaded)
			return;
		if (this.timerID != null)
		{
			window.clearTimeout(this.timerID);
			this.timerID = null;
		}
		this.hideAll();
		if (this.focus == null)
			this.focus = this.names[sm];
		this.showNode(this.focus);
	} // show(sm)
	this.showNode = function func10(sm)
	{
		if (sm.parent != null)
			this.showNode(sm.parent);
		var p = this.getElementPos(sm.anchor);
		if (document.all || document.getElementById)
		{
			// NN6 & IE5 & IE4
			var dx = 0;
			if (sm.parent)
				dx = sm.anchor.offsetWidth;
			var sl = document.body.scrollLeft;
			var sr = document.body.scrollLeft + document.body.clientWidth;
			if (p.x - sl > document.body.offsetWidth/2)
			{
				if (sm.parent == null)
					dx = sm.anchor.offsetWidth - sm.ref.offsetWidth;
				else
					dx = -sm.ref.offsetWidth;
			}
			if (p.x + dx + sm.ref.offsetWidth > sr)
				dx = sr - p.x - sm.ref.offsetWidth;
			if (p.x + dx < sl)
			{
				dx = sl - p.x;
				if (sm.parent != null)
					dx += sm.anchor.offsetWidth;
			}
			sm.ref.style.left = p.x + dx + 'px';
			sm.ref.style.top = p.y + 'px';
			var node = sm.ref.style.visibility = 'visible';
		}
		else if (document.layers)
		{
			// NN4
			if (sm.pl != null)
			{
				p.x += sm.pl.pageX;
				p.y += sm.pl.pageY;
			}
			var dx = 0;
			if (sm.parent)
				dx = sm.parent.ref.clip.width;
			var sl = window.pageXOffset;
			var sr = window.pageXOffset + window.innerWidth;
			if (p.x - sl > window.innerWidth/2)
			{
				if (sm.parent == null)
					dx = 80 - sm.ref.clip.width;
				else
					dx = -sm.ref.clip.width;
			}
			if (p.x + dx + sm.ref.clip.width > sr)
				dx = sr - p.x - sm.ref.clip.width;
			if (p.x + dx < sl)
			{
				dx = sl - p.x;
				if (sm.parent != null)
					dx += sm.parent.ref.clip.width;
			}
			sm.ref.left = p.x + dx;
			sm.ref.top = p.y;
			sm.ref.visibility = 'visible';
		}
	} // showNode(sm)
}

