
function subMenuCreate(parentObj, childObj, activeObj, activation, menuAlignment, cursor) {
//INITIALIZE objects to ensure proper use
	if((typeof(parentObj)!="undefined") && $(parentObj)) {
		parentObj = $(parentObj);
	}
	if((typeof(childObj)!="undefined") && $(childObj)) {
		childObj = $(childObj);
	}
	if((typeof(activeObj)!="undefined") && $(activeObj)) {
		activeObj = $(activeObj);
	}
//LINK object relationships
	if((typeof(parentObj.id)!="undefined") && $(parentObj.id)) {
		childObj.mParent = parentObj.id;
		activeObj.mParent = parentObj.id;
	}
	if((typeof(childObj.id)!="undefined") && $(childObj.id)) {
		activeObj.mChild = childObj.id;
		//ability to perform same funcs as activeObj
		//childObj.mChild = childObj.id;
	}
//ALIGN specification for new menu
	if((typeof(menuAlignment)!="undefined")) {
		childObj.mAlign = menuAlignment;
	}
	else {
		childObj.mAlign = "y";
	}
	//alert(childObj.id);
//STYLE submenu properly
	$S(childObj).position	= "absolute";
	$S(childObj).visibility	= "hidden";
	$S(childObj).display	= "none";
//SET cursor on menu activator
	if (typeof(cursor) != "undefined") $S(activeObj).cursor = cursor;

	childObj.timeFunc = "setTimeout(function(){$S('"+childObj.id+"').visibility = 'hidden'; $S('"+childObj.id+"').display = 'none';}, 200);";
	switch (activation) {
		case "click":
			activeObj.onclick		= subMenuToggle;
			activeObj.onmouseout	= subMenuHide;
			childObj.onmouseover	= subMenuShow;
			childObj.onmouseout		= subMenuHide;
			break;
		default:
		case "hover":
			if(document.attachEvent) {
				activeObj.onmousemove = activeObj.onmouseover;
				activeObj.onmouseenter = subMenuShow;
				activeObj.onmouseleave = subMenuHide;
				//activeObj.attachEvent("onmouseover", subMenuShow);
				//activeObj.firstChild.attachEvent("onmouseover", subMenuShow);
				//activeObj.attachEvent("onmouseout", subMenuHide);	
			}
			else {
				activeObj.addEventListener("mouseover", subMenuShow,false);
				activeObj.firstChild.addEventListener("mouseover", subMenuShow,false);
				activeObj.addEventListener("mouseout", subMenuHide,false);
			}
			childObj.onmouseover	= subMenuShow;
			childObj.onmouseout		= subMenuHide;
			break;
	}
	return false;

	function subMenuShow() {
		var parentObj = this;
		if(parentObj.id=="") parentObj=$(parentObj.parentNode.id);
		if(typeof(parentObj.mChild)!=="undefined") {
			var childObj = $(parentObj.mChild);
			clearTimeout(childObj.mTimeout);
		}
		clearTimeout(parentObj.mTimeout);
		subMenuActivate(parentObj.mParent, parentObj.mChild,parentObj);
		while (parentObj != null) { 
			clearTimeout(parentObj.mTimeout);
			if(typeof(parentObj.mParent)!="undefined") {
				parentObj = $(parentObj.mParent); 
			}
			else break;
		}
		return false;
	}

	function subMenuToggle() {
		var parentObj = $(this.mParent);
		var childObj = $(this.mChild);
		if ($S(childObj).visibility != "visible") subMenuActivate(this.mParent, this.mChild);
		else { $S(childObj).visibility = "hidden"; $S(childObj).display = "none"; }
		return false;
	}

	function subMenuHide() {
		var childObj = this;
		while (childObj !==null) { 
			childObj.mTimeout = eval(childObj.timeFunc);
			if(typeof(childObj.mChild)!="undefined") {
				childObj = $(childObj.mChild); 
			}
			else break;
		}
		return false;
	}

	function subMenuActivate(mParent, mChild,activeObj) {
		var parentObj = $(mParent);
		var childObj = $(mChild);
		var UCSElement = UCS(activeObj,"PROPERTIES");
		//alert(parentObj.mAlign);
		if(typeof(parentObj.mAlign)!=="undefined") {
			var left = (parentObj.mAlign=="x")?UCSElement["POSITION"]["x"]:UCSElement["POSITION"]["x"]+UCSElement["POSITION"]["w"];
			var top = (parentObj.mAlign=="x")?UCSElement["POSITION"]["y"]+UCSElement["POSITION"]["h"]:+UCSElement["POSITION"]["y"];
		}
		else { var top = 0; var left = 0; }
		//$S(childObj).position   = "absolute";
		$S(childObj).top        = top	+ "px";
		$S(childObj).left       = left	+ "px";
		$S(childObj).visibility = "visible";
		$S(childObj).display	= "block";
		return false;
	}
}

function subMenuPositioning(childObj,posType){
	if((typeof(childObj)!="undefined") && $(childObj)) {
		childObj = $(childObj);
		$S(childObj).position = posType;
	}
	return false;
}
