//////////////////////////////////////////////////////////////////////
// COPYRIGHT (C) 1999-2004 PeopleSoft(R), Inc.  All Rights Reserved //
//////////////////////////////////////////////////////////////////////

var webguiDebug = false;
function webguiDebugToggle()
{
    webguiDebug = !webguiDebug;
    if (webguiDebug)
        alert("WebGUI debug is enabled.");
    else
        alert("WebGUI debug is disabled.");
}

///////////////////////////////////////////////////////////////////////
// START OF SCRIPTS FOR COLLAPSIBLE TREES

function jdeWebGuiToggleTreeNode(domObjectID, toggleType/*unused*/, overrideExpandedURL, overrideCollapsedURL)
{
	var theToggledObject = document.getElementById(domObjectID);
	var theToggleButton = document.getElementById(domObjectID+"_BUTTON");
	if (theToggledObject.style.display == "none")
	{
		theToggledObject.style.display = "block";
		if (overrideExpandedURL)
			theToggleButton.src = overrideExpandedURL;
		else
			theToggleButton.src = getWebGUIResourcePath()+"images/treeexpanded.gif";
	}
	else
	{
		theToggledObject.style.display = "none";
		if (overrideCollapsedURL)
			theToggleButton.src = overrideCollapsedURL;
		else
		{
			var treeCollapsedImg = "images/treecollapsed";
			if (document.documentElement.dir == "rtl")
				treeCollapsedImg += "_rtl";
			treeCollapsedImg += ".gif";
			theToggleButton.src = getWebGUIResourcePath()+treeCollapsedImg;
		}
	}
}

// END OF SCRIPTS FOR COLLAPSIBLE TREES
//////////////////////////////////
// START OF SCRIPTS FOR INTERACTIVE TREES

self.webGuiInteractiveTree = new function()
{
	this.isFocusableElement = function(node)
	{
		return ( (node != null) && node.getAttribute && (node.getAttribute("arrownav") == "yes") );
	};
	this.getFirstFocusableElement = function(nodesToExamine)
	{
		for (var i=0; i<nodesToExamine.length; i++)
		{
			var currentNode = nodesToExamine[i];
			if (this.isFocusableElement(currentNode))
			{
				return currentNode; // we found it!
			}
			var firstFocusableElementInChild = this.getFirstFocusableElement(currentNode.childNodes);
			if (firstFocusableElementInChild != null)
			{
				return firstFocusableElementInChild;
			}
		}
		return null; // didn't find the element
	};
	this.getLastFocusableElement = function(nodesToExamine)
	{
		for (var i=nodesToExamine.length-1; i>=0; i--)
		{
			var currentNode = nodesToExamine[i];
			if (this.isFocusableElement(currentNode))
			{
				return currentNode; // we found it!
			}
			var lastFocusableElementInChild = this.getLastFocusableElement(currentNode.childNodes);
			if (lastFocusableElementInChild != null)
			{
				return lastFocusableElementInChild;
			}
		}
		return null; // didn't find the element
	};
	this.getDeepestChildNode = function(ancestorNode)
	{
		if (ancestorNode.hasChildNodes())
		{
			return this.getDeepestChildNode(ancestorNode.lastChild);
		}
		else
		{
			return ancestorNode;
		}
	};
	this.getPreviousFocusableElement = function(currentNode, overallParentNode)
	{
		if (currentNode == overallParentNode)
		{
			return null;
		}
		var potentialNode;
		if (currentNode.previousSibling)
		{
			potentialNode = this.getDeepestChildNode(currentNode.previousSibling);
			if (this.isFocusableElement(potentialNode))
			{
				return potentialNode;
			}
			return this.getPreviousFocusableElement(potentialNode, overallParentNode);
		}
		else if (currentNode.parentNode)
		{
			potentialNode = currentNode.parentNode;
			if (this.isFocusableElement(potentialNode))
			{
				return potentialNode;
			}
			return this.getPreviousFocusableElement(potentialNode, overallParentNode);
		}
		return null;
	};
	this.getFirstFocusableChild = function(parent)
	{
		if (parent.hasChildNodes())
		{
			var childNodes = parent.childNodes;
			for (var i=0; i<childNodes.length; i++)
			{
				var child = childNodes[i];
				if (this.isFocusableElement(child))
				{
					return child; // we found it!
				}
				var firstFocusableChild = this.getFirstFocusableChild(child);
				if (firstFocusableChild != null)
					return firstFocusableChild;
			}
		}
		return null;
	};
	this.getNextFocusableElement = function(currentNode, overallParentNode)
	{
		// examine children
		var potentialNode = this.getFirstFocusableChild(currentNode);
		if (potentialNode != null)
		{
			return potentialNode; // we found it!
		}
		
		// for each next sibling (examine it and its children)
		potentialNode = currentNode;
		while (potentialNode.nextSibling)
		{
			potentialNode = potentialNode.nextSibling;
			if (this.isFocusableElement(potentialNode))
			{
				return potentialNode; // we found it!
			}
			var firstFocusableChild = this.getFirstFocusableChild(potentialNode);
			if (firstFocusableChild != null)
			{
				return firstFocusableChild;
			}
		}
		
		// if no more siblings, go up to parents and and then use it's next siblings
		var parentNode = currentNode;
		while (parentNode.parentNode)
		{
			parentNode = parentNode.parentNode;
			if (parentNode == overallParentNode)
			{
				return null;
			}
			var sibling = parentNode;
			while (sibling.nextSibling)
			{
				sibling = sibling.nextSibling;
				potentialNode = this.getNextFocusableElement(sibling, overallParentNode);
				if (potentialNode != null)
				{
					return potentialNode;
				}
			}
		}
		
		return null;
	};
}
function doWebInteractiveKeyDown(eventElement, event, parentContainerID)
{
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	var parentContainer = document.getElementById(parentContainerID);
	var leftArrow = 37;
	var rightArrow = 39;
	if (document.documentElement.dir == "rtl")
	{
		leftArrow = 39;
		rightArrow = 37;
	}
	switch (keyCode)
	{
		case 40: /*down arrow*/
			self.currentFound = false;
			var treeRootNodes = parentContainer.childNodes;
			var foundElement = self.webGuiInteractiveTree.getNextFocusableElement(eventElement, parentContainer);
			if (foundElement == null)
			{
				foundElement = self.webGuiInteractiveTree.getFirstFocusableElement(treeRootNodes);
			}
			if (foundElement != null)
			{
				try
				{
					foundElement.focus();
				}
				catch (problem)
				{
					window.status = problem;
				}
			}
			return false;
		case 38: /*up arrow*/
			self.previousNode = null;
			var treeRootNodes = parentContainer.childNodes;
			var foundElement = self.webGuiInteractiveTree.getPreviousFocusableElement(eventElement, parentContainer);
			self.previousNode = null;
			if (foundElement == null)
			{
				foundElement = self.webGuiInteractiveTree.getLastFocusableElement(treeRootNodes);
			}
			if (foundElement != null)
			{
				try
				{
					foundElement.focus();
				}
				catch (problem)
				{
					window.status = problem;
				}
			}
			return false;
		case leftArrow:
			if (eventElement.getAttribute)
			{
				var collapseScript = eventElement.getAttribute("collapseScript");
				if (collapseScript != "null")
					eval(collapseScript);
			}
			try
			{
				event.returnValue = false;
				event.cancelBubble = true;
			}
			catch (e) {}
			return false;
		case rightArrow:
			if (eventElement.getAttribute)
			{
				var expandScript = eventElement.getAttribute("expandScript");
				if (expandScript != "null")
					eval(expandScript);
			}
			try
			{
				event.returnValue = false;
				event.cancelBubble = true;
			}
			catch (e) {}
			return false;
	}
	return true;
}

function doActivateNodeWebGUI(nodeId, parentNodeId, indentLevel, activeNodeRememberedInCookie, treeId)
{
	// these 2 global values are in text fields so the content can easily be transferred between frames
	var currentActiveTreeSectionField = document.getElementById("currentActiveTreeSection" + treeId);
	var currentActiveTreeSection = currentActiveTreeSectionField.value;
	var currentActiveTreeItemField = document.getElementById("currentActiveTreeItem" + treeId);
	var currentActiveTreeItem = currentActiveTreeItemField.value;

	if (currentActiveTreeSection != "")
	{
		try
		{
			document.getElementById(currentActiveTreeSection).className = "";
		}
		catch (problem) {}
	}
	if (currentActiveTreeItem != "")
	{
		try
		{
			document.getElementById(currentActiveTreeItem).className = "";
		}
		catch (problem) {}
	}
	if (parentNodeId == "")
	{
		currentActiveTreeSection = "";
		currentActiveTreeSectionField.value = currentActiveTreeSection;
	}
	else
	{
		currentActiveTreeSection = "node" + treeId + parentNodeId; // NODE_DIV_PREFIX
		currentActiveTreeSectionField.value = currentActiveTreeSection;
	}
	if (currentActiveTreeSection != "")
	{
		try
		{
			if (parentNodeId == nodeId)
				document.getElementById(currentActiveTreeSection).className = "treeactivesectionbottomonly";
			else
				document.getElementById(currentActiveTreeSection).className = "treeactivesection";
		}
		catch (problem)
		{
			currentActiveTreeSection = "";
			currentActiveTreeSectionField.value = currentActiveTreeSection;
		}
	}
	currentActiveTreeItem = "nodeHead" + treeId + nodeId; // NODE_HEAD_DIV_PREFIX
	currentActiveTreeItemField.value = currentActiveTreeItem;
	try
	{
		document.getElementById(currentActiveTreeItem).className = "treeactiveitem";
	}
	catch (problem)
	{
		currentActiveTreeItem = "";
		currentActiveTreeItemField.value = currentActiveTreeItem;
	}

	if (activeNodeRememberedInCookie)
	{
		jdeWebGUIsetExpirableSubCookie("webguiinteractivetree", treeId+"ActiveNodeId", nodeId, "");
		jdeWebGUIsetExpirableSubCookie("webguiinteractivetree", treeId+"ActiveParent", parentNodeId, "");
		jdeWebGUIsetExpirableSubCookie("webguiinteractivetree", treeId+"ActiveIndent", indentLevel, "");
	}
}

function doTreeIframeWebGUI(nodeId, indentLevel, nodeIconId, collapsedIconURL, expandedIconURL, toggleMode, activeNodeRememberedInCookie, treeId)
{
	doActivateNodeWebGUI(nodeId, nodeId/*parent*/, indentLevel, activeNodeRememberedInCookie, treeId);
	var childDiv = document.getElementById("treechild" + treeId + nodeId); // CHILD_DIV_PREFIX
	var expanded = (childDiv.style.display == "block");
	if (expanded && (toggleMode == 'expand'))
	{
		return;
	}
	else if (expanded)
	{
		var theToggleIcon = document.getElementById(nodeIconId);
		theToggleIcon.src = collapsedIconURL;
		childDiv.innerHTML = "";
		childDiv.style.display = "none";
	}
	else if (toggleMode == 'collapse')
	{
		return;
	}
	else
	{
		var theToggleIcon = document.getElementById(nodeIconId);
		theToggleIcon.src = expandedIconURL;
		childDiv.style.display = "block";
		var loadingIndent = indentLevel * 12; // INDENT_SIZE
		var loadingMessage = document.getElementById("loadingMessage" + treeId).value;
		childDiv.innerHTML = "<table cellpadding=0 cellspacing=0><tr><td><img src='" + getWebGUIResourcePath() + "images/spacer.gif' alt=\"\" width=" + loadingIndent + " height=3></td><td>&nbsp;" + loadingMessage + "</td></tr></table>";
	}
	var iframeDiv = document.getElementById("treeiframediv" + treeId); // IFRAME_DIV_ID
	iframeDiv.style.display = "";
	var callBackUrlPrefix = document.getElementById("callBackUrlPrefix" + treeId).value;
	var nodeIdParam = document.getElementById("nodeIdParam" + treeId).value;
	var indentLevelParam = document.getElementById("indentLevelParam" + treeId).value;
	iframeDiv.innerHTML = "<iframe tabindex=\"-1\" width=1 height=1 scrolling=no frameborder=0 src='" + callBackUrlPrefix + nodeIdParam + "=" + escape(nodeId) + "&" + indentLevelParam + "=" + escape(indentLevel) + "'></iframe>";
}

function doLoadActiveNodeWebGUI(activeNodeRememberedInCookie, treeId)
{
	try
	{
		var nodeId = jdeWebGUIgetSubCookie("webguiinteractivetree", treeId + "ActiveNodeId");
		var parentNodeId = jdeWebGUIgetSubCookie("webguiinteractivetree", treeId + "ActiveParent");
		var indentLevel = jdeWebGUIgetSubCookie("webguiinteractivetree", treeId + "ActiveIndent");
		var indentLevelInt = 0;
		if (indentLevel != "")
			indentLevelInt = parseInt(indentLevel);
		if (nodeId != "")
			doActivateNodeWebGUI(nodeId, parentNodeId, indentLevelInt, activeNodeRememberedInCookie, treeId);
	}
	catch (problem) {}
}

// END OF SCRIPTS FOR INTERACTIVE TREES
//////////////////////////////////
// START OF SCRIPTS FOR MULTISELECTS

function jdeWebGuiMultiSelectCategory(category_id, category_desc)
{
	this.category_id = category_id;
	this.category_desc = category_desc;
}

function jdeWebGuiMultiSelectItem(item_id, item_name, item_desc, category_id)
{
	this.item_id = item_id;
	this.item_name = item_name;
	this.item_desc = item_desc;
	this.category_id = category_id;
}

// END OF SCRIPTS FOR MULTISELECTS
//////////////////////////////////
// START OF SCRIPTS FOR MENUS
var g_jdeWebGUIMenuShown=false;
var g_PrevFocusedElement = null;

function jdeWebGUISaveFocusedElement(evt)
{
	g_PrevFocusedElement = document.all?document.activeElement:evt.target;
}

function jdeWebGUICheckToRestorePrevFocus()
{
	if(g_jdeWebGUIMenuShown==false && g_PrevFocusedElement)
	{	
		try{
			g_PrevFocusedElement.focus();
		}
		catch(error){
		}
		g_PrevFocusedElement = null;
	}
}

function jdeWebGUIUpdateMenuShownFlag()
{
	if(jdeWebGUIGetMenuStackDepth() >0 )
		g_jdeWebGUIMenuShown = true;
	else
		g_jdeWebGUIMenuShown = false;
}

function jdeWebGUIOnMenuUpKey()
{
	var activeMenuItem = jdeWebGUIGetActiveMenuItem();
	if(activeMenuItem != null)
	{
		var nextElement = jdeWebGUIGetPreviousVisibleElementWithFlag(activeMenuItem, "jdeMenuHighlightable", "yes");
		if(nextElement != null){
			jdeWebGUIHighlightMenuItem(nextElement);
			return true;	
		}
	}
	return false;	
}

function jdeWebGUIOnMenuDownKey()
{
	var activeMenuItem = jdeWebGUIGetActiveMenuItem();
	if(activeMenuItem != null)
	{
		var nextElement = jdeWebGUIGetNextVisibleElementWithFlag(activeMenuItem, "jdeMenuHighlightable", "yes");
		if(nextElement != null){
			jdeWebGUIHighlightMenuItem(nextElement);
			return true;
		}
	}
	return false;	
}

