function getPosOffset(obj, type) {
	if (obj != null) {
		return (type == "left" ? obj.offsetLeft : obj.offsetTop) + getPosOffset(obj.offsetParent, type);
	}
	return null;
}

function submenu_show() {
	var p = document.getElementById(this["submenu_parent"]);
	var c = document.getElementById(this["submenu_child" ]);

	var top  = getPosOffset(p, "top") + p.offsetHeight - 1;
	var left = getPosOffset(p, "left");

	c.style.position   = "absolute";
	c.style.top        = top  + 'px';
	c.style.left       = left + 'px';
	c.style.visibility = "visible";

	p.style.backgroundImage = "url('../images/menu-top-on.gif')";
	p.style.backgroundRepeat = "repeat-x";
	p.style.backgroundPosition = "left top";
}

function submenu_hide() {
	var p = document.getElementById(this["submenu_parent"]);
	var c = document.getElementById(this["submenu_child"]);
	document.getElementById(c.id).style.visibility = 'hidden';

	p.style.backgroundImage = "url('../images/menu-top.gif')";
	p.style.backgroundRepeat = "repeat-x";
	p.style.backgroundPosition = "left top";
}

function at_attach(parent, child) {
	p = document.getElementById(parent);
	c = document.getElementById(child);

	p["submenu_parent"] = p.id;
	c["submenu_parent"] = p.id;
	p["submenu_child"]  = c.id;
	c["submenu_child"]  = c.id;

	c.style.position    = "absolute";
	c.style.visibility  = "hidden";

	p.onmouseover = submenu_show;
	p.onmouseout  = submenu_hide;
	c.onmouseover = submenu_show;
	c.onmouseout  = submenu_hide;

	/* Attach SubMenu Items */
	subs = c.getElementsByTagName("td");
	for (var cnt = 0; cnt < subs.length; cnt++) {
		sub = subs[cnt];
		sub.onmouseover = at_over;
		sub.onmouseout = at_out;
	}
}

function at_over() {
	tdObject = this;
	tdObject.style.background = "#829EB4";
	aObjects = tdObject.getElementsByTagName("a");
	if (aObjects.length == 1) {
		aObject = aObjects[0];
		aObject.style.color = "#FFFFFF";
		aObject.style.backgroundImage = "url('images/arrow.gif')";
		aObject.style.backgroundRepeat = "no-repeat";
		aObject.style.backgroundPosition = "0px 5px";
	}
}

function at_out() {
	tdObject = this;
	tdObject.style.background = "#BECCD6";
	aObjects = tdObject.getElementsByTagName("a");
	if (aObjects.length == 1) {
		aObjects[0].style.color = "#4C4C4C";
		aObjects[0].style.backgroundImage = "";
	}
}

function submenu_over() {
	this.style.backgroundImage = "url('../images/menu-top-on.gif')";
	this.style.backgroundRepeat = "repeat-x";
	this.style.backgroundPosition = "left top";
}

function submenu_out() {
	this.style.backgroundImage = "url('../images/menu-top.gif')";
	this.style.backgroundRepeat = "repeat-x";
	this.style.backgroundPosition = "left top";
}

function at_attach_hover(parent) {
	p = document.getElementById(parent);
	p.onmouseover = submenu_over;
	p.onmouseout  = submenu_out;
}