function jdeWebGUIOnMenuExpandKey()
{
	var activeMenuItem = jdeWebGUIGetActiveMenuItem();
	if(activeMenuItem != null)
	{
		var subMenuId = activeMenuItem.getAttribute("id");
		//truncate the substring "-show" to get the ID of the submenu
		subMenuId = subMenuId.substring(0, subMenuId.lastIndexOf("-"));		
		jdeWebGUIdoToggleSubMenuOnKeyDown(activeMenuItem, subMenuId, false);				
		return true;
	}
	return false;
}

function jdeWebGUIOnMenuEnterKey()
{
	var activeMenuItem = jdeWebGUIGetActiveMenuItem();
	if(activeMenuItem != null)
	{
		if(jdeWebGUIIsElementAttributeOn(activeMenuItem, "subMenu", "yes"))
		{
			jdeWebGUIOnMenuExpandKey();
		}
		else{
			var menuItemId = activeMenuItem.getAttribute("id");
			//strip out the prefix "outer"
			menuItemId = menuItemId.substring(5);
			jdeWebGUIhideAllMenus(null, null, null);
			jdeWebGUICheckToRestorePrevFocus();
			document.getElementById(menuItemId).onclick();
		}
		return true;
	}
	return false;
}

function jdeWebGUIOnDefaultKeyDown(e)
{
	var event=document.all?window.event:e;
	jdeWebGUIhideAllMenus(null, null, null);
	jdeWebGUICheckToRestorePrevFocus();
	return true;		
}

function jdeWebGUIOnMenuKeyDown(e)
{
	var event=document.all?window.event:e;
	var cancelBubbling = false;
	
	if(g_jdeWebGUIMenuShown==false)
		return false;
		
	if(event.keyCode==38) //Up Arrow
	{
		jdeWebGUIOnMenuUpKey();
		cancelBubbling = true;
	}
	else if(event.keyCode==40) //Down Arrow
	{
		jdeWebGUIOnMenuDownKey();
		cancelBubbling = true;
	}
	else if(event.keyCode==39) //right arrow key
	{
		var activeMenuItem = jdeWebGUIGetActiveMenuItem();
		if(activeMenuItem != null)
		{
			if(jdeWebGUIIsElementAttributeOn(activeMenuItem, "subMenu", "yes"))
			{
				jdeWebGUIOnMenuExpandKey();
			}
		}
		cancelBubbling = true;
	}
	else if(event.keyCode==37) //left arrow
	{
		if(jdeWebGUIGetMenuStackDepth() > 1)
		{
			jdeWebGUIHideLastLevelMenu();
		}
		cancelBubbling = true;
	}
	else if(event.keyCode==13){  //Enter key
		jdeWebGUIOnMenuEnterKey()
		cancelBubbling = true;
	}
	else
	{
		jdeWebGUIOnDefaultKeyDown(event)
		if(event.keyCode!=17 && event.keyCode!=18) //For Ctrl and Alt key, leave it to document level
			cancelBubbling = true; 
	}
	if(cancelBubbling)
	{
		if(document.all){
			event.cancelBubble = true;
			event.returnValue = false;
		}
		else{
			event.stopPropagation();
			event.preventDefault();
        }
	}
	return cancelBubbling;
}

function jdeWebGUIexecuteLinkInFrame(linkurl, linktarget)
{
	// linktarget must be a valid frame or iframe name or nothing will happen ("_new" will not work)
	eval(linktarget + ".location=\"" + linkurl + "\"");
}

function jdeWebGUIstartMenu(menuID)
{
	writeString = "<div ID=\"" + menuID + "\" ALIGN=LEFT jdeWebGUIPopupMenu=\"yes\" style=\"display:none;position:absolute;z-index:9;\" class=MenuDropdownBack";
	if (document.documentElement.dir == "rtl")
		writeString += "_rtl";
	writeString += " onclick=\"jdeWebGUIhideAllMenus(this,'" + menuID + "', event);\">\n";
	if (document.documentElement.dir == "rtl")
		writeString += "<table ID=\"" + menuID + "_rtl\" cellpadding=0 cellspacing=0><tr><td>";
	if (!document.all)
		writeString += "<table cellpadding=0 cellspacing=0><tr><td>\n";
}

function jdeWebGUIstartSubMenu(menuID)
{
	writeString = "<div ID=\"" + menuID + "\" align=left style=\"display:none;position:absolute;z-index:9;\" class=MenuDropdownBack";
	if (document.documentElement.dir == "rtl")
		writeString += "_rtl";
	writeString +=" jdeWebGUIPopupMenu=\"yes\" onclick=\"jdeWebGUIhideAllMenus(this, '" + menuID + "', event);\">\n";
	if (document.documentElement.dir == "rtl")
		writeString += "<table ID=\"" + menuID + "_rtl\" cellpadding=0 cellspacing=0><tr><td>";
	if (!document.all)
		writeString += "<table cellpadding=0 cellspacing=0><tr><td>\n";
}

function jdeWebGUIwriteMenu()
{
	if (!document.all)
		writeString += "</td></tr></table>";
	if (document.documentElement.dir == "rtl") // workaround for Mozilla in RTL
		writeString += "</td></tr></table>";
	writeString += "</div>";
	document.writeln(writeString);
	writeString = ""; // free up the memory
}

function jdeWebGUIaddMenuItem(MenuID, MenuItemStr, MenuItemHref, Type, MenuItemID, menuAltDesc, blankAltDesc)
{
    if (Type.indexOf("DISABLEDSUB") != -1)
	{
		writeString += "<span jdeWebGUIPopupMenu=\"yes\" style=\"cursor: pointer;\" onclick=\"jdeWebGUIpreventHideAll=true;\"><table jdeWebGUIPopupMenu=\"yes\" cellpadding=0 cellspacing=0 width=100%><tr jdeWebGUIPopupMenu=\"yes\"><td style=\"width: 20px;\" width=20 jdeWebGUIPopupMenu=\"yes\"><nobr jdeWebGUIPopupMenu=\"yes\">&nbsp;<IMG jdeWebGUIPopupMenu=\"yes\" align=absmiddle border=0 width=9 height=10 SRC='"+getWebGUIResourcePath()+"images/menuitemblank.gif' alt=\"" + blankAltDesc + "\">&nbsp;</nobr></td><td jdeWebGUIPopupMenu=\"yes\" width=100% class=MenuItemDisabled><span class=MenuItemDisabled><nobr jdeWebGUIPopupMenu=\"yes\">" + MenuItemStr + "&nbsp;&nbsp;&nbsp;</nobr></span></td><td jdeWebGUIPopupMenu=\"yes\" style=\"width: 20px;\" width=20 align=right><nobr jdeWebGUIPopupMenu=\"yes\"><IMG jdeWebGUIPopupMenu=\"yes\" align=absmiddle border=0 width=9 height=10 SRC='"+getWebGUIResourcePath()+"images/submenuitemdisabled";
		if (document.documentElement.dir == "rtl")
			writeString += "_rtl";
		writeString += ".gif' alt=\"" + menuAltDesc + "\">&nbsp;</nobr></td></tr></table></span>\n";
	}
    else if (Type.indexOf("SUBMENU") != -1)
	{
		writeString += "<SPAN jdeWebGUIPopupMenu=\"yes\" jdeMenuHighlightable=\"yes\" subMenu=\"yes\" style=\"cursor: pointer;\" ID='" + MenuID + "-" + MenuItemID + "-Show' onmouseover=\"jdeWebGUIHighlightMenuItemById('"+MenuID + "-" + MenuItemID + "-Show');\" onclick=\"jdeWebGUIpreventHideAll=true;jdeWebGUIdoToggleSubMenu(this, '" + MenuID + "-" + MenuItemID + "', event);\"><table jdeWebGUIPopupMenu=\"yes\" cellpadding=0 cellspacing=0 width=100%><tr jdeWebGUIPopupMenu=\"yes\"><td style=\"width: 20px;\" width=20 jdeWebGUIPopupMenu=\"yes\"><nobr jdeWebGUIPopupMenu=\"yes\">&nbsp;<IMG jdeWebGUIPopupMenu=\"yes\" align=absmiddle border=0 width=9 height=10 SRC='"+getWebGUIResourcePath()+"images/menuitemblank.gif' alt=\"" + blankAltDesc + "\">&nbsp;</nobr></td><td jdeWebGUIPopupMenu=\"yes\" style=\"WIDTH: 100%\" class=MenuItemSubMenu ID=\"SubMenu_" + MenuItemID + "\"><span class=MenuItemSubMenu><nobr style=\"WIDTH: 100%\" jdeWebGUIPopupMenu=\"yes\">" + MenuItemStr + "&nbsp;&nbsp;&nbsp;</nobr></span><nobr><LABEL FOR=\"SubMenu_" + MenuItemID + "\"><span STYLE=\"display:none;\">&nbsp;" + Type + "&nbsp;</span></LABEL></nobr></td><td jdeWebGUIPopupMenu=\"yes\" style=\"width: 20px;\" width=20 align=right><nobr jdeWebGUIPopupMenu=\"yes\"><IMG jdeWebGUIPopupMenu=\"yes\" align=absmiddle border=0 width=9 height=10 SRC='"+getWebGUIResourcePath()+"images/submenuitem";
		if (document.documentElement.dir == "rtl")
			writeString += "_rtl";
		writeString += ".gif' alt=\"" + menuAltDesc + "\">&nbsp;</nobr></td></tr></table></SPAN>\n";
	}
    else if (Type.indexOf("SEPARATOR") != -1)
	{
		writeString += "<table width=100% cellpadding=0 cellspacing=0><tr><td jdeWebGUIPopupMenu=\"yes\" style=\"cursor: pointer;\" onclick=\"jdeWebGUIpreventHideAll=true;\"><HR style=\"cursor: pointer;\" onclick=\"jdeWebGUIpreventHideAll=true;\" jdeWebGUIPopupMenu=\"yes\" class=HR1 SIZE=1></td></tr></table>\n";
	}
    else
	{
		writeString += "<span id=\"outer" + MenuItemID+"\"";
		//Disabled item should not be hilightable
		if ( Type.indexOf("DISABLED") == -1 )
			writeString += " jdeMenuHighlightable=\"yes\"";
		writeString += ">";
		writeString += getWebGUIMenuItemInnerHTML(MenuID, MenuItemStr, MenuItemHref, Type, MenuItemID);
		writeString += "</span>\n";
	}
}

function jdeWebGUIChangeDisplayStyle(theElementID, newDisplayStyle)
{
	var theElement = document.getElementById(theElementID);
	if (theElement)
	{
		if (newDisplayStyle) // true means to show it
			theElement.style.display = "";
		else // false means to hide it
		theElement.style.display = "none";
	}
}

function getWebGUIMenuItemInnerHTML(MenuID, MenuItemStr, MenuItemHref, Type, MenuItemID)
{
	var writeString = "";

	writeString = "<table jdeWebGUIPopupMenu=\"yes\" ID=\"" + MenuItemID + "\" cellpadding=0 cellspacing=0 width=100% style=\"cursor: pointer;\"";

	if ( Type.indexOf("DISABLED") == -1 )
	{
		writeString += " onmouseover=\"jdeWebGUIHighlightMenuItemById('outer"+ MenuItemID +"');\" ";
		if (MenuItemHref.indexOf("javascript:") == -1) // not a JavaScript call
		{
			writeString += " onclick=\"self.location='";
			var hrefDelimitedItems = MenuItemHref.split("'");
			var i = 0;
			for (; i<hrefDelimitedItems.length-1; i++)
				writeString += hrefDelimitedItems[i] + "\\'";
			writeString += hrefDelimitedItems[i];
			writeString += "';\"";
		}
		else // is a JavaScript call, immediately evaluate it when clicked
		{
			writeString += " onclick=\"eval('";
			var hrefDelimitedItems = MenuItemHref.split("'");
			var i = 0;
			for (; i<hrefDelimitedItems.length-1; i++)
				writeString += hrefDelimitedItems[i] + "\\'";
			writeString += hrefDelimitedItems[i];
			writeString += "');\"";
		}
		}
		else
		{
			writeString += " onclick=\"jdeWebGUIpreventHideAll=true;\""
		}
	writeString += "><tr jdeWebGUIPopupMenu=\"yes\"><td jdeWebGUIPopupMenu=\"yes\" style=\"width: 20px;\" width=20><nobr jdeWebGUIPopupMenu=\"yes\">&nbsp;<IMG jdeWebGUIPopupMenu=\"yes\" align=absmiddle border=0 width=9 height=10 SRC='"+getWebGUIResourcePath()+"images/menuitem";
		if (Type.indexOf("DISABLEDCHECK") != -1)
			writeString += "checkdisabled";
		else if (Type.indexOf("CHECK") != -1)
			writeString += "check";
		else if (Type.indexOf("DISABLEDRADIO") != -1)
			writeString += "bulletdisabled";
		else if (Type.indexOf("RADIO") != -1)
			writeString += "bullet";
		else
			writeString += "blank";
	writeString += ".gif'>&nbsp;</nobr></td><td jdeWebGUIPopupMenu=\"yes\" style=\"width: 100%;\" class=";
		if (Type.indexOf("DISABLED") != -1)
			writeString += "MenuItemDisabled";
		else
			writeString += "MenuItem";
	writeString += "><span jdeWebGUIPopupMenu=\"yes\" CLASS=";
		if (Type.indexOf("DISABLED") != -1)
			writeString += "MenuItemDisabled";
		else
		{
			writeString += "MenuItem";
		}
	writeString += "><nobr jdeWebGUIPopupMenu=\"yes\">" + MenuItemStr + "&nbsp;</nobr></span>";
	writeString += "</td><td jdeWebGUIPopupMenu=\"yes\" style=\"width: 20px;\" width=20 align=right><img src='"+getWebGUIResourcePath()+"images/spacer.gif' alt=\"\" width=10 height=1></td></tr></table>";

	return writeString;
}

var jdeWebGUIcurrentMenu = null;
var jdeWebGUIcurrentSubMenu = null;
var jdeWebGUIbaseTriggerAbsolutePositioned = false;

var jdeWebGUIPopupMenuEventHandlerEnabled = false;
var jdeWebGUIPopupMenuEventHandlerParent = null;
var jdeWebGUIPopupMenuEventHandlerMenuID = null;
function jdeWebGUIPopupMenuEventHandler(event)
{
	if (document.all)
	{
		if (jdeWebGUIPopupMenuEventHandlerEnabled)
		{
			// check to see if we need to hide the menus or not
			if (window.event.srcElement.jdeWebGUIPopupMenu != "yes")
			{
				jdeWebGUIhideAllMenus(jdeWebGUIPopupMenuEventHandlerParent, jdeWebGUIPopupMenuEventHandlerMenuID, window.event);
			}
		}
	}
	else
	{
		if (jdeWebGUIPopupMenuEventHandlerEnabled)
		{
			// check to see if we need to hide the menus or not
			if (event.currentTarget.jdeWebGUIPopupMenu != "yes")
			{
				if (event.target.parentNode.jdeWebGUIPopupMenu != "yes") //work around for Safari
					jdeWebGUIhideAllMenus(jdeWebGUIPopupMenuEventHandlerParent, jdeWebGUIPopupMenuEventHandlerMenuID, event);
			}
		}
	}
	jdeWebGUIPopupMenuEventHandlerEnabled = true;
}

function jdeWebGUIdoMenu(Parent, MenuID)
{
    var thisMenu = document.getElementById(MenuID);

	// register the custom onclick trapping method
	jdeWebGUIPopupMenuEventHandlerEnabled = false;
	jdeWebGUIPopupMenuEventHandlerParent = Parent;
	jdeWebGUIPopupMenuEventHandlerMenuID = MenuID;
	
	if (document.all)
	{
		document.onclick = jdeWebGUIPopupMenuEventHandler;
	}
	else // Netscape's version
	{
		document.addEventListener("click", jdeWebGUIPopupMenuEventHandler, false);
	}
	
	var x, y;

	// Set dropdown menu display position
	x = Parent.offsetLeft + document.body.offsetLeft;
	y = Parent.offsetTop + Parent.offsetHeight + document.body.offsetTop;
	
	var vaParent = Parent.offsetParent;

	if (!jdeWebGUIbaseTriggerAbsolutePositioned)
	{
		while (vaParent)
		{
			x += vaParent.offsetLeft;
			y += vaParent.offsetTop;
			vaParent = vaParent.offsetParent;
		}
	}

	thisMenu.style.top  = y;
	thisMenu.style.left = x;

	thisMenu.style.clip = "rect(auto auto auto auto)";
	thisMenu.style.display = "block";
	thisMenu.style.zIndex = 2000000000; // assuming minimum 32-bit integer

	if (document.documentElement.dir == "rtl")
	{
		var rtlWrapper = document.getElementById(MenuID+"_rtl");
		var theWidth = rtlWrapper.offsetWidth;
		thisMenu.style.width = theWidth;
		
		// flip menus by changing their left positions
		x = x - (theWidth - Parent.offsetWidth);
		thisMenu.style.left = x;
	}

	hideOSDrawnControls();
	if (jdeWebGUIcurrentMenu != null) // get rid of any old menu if present 
	{
	    jdeWebGUIcurrentMenu.style.display = "none";
		removeItemShadow(jdeWebGUIcurrentMenu);
	}
	jdeWebGUIcurrentMenu = thisMenu;
	if (document.all)
	{
		jdeWebGUIcurrentMenu.setActive();
		jdeWebGUIcurrentMenu.focus();
	}
	showItemShadow(thisMenu);
}

function jdeWebGUIshowMenu()
{
	if (jdeWebGUIcurrentMenu != null)
		jdeWebGUIcurrentMenu.style.clip = "rect(auto auto auto auto)";
}

function jdeWebGUIshowSubMenu()
{
	if (jdeWebGUIcurrentSubMenu != null)
		jdeWebGUIcurrentSubMenu.style.clip = "rect(auto auto auto auto)";
}

function showItemShadow(el, maskFrame)
{
    // IE has problems with comboboxes and native controls. Putting an iframe underneath fixes it.
    if (document.all)  //IE
    {
        var itemMask = (maskFrame != null)?maskFrame:window.GlobalMaskFrame;
        itemMask.attachMask(el);
    }
	
    var elmID = el.id + "-shadow";
    var elmBorder = document.getElementById(elmID+0);
    if (elmBorder == null){
        if ( (el.style.zIndex == undefined) || (parseInt(el.style.zIndex) <= 2) ){
                el.style.zIndex = 3;
        }
        var elTop = parseInt(el.style.top);
        var elLeft = parseInt(el.style.left);
        var elWidth = el.offsetWidth;
        var elHeight = el.offsetHeight;
        var isRtl = (document.documentElement.dir == "rtl");
        var isSafari = (navigator.userAgent.toUpperCase().indexOf("SAFARI") >= 0);
        var ssTop = elTop + 1;
        var ssLeft = elLeft;
        for (var i=0; i<6; i++){
                var shade = document.createElement('div');
                var ss = shade.style;
                ss.position = "absolute";
                ss.left = ssLeft;
                ss.top = ssTop;
                if (i%2 == 0){
                        if (isRtl)
                                ssLeft--;
                        else
                                ssLeft++;
                }
                else
                        ssTop++;
                ss.width = elWidth;
                ss.height = elHeight;
                if ( !isSafari && (null != el.style.zIndex) )
                        ss.zIndex = parseInt(el.style.zIndex) - 1;
                else
                        ss.zIndex = 2;
                ss.backgroundColor = "#000000";
                webguiSetOpacity(shade,10);
                if (el.nextSibling) 
                        el.parentNode.insertBefore(shade,el.nextSibling);
                else
                        el.parentNode.appendChild(shade);
                shade.id = elmID + i;
        }
        el.style.opacity = 0.99; // fix for Safari 1.2
    }
}
function webguiSetOpacity(el, opacityPercent)
{
    el.style.opacity = (opacityPercent / 100);
    el.style.filter = "alpha(opacity=" + opacityPercent + ")"; 
    el.style.MozOpacity = (opacityPercent / 100);
}

function moveItemShadow(el)
{
    if (document.all)  //IE
    {
        var maskframe = document.getElementById(el.id + "-maskframe");
        if(null != maskframe){
                maskframe.style.top = parseInt(el.style.top);
                maskframe.style.left = parseInt(el.style.left);
                maskframe.style.width = el.offsetWidth;
                maskframe.style.height = el.offsetHeight;
        }
    }

    var elmID, elmBorder;
    elmID = el.id + "-shadow";
    var elTop = parseInt(el.style.top);
    var elLeft = parseInt(el.style.left);
    var elWidth = el.offsetWidth;
    var elHeight = el.offsetHeight;
    var isRtl = (document.documentElement.dir == "rtl");
    var ssTop = elTop + 1;
    var ssLeft = elLeft;
    for (var i=0; i<6; i++){
            elmBorder = document.getElementById(elmID+i);
            if (elmBorder != null){
                    var ss = elmBorder.style;
                    ss.left = ssLeft;
                    ss.top = ssTop;
                    if (i%2 == 0){
                            if (isRtl)
                                    ssLeft--;
                            else
                                    ssLeft++;
                    }
                    else
                            ssTop++;
                    ss.width = elWidth;
                    ss.height = elHeight;
            }
    }
}

function removeItemShadow(el, maskFrame)
{
    if (document.all)  //IE
    {
        var itemMask = (maskFrame != null)?maskFrame:window.GlobalMaskFrame;
        itemMask.detachMask();
    }
	
    var elmID, elmBorder;
    elmID = el.id + "-shadow";
    for (var i=0; i<6; i++)
    {
            elmBorder = document.getElementById(elmID+i);
            if (elmBorder != null)
            {
                    var elmBorderParent = elmBorder.parentNode;
                    elmBorderParent.removeChild(elmBorder);
            }
    }
}

var jdeWebGUIpreventHideAll = false;
var jdeWebGUImenuStack = new Array(50);

function jdeWebGUIdoToggleSubMenuOnKeyDown(Parent, MenuID, isBaseMenu)
{
	if(document.all)
	{
		Parent.click(); //mimic click to fix accessability
	}
	else
	{	
		jdeWebGUIdoToggleSubMenu(Parent, MenuID, null, isBaseMenu);
	}	
	jdeWebGUIPopupMenuEventHandlerEnabled = true;
	var menuElement = document.getElementById(MenuID);
	if(menuElement != null)
	{
		var hilightableMenuItemOuterElement = jdeWebGUIGetFirstVisibleDescendentWithFlag(menuElement, "jdeMenuHighlightable", "yes");
		if(hilightableMenuItemOuterElement != null)
		{
			jdeWebGUIHighlightMenuItem(hilightableMenuItemOuterElement);
		}
	}
}

function jdeWebGUIHighlightMenuItem(element)
{
	jdeWebGUIUnhighlightAllItemsInParentMenu(element);
	element.className = "MenuActive";
	element.setAttribute("highlighted", "yes");
}

function jdeWebGUIUnhighlightAllItemsInParentMenu(element)
{
	var siblingNodes = element.parentNode.childNodes;
	for (var i=0; i <siblingNodes.length; i++)
	{
		if(siblingNodes[i].className=="MenuActive")
		{
			jdeWebGUIUnhighlightMenuItem(siblingNodes[i]);
		}
	}
}

function jdeWebGUIHighlightMenuItemById(Id)
{
	var element = document.getElementById(Id);
	if(element)
		jdeWebGUIHighlightMenuItem(element);
}

function jdeWebGUIUnhighlightMenuItem(menuItemElement)
{
	if(menuItemElement != null)
	{
		menuItemElement.className = "MenuNormal";
		menuItemElement.removeAttribute("highlighted");
	}
}


function jdeWebGUIdoToggleSubMenu(Parent, MenuID, event, isBaseMenu)
{
	// get the real number of items in this array
	var stackSize = 0;
	while ( (jdeWebGUImenuStack[stackSize] != null) && (jdeWebGUImenuStack[stackSize] != "") && (stackSize < jdeWebGUImenuStack.length) )
	{
		stackSize++;
	}
	// determine if the stack contains this menu (so we know whether to show it or not)
	var needToShow = true;
	var menuLevel = 0;
	if (MenuID == "")
	{
		needToShow = false;
	}
	else
	{
		for (i=0; i<stackSize; i++)
		{
			if (jdeWebGUImenuStack[i] == MenuID)
				needToShow = false;
		}
		menuLevel = jdeWebGUIgetMenuLevel(MenuID);
	}
	
	// hide all submenus that are at the same level as this one or deeper
	for (j=stackSize-1; j>=0; j--)
	{
		if (jdeWebGUIgetMenuLevel(jdeWebGUImenuStack[j]) >= menuLevel)
		{
			jdeWebGUIhideMenu(Parent, jdeWebGUImenuStack[j], event);
			jdeWebGUImenuStack[j] = "";
		}
	}
	if (needToShow)
	{
		stackSize = 0;
		while ( (jdeWebGUImenuStack[stackSize] != null) && (jdeWebGUImenuStack[stackSize] != "") && (stackSize < jdeWebGUImenuStack.length) )
		{
			stackSize++;
		}
		if (isBaseMenu)
			jdeWebGUIdoMenu(Parent, MenuID, event);
		else
			jdeWebGUIdoSubMenu(Parent, MenuID, event);
		jdeWebGUImenuStack[stackSize] = MenuID;
	}
	showOSDrawnControls();
	jdeWebGUIUpdateMenuShownFlag();
}
function jdeWebGUIhideAllMenus(Parent, MenuID, event)
{
	if (jdeWebGUIpreventHideAll && event !=null)
	{
		jdeWebGUIpreventHideAll = false;
		if (!document.all)
		{
			event.stopPropagation();
			event.preventDefault();
		}
		return;
	}
	
	// get the real number of items in this array
	var stackSize = 0;
	while ( (jdeWebGUImenuStack[stackSize] != null) && (jdeWebGUImenuStack[stackSize] != "") && (stackSize < jdeWebGUImenuStack.length) )
	{
		stackSize++;
	}
	
	// hide all submenus that are at the same level as this one or deeper
    for (j=stackSize-1; j>=0; j--)
    {
        try
        {
        var thisMenu = document.getElementById(jdeWebGUImenuStack[j]);
        jdeWebGUIUnhighlightMenuItem(jdeWebGUIGetActiveItemInMenu(thisMenu));
        thisMenu.style.display = "none";
        removeItemShadow(thisMenu);
        }
        catch (problem)
        {
            // the object no longer exists on the page so let's just remove it from the stack
        }
        jdeWebGUImenuStack[j] = "";
    }
	jdeWebGUIcurrentMenu = null;
	showOSDrawnControls();
	jdeWebGUIUpdateMenuShownFlag();
}

function jdeWebGUIgetMenuLevel(MenuID)
{
	return MenuID.split("_").length;
}

function jdeWebGUIdoSubMenu(Parent, MenuID, event)
{
    var thisMenu = document.getElementById(MenuID);
	var parString = MenuID.substring(0, MenuID.lastIndexOf("-"));
    var ParentMenu = document.getElementById(parString);
    var x, y;
    var clipVal;

	// Reset dropdown menu
	jdeWebGUIcurrentSubMenu = thisMenu;

	// Set dropdown menu display position
	if (document.all)
		x  = Parent.offsetParent.style.posLeft + Parent.offsetParent.offsetWidth;
	else
		x  = parseInt(ParentMenu.style.left) + ParentMenu.offsetWidth;

    y = Parent.offsetTop + document.body.offsetTop;
	var vaParent = Parent.offsetParent;

	if (!jdeWebGUIbaseTriggerAbsolutePositioned)
	{
		while (vaParent)
		{
			y += vaParent.offsetTop;
			vaParent = vaParent.offsetParent;
		}
	}
	else
	{
		y += 15;
	}

	thisMenu.style.top  = y;
	thisMenu.style.left = x;

	thisMenu.style.clip =  "rect(auto auto auto auto)";
	thisMenu.style.display = "block";
	thisMenu.style.zIndex = 2000000000; // assuming minimum 32-bit integer

	if (document.documentElement.dir == "rtl")
	{
		var rtlWrapper = document.getElementById(MenuID+"_rtl");
		var theWidth = rtlWrapper.offsetWidth;
		thisMenu.style.width = theWidth;
		
		// flip menus by changing their left positions
		x = parseInt(ParentMenu.style.left) - theWidth;
		thisMenu.style.left = x;
	}

	if (document.all)
	{
		thisMenu.setActive();
		thisMenu.focus();
	}
	showItemShadow(thisMenu);
}

function jdeWebGUIhideMenu(Parent, MenuID, event)
{
    var thisMenu = document.getElementById(MenuID);
	if (thisMenu != null)
	{
		var cX, cY;
		var bHideMenu = true;
		//If pass in null event, that is a keydown command, hide it always
		if(event != null)
		{
		if (document.all)
		{
			cX = event.clientX + document.body.scrollLeft;
			cY = event.clientY + document.body.scrollTop;
		}
		else
		{
			cX = event.clientX + window.pageXOffset;
			cY = event.clientY + window.pageYOffset;
		}
		var x, x2, y, y2;

        // Get menu position, width and height
		if (document.all)
		{
	        x  = thisMenu.style.posLeft;
    	    y  = thisMenu.style.posTop;
		}
		else
		{
			x  = parseInt(thisMenu.style.left);
	        y  = parseInt(thisMenu.style.top);
		}
		
        x2 = x + thisMenu.offsetWidth;
        y2 = y + thisMenu.offsetHeight;

		if (cY > y-2 && cY < y2-2)
		{
			if (cX > x && cX < x2-2) bHideMenu = false;
		}
		// this prevents it from opening multiple exit menus.  32 is the size of the bitmap.
		if (cX > x + 32 && cX < x2)
		{
			if (cY < y)	bHideMenu = true;
		}

        // see if we have popped up a child menu and we are jumping over to it
        if (jdeWebGUIcurrentSubMenu != null)
        {
			if (document.all)
			{
	            if ( (cX >= jdeWebGUIcurrentSubMenu.style.posLeft && cX <= (jdeWebGUIcurrentSubMenu.style.posLeft + jdeWebGUIcurrentSubMenu.offsetWidth)) &&
   	              (cY >= jdeWebGUIcurrentSubMenu.style.posTop && cY <= (jdeWebGUIcurrentSubMenu.style.posTop + jdeWebGUIcurrentSubMenu.offsetHeight)) )
   	         {
   	             bHideMenu = false;
   	         }
			}
			else
			{
	            x  = parseInt(jdeWebGUIcurrentSubMenu.style.left);
	            y  = parseInt(jdeWebGUIcurrentSubMenu.style.top);
	
            	if( (cX >= x && cX <= (x + jdeWebGUIcurrentSubMenu.offsetWidth)) &&
            	    (cY >= y && cY <= (y + jdeWebGUIcurrentSubMenu.offsetHeight)) )
            	{
            	    bHideMenu = false;
            	}
	      }
           }
        }
		if (! bHideMenu)
		{
			return;
		}
		jdeWebGUIUnhighlightMenuItem(jdeWebGUIGetActiveItemInMenu(thisMenu));
                jdeWebGUIcurrentMenu = null;
		thisMenu.style.display = "none";
		removeItemShadow(thisMenu);
		showOSDrawnControls();
	}
}

function jdeWebGUIhideSubMenu(Parent, MenuID, event)
{
    var thisMenu = document.getElementById(MenuID);
	var parString = MenuID.substring(0, MenuID.lastIndexOf("-"));
    var ParentMenu = document.getElementById(parString);
	if (thisMenu != null)
	{
		var bHideMenu = true;
		if(event != null)
		{
		var cX, cY;
		if (document.all)
		{
			cX = event.clientX + document.body.scrollLeft;
			cY = event.clientY + document.body.scrollTop;
		}
		else
		{
			cX = event.clientX + window.pageXOffset;
			cY = event.clientY + window.pageYOffset;
		}
		var x, x2, y, y2;

	    // Get menu position, width and height
		if (document.all)
		{
	    	x  = Parent.offsetParent.style.posLeft;
	    	y  = Parent.offsetParent.style.posTop + Parent.offsetTop;

	    	x2 = x + Parent.offsetParent.offsetWidth;
			y2 = y + Parent.offsetHeight;
		}
		else
		{
			x  = parseInt(ParentMenu.style.left);
	    	y  = Parent.offsetTop;

	    	x2 = x + ParentMenu.offsetWidth;
			y2 = y + Parent.offsetHeight;
		}

		if ((cX < x2) && (cX > x ))
		{
		    if ((cY > y+2) && (cY < y2-2))
		        bHideMenu = false;
		}

		// if we are jumping back to the submenu dont hide it
	    if (document.all)
		{
			x  = thisMenu.style.posLeft;
	    	y  = thisMenu.style.posTop;
		}
		else
		{
			x  = parseInt(thisMenu.style.left);
	    	y  = parseInt(thisMenu.style.top);
		}

	    x2 = x + thisMenu.offsetWidth;
		y2 = y + thisMenu.offsetHeight;

		if ((cX <= x2 + 2) && (cX > x - 2 ))
		{
		    if ((cY > y) && (cY < y2))
		        bHideMenu = false;
		}
	      }
		if (! bHideMenu)
		{
			return;
		}

		jdeWebGUIUnhighlightMenuItem(jdeWebGUIGetActiveItemInMenu(thisMenu));
        jdeWebGUIcurrentSubMenu  = null;
		thisMenu.style.display = "none";
		removeItemShadow(thisMenu);
	}
}

function jdeWebGUIHideLastLevelMenu()
{
	var lastLevelMenuID = jdeWebGUIGetLastLevelMenuID();
	var menuDepth = jdeWebGUIGetMenuStackDepth();
	if(menuDepth == 1)
	{
		jdeWebGUIhideMenu(null, lastLevelMenuID, null);
	}
	else if(menuDepth >0){
		jdeWebGUIhideSubMenu(null, lastLevelMenuID, null);
	}
	jdeWebGUImenuStack[menuDepth-1] = "";
	jdeWebGUIUpdateMenuShownFlag();
	if(g_jdeWebGUIMenuShown == false)
		showOSDrawnControls();
	jdeWebGUICheckToRestorePrevFocus();		
	return true;
}

function jdeWebGUIGetMenuStackDepth()
{
	var stackSize = 0;
	while ( (jdeWebGUImenuStack[stackSize] != null) && (jdeWebGUImenuStack[stackSize] != "") && (stackSize < jdeWebGUImenuStack.length) )
	{
		stackSize++;
	}
	return stackSize;
}

function jdeWebGUIGetLastLevelMenuID()
{
	var menuDepth = jdeWebGUIGetMenuStackDepth();
	if(menuDepth > 0)
		return jdeWebGUImenuStack[menuDepth-1];
	else
		return null;
}

function jdeWebGUIGetActiveMenuItem()
{
	var menuDepth = jdeWebGUIGetMenuStackDepth();
	var activeItem = null;
	if(menuDepth > 0){
		var menuElement = document.getElementById(jdeWebGUIGetLastLevelMenuID());
		activeItem = jdeWebGUIGetActiveItemInMenu(menuElement);
	}
	return activeItem;	
}

function jdeWebGUIGetActiveItemInMenu(menuElement)
{
	if(menuElement != null){
		return jdeWebGUIGetFirstVisibleDescendentWithFlag(menuElement, "highlighted", "yes");
	}
	return null;	
}

function jdeWebGUIRecurseHideMenu(MenuID, event)
{
    var thisMenu = document.getElementById(MenuID);
	var Parent = document.getElementById(MenuID+'-Show');
	var bDoNotHide = false;
	
	if (thisMenu != null)
	{
		var cX, cY;
		if (document.all)
		{
			cX = event.clientX + document.body.scrollLeft;
			cY = event.clientY + document.body.scrollTop;
		}
		else
		{
			cX = event.clientX + window.pageXOffset;
			cY = event.clientY + window.pageYOffset;
		}
		var x, x2, y, y2;
		var bHideMenu = true;
        var lastIndex = -1;
        var tempStr = MenuID;
        var tempMenu;

	    // Get menu position, width and height
		if (document.all)
		{
		    x  = thisMenu.style.posLeft;
		    y  = thisMenu.style.posTop;
		}
		else
		{
			x  = parseInt(thisMenu.style.left);
	        y  = parseInt(thisMenu.style.top);
		}

	    x2 = x + thisMenu.offsetWidth;
		y2 = y + thisMenu.offsetHeight;

		if (cY < (y + Parent.offsetHeight -2) && cY > y)
		{
			if (cX >= (x2-2) && cX <= (x2 + Parent.offsetWidth - 2)) bHideMenu = false;
		}

		if (! bHideMenu)
		{
			return;
		}

		if (cY > y+2 && cY < y2-2)
		{
			if (cX > (x-3) && cX < x2-2) bHideMenu = false;
		}

        // see if we have popped up a child menu and we arejumping over to it
        if (jdeWebGUIcurrentSubMenu != null && jdeWebGUIcurrentSubMenu != thisMenu)
        {
			if (! document.all)
			{
	            if ( (cX >= jdeWebGUIcurrentSubMenu.style.posLeft && cX <= 	(jdeWebGUIcurrentSubMenu.style.posLeft + jdeWebGUIcurrentSubMenu.offsetWidth)) &&
	                 (cY >= jdeWebGUIcurrentSubMenu.style.posTop && cY <= (jdeWebGUIcurrentSubMenu.style.posTop + jdeWebGUIcurrentSubMenu.offsetHeight)) )
	            {
	                bHideMenu = false;
	            }
			}
			else
			{
	            x  = parseInt(jdeWebGUIcurrentSubMenu.style.left);
	            y  = parseInt(jdeWebGUIcurrentSubMenu.style.top);
	
            	if( (cX >= x && cX <= (x + jdeWebGUIcurrentSubMenu.offsetWidth)) &&
            	    (cY >= y && cY <= (y + jdeWebGUIcurrentSubMenu.offsetHeight)) )
            	{
            	    bHideMenu = false;
            	}
			}
        }

		if (! bHideMenu)
		{
			return;
		}

		jdeWebGUIcurrentSubMenu = null;
		thisMenu.style.display = "none";
        removeItemShadow(thisMenu);
        // now recursively start hiding the parent menus
        while (true)
        {
            lastIndex = tempStr.lastIndexOf("_");
            if (lastIndex == -1)
                break;
            // get the previous menu
            tempStr = tempStr.substring(0,lastIndex);
			tempMenu = document.getElementById(tempStr);

            // if the mouse is on the previous menu dont hide it
			if (document.all)
			{
            	if ( (cX >= tempMenu.style.posLeft && cX <= (tempMenu.style.posLeft + tempMenu.offsetWidth)) &&
            	     (cY >= tempMenu.style.posTop && cY <= (tempMenu.style.posTop + tempMenu.offsetHeight)) )
            	{
            	    bDoNotHide = true;
            	    break;
            	}
			}
			else
			{
				x  = parseInt(tempMenu.style.left);
            	y  = parseInt(tempMenu.style.top);            
            	if( (cX >= x && cX <= (x + tempMenu.offsetWidth)) &&
            	    (cY >= y && cY <= (y + tempMenu.offsetHeight)) )
            	{
            	    bDoNotHide = true;
            	    break;
            	}
			}
            // just hide the menu
            tempMenu.style.display = "none";
            removeItemShadow(tempMenu);
            showOSDrawnControls();
        }

		if (!bDoNotHide)
        {
			jdeWebGUIcurrentMenu = null;
		}
	}
}

/////Menu Key Handling

	//Check if the DOM element has the passed attribute with the passed in value 
	function jdeWebGUIIsElementAttributeOn(node, attribute, value)
	{
		return ( (node != null) && node.getAttribute && (node.getAttribute(attribute) == value) );
	}

	function jdeWebGUIGetFirstVisibleDescendentWithFlag(parent, attribute, value)
	{
		if (parent.hasChildNodes())
		{
			var childNodes = parent.childNodes;
			for (var i=0; i<childNodes.length; i++)
			{
				var child = childNodes[i];
				if(child.style && child.style.display != "none")
				{
					if (jdeWebGUIIsElementAttributeOn(child, attribute, value))
					{
						return child;
					}
				}
				var result = jdeWebGUIGetFirstVisibleDescendentWithFlag(child, attribute, value);
				if (result != null)
					return result;
			}
		}
		return null;
	}

	function jdeWebGUIGetPreviousVisibleElementWithFlag(currentNode, attribute, value)
	{
		// for each previous sibling (examine it and its children)
		var potentialNode = currentNode;
		do{
			if(potentialNode.previousSibling)
				potentialNode = potentialNode.previousSibling;
			else{ 
				potentialNode = potentialNode.parentNode.lastChild;
			}
			if(potentialNode == currentNode)
				break;
			
			if(potentialNode.style && potentialNode.style.display=="none")
				continue;
			if (jdeWebGUIIsElementAttributeOn(potentialNode, attribute, value))
			{
				return potentialNode; // we found it!
			}			
		}while (potentialNode != currentNode);	
		return null;
	}
	
	
	function jdeWebGUIGetNextVisibleElementWithFlag(currentNode, attribute, value)
	{
		// for each next sibling (examine it and its children)
		var potentialNode = currentNode;
		do{
			if(potentialNode.nextSibling)
				potentialNode = potentialNode.nextSibling;
			else{ 
				potentialNode = potentialNode.parentNode.firstChild;
			}
			if(potentialNode == currentNode)
				break;
			
			if(potentialNode.style && potentialNode.style.display=="none")
				continue;
			if (jdeWebGUIIsElementAttributeOn(potentialNode, attribute, value))
			{
				return potentialNode; // we found it!
			}			
		}while (potentialNode != currentNode);	
		return null;
	}


/////End Menu Key handling

function declareOSDrawnControl(anotherControlID)
{
}

function temporarilyExcludeOSDrawnControl(controlID)
{
}

function hideOSDrawnControls()
{
}

function showOSDrawnControls()
{

}

// END OF SCRIPTS FOR MENUS
///////////////////////////
// START OF SCRIPTS FOR COOKIES

function jdeWebGUIsetSubCookie(cookiename, subcookiename, setting)
{
	var expiration = "";
	var expire = new Date();
	expire.setTime(expire.getTime() + ( 180 * 24*60*60*1000 ) ); // expire in 180 days
	jdeWebGUIsetExpirableSubCookie(cookiename, subcookiename, setting, expire.toGMTString());
}
function jdeWebGUIsetExpirableSubCookie(cookiename, subcookiename, setting, expiration, path)
{
	var bigcookievalue = "";
	var oldbigcookie = jdeWebGUIgetCookie(cookiename, false);
	var subarray = oldbigcookie.split("&");
	for (i=0; i<subarray.length; i++)
	{
		var curVal = subarray[i].split("=");
		if (curVal.length > 1)
		{
			var curName = curVal[0];
			var curVal = unescape(curVal[1]);
			if (curName != subcookiename)
				bigcookievalue += curName + "=" + escape(curVal) + "&";
		}
	}
	
	bigcookievalue += subcookiename + "=" + escape(setting);
	
	var theCookie = cookiename + "=" + bigcookievalue + ";";
	if (!path)
		theCookie += " path=/;";
	else
		theCookie += " path=" + path + ";";

	theCookie += " " + expiration;
	document.cookie = theCookie;
}
function jdeWebGUIgetSubCookie(cookiename, subcookiename)
{
	var bigcookie = jdeWebGUIgetCookie(cookiename, false);
	var subarray = bigcookie.split("&");
	for (i=0; i<subarray.length; i++)
	{
		var curVal = subarray[i].split("=");
		if (curVal.length > 1)
		{
			var curName = curVal[0];
			var curVal = unescape(curVal[1]);
			if (curName == subcookiename)
				return curVal;
		}
	}
	return "";
}
function jdeWebGUIresetCookie(cookiename)
{
	var expire = new Date();
	expire.setTime(expire.getTime() + 1 ); // expire in 1 millisecond
	document.cookie = cookiename + "=" + escape("zzz") + "; path=/; expires=" + expire.toGMTString();
}
function jdeWebGUIsetCookie(cookiename, setting)
{
	var expire = new Date();
	expire.setTime(expire.getTime() + ( 180 * 24*60*60*1000 ) ); // expire in 180 days
	document.cookie = cookiename + "=" + escape(setting) + "; path=/; expires=" + expire.toGMTString();
}
function jdeWebGUIgetCookie(cookiename, unescapeResult)
{
	var arg = cookiename + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		{
			var endstr = document.cookie.indexOf(";", j);
			if (endstr == -1)
				endstr = document.cookie.length;
			if (unescapeResult)
				return unescape(document.cookie.substring(j, endstr));
			else
				return document.cookie.substring(j, endstr);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
	}
	return "";
}

// END OF SCRIPTS FOR COOKIES
//////////////////////////////////

///////////////////////////////////////////////////////////////
// START OF CALENDAR SCRIPTS

function jdeWebGUIshowCalendar(updateFieldId, dateSeparator, dateFormatEnum, timeFormatEnum)
{
	var dateFormat = "MDE";
	if (dateFormatEnum == "1")
		dateFormat = "EMD";
	else if (dateFormatEnum == "2")
		dateFormat = "DME";

	var utcEnabled = false;
	var utc24 = false;
	if (timeFormatEnum == "1")
		utcEnabled = true;
	else if (timeFormatEnum == "2")
	{
		utcEnabled = true;
		utc24 = true;
	}
	var windowHeight = 210;
	if (utcEnabled)
		windowHeight = 310;

	var minYear = 1500;
	var maxYear = 2500;

	var calWindow = window.open("", "jdeCalendarWindow"+updateFieldId, "height="+windowHeight+",width=240,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1" );

	// build the calendar window content
	var writeString;
	if (document.documentElement.dir == "rtl")
		writeString = "<html dir=rtl>";
	else
		writeString = "<html>";
	writeString += "\n<head>\n";
	writeString += "<title>"+jdeWebGUIcalendarStrings[0]+"</title>\n";
	writeString += "<SCRIPT LANGUAGE=\"JavaScript\" SRC='"+jdeWebGUIjavaScriptPath+"'></SCRIPT>\n";
	writeString += "<style>\n";
	writeString += "BODY {\n";
	writeString += "font-size: 9pt;\n";
	writeString += "margin-left: 0;\n";
	writeString += "margin-top: 0;\n";
	writeString += "margin-right: 0;\n";
	writeString += "margin-bottom: 0;\n";
	writeString += "font-family: Arial,Helvetica,Verdana,Sans-Serif;\n";
	writeString += "color: #000000;\n";
	writeString += "background-color: #FFFFFF;\n";
	writeString += "}\n";
	writeString += "TABLE TD {\n";
	writeString += "font-size: 9pt;\n";
	writeString += "}\n";
	writeString += "INPUT {\n";
	writeString += "font-size: 8pt;\n";
	writeString += "}\n";
	writeString += "SELECT {\n";
	writeString += "font-size: 9pt;\n";
	writeString += "}\n";
	writeString += ".textfield {\n";
	writeString += "font-size: 9pt;\n";
	writeString += "color: #000000;\n";
	writeString += "background-color: #FFFFFF;\n";
	writeString += "border-width: 1px;\n";
	writeString += "border-style: solid;\n";
	writeString += "border-top-color: #999999;\n";
	writeString += "border-bottom-color: #CCCCCC;\n";
	writeString += "border-left-color: #999999;\n";
	writeString += "border-right-color: #CCCCCC;\n";
	writeString += "}\n";
	writeString += "</style>\n";
	writeString += "</head>\n";
	if (document.documentElement.dir == "rtl")
		writeString += "<body dir=rtl";
	else
		writeString += "<body";
	writeString += " onload=\"jdeWebGUIinitToday();jdeWebGUIbuildCaln();\">\n";
	writeString += "<div id=\"calendar\" align=\"center\"></div>\n";
	writeString += "<script>\n";
	writeString += "var jdeWebGUIResourcePath = \""+getWebGUIResourcePath()+"\";\n";
	writeString += "var jdeWebGUIdateseparator = \""+dateSeparator+"\";\n";
	writeString += "var jdeWebGUIdateformat = \""+dateFormat+"\";\n";
	writeString += "var jdeWebGUIisUTimeAMPM = !"+utc24+";\n";
	writeString += "var jdeWebGUIisUTime = "+utcEnabled+";\n";
	writeString += "var jdeWebGUIcalendarTextFieldId = \""+updateFieldId+"\";\n";
	writeString += "var jdeWebGUIcalendarStrings = new Array(";
	for (var i=0; i<jdeWebGUIcalendarStrings.length; i++)
	{
		if (i > 0)
			writeString += ", ";
		writeString += "\""+jdeWebGUIcalendarStrings[i]+"\"";
	}
	writeString += ");\n";
	writeString += "var jdeWebGUI_MINYEAR = "+minYear+";\n";
	writeString += "var jdeWebGUI_MAXYEAR = "+maxYear+";\n";
	writeString += "</script>\n";
	writeString += "</body>\n</html>\n";
	
	try
	{
		calWindow.focus();
	}
	catch (problem)
	{
		// Netscape 7 may not allow this
	}
	calWindow.document.write(writeString);
	calWindow.document.close(); // close the layout stream
}

var jdeWebGUImonthdays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var jdeWebGUItodayDate;
var jdeWebGUIcurday;
var jdeWebGUIcurmonth;
var jdeWebGUIcurdate;
var jdeWebGUIcuryear;
var jdeWebGUIstartspaces;
var jdeWebGUIdays;
var jdeWebGUIcurDateObj = new Date();

function jdeWebGUIinitToday()
{
	jdeWebGUItodayDate = new Date();
	jdeWebGUIcurmonth = jdeWebGUItodayDate.getMonth();
	jdeWebGUIcurdate = jdeWebGUItodayDate.getDate();
	jdeWebGUIcuryear = jdeWebGUItodayDate.getFullYear();
	
	// Abbreviate the days
	jdeWebGUIdays = new Array(jdeWebGUIcalendarStrings[13], jdeWebGUIcalendarStrings[14], jdeWebGUIcalendarStrings[15], jdeWebGUIcalendarStrings[16], jdeWebGUIcalendarStrings[17], jdeWebGUIcalendarStrings[18], jdeWebGUIcalendarStrings[19]);
	for (var i=0; i<7; i++)
	{
		var startChar = jdeWebGUIdays[i].charAt(0);
		var need2Day = false;
		for (var j=0; j<7; j++)
		{
			if (i != j)
			{
				if (startChar == jdeWebGUIdays[j].charAt(0))
				{
					need2Day = true;
					continue;
				}
			}
		}
		if (need2Day)
			jdeWebGUIdays[i] = jdeWebGUIdays[i].substring(0,2);
		else
			jdeWebGUIdays[i] = startChar;
	}
}

function jdeWebGUIcalcCurrentValues()
{
	jdeWebGUIcurDateObj.setDate(jdeWebGUIcurdate);
	jdeWebGUIcurDateObj.setYear(jdeWebGUIcuryear);
	jdeWebGUIcurDateObj.setMonth(jdeWebGUIcurmonth);

	jdeWebGUIcurday = jdeWebGUIcurDateObj.getDay();

	if (((jdeWebGUIcuryear % 4 == 0) && !(jdeWebGUIcuryear % 100 == 0)) ||(jdeWebGUIcuryear % 400 == 0))
		jdeWebGUImonthdays[1] = 29;
	else
		jdeWebGUImonthdays[1] = 28;

	jdeWebGUIstartspaces=jdeWebGUIcurdate;

	while (jdeWebGUIstartspaces > 7)
		jdeWebGUIstartspaces-=7;

	jdeWebGUIstartspaces = jdeWebGUIcurday - jdeWebGUIstartspaces + 1;
	if (jdeWebGUIstartspaces < 0)
		jdeWebGUIstartspaces+=7;
}

function jdeWebGUIprevMonth()
{
	jdeWebGUIcurmonth--;

	if (jdeWebGUIcurmonth < 0)
	{
		jdeWebGUIcurmonth=11;
		jdeWebGUIcuryear--;
		if (jdeWebGUIcuryear < jdeWebGUI_MINYEAR)
			jdeWebGUIcuryear = jdeWebGUI_MAXYEAR;
	}
	jdeWebGUIbuildCaln();
}

function jdeWebGUInextMonth()
{
	jdeWebGUIcurmonth++;

	if (jdeWebGUIcurmonth > 11)
	{
		jdeWebGUIcurmonth=0;
		jdeWebGUIcuryear++;
		if (jdeWebGUIcuryear > jdeWebGUI_MAXYEAR)
			jdeWebGUIcuryear = jdeWebGUI_MINYEAR;
	}
	jdeWebGUIbuildCaln();
}

function jdeWebGUIprevYear()
{
	jdeWebGUIcuryear--;
	if (jdeWebGUIcuryear < jdeWebGUI_MINYEAR)
		jdeWebGUIcuryear = jdeWebGUI_MAXYEAR;

	jdeWebGUIbuildCaln();
}

function jdeWebGUInextYear()
{
	jdeWebGUIcuryear++;
	if (jdeWebGUIcuryear > jdeWebGUI_MAXYEAR)
		jdeWebGUIcuryear = jdeWebGUI_MINYEAR;

	jdeWebGUIbuildCaln();
}

function jdeWebGUIhighlightSel(field)
{
	field.style.color = "red";
}

function jdeWebGUIremHighlight(field, isWeekend)
{
	if (isWeekend)
		field.style.color = "black";//"#666666";
	else
		field.style.color = "black";
}

function jdeWebGUIremHighlightBtn(field)
{
	field.style.borderColor = "gray";
}

function jdeWebGUIsetCurDate(dateval)
{
	jdeWebGUIcurdate = dateval;
	jdeWebGUIbuildCaln();
}

function jdeWebGUIformatDate(strVal)
{
	var strDay = "" +jdeWebGUIcurDateObj.getDate(), strMonth = "", strYear = "";

	if (jdeWebGUIcurDateObj.getDate() < 10)
		strDay = "0" + jdeWebGUIcurDateObj.getDate();

	if (jdeWebGUIcurDateObj.getMonth() < 9)
		strMonth = "0" + (jdeWebGUIcurDateObj.getMonth()+1);
	else
		strMonth += (jdeWebGUIcurDateObj.getMonth()+1);

	var yrVal = jdeWebGUIcurDateObj.getYear();
	if(!document.all)
		yrVal = jdeWebGUIcurDateObj.getFullYear();
	if (jdeWebGUIdateformat.indexOf("E") != -1)
		strYear += yrVal;
	else
	{
		var yrTmp = yrVal%100;
		if (yrTmp < 10)
			strYear += "0" + yrTmp;
		else
			strYear += yrTmp;
	}
	if (jdeWebGUIdateformat == "DME" || jdeWebGUIdateformat =="DMY")
	{
		strVal = strDay + jdeWebGUIdateseparator + strMonth + jdeWebGUIdateseparator + strYear;
	}
	else if (jdeWebGUIdateformat =="EMD" || jdeWebGUIdateformat =="YMD")
	{
		strVal = strYear + jdeWebGUIdateseparator + strMonth + jdeWebGUIdateseparator + strDay;
	}
	else if (jdeWebGUIdateformat=="MDE" || jdeWebGUIdateformat=="MDY")
	{
		strVal = strMonth + jdeWebGUIdateseparator + strDay + jdeWebGUIdateseparator + strYear;
	}
	//UTime stuff
	if (jdeWebGUIisUTime)
	{
		var hrVal = new Number(document.getElementById("utimeHR").value);
		if (jdeWebGUIisUTimeAMPM )
		{
			var ampmField = document.getElementById("utimeAMPM");
			if (ampmField.innerHTML == jdeWebGUIcalendarStrings[28]) // PM
				hrVal += 12;
		}
		var theHours = ""+hrVal;
		if (theHours == "")
			theHours = "00";
		var theMinutes = ""+document.getElementById("utimeMIN").value;
		if (theMinutes == "")
			theMinutes = "00";
		var theSeconds = ""+document.getElementById("utimeSEC").value;
		if (theSeconds == "")
			theSeconds = "00";
		strVal +=" " + theHours;
		strVal +=":" + theMinutes;
		strVal +=":" + theSeconds;
		strVal +=" " + document.getElementById("utimeTZ").options[document.getElementById("utimeTZ").selectedIndex].text;
	}

	return strVal;
}

function jdeWebGUIdoAMPM(amString, pmString)
{
	var ampmField = document.getElementById("utimeAMPM");
	if (ampmField.innerHTML == amString)
		ampmField.innerHTML = pmString;
	else
		ampmField.innerHTML = amString;
}

function jdeWebGUIbuildCaln()
{
	jdeWebGUIcalcCurrentValues();
	writeString = "<table dir=ltr><tr><td>";
	var rtlEnabled = false;
	if (document.documentElement.dir == "rtl")
	{
		rtlEnabled = true;
	}
	writeString += "<table border=0 cellpadding=0 cellspacing=0>\n";
	writeString += "<tr valign=MIDDLE>\n";
	if (rtlEnabled)
	{
		writeString += "<td align=left>";
		writeString += "<A ID=va_caln_cancel title=\""+jdeWebGUIcalendarStrings[21]+"\" href=\"javascript:jdeWebGUIonCancelCaln()\"><IMG onmouseover=\"this.src='"+getWebGUIResourcePath()+"images/tiny-cancel-mo.gif'\" onmouseout=\"this.src='"+getWebGUIResourcePath()+"images/tiny-cancel.gif'\" src=\""+getWebGUIResourcePath()+"images/tiny-cancel.gif\" alt=\"" + jdeWebGUIcalendarStrings[21] + "\" border=0></A>";
		writeString += "<A ID=va_caln_ok title=\""+jdeWebGUIcalendarStrings[20]+"\" href=\"javascript:jdeWebGUIonOKCaln()\"><IMG onmouseover=\"this.src='"+getWebGUIResourcePath()+"images/tiny-ok-mo.gif'\" onmouseout=\"this.src='"+getWebGUIResourcePath()+"images/tiny-ok.gif'\" src=\""+getWebGUIResourcePath()+"images/tiny-ok.gif\" alt=\"" +jdeWebGUIcalendarStrings[20]+ "\" border=0></A>";
		writeString += "</td>\n";
		writeString += "<td align=right><b>"+ jdeWebGUIcalendarStrings[0]+ "</b></td>\n";
	}
	else
	{
		writeString += "<td align=left><b>"+ jdeWebGUIcalendarStrings[0]+ "</b></td>\n";
		writeString += "<td align=right>";
		writeString += "<A ID=va_caln_ok title=\""+jdeWebGUIcalendarStrings[20]+"\" href=\"javascript:jdeWebGUIonOKCaln()\"><IMG onmouseover=\"this.src='"+getWebGUIResourcePath()+"images/tiny-ok-mo.gif'\" onmouseout=\"this.src='"+getWebGUIResourcePath()+"images/tiny-ok.gif'\" src=\""+getWebGUIResourcePath()+"images/tiny-ok.gif\" alt=\"" +jdeWebGUIcalendarStrings[20]+ "\" border=0></A>";
		writeString += "<A ID=va_caln_cancel title=\""+jdeWebGUIcalendarStrings[21]+"\" href=\"javascript:jdeWebGUIonCancelCaln()\"><IMG onmouseover=\"this.src='"+getWebGUIResourcePath()+"images/tiny-cancel-mo.gif'\" onmouseout=\"this.src='"+getWebGUIResourcePath()+"images/tiny-cancel.gif'\" src=\""+getWebGUIResourcePath()+"images/tiny-cancel.gif\" alt=\"" + jdeWebGUIcalendarStrings[21]+ "\" border=0></A>";
		writeString += "</td>\n";
	}
	writeString += "</tr>\n";
	writeString += "<tr valign=top>\n";
	writeString += "<td colspan=2 align=center><HR></td>\n";
	writeString += "</tr>\n";
	writeString += "<tr><td colspan=2 align=center><table border=0 cellpadding=0 cellspacing=0>\n";
	writeString += "<tr valign=MIDDLE>\n";
	writeString += "<td colspan=7><table width=100% border=0 cellpadding=0 cellspacing=0><tr>";
	if (rtlEnabled)
	{
		writeString += "<td style=\"cursor:pointer\" onclick=\"javascript:jdeWebGUInextYear()\" title=\"" + jdeWebGUIcalendarStrings[25] +"\" onmouseover=\"javascript:jdeWebGUIhighlightSel(this)\" onmouseout=\"javascript:jdeWebGUIremHighlightBtn(this)\"><img src='"+getWebGUIResourcePath()+"images/tiny-moveallleft.gif' alt=\"" + jdeWebGUIcalendarStrings[25] + "\" onMouseOver=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveallleft-mo.gif'\" onMouseOut=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveallleft.gif'\" border=0 width=20 height=20></td>\n";
		writeString += "<td style=\"cursor:pointer\" onclick=\"javascript:jdeWebGUInextMonth()\" title=\"" + jdeWebGUIcalendarStrings[24] +"\" onmouseover=\"javascript:jdeWebGUIhighlightSel(this)\" onmouseout=\"javascript:jdeWebGUIremHighlightBtn(this)\"><nobr><img src='"+getWebGUIResourcePath()+"images/tiny-moveleft.gif' alt=\"" + jdeWebGUIcalendarStrings[24] + "\" onMouseOver=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveleft-mo.gif'\" onMouseOut=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveleft.gif'\" border=0 width=20 height=20 align=absmiddle>&nbsp;</nobr></td>\n";
		writeString += "<td width=120 nowrap align=center><b>" + jdeWebGUIcalendarStrings[jdeWebGUIcurmonth+1] + " " + jdeWebGUIcuryear + "</b></td>\n";
		writeString += "<td style=\"cursor:pointer\" onclick=\"javascript:jdeWebGUIprevMonth()\" title=\"" + jdeWebGUIcalendarStrings[23] +"\" onmouseover=\"javascript:jdeWebGUIhighlightSel(this)\" onmouseout=\"javascript:jdeWebGUIremHighlightBtn(this)\"><nobr>&nbsp;<img src='"+getWebGUIResourcePath()+"images/tiny-moveright.gif' alt=\"" + jdeWebGUIcalendarStrings[23] + "\" onMouseOver=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveright-mo.gif'\" onMouseOut=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveright.gif'\" border=0 width=20 height=20 align=absmiddle></nobr></td>\n";
		writeString += "<td style=\"cursor:pointer\" onclick=\"javascript:jdeWebGUIprevYear()\" title=\"" + jdeWebGUIcalendarStrings[22] +"\" onmouseover=\"javascript:jdeWebGUIhighlightSel(this)\" onmouseout=\"javascript:jdeWebGUIremHighlightBtn(this)\"><img src='"+getWebGUIResourcePath()+"images/tiny-moveallright.gif' alt=\"" + jdeWebGUIcalendarStrings[22] + "\" onMouseOver=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveallright-mo.gif'\" onMouseOut=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveallright.gif'\" border=0 width=20 height=20></td>\n";
	}
	else
	{
		writeString += "<td style=\"cursor:pointer\" onclick=\"javascript:jdeWebGUIprevYear()\" title=\"" + jdeWebGUIcalendarStrings[22] +"\" onmouseover=\"javascript:jdeWebGUIhighlightSel(this)\" onmouseout=\"javascript:jdeWebGUIremHighlightBtn(this)\"><img src='"+getWebGUIResourcePath()+"images/tiny-moveallleft.gif' alt=\"" + jdeWebGUIcalendarStrings[22] + "\" onMouseOver=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveallleft-mo.gif'\" onMouseOut=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveallleft.gif'\" border=0 width=20 height=20></td>\n";
		writeString += "<td style=\"cursor:pointer\" onclick=\"javascript:jdeWebGUIprevMonth()\" title=\"" + jdeWebGUIcalendarStrings[23] +"\" onmouseover=\"javascript:jdeWebGUIhighlightSel(this)\" onmouseout=\"javascript:jdeWebGUIremHighlightBtn(this)\"><nobr>&nbsp;<img src='"+getWebGUIResourcePath()+"images/tiny-moveleft.gif' alt=\"" + jdeWebGUIcalendarStrings[23] + "\" onMouseOver=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveleft-mo.gif'\" onMouseOut=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveleft.gif'\" border=0 width=20 height=20 align=absmiddle></nobr></td>\n";
		writeString += "<td width=120 nowrap align=center><b>" + jdeWebGUIcalendarStrings[jdeWebGUIcurmonth+1] + " " + jdeWebGUIcuryear + "</b></td>\n";
		writeString += "<td style=\"cursor:pointer\" onclick=\"javascript:jdeWebGUInextMonth()\" title=\"" + jdeWebGUIcalendarStrings[24] +"\" onmouseover=\"javascript:jdeWebGUIhighlightSel(this)\" onmouseout=\"javascript:jdeWebGUIremHighlightBtn(this)\"><nobr><img src='"+getWebGUIResourcePath()+"images/tiny-moveright.gif' alt=\"" + jdeWebGUIcalendarStrings[24] + "\" onMouseOver=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveright-mo.gif'\" onMouseOut=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveright.gif'\" border=0 width=20 height=20 align=absmiddle>&nbsp;</nobr></td>\n";
		writeString += "<td style=\"cursor:pointer\" onclick=\"javascript:jdeWebGUInextYear()\" title=\"" + jdeWebGUIcalendarStrings[25] +"\" onmouseover=\"javascript:jdeWebGUIhighlightSel(this)\" onmouseout=\"javascript:jdeWebGUIremHighlightBtn(this)\"><img src='"+getWebGUIResourcePath()+"images/tiny-moveallright.gif' alt=\"" + jdeWebGUIcalendarStrings[25] + "\" onMouseOver=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveallright-mo.gif'\" onMouseOut=\"this.src='"+getWebGUIResourcePath()+"images/tiny-moveallright.gif'\" border=0 width=20 height=20></td>\n";
	}
	writeString += "</tr></table></td>\n"
	writeString += "</tr>\n";
	writeString += "<tr valign=top>\n";
	writeString += "<td colspan=7 align=center><HR></td>\n";
	writeString += "</tr>\n";
	writeString += "<tr style=\"text-decoration: underline\" valign=MIDDLE>\n";
	for (var i=0; i<7; ++i)
		writeString += "<td width=25 align=center>" + jdeWebGUIdays[i] +"</td>\n";
	writeString += "</tr>\n";
	writeString += "<tr valign=MIDDLE>\n";
	for (s=0;s<jdeWebGUIstartspaces;s++)
		writeString += "<td> </td>\n";

	x = jdeWebGUIstartspaces; count=1;
	var rowsDrawn = 0;

	while (count <= jdeWebGUImonthdays[jdeWebGUIcurmonth])
	{
		for (b = jdeWebGUIstartspaces;b<7;b++)
		{
			linktrue=false;

			writeString += "<td align=right style='cursor:pointer;";
			if ( (((count + x) % 7) == 0) || (((count + x) % 7) == 1) ) // is weekend
			{
				writeString += "font-style:italic;'";

				if (count <= jdeWebGUImonthdays[jdeWebGUIcurmonth])
				{
					if (count==jdeWebGUIcurdate) // if this day is selected, next click shall select it
						writeString += " onmouseover=\"javascript:jdeWebGUIhighlightSel(this)\" onmouseout=\"javascript:jdeWebGUIremHighlight(this, true)\" onclick=\"javascript:jdeWebGUIonOKCaln()\"";
					else // a single click will highlight it
						writeString += " onmouseover=\"javascript:jdeWebGUIhighlightSel(this)\" onDblClick=\"javascript:jdeWebGUIonOKCaln()\" onmouseout=\"javascript:jdeWebGUIremHighlight(this, true)\" onclick=\"javascript:jdeWebGUIsetCurDate("+count+")\"";
				}
			}
			else
			{
				writeString += "'";

				if (count <= jdeWebGUImonthdays[jdeWebGUIcurmonth])
				{
					if (count==jdeWebGUIcurdate) // if this day is selected, next click shall select it
						writeString += " onmouseover=\"javascript:jdeWebGUIhighlightSel(this)\" onmouseout=\"javascript:jdeWebGUIremHighlight(this, false)\" onclick=\"javascript:jdeWebGUIonOKCaln()\"";
					else // a single click will highlight it
						writeString += " onmouseover=\"javascript:jdeWebGUIhighlightSel(this)\" onDblClick=\"javascript:jdeWebGUIonOKCaln()\" onmouseout=\"javascript:jdeWebGUIremHighlight(this, false)\" onclick=\"javascript:jdeWebGUIsetCurDate("+count+")\"";
				}
			}

			writeString += ">";

			if (count==jdeWebGUIcurdate)
				writeString += "<font color='#FF0000'><strong>";

			if (count <= jdeWebGUImonthdays[jdeWebGUIcurmonth])
				writeString += count;
			else
				writeString += " ";

			if (count==jdeWebGUIcurdate)
				writeString += "</strong></font>";

			writeString += "&nbsp;&nbsp;</td>\n";
			count++;
		}
		writeString += "</tr>\n";
		if (count <= jdeWebGUImonthdays[jdeWebGUIcurmonth])
			writeString += "<tr valign=MIDDLE>\n";
		rowsDrawn++;
		jdeWebGUIstartspaces=0;
	}
	while (rowsDrawn++ < 6) // months can have from 4 to 6 actual rows in the calendar
		writeString += "<tr valign=MIDDLE><td>&nbsp;</td></tr>";

	writeString += "</table></td></tr>\n";
	if(jdeWebGUIisUTime)
	{
		writeString += "<tr valign=MIDDLE><td colspan=7 align=center><HR></td></tr>";
		writeString += "<tr valign=MIDDLE><td colspan=7>";
		if (rtlEnabled)
			writeString += "<table align=right dir=rtl><tr>";
		else
			writeString += "<table><tr>";
		writeString += "<td width=20>&nbsp;</td><td><b>"+jdeWebGUIcalendarStrings[26]+"</b></td>";
		writeString += "<td width=30>&nbsp;</td><td width=35>&nbsp;</td>";
		writeString += "<td colspan=3><b>+/- UTC</b></td>";
		writeString += "</tr></table>";
		writeString += "</td></tr>";
		writeString += "<tr valign=MIDDLE><td colspan=7 align=center><HR></td></tr>";
		writeString += "<tr valign=MIDDLE><td colspan=7 align=center>";

		if (rtlEnabled)
			writeString += "<table dir=rtl><tr>";
		else
			writeString += "<table><tr>";

		var utimeHrs = jdeWebGUItodayDate.getHours();
		var isPM=false;
		if (jdeWebGUIisUTimeAMPM && utimeHrs>=12)
		{
			utimeHrs -= 12;
			isPM=true;
		}

		if (utimeHrs < 10)
			utimeHrs = "0" + utimeHrs;

		var utimeMin = jdeWebGUItodayDate.getMinutes();
		if (utimeMin < 10)
			utimeMin = "0" + utimeMin;

		var utimeSec = jdeWebGUItodayDate.getSeconds();
		if (utimeSec < 10)
			utimeSec = "0" + utimeSec;

		if (rtlEnabled)
		{
			writeString += "<td><nobr><input type=text class='textfield' style='width:20' maxlength=2 id=\"utimeSEC\" value="+utimeSec +">:</td>";
			writeString += "<td><nobr><input type=text class='textfield' style='width:20' maxlength=2 id=\"utimeMIN\" value="+utimeMin +">:</nobr></td>"
			writeString += "<td><nobr><input type=text class='textfield' style='width:20' maxlength=2 id=\"utimeHR\" value="+utimeHrs+"></nobr>"
			if (jdeWebGUIisUTimeAMPM)
			{
				writeString += "<td><A href=\"javascript:jdeWebGUIdoAMPM('"+jdeWebGUIcalendarStrings[27]+"', '"+jdeWebGUIcalendarStrings[28]+"')\" id=\"utimeAMPM\">";
				if (isPM)
					writeString += jdeWebGUIcalendarStrings[28]; // PM
				else
					writeString += jdeWebGUIcalendarStrings[27]; // AM
				writeString += "</A>";
			}
			writeString += "</td>";
		}
		else
		{
			writeString += "<td><nobr><input type=text class='textfield' style='width:20' maxlength=2 id=\"utimeHR\" value="+utimeHrs+">:</nobr></td>"
			writeString += "<td><nobr><input type=text class='textfield' style='width:20' maxlength=2 id=\"utimeMIN\" value="+utimeMin +">:</nobr></td>"
			writeString += "<td><input type=text class='textfield' style='width:20' maxlength=2 id=\"utimeSEC\" value="+utimeSec +">";
			if (jdeWebGUIisUTimeAMPM)
			{
				writeString += "<td><A href=\"javascript:jdeWebGUIdoAMPM('"+jdeWebGUIcalendarStrings[27]+"', '"+jdeWebGUIcalendarStrings[28]+"')\" id=\"utimeAMPM\">";
				if (isPM)
					writeString += jdeWebGUIcalendarStrings[28]; // PM
				else
					writeString += jdeWebGUIcalendarStrings[27]; // AM
				writeString += "</A>";
			}
			writeString += "</td>";
		}

		writeString += "<td width=20>&nbsp;</td>";
		writeString += "<td><select size=1 id=\"utimeTZ\">";
		writeString += "<option>UTC </option>";
		writeString += "<option>UTC-12:00</option>";
		writeString += "<option>UTC-11:00</option>";
		writeString += "<option>UTC-10:00</option>";
		writeString += "<option>UTC-09:00</option>";
		writeString += "<option>UTC-08:00</option>";
		writeString += "<option>UTC-07:00</option>";
		writeString += "<option>UTC-06:00</option>";
		writeString += "<option>UTC-05:00</option>";
		writeString += "<option>UTC-04:00</option>";
		writeString += "<option>UTC-03:00</option>";
		writeString += "<option>UTC-02:00</option>";
		writeString += "<option>UTC-01:00</option>";
		writeString += "<option>UTC+01:00</option>";
		writeString += "<option>UTC+02:00</option>";
		writeString += "<option>UTC+03:00</option>";
		writeString += "<option>UTC+03:30</option>";
		writeString += "<option>UTC+04:00</option>";
		writeString += "<option>UTC+04:30</option>";
		writeString += "<option>UTC+05:00</option>";
		writeString += "<option>UTC+05:30</option>";
		writeString += "<option>UTC+05:45</option>";
		writeString += "<option>UTC+06:00</option>";
		writeString += "<option>UTC+06:30</option>";
		writeString += "<option>UTC+07:00</option>";
		writeString += "<option>UTC+08:00</option>";
		writeString += "<option>UTC+09:00</option>";
		writeString += "<option>UTC+09:30</option>";
		writeString += "<option>UTC+10:00</option>";
		writeString += "<option>UTC+11:00</option>";
		writeString += "<option>UTC+12:00</option>";
		writeString += "<option>UTC+13:00</option>";
		writeString += "</select></td>\n";

		writeString += "</tr></table></td>";
		writeString += "</tr>\n";
	}
	writeString += "</table>\n"; // close of above UTime

	writeString += "</table>\n"; // close of dates
	writeString += "</td></tr></table>\n"; // close of internal layout
	writeString += "</td></tr></table>\n"; // close of outer border
	document.getElementById("calendar").innerHTML = writeString;
}

function jdeWebGUIonOKCaln()
{
	var strVal = jdeWebGUIformatDate();
	jdeWebGUIupdateOpenerFieldValue(jdeWebGUIcalendarTextFieldId, strVal, true);
}

function jdeWebGUIonCancelCaln()
{
	self.close();
}

// END OF SCRIPTS FOR CALENDAR
//////////////////////////////////

///////////////////////////////////////////////////////////////
// START OF UTILITY SCRIPTS

function getWebGUIResourcePath()
{
	try { return jdeWebGUIResourcePath; } catch (problem) { return "share/"; }
}

function isCSSLevel1Supported()
{
	try { return jdeWebGUICSS1; } catch (problem) { return false; }
}

function isDOMLevel1Supported()
{
	try { return jdeWebGUIDOM1; } catch (problem) { return false; }
}

function isDOMLevel2Supported()
{
	try { return jdeWebGUIDOM2; } catch (problem) { return false; }
}

function isDynamicMenusSupported()
{
	try { return jdeWebGUIDynamicMenus; } catch (problem) { return false; }
}

function isDynamicOptionsSupported()
{
	try { return jdeWebGUIDynamicOptions; } catch (problem) { return false; }
}

function isEventOffsetCoordsSupported()
{
	try { return jdeWebGUIEventOffsetCoords; } catch (problem) { return false; }
}

function isSmallScreenSupported()
{
	try { return jdeWebGUISmallScreen; } catch (problem) { return false; }
}

function isAppletsSupported()
{
	try { return jdeWebGUIApplets; } catch (problem) { return false; }
}

function getAbsoluteLeftPos(item, adjustScrollbars)
{
	var itemLeft= item.offsetLeft + document.body.offsetLeft;
	var itemParent = item.offsetParent;

	while(itemParent)
	{
		if (document.documentElement.dir == "rtl" && itemParent.offsetLeft < 0)
			itemLeft += itemParent.style.posLeft;
		else
			itemLeft += itemParent.offsetLeft;
		if(true == adjustScrollbars && itemParent != document.body)
			itemLeft -= itemParent.scrollLeft;
		itemParent = itemParent.offsetParent;
	}

	return itemLeft;
}

function getAbsoluteTopPos(item, adjustScrollbars)
{
	var itemTop= item.offsetTop + document.body.offsetTop;
	var itemParent = item.offsetParent;

	while(itemParent)
	{
		itemTop += itemParent.offsetTop;
		if(true == adjustScrollbars && itemParent != document.body)
			itemTop -= itemParent.scrollTop;

		itemParent = itemParent.offsetParent;
	}

	return itemTop;
}

function showMotion(elem)
{
	var dot = elem.src.indexOf('.gif');
	if (dot != -1)
		elem.src= elem.src.substring(0,dot)+ "mo.gif";
}

function removeMotion(elem)
{
	var dot = elem.src.indexOf('mo.gif');
	if (dot != -1)
		elem.src= elem.src.substring(0,dot)+ ".gif";
}

// This function Completely equivilant to "showMotion" but it deals with RTL images.
// N.B Some images fliped in RTL, then we add _rtl to the end of the image file name
function showMotion_rtl(elem)
{
	var dot = elem.src.indexOf('_rtl.gif');
	if (dot != -1)
		elem.src= elem.src.substring(0,dot)+ "mo_rtl.gif";
}

// This function completely equivilant to "removeMotion" but it deals with RTL images.
function removeMotion_rtl(elem)
{
	var dot = elem.src.indexOf('mo_rtl.gif');
	if (dot != -1)
		elem.src= elem.src.substring(0,dot)+ "_rtl.gif";
}

function jdeWebGUIgetLocationParameter(parameterName)
{
	// @todo handle multiple params of the same name
	// @todo lookup the parameter name with a leading "?" and leading "&" so other params that contain the name will not be mistakenly received
	var myURL = ""+self.location;
	var index = myURL.lastIndexOf(parameterName+"=");
	var parameterValue = "";
	if (index > 1)
	{
		myURL = myURL.substr(index+parameterName.length+1, myURL.length);
		index = myURL.indexOf("&");
		if (index == -1)
			parameterValue = myURL;
		else
			parameterValue = myURL.substring(0,index);
	}
	return parameterValue;
}

function jdeWebGUIupdateOpenerFieldValue(documentFieldId, theValue, closeSelf)
{
	window.opener.document.getElementById(documentFieldId).value=theValue;
	if (closeSelf)
	{
		self.close();
	}
}

function jdeWebGUIReplaceSubstring(source, pattern, replace)
{
	return source.replace(new RegExp(pattern, "g"), replace);
}

function PSStringBuffer()
{
	this.maxStreamLength = (document.all?100:10000);
	this.data = new Array(100);
	this.iStr = 0;
	this.append = function(obj)
	{
		this.data[this.iStr++] = obj;
		if (this.data.length > this.maxStreamLength)
		{
			this.data = [this.data.join("")];
			this.data.length = 100;
			this.iStr = 1;
		}
		return this;
	};
	this.toString = function()
	{
		return this.data.join("");
	};
}

PSStringBuffer._joinFunc = Array.prototype.join;
PSStringBuffer.concat = function () {
	arguments.join = this._joinFunc;
	return arguments.join("")
}

var PI_MOTION_TIMER=document.all?500:100;
var piStopTimout;

function ProcessingIndicator()
{
}

ProcessingIndicator.createInstance = function(procText, maxWidth, height, topOffset, rightOffset){
    ProcessingIndicator.theInstance = new ProcessingIndicator();
    ProcessingIndicator.theInstance.PIText = procText;
    ProcessingIndicator.theInstance.isProcIndDisplayed = false;
    ProcessingIndicator.theInstance.procIndicatorElem = null;
    ProcessingIndicator.theInstance.movePIIndicatorTimer = null;
    ProcessingIndicator.theInstance.height=height;
    ProcessingIndicator.theInstance.maxWidth=maxWidth;
    ProcessingIndicator.theInstance.topOffset=topOffset;
    ProcessingIndicator.theInstance.rightOffset=rightOffset;
    return ProcessingIndicator.theInstance;
}

ProcessingIndicator.getInstance = function()
{
    return ProcessingIndicator.theInstance;
}

ProcessingIndicator.positionProcessingIndicator = function()
{
	if(ProcessingIndicator.theInstance != null)
		ProcessingIndicator.theInstance.position();
}
ProcessingIndicator.stopProcessingIndicator= function()
{
    if(ProcessingIndicator.theInstance != null){
        ProcessingIndicator.theInstance.display(false);
        //delete ProcessingIndicator.theInstance;
        ProcessingIndicator.theInstance = null;
    }
    if(piStopTimout != null){
        window.clearTimeout(piStopTimout);
        piStopTimout = null;
    }
}

// Create the processing indicator element
ProcessingIndicator.prototype.createPIElem = function(){
	var elem = document.createElement("div");
	var leftPos = document.body.clientWidth + document.body.scrollLeft - this.maxWidth - this.rightOffset;
	if(document.documentElement.dir == "rtl")
		leftPos = this.rightOffset;

	document.body.appendChild(elem);
	elem.id = "procIndicatorFloatLyr";
	elem.noWrap = "true";
	elem.innerHTML = PSStringBuffer.concat("<table cellpadding=0 cellspacing=0 border=0><tr nowrap>",
                     "<td style='padding-top:1px; padding-left:3px; padding-right:2px;'>",
                     "<img src='",getWebGUIResourcePath(),"images/circular_slush.gif' width=16 height=16>",
                     "</td><td>",
                     "<span id=\"procIndicatorTextSpan\" nowrap style='height:",this.height,"; padding-top:2px; font-family:arial; color:rgb(65,65,65); font-size:10pt; font-weight:bold; overflow:hidden; text-overflow:ellipsis; white-space:nowrap'>",
                     this.PIText,"...&nbsp;&nbsp;" ,
                     "</span>",
                     "</td></tr></table>");                           
	elem.style.display = "none";
	elem.style.position = "absolute";
	elem.style.left = leftPos;
	elem.style.top = this.topOffset;
	elem.style.height = this.height;
	elem.style.zIndex = 2000000000; // assuming minimum 32-bit integer
	elem.style.backgroundColor = "#FFF2A9"; 
	elem.style.borderWidth = "1px"; 
	elem.style.borderStyle = "solid"; 
	elem.style.borderColor = "#B3A976";   

        return elem;
}

	
ProcessingIndicator.prototype.position = function(){		
	var oldY = document.all? this.procIndicatorElem.style.pixelTop : this.procIndicatorElem.style.top; 
	var newY = document.body.scrollTop + this.topOffset;
	var posChanged = false;
	//in Mozilla/Firefox/Safari, the oldY is in the format of "123px", so strip the px
	if(!document.all)
	    oldY = oldY.substring(0, oldY.length-2);

	if(oldY != newY){	
		if(document.all)
			this.procIndicatorElem.style.pixelTop = newY;
		else
			this.procIndicatorElem.style.top = newY;
		posChanged = true;
	}
	var oldX = document.all? this.procIndicatorElem.style.pixelLeft : this.procIndicatorElem.style.left; 
	var newX = document.body.clientWidth + document.body.scrollLeft - this.maxWidth - this.rightOffset;
	if(document.documentElement.dir == "rtl")
		newX = document.body.scrollLeft + this.rightOffset;	
	if(!document.all)
	    oldX = oldX.substring(0, oldX.length-2);
	if(oldX != newX){
		if(document.all)
			this.procIndicatorElem.style.pixelLeft = newX;
		else
			this.procIndicatorElem.style.left = newX;
		posChanged = true;
	}

	if(posChanged)
	{
		removeItemShadow(this.procIndicatorElem, this.procIndMask);
		showItemShadow(this.procIndicatorElem, this.procIndMask);
	}
}
	
ProcessingIndicator.prototype.display = function(show, overrideText)
{
	this.procIndicatorElem = document.getElementById("procIndicatorFloatLyr");

	if(this.procIndicatorElem == null)
        {
            this.procIndicatorElem = this.createPIElem();
            if (document.all)  //IE
            {
                this.procIndMask = new MaskFrame("procIndMask", this.procIndicatorElem);
            }
            else
            {
                this.procIndMask = null;
            }
	}

        else
        {
            if (overrideText)
            {
                removeItemShadow(this.procIndicatorElem);
                document.getElementById("procIndicatorTextSpan").innerHTML = this.PIText + "...&nbsp;&nbsp;";
                showItemShadow(this.procIndicatorElem);
            }
        }
	if(this.procIndicatorElem != null)
	{
		if(show && !this.isProcIndDisplayed)
		{
			this.procIndicatorElem.style.display = "block";
			showItemShadow(this.procIndicatorElem, this.procIndMask);
			this.movePIIndicatorTimer = window.setInterval("ProcessingIndicator.positionProcessingIndicator()", PI_MOTION_TIMER);
			this.isProcIndDisplayed = true;
		}
		else
		{
			removeItemShadow(this.procIndicatorElem, this.procIndMask);
			this.procIndicatorElem.style.display = "none";
			if(this.isProcIndDisplayed){ // clear our timer
				window.clearInterval(this.movePIIndicatorTimer);	
			}
			this.isProcIndDisplayed = false; 		
		}	
	}
}

// Since IFRAME masking techniques for floating DIVs are only required to address 
// a zIndex bug in IE, don't even define this object if using Firefox
if (document.all)  //IE
{
    function MaskFrame(defaultId, fixedParentElem) 
    {
        var maskFrame = document.createElement('iframe')
        maskFrame.src = getWebGUIResourcePath()+"https_dummy.html";
        maskFrame.style.display = "none";
        maskFrame.style.position = "absolute";
        maskFrame.id = this.defaultId = defaultId;
        this.domElement = maskFrame;
        if (fixedParentElem)
        {
            this.setFixedParent(fixedParentElem);
        }
    }
    
    /**
      The setFixedParent method is ONLY used by non-shared Masks (currently this
      is only the ProcessingInd mask).  It is used to stop resetting the 
      parentNode for the IFRAME element repeatedly, which appears to be doing
      nasty things to the DOM.  Once the parent is fixed to the IFRAME, it can
      never be reset using the attach or detach methods.
    **/
    MaskFrame.prototype.setFixedParent = function(elem)
    {
        if (!elem)
        {
            return;
        }
        
        elem.parentNode.appendChild(this.domElement);
        
        //now repoint the attach/detach methods to just show/hide instead
        //this allows an "owned" maskFrame item to maintain it's place in
        //the DOM without being added and removed incessently.
        this.attachMask = this.showMask;
        this.detachMask = this.hideMask;
    }
    
    MaskFrame.prototype.attachMask = function(elem)
    {
        if (!elem)
        {
            return;
        }
        
        var maskFrame = this.domElement;
        
        if (maskFrame.parentNode != null)  //already attached to something
        {
            this.detachMask();
        }
        elem.parentNode.appendChild(maskFrame);
        this.showMask(elem);
    }
    
    MaskFrame.prototype.showMask = function(elem)
    {
        if (!elem)
        {
            return;
        }
        
        var maskFrame = this.domElement;
        
        maskFrame.style.top = parseInt(elem.style.top);
        maskFrame.style.left = parseInt(elem.style.left);
        maskFrame.style.width = elem.offsetWidth;
        maskFrame.style.height = elem.offsetHeight;
        maskFrame.style.zIndex = elem.style.zIndex - 1;
        maskFrame.style.display = "block";
        maskFrame.id = elem.id + "-maskframe";
    }
    
    MaskFrame.prototype.detachMask = function()
    {
        
	this.hideMask();

        var maskFrame = this.domElement;

        //test parent first, in case detach called twice consecutively
        if (maskFrame.parentNode != null)
        {
            maskFrame.parentNode.removeChild(maskFrame);
        }
    }

    MaskFrame.prototype.hideMask = function()
    {
        var maskFrame = this.domElement;
        
        maskFrame.style.display = "none";
        maskFrame.id = this.defaultId;
    }
    /** Create a single multi-use masking IFRAME for generic floating DIV needs **/
    var GlobalMaskFrame = new MaskFrame("globalMask");
}

function PopupWindow(id, resizable, titleInfo, eventListener){
	this.id = id;
	this.resizable = resizable;
	this.eventListener = eventListener;

	window[id] = this;
	
	this.titleInfo = titleInfo;
	this.minWidth = 188;
	this.minHeight = 60;		
	this.windowElem = null;
	this.contentHTML = null;
		
	//variables used for moving the window
	this.titleElem = null;
	this.titleHasCapture = false; 
	this.initWindowX = this.initWindowY = this.initClientX = this.initClientY = 0;

	//variables used for resizing the window
	this.containerHasCapture = false;
	this.initDirection = "";
	this.initWindowWidth = this.initWindowHeight = 0;
	
    this.windowElem = document.getElementById(id);
	if(this.windowElem == null){
		this._createPopupElem(id);
		this.windowElem = document.getElementById(id);
	}	
}

PopupWindow.prototype.RESIZE_TOLERANCE = 8;
PopupWindow.prototype.currentInstance = null;
//this should be larger than the layer(z-index) defined as 
//UIBLOCKING_LAYER_ZINDEX for UIBlocking layer in UIBlocking.js
var MSGFORM_LAYER_ZINDEX = 100002;
PopupWindow.prototype.setMinSize = function(width, height){
	this.minWidth = width;
	this.minHeight = height;
}

PopupWindow.prototype._createPopupElem = function(id){
	var elem = document.createElement("div");
	document.body.appendChild(elem);
	elem.id = id;
	elem.style.backgroundColor = "#ffffff";
	elem.style.zIndex = MSGFORM_LAYER_ZINDEX;
	elem.style.position = 'absolute';
	elem.style.overflow = 'hidden';	
}

PopupWindow.prototype.setContent = function(htmlContent){
    this.contentHTML = htmlContent;
}

PopupWindow.prototype.getWidth = function(){
	return parseInt(this.windowElem.style.width);
}

PopupWindow.prototype.getHeight = function(){
	return parseInt(this.windowElem.style.height);
}

PopupWindow.prototype._buildHTML = function(){
	var sb = new PSStringBuffer();
	sb.append("<table border=0 cellspacing=0 cellpadding=0 width=100% height=100%>");
	sb.append("<tr><td style=\"height:18px;\"><table width=100% height=100% border=0 cellspacing=0 cellpadding=0>");
	sb.append("<tr");
	if(!this.titleInfo.backgroundImage)
		sb.append(" style=\"background-color: #486CAE\"");
	sb.append("><td");
	if(this.titleInfo.backgroundImage)
		sb.append(" background='").append(enterpriseOneContext).append(this.titleInfo.backgroundImage).append("'");
	sb.append(">");
	
	if(this.titleInfo.titleIcon){
		sb.append("<img border=0 hspace=3 src='").append(enterpriseOneContext); 
		sb.append(this.titleInfo.titleIcon).append("' alt=\"").append(this.titleInfo.titleText).append("\">"); 
	}else{
		sb.append("&nbsp;");
	}
	
	var titleTextColor = this.titleInfo.titleTextColor?this.titleInfo.titleTextColor: "#ffffff";
	sb.append("</td><td style=\"font-size:10pt;font-weight:bold;color:").append(titleTextColor).append("\"");
	if(this.titleInfo.backgroundImage)
		sb.append(" background='").append(enterpriseOneContext).append(this.titleInfo.backgroundImage).append("'");
	sb.append("><nobr><div id=popupWindowTitle").append(this.id);
	sb.append(" title=\"").append(this.titleInfo.titleText).append("\"");
	sb.append(" style=\"overflow:hidden; text-overflow:ellipsis;\">").append(this.titleInfo.titleText);
	sb.append("</div></nobr></td>");

	if(this.titleInfo.hasAbout){
		sb.append("<td align=right>");
		sb.append("<img style=\"cursor:pointer\" onclick=\"javascript:about()\" align=absmiddle alt=\"").append(this.titleInfo.aboutText).append("\"; title = \"").append(this.titleInfo.aboutText).append("\"");
		sb.append(" src='").append(enterpriseOneContext).append("/img/jdeabout.gif' onmouseOver=showMotion(this) onmouseOut=removeMotion(this) hspace=3 border=0>");
		sb.append("</td>");
	}
	if(this.titleInfo.hasClose){
		sb.append("<td align=right");
		if(this.titleInfo.backgroundImage)
			sb.append(" background='").append(enterpriseOneContext).append(this.titleInfo.backgroundImage).append("'");
		sb.append(">");		
		sb.append("<img style=\"cursor:pointer\" onclick=\"javascript:window['").append(this.id).append("'].onClose()\"");
		sb.append(" src='").append(enterpriseOneContext).append("/img/close.gif' alt=\"").append(this.titleInfo.titleText).append("\" onmouseOver=showMotion(this) onmouseOut=removeMotion(this) hspace=3 border=0>");
		sb.append("</td>");
	}
	sb.append("</tr></table></td></tr>");

	sb.append("<tr><td>");
	sb.append(this.contentHTML);	
	sb.append("</td></tr>");
	sb.append("</table>");
	this.windowElem.innerHTML = sb.toString();
	delete this.contentHTML;
}

PopupWindow.prototype.display = function(left,top,width, height){
	this._buildHTML();
	this.titleElem = document.getElementById("popupWindowTitle"+this.id);
	this.titleElem.style.width = width - 50;
	this.titleElem.style.cursor = "move";
	
	this.windowElem.style.left = left;
    this.windowElem.style.top = top;
    this.windowElem.style.width = width;
    this.windowElem.style.height = height;
	this.windowElem.className = "RaisedBorders";
    this.windowElem.style.display = "block";

	if (this.resizable){
		this.windowElem.onmousedown = new Function("window['"+this.id+"'].mouseDownContainer(arguments[0])");
		this.windowElem.onmousemove = new Function("window['"+this.id+"'].mouseMoveContainer(arguments[0])");
		this.windowElem.onmouseup = new Function("window['"+this.id+"'].mouseUpContainer(arguments[0])");
	}
	
	if(this.titleElem != null){	
		this.titleElem.onmousedown = new Function("window['"+this.id+"'].mouseDownTitle(arguments[0])");
		this.titleElem.onmousemove = new Function("window['"+this.id+"'].mouseMoveTitle(arguments[0])");
		this.titleElem.onmouseup = new Function("window['"+this.id+"'].mouseUpTitle(arguments[0])");
	}
	
	showItemShadow(this.windowElem);
}

PopupWindow.prototype.hide = function(left,top,width, height){
	this.windowElem.style.display = "none";
	removeItemShadow(this.windowElem);
}

PopupWindow.prototype.moveTo = function(left, top){
	this.windowElem.style.left = left;
    this.windowElem.style.top = top;
    moveItemShadow(this.windowElem);
}

PopupWindow.prototype.onClose = function(){
	if(this.eventListener && this.eventListener.onClose)
		this.eventListener.onClose();
	this.hide();
}

PopupWindow.prototype.mouseDownTitle = function(e){
	if(this.eventListener && this.eventListener.mouseDown)
		this.eventListener.mouseDown();

	var evt = document.all ? window.event : e;	
	if (document.all)
		this.titleElem.setCapture();
	else {		
	    window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
	    this.oldMouseMove = document["onmousemove"];
	    document["onmousemove"] = this.mouseMoveTitle;
	    this.oldMouseUp = document["onmouseup"];
	    document["onmouseup"] = this.mouseUpTitle;
	}
	this.initWindowX = parseInt(this.windowElem.style.left);
	this.initWindowY = parseInt(this.windowElem.style.top);
	this.initClientX = evt.clientX;
	this.initClientY = evt.clientY;
	this.titleHasCapture = true;
	PopupWindow.prototype.currentInstance = this;
	if(document.all){
		evt.cancelBubble = true;
		evt.returnValue = false;
	}
	else{
		if (evt.cancelable){
			evt.stopPropagation();
			evt.preventDefault();
		}
    }
}
	
PopupWindow.prototype.mouseMoveTitle = function(e){
  	var popupWin = this;
  	if(!document.all && this != PopupWindow.prototype.currentInstance && 
  		PopupWindow.prototype.currentInstance!=null){
		popupWin = PopupWindow.prototype.currentInstance;
	}
  	if (!popupWin.titleHasCapture) 
  		return;
  	var evt = document.all ? window.event : e;
  	popupWin.windowElem.style.left=popupWin.initWindowX+evt.clientX-popupWin.initClientX; 
  	popupWin.windowElem.style.top= popupWin.initWindowY+evt.clientY-popupWin.initClientY;
  	moveItemShadow(popupWin.windowElem);

  	if(popupWin.eventListener && popupWin.eventListener.movedTo)
  		popupWin.eventListener.movedTo(popupWin.windowElem.style.left, popupWin.windowElem.style.top);
}

PopupWindow.prototype.mouseUpTitle = function(e){
  	var popupWin = this;
  	if(this != PopupWindow.prototype.currentInstance && 
  		PopupWindow.prototype.currentInstance!=null){
		popupWin = PopupWindow.prototype.currentInstance;
	}
	
	PopupWindow.prototype.currentInstance = null;
	if (true == popupWin.titleHasCapture){
	    if (document.all)
	        popupWin.titleElem.releaseCapture();
	    else {
	        window.releaseEvents(Event.MOUSEMOVE | Event.MOUSEUP);
	        document["onmousemove"] = popupWin.oldMouseMove;
	        document["onmouseup"] = popupWin.oldMouseUp;
        }
	    popupWin.titleHasCapture = false;
	}
	
}

PopupWindow.prototype.getContainerMoveDirection = function(e, containerElm){
	var direction = "";
	var evt = document.all ? window.event : e;
	var container = document.all ? event.srcElement : e.target;
	var x,y,windowX,windowY;
	
	if(document.all){
		x = evt.x + document.body.scrollLeft;
		y = evt.y + document.body.scrollTop;
	}
	else{
		x = evt.pageX;
		y = evt.pageY;
	}
	
	windowX = getAbsoluteLeftPos(containerElm);
	windowY = getAbsoluteTopPos(containerElm);	
	
	if ((y-windowY) < PopupWindow.prototype.RESIZE_TOLERANCE)
		direction += "";
	else if ((y-windowY) > containerElm.offsetHeight - PopupWindow.prototype.RESIZE_TOLERANCE)
		direction += "s";
	if ((x-windowX) < PopupWindow.prototype.RESIZE_TOLERANCE)
		direction += "w";
	else if ((x-windowX) > containerElm.offsetWidth - PopupWindow.prototype.RESIZE_TOLERANCE)
		direction += "e";
	return direction;
}

PopupWindow.prototype.mouseDownContainer = function(e){
	if(this.eventListener && this.eventListener.mouseDown)
		this.eventListener.mouseDown();
	
	var evt = document.all ? window.event : e;
	var container = document.all ? event.srcElement : e.target;
		
	this.initDirection = this.getContainerMoveDirection(e, this.windowElem);
	if (this.initDirection == ""){
		return;
	}
	this.containerHasCapture = true;	
	if (document.all)
		this.windowElem.setCapture();
	else {
	    window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
	    this.oldMouseMove = document["onmousemove"];
	    document["onmousemove"] = this.mouseMoveContainer;
	    this.oldMouseUp = document["onmouseup"];
	    document["onmouseup"] = this.mouseUpContainer;
	}		
	this.initWindowX = parseInt(this.windowElem.offsetLeft);
	this.initWindowY = parseInt(this.windowElem.offsetTop);
	this.initClientX = evt.clientX;
	this.initClientY = evt.clientY;
	this.initWindowWidth = parseInt(this.windowElem.offsetWidth);
	this.initWindowHeight = parseInt(this.windowElem.offsetHeight);
	PopupWindow.prototype.currentInstance = this;
	if(document.all){
		evt.cancelBubble = true;
		evt.returnValue = false;
	}
	else{
		if (evt.cancelable){
			evt.stopPropagation();
			evt.preventDefault();
		}
    }
}

PopupWindow.prototype.mouseMoveContainer = function(e){
  	var popupWin = this;
  	if(!document.all && this != PopupWindow.prototype.currentInstance && 
  		PopupWindow.prototype.currentInstance!=null){
		popupWin = PopupWindow.prototype.currentInstance;
	}

  	var evt = document.all ? window.event : e;
	
	if (!popupWin.containerHasCapture){ 
		var direction = popupWin.getContainerMoveDirection(e, popupWin.windowElem);  	
		if (direction == "")
			popupWin.windowElem.style.cursor = "default";
		else
		  	popupWin.windowElem.style.cursor = direction + "-resize";	
  		return;
  	}
  		
	if (popupWin.initDirection.indexOf("e") != -1)
		popupWin.windowElem.style.width = Math.max(popupWin.minWidth, 
			popupWin.initWindowWidth + evt.clientX - popupWin.initClientX);
	if (popupWin.initDirection.indexOf("s") != -1)
		popupWin.windowElem.style.height = Math.max(popupWin.minHeight, 
			popupWin.initWindowHeight + evt.clientY - popupWin.initClientY);
	if (popupWin.initDirection.indexOf("w") != -1) {
		popupWin.windowElem.style.left = Math.min(popupWin.initWindowX + evt.clientX - popupWin.initClientX, 
			popupWin.initWindowX + popupWin.initWindowWidth - popupWin.minWidth);
		popupWin.windowElem.style.width = Math.max(popupWin.minWidth, 
			popupWin.initWindowWidth - evt.clientX + popupWin.initClientX);
	}
	if (popupWin.initDirection.indexOf("n") != -1) {
		popupWin.windowElem.style.top = Math.min(popupWin.initWindowY + evt.clientY - popupWin.initClientY, 
			popupWin.initWindowY + popupWin.initWindowHeight - popupWin.minHeight);
		popupWin.windowElem.style.height = Math.max(popupWin.minHeight, 
			popupWin.initWindowHeight - evt.clientY + popupWin.initClientY);
	}
  	moveItemShadow(popupWin.windowElem);
	
	this.titleElem.style.width = parseInt(popupWin.windowElem.style.width) - 50;
  	
  	if(popupWin.eventListener && popupWin.eventListener.resizedTo)
  		popupWin.eventListener.resizedTo(popupWin.windowElem.style.width, popupWin.windowElem.style.height);
}

PopupWindow.prototype.mouseUpContainer = function(e){
  	var popupWin = this;
  	if(!document.all && this != PopupWindow.prototype.currentInstance && 
  		PopupWindow.prototype.currentInstance!=null){
		popupWin = PopupWindow.prototype.currentInstance;
	}
	
	PopupWindow.prototype.currentInstance = null;
	
	if (true == popupWin.containerHasCapture){
	    if (document.all)
	        popupWin.windowElem.releaseCapture();
	    else {
	        window.releaseEvents(Event.MOUSEMOVE | Event.MOUSEUP);
	        document["onmousemove"] = popupWin.oldMouseMove;
	        document["onmouseup"] = popupWin.oldMouseUp;
	    }
	    popupWin.containerHasCapture = false;
	}
}

/**
 * This is the customized E1 tooltip component.<br> 
 * User can set the follwing parameters: background color, 
 * show delay time, hide delay time, show delay, hide delay, 
 * vertical offset, horizontal offset.<br> 
 */
function Tooltip(id)
{
	this.id = id;
	window[id] = this;
	
	this.showDelayTime = 800;
	this.hideDelayTime = 0;
		
	this.xOffset = 9;
	this.yOffset = 12;
		
	this.showDelay = null;
	this.hideDelay = null;
	
	this.tooltipElem = document.getElementById(this.id);
	if(this.tooltipElem == null)
	{
	    this.tooltipElem = this._createTooltip(this.id);
	}
}

Tooltip.prototype.NEW_LINE = "<br>";

Tooltip.prototype._createTooltip = function(id)
{
	var elem = document.createElement("div");
	elem.id = id;
	elem.className = 'JSGridTooltip';

	document.body.appendChild(elem);
	return elem;
}

Tooltip.prototype.setTooltip = function(tooltipContent, obj, e)
{	
	if (window.event) 
	{
		event.cancelBubble = true;
	}
	else if (e.stopPropagation) 
	{
		e.stopPropagation();
	}	
		
	this.tooltipElem.innerHTML = tooltipContent;
	this.tooltipElem.x = getAbsoluteLeftPos(obj, true);
	this.tooltipElem.y = getAbsoluteTopPos(obj, true);		
	this.tooltipElem.style.left = 
        this.tooltipElem.x + this.xOffset + "px";
	this.tooltipElem.style.top = 
        this.tooltipElem.y + obj.offsetHeight + this.yOffset + "px";	
}

Tooltip.prototype.showTooltip = function()
{
	if (this.tooltipElem != null)
	{
		this.tooltipElem.style.visibility = "visible";
	}
}

Tooltip.prototype.hideTooltip = function()
{
	if (this.tooltipElem != null)
	{
		this.tooltipElem.style.visibility = "hidden";
	}
}

Tooltip.prototype.clearHideTooltipDelay = function()
{
	if (this.hideDelay != null)
	{
		clearTimeout(this.hideDelay);
	}
}

Tooltip.prototype.clearShowTooltipDelay = function()
{
	if (this.showDelay != null)
	{
		clearTimeout(this.showDelay);
	}
}

Tooltip.prototype.setShowTooltipDelay = function(showDelay)
{
	this.showDelay = showDelay;
}

Tooltip.prototype.setHideTooltipDelay = function(hideDelay)
{
	this.hideDelay = hideDelay;
}

Tooltip.prototype.setShowDelayTime = function(showDelayTime)
{
	this.showDelayTime = showDelayTime;
}

Tooltip.prototype.setHideDelayTime = function(hideDelayTime)
{
	this.hideDelayTime = hideDelayTime;
}

Tooltip.prototype.getShowDelayTime = function()
{
	return this.showDelayTime;
}

Tooltip.prototype.getHideDelayTime = function()
{
	return this.hideDelayTime;
}

Tooltip.prototype.setXOffset = function(xOffset)
{
	this.xOffset = xOffset;
}

Tooltip.prototype.setYOffset = function(yOffset)
{
	this.yOffset = yOffset;
}

Tooltip.prototype.setBGColor = function(bgColor)
{
	if (this.tooltipElem != null)
	{
		this.tooltipElem.style.backgroundColor = bgColor;
	}
}

