// The hard-coded numbers in functions - drawToolbar() & resizeToolbar()
// correspond to the dimension of the four gif files:
//		ICP_BANNER: -20h x 250w
//		ADS_BANNER: 40h x 200w
//		MSC_BANNER: 40h x 112w
//		Curve:	    20h x 18w

var ToolBar_Supported = ToolBar_Supported ;

var MainMenuFontSize="";
var MainMenuFontName="";
var MainMenuFontBold="";
var MainMenuFontItalic="";
var MainMenuFontUnderline="";
	
var SubMenuFontSize="";
var SubMenuFontName="";
var SubMenuFontBold="";
var SubMenuFontItalic="";
var SubMenuFontUnderline="";
var strOldMenuIDStr="";

var ToolBarMenuDesign=new Array();

var cstrOnClick="onclick";
var cstrMouseOver="onmouseover";

var cintPopupMenuName=0;
var cintPopupMenuBgColor=1;
var cintPopupMenuMouseBgColor=2;
var cintPopupMenuMouseClickedBgColor=3;
var cintPopupMenuFontColor=4;
var cintPopupMenuMouseOverFontColor=5;
var cintPopupMenuSubMenuBgColor=6;
var cintPopupMenuSubMenuMouseOverBgColor=7;
var cintPopupMenuSubMenuFontColor=8;
var cintPopupMenuSubMenuMouseOverFontColor=9;

var intMouseClickedMenuId=-1;

function drawToolbar(strMenuDisplayStyle)
{
	HTMLStr += "</DIV>";
	document.write(HTMLStr);
	
	//document.write('<TEXTAREA rows=20 cols=80>'+HTMLStr+'</TEXTAREA>');
	ToolbarLoaded = true;
	
	eval(strToolbarName+".style.backgroundColor= ToolbarBGColor;")
	
	//idICPMenuPane.style.backgroundColor  = aDefMSColor[0];
	eval(stridICPMenuPane+".style.backgroundColor  = aDefMSColor[0];");
	//idICPMenuPane.style.backgroundColor = "";//aDefICPColor[0];
	eval(stridICPMenuPane+".style.backgroundColor = '';");
	
	resizeToolbar();

	for (i = 0; i < TotalMenu; i++) 
	{
		thisMenu = document.all(arrMenuInfo[i].IDStr);
		if (thisMenu != null)
		{
			if (arrMenuInfo[i].IDStr == LastMSMenu && arrMenuInfo[i].type == "R")
			{
				//Last MSMenu has to be absolute width
				arrMenuInfo[i].type = "A";
				arrMenuInfo[i].unit = 200;
			}
			if (arrMenuInfo[i].type == "A")
				{
				
				if (strMenuDisplayStyle==cstrMenuOver)
					thisMenu.style.width = arrMenuInfo[i].unit;			
				else
					thisMenu.style.width = arrMenuInfo[i].unit+440;

				}
			else 
				thisMenu.style.width = Math.round(arrMenuInfo[i].width * arrMenuInfo[i].unit) + 'em';
		}
	}
}

function resizeToolbar()
{
	if (ToolBar_Supported == false) return;

	w = Math.max(ToolbarMinWidth, document.body.clientWidth) - ToolbarMinWidth;
	
}
function setToolbarBGColor(color)
{	
	ToolbarBGColor = color;
	if (ToolbarLoaded == true)
		eval(strToolbarName+"+.style.backgroundColor = ToolbarBGColor;");
}	

function setMSMenuFont(sFont)
{	MSFont = sFont;
}

function setICPMenuFont(sFont)
{	ICPFont = sFont;
}

function setDefaultMSMenuColor(bgColor, fontColor, mouseoverColor)
{	
	if (bgColor   != "")	  aDefMSColor[0] = bgColor;
	if (fontColor != "")	  aDefMSColor[1] = fontColor;
	if (mouseoverColor != "") aDefMSColor[2] = mouseoverColor;
}

function setDefaultICPMenuColor(bgColor, fontColor, mouseoverColor)
{	
	if (bgColor   != "")	  aDefICPColor[0] = "";//bgColor;
	if (fontColor != "")	  aDefICPColor[1] = fontColor;
	if (mouseoverColor != "") aDefICPColor[2] = mouseoverColor;
}

function setICPMenuColor(MenuIDStr, bgColor, fontColor, mouseoverColor)
{
	if (ToolbarLoaded == false) return;

	// Reset previous ICP Menu color if any
	if (CurICPMenu != "")
	{
		PrevID = CurICPMenu.substring(4);
		CurICPMenu = "";
		setICPMenuColor(PrevID, aDefICPColor[0], aDefICPColor[1], aDefICPColor[2]);
	}

	var	id = "AM_" + "ICP_" + MenuIDStr;
	var thisMenu = document.all(id);
	
	if (thisMenu != null)
	{
		CurICPMenu = "ICP_" + MenuIDStr;
		aCurICPColor[0] = bgColor;
		aCurICPColor[1] = fontColor;
		aCurICPColor[2] = mouseoverColor;

		// Change menu color
		if (bgColor != "")
			thisMenu.style.backgroundColor = bgColor;
		if (fontColor != "")
			thisMenu.style.color = fontColor;

		// Change subMenu color
		id = "ICP_" + MenuIDStr;
		thisMenu = document.all(id);
		if (thisMenu != null)
		{
			if (bgColor != "")
				thisMenu.style.backgroundColor = bgColor;
			
			if (fontColor != "")
			{
				i = 0;
				id = "AS_" + "ICP_" + MenuIDStr;
				thisMenu = document.all.item(id,i);
				while (thisMenu != null)
				{
					thisMenu.style.color = fontColor;
					i += 1;
					thisMenu = document.all.item(id,i);
				}
			}
		}
	}
}

function setAds(Gif,Url,AltStr)
{	setBanner(Gif,Url,AltStr,"<!--BEG_ADS_BANNER-->","<!--END_ADS_BANNER-->");
}

function setICPBanner(Gif,Url,AltStr)
{	setBanner(Gif,Url,AltStr,"<!--BEG_ICP_BANNER-->","<!--END_ICP_BANNER-->");
}

function setMSBanner(Gif,Url,AltStr)
{	tempGif = "/library/toolbar/images/" + Gif;
	setBanner(tempGif,Url,AltStr,"<!--BEG_MSC_BANNER-->","<!--END_MSC_BANNER-->");
}

function setBanner(BanGif, BanUrl, BanAltStr, BanBegTag, BanEndTag)
{
	begPos = HTMLStr.indexOf(BanBegTag);
	endPos = HTMLStr.indexOf(BanEndTag) + BanEndTag.length;
	
	SubStr = HTMLStr.substring(begPos, endPos);
	SrcStr = "";
	if (BanUrl != "")
		SrcStr += "<A Target='_top' HREF='" + formatURL(BanUrl, BanGif) + "'>";
	SrcStr += "<IMG SRC='" + BanGif + "' ALT='" + BanAltStr + "' BORDER=0>";
	if (BanUrl != "")
		SrcStr += "</A>";
	SrcStr = BanBegTag + SrcStr + BanEndTag;
	HTMLStr = HTMLStr.replace(SubStr, SrcStr);	
}

function setICPSubMenuWidth(MenuIDStr, WidthType, WidthUnit)
{	tempID = "ICP_" + MenuIDStr;
	setSubMenuWidth(tempID, WidthType, WidthUnit);
}

function setMSSubMenuWidth(MenuIDStr, WidthType, WidthUnit)
{	tempID = "MS_" + MenuIDStr;
	setSubMenuWidth(tempID, WidthType, WidthUnit);
}

function setSubMenuWidth(MenuIDStr, WidthType, WidthUnit)
{
	var fFound = false;
	if (TotalMenu == MaxMenu)
	{
		alert("Unable to process menu. Maximum of " + MaxMenu + " reached.");
		return;
	}
	
	for (i = 0; i < TotalMenu; i++)
		if (arrMenuInfo[i].IDStr == MenuIDStr)
		{
			fFound = true;
			break;
		}

	if (!fFound)
	{
		arrMenuInfo[i] = new menuInfo(MenuIDStr);
		TotalMenu += 1;
	}

	if (!fFound && WidthType.toUpperCase().indexOf("DEFAULT") != -1)
	{
		arrMenuInfo[i].type = "A";
		arrMenuInfo[i].unit = 220;
	}
	else
	{
		arrMenuInfo[i].type = (WidthType.toUpperCase().indexOf("ABSOLUTE") != -1)? "A" : "R";
		arrMenuInfo[i].unit = WidthUnit;
	}
}

// This function creates a menuInfo object instance.
function menuInfo(MenuIDStr)
{
	this.IDStr = MenuIDStr;
	this.type  = "";
	this.unit  = 0;
	this.width = 0;
	this.count = 0;
}

function updateSubMenuWidth(MenuIDStr)
{
	for (i = 0; i < TotalMenu; i++)
		if (arrMenuInfo[i].IDStr == MenuIDStr)
		{
			if (arrMenuInfo[i].width < MenuIDStr.length) 
				arrMenuInfo[i].width = MenuIDStr.length;
			arrMenuInfo[i].count = arrMenuInfo[i].count + 1;
			break;
		}
}

function addICPMenu(MenuIDStr, MenuDisplayStr, MenuHelpStr, MenuURLStr,strTarget,strBgColor,strFontColor,strMenuStyle,strMouseAction,intMenuIndex)
{
/*	if (addICPMenu.arguments.length > 2)
		TargetStr = "_parent" ;
//addICPMenu.arguments[2];
	else
		TargetStr = "_parent";*/
	
	if (strTarget=="")
	    strTarget = "_parent";	
	
	TargetStr = strTarget;

	tempID = "ICP_" + MenuIDStr;
	
	addMenu(tempID, MenuDisplayStr, MenuHelpStr, MenuURLStr, TargetStr, true,strBgColor,strFontColor,strMenuStyle,strMouseAction,intMenuIndex); 
}

function addMSMenu(MenuIDStr, MenuDisplayStr, MenuHelpStr, MenuURLStr)
{	
	TargetStr = "_top";
	tempID = "MS_" + MenuIDStr;
	addMenu(tempID, MenuDisplayStr, MenuHelpStr, MenuURLStr, TargetStr, false); 
	LastMSMenu = tempID;
}

function addMenu(MenuIDStr, MenuDisplayStr, MenuHelpStr, MenuURLStr, TargetStr, bICPMenu,strBgColor,strFontColor,strMenuStyle,strMouseAction,intMenuIndex)
{ 
	var strMouseOverAction="";
	var strMouseOutAction="";
	var strMouseClickAction="";
	
	//cFont   = bICPMenu? ICPFont : MSFont;
	cFont=MainMenuFontName;
	cColor0 = bICPMenu? aDefICPColor[0] : aDefMSColor[0];
	cColor1 = bICPMenu? aDefICPColor[1] : aDefMSColor[1];
	cColor2 = bICPMenu? aDefICPColor[2] : aDefMSColor[2];
	tagStr  = bICPMenu? "<!--ICP_MENU_TITLES-->" : "<!--MS_MENU_TITLES-->";

	cColor0=strBgColor;
	
	MenuStr = newLineChar;
	if (bICPMenu == false && LastMSMenu != "")
		MenuStr += "<SPAN STYLE='font:" + cFont + ";color:" + cColor1 + "'>&nbsp;</SPAN>"; 
	MenuStr += "<td nowrap><A TARGET='" + TargetStr + "' TITLE='" + MenuHelpStr + "'" +
			   "   ID='AM_" + MenuIDStr + "'" +
			   "   STYLE='height:20px;text-decoration:none;cursor:normal;TEXT-DECORATION:"+MainMenuFontUnderline+";font-style:"+MainMenuFontItalic+";font-weight:"+MainMenuFontBold+";font-size:"+MainMenuFontSize+";font-family:" + cFont + ";background-color:" + cColor0 + ";color:" + strFontColor + ";'";
	if (MenuURLStr != "")
	{
		if (bICPMenu)
			MenuStr += " HREF='" + formatURL(MenuURLStr, ("ICP_" + MenuDisplayStr)) + "'";
		else
			MenuStr += " HREF='" + formatURL(MenuURLStr, ("MS_" + MenuDisplayStr)) + "'";
	}
	else
		MenuStr += " HREF='' onclick='window.event.returnValue=false;'";
	//MenuStr += 	" onmouseover="  + char34 + "mouseMenu('out' ,'" + MenuIDStr + "'); hideMenu();" + char34 + 
				" " +strMouseAction+"=" + char34 + "mouseMenu('over','" + MenuIDStr + "'); doMenu('"+ MenuIDStr + "');" + char34 + ">" +
				"&nbsp;" + MenuDisplayStr + "&nbsp;</a></td>";
	//MenuStr += 	" onmouseover=" + char34 + "document.getElementById(this.id).style.color='"+strMouseOverFontColor+"';" + char34 + 
				" " +strMouseAction+"=" + char34 + "mouseMenu('over','" + MenuIDStr + "'); doMenu('"+ MenuIDStr + "');" + char34 + ">" +
				"&nbsp;" + MenuDisplayStr + "&nbsp;</a></td>";
	//MenuStr += 	" onmouseover=" + char34 + "document.getElementById(this.id).style.color='"+strMouseOverFontColor+"';" + char34 +
				" onmouseout=" + char34 + "document.getElementById(this.id).style.color='"+strFontColor+"';" + char34 +  
				" " +strMouseAction+"=" + char34 + "mouseMenu('over','" + MenuIDStr + "'); doMenu('"+ MenuIDStr + "');" + char34 + ">" +
				"&nbsp;" + MenuDisplayStr + "&nbsp;</a></td>";

	//Mouse over strings
	/*if (strMouseOverBgColor!="")
		strMouseOverAction=" document.getElementById(this.id).style.backgroundColor='"+strMouseOverBgColor+"';"
	if (strMouseOverFontColor!="")
		strMouseOverAction=strMouseOverAction + 
			" document.getElementById(this.id).style.color='"+strMouseOverFontColor+"';"*/

	//Mouse out strings
	/*if (strBgColor!="")
		strMouseOutAction=" document.getElementById(this.id).style.backgroundColor='"+strBgColor+"';"
	if (strFontColor!="")
		strMouseOutAction=strMouseOutAction + 
			" document.getElementById(this.id).style.color='"+strFontColor+"';"*/

 	//Mouse click strings
	/*if (strClickedBgColor!="")
		strMouseClickAction=" document.getElementById(this.id).style.backgroundColor='"+strClickedBgColor+"';"*/
	
	if (strMouseAction==cstrMouseOver)
		{
		strMouseOverAction = " "+cstrMouseOver+"="+ char34 + "changemouseoveraction("+intMenuIndex+",true,0);mouseMenu('over','" + MenuIDStr + "'); doMenu('"+ MenuIDStr + "','"+strMenuStyle+"');" +
							" " + strMouseOverAction + char34 +
							" " + cstrOnClick + "="+char34+strMouseClickAction+char34+" ";
		
		MenuStr += strMouseOverAction + " " +
				" onmouseout="+char34+"changemouseoutaction("+intMenuIndex+",true,0)" +char34+ " " +
				 " " + ">" + "&nbsp;" + MenuDisplayStr + "&nbsp;</a></td>";

		}
	else
	{
		strMouseClickAction=" "+strMouseAction+"="+ char34 + "changemouseclickaction("+intMenuIndex+",true);mouseMenu('over','" + MenuIDStr + "'); doMenu('"+ MenuIDStr + "','"+strMenuStyle+"');" + 
					" " + strMouseClickAction + char34 +
					" " + cstrMouseOver + "="+char34+"changemouseoveraction("+intMenuIndex+",true,0)"+char34+" ";
		
		MenuStr += strMouseClickAction + " " +
				" onmouseout="+char34+"changemouseoutaction("+intMenuIndex+",true,0)" +char34+ " " +
				 " " + ">" + "&nbsp;" + MenuDisplayStr + "&nbsp;</a></td>";
				 
	}	
	
	//MenuStr += 	" " +strMouseAction+"=" + char34 + "mouseMenu('over','" + MenuIDStr + "'); doMenu('"+ MenuIDStr + "','"+strMenuStyle+"');" + char34 + ">" +
				"&nbsp;" + MenuDisplayStr + "&nbsp;</a></td>";

	if (bICPMenu)
		MenuStr += "";
	MenuStr += tagStr;

	HTMLStr = HTMLStr.replace(tagStr, MenuStr);	

	if (strMenuStyle==cstrMenuOver)	
		setSubMenuWidth(MenuIDStr,"default",0);
	else
		//setSubMenuWidth(MenuIDStr+strSubMenuString,"default",0);
		setSubMenuWidth(MenuIDStr,"default",1);
}

function addICPSubMenu(MenuIDStr, SubMenuStr, SubMenuURLStr,strTarget,strMenuStyle,strSubMenuBgColor,strSubMenuFontColor,intMenuIndex,intSubMenuIndex)
{
	if (addICPSubMenu.arguments.length > 3)
		TargetStr = addICPSubMenu.arguments[3];
	else
		TargetStr = "_top";
	tempID = "ICP_" + MenuIDStr;
	addSubMenu(tempID,SubMenuStr,SubMenuURLStr,strTarget,true,strMenuStyle,strSubMenuBgColor,strSubMenuFontColor,intMenuIndex,intSubMenuIndex); 
}

function addMSSubMenu(MenuIDStr, SubMenuStr, SubMenuURLStr)
{	
	TargetStr = "_top";
	tempID = "MS_" + MenuIDStr;
	addSubMenu(tempID,SubMenuStr,SubMenuURLStr,TargetStr,false); 
}

function addSubMenu(MenuIDStr, SubMenuStr, SubMenuURLStr, TargetStr, bICPMenu,strMenuStyle,strSubMenuBgColor,strSubMenuFontColor,intMenuIndex,intSubMenuIndex)
{
	//cFont   = bICPMenu? ICPFont : MSFont;
	cFont=SubMenuFontName;

	cColor0 = bICPMenu? aDefICPColor[0] : aDefMSColor[0];
	//cColor1 = bICPMenu? aDefICPColor[1] : aDefMSColor[1];
	cColor1   = strSubMenuFontColor;
	cColor2 = bICPMenu? aDefICPColor[2] : aDefMSColor[2];
	
	var MenuPos = MenuIDStr.toUpperCase().indexOf("MENU");
	if (MenuPos == -1) { MenuPos = MenuIDStr.length; }
	InstrumentStr = MenuIDStr.substring(0 , MenuPos) + "|" + SubMenuStr;;
	URLStr        = formatURL(SubMenuURLStr, InstrumentStr);

	var LookUpTag  = "<!--" + MenuIDStr + "-->";
	var sPos = HTMLStr.indexOf(LookUpTag);
	if (sPos <= 0)
	{
		if (strMenuStyle==cstrMenuOver)	
			HTMLStr += newLineChar + newLineChar +
					"<SPAN ID='" + MenuIDStr + "'" +
					" STYLE='display:none;position:absolute;background-color:" + strSubMenuBgColor + ";padding-top:0;padding-left:0;padding-bottom:20;z-index:9;'" +
					" onmouseout='hideMenu();'>";
		else
			HTMLStr += newLineChar + newLineChar +
					"<SPAN ID='" + MenuIDStr + "'" +
					" STYLE='display:none;position:absolute;padding-top:00;padding-left:0;padding-bottom:20;z-index:9;'" +
					" onmouseout='hideMenu();'>";
		
		if (Frame_Supported == false || bICPMenu == false)
			HTMLStr += "<HR  STYLE='position:absolute;left:0;top:0;color:" + cColor1 + "' SIZE=1>";
		if (strMenuStyle==cstrMenuOver)	
			HTMLStr += "<DIV STYLE='position:relative;left:2;top:8;'>";
		else
			HTMLStr += "<DIV STYLE='position:relative;left:2;top:8;'>";
		
		
		
			//width:47pc;
	}

	TempStr = newLineChar +
				"<A ID='AS_" + MenuIDStr + "_" + intSubMenuIndex + "'" +
				"   STYLE='text-decoration:none;height:5;cursor:hand;background-color:"+ strSubMenuBgColor +";TEXT-DECORATION:"+SubMenuFontUnderline+";font-style:"+SubMenuFontItalic+";font-weight:"+SubMenuFontBold+";font-size:"+SubMenuFontSize+";font-family:" + cFont + ";color:" + cColor1 + "'" +
				"   HREF='" + URLStr + "' TARGET='" + TargetStr + "'" +
				" onmouseout="  + char34 + "changemouseoutaction("+intMenuIndex+",false,"+intSubMenuIndex+");mouseMenu('out' ,'" + MenuIDStr + "');" + char34 + 
				" onmouseover=" + char34 + "changemouseoveraction("+intMenuIndex+",false,"+intSubMenuIndex+");mouseMenu('over','" + MenuIDStr + "');" + char34 + ">" +
				"&nbsp;" + SubMenuStr + "</A>";
		
	if (strMenuStyle==cstrMenuOver)
		TempStr = TempStr +	"<BR>" + LookUpTag;
	else				
		TempStr = TempStr + LookUpTag;
		
	if (sPos <= 0)
		{
		HTMLStr += TempStr + "</DIV></SPAN>";
		
		}
	else
		{
		HTMLStr = HTMLStr.replace(LookUpTag, TempStr);	
		}

	updateSubMenuWidth(MenuIDStr);	
}

function addICPSubMenuLine(MenuIDStr)
{	
	tempID = "ICP_" + MenuIDStr;
	addSubMenuLine(tempID,true);
}

function addMSSubMenuLine(MenuIDStr)
{	
	tempID = "MS_" + MenuIDStr;
	addSubMenuLine(tempID,false);
}

function addSubMenuLine(MenuIDStr, bICPMenu)
{
	var LookUpTag = "<!--" + MenuIDStr + "-->";
	var sPos = HTMLStr.indexOf(LookUpTag);
	if (sPos > 0)
	{
		cColor  = bICPMenu? aDefICPColor[1] : aDefMSColor[1];
		TempStr = newLineChar + "<HR STYLE='color:" + cColor + "' SIZE=1>" + LookUpTag;
		HTMLStr = HTMLStr.replace(LookUpTag, TempStr);
	}
}

function mouseMenu(id, MenuIDStr) 
{	
	
	IsMSMenu   = (MenuIDStr.toUpperCase().indexOf("MS_") != -1);
	IsMouseout = (id.toUpperCase().indexOf("OUT") != -1);
	
	if (IsMouseout)
	{
		color = IsMSMenu? aDefMSColor[1] : aDefICPColor[1];
		if (MenuIDStr == CurICPMenu && aCurICPColor[1] != "") 
			color = aCurICPColor[1];
			
	}
	else
	{
	
		color = IsMSMenu? aDefMSColor[2] : aDefICPColor[2];
		if (MenuIDStr == CurICPMenu && aCurICPColor[2] != "") 
			color = aCurICPColor[2];
	}
	//window.event.srcElement.style.color = color;
	
}

function doMenu(MenuIDStr,strMenuStyle) 
{
	var thisMenu = document.all(MenuIDStr);
	if (ToolbarMenu == null || thisMenu == null || thisMenu == ToolbarMenu) 
	{
		window.event.cancelBubble = true;
		return false;
	}
	// Reset dropdown menu
	window.event.cancelBubble = true;
	ToolbarMenu.style.display = "none";
	showElement("SELECT");
	showElement("OBJECT");
	ToolbarMenu = thisMenu;
	IsMSMenu = (MenuIDStr.toUpperCase().indexOf("MS_") != -1);

	// Set dropdown menu display position

	if (strMenuStyle==cstrMenuOver)	
		//x  = window.event.srcElement.offsetLeft +
	 	// window.event.srcElement.offsetParent.offsetLeft;
		//x=eval(strToolbarName+".offsetParent.offsetLeft")+window.event.srcElement.offsetParent.offsetLeft;	 	
		x=eval(strIdRow2+".offsetLeft")+window.event.srcElement.offsetParent.offsetLeft;	 	
		
	else
		//x  = window.event.srcElement.offsetLeft;
		//x=eval(strToolbarName+".offsetParent.offsetLeft"); 	
		x=eval(strIdRow2+".offsetLeft");
	
	
	/*if (MenuIDStr == LastMSMenu) 
		x += (window.event.srcElement.offsetWidth - thisMenu.style.posWidth);*/

	if (strMenuStyle==cstrMenuOver)	
		x2 = x + window.event.srcElement.offsetWidth;
	else
		x2 = x + window.event.srcElement.offsetWidth+window.event.srcElement.offsetParent.offsetLeft+600;
	
	//y  = (IsMSMenu)? 
	//	 (idRow1.offsetHeight) :
	//	 (idRow1.offsetHeight + idRow2.offsetHeight + idRow3.offsetHeight);
	//y=idRow2.offsetParent.offsetTop+38;

	if (strMenuStyle==cstrMenuOver)	
		y=eval(strIdRow2+".offsetTop+40;");
	else
		y=eval(strIdRow2+".offsetTop+60;");
	
	//x=x+6;

	//x=x+10;	

	thisMenu.style.top  = y;
	thisMenu.style.left = x;
	thisMenu.style.clip = "rect(0 0 0 0)";
	thisMenu.style.display = "block";

	// delay 2 millsecond to allow the value of ToolbarMenu.offsetHeight be set
	window.setTimeout("showMenu()", 2);

	return true;
}

function showMenu() 
{
	if (ToolbarMenu != null) 
	{ 
		IsMenuDropDown = (Frame_Supported && IsMSMenu == false)? false : true;
		if (IsMenuDropDown == false)
		{
			//y = (y - ToolbarMenu.offsetHeight - idRow3.offsetHeight);
			y = eval("(y - ToolbarMenu.offsetHeight - "+strIdRow3+".offsetHeight);");
			if (y < 0) y = 0;
			ToolbarMenu.style.top = y;

		}
		
		y2 = y + ToolbarMenu.offsetHeight+ToolbarMenu.offsetTop;

		ToolbarMenu.style.clip = "rect(auto auto auto auto)";
		hideElement("SELECT");
		hideElement("OBJECT");
	}
}

function hideMenu()
{
	if (ToolbarMenu != null && ToolbarMenu != strStartMenu) 
	{
		// Don't hide the menu if the mouse move between the menu and submenus
		cY = event.clientY + document.body.scrollTop;
		if ( (event.clientX >= (x+5) && event.clientX <= x2) &&
			 ((IsMenuDropDown == true  && cY > (y-10) && cY <= y2)      ||
			  (IsMenuDropDown == false && cY >= y     && cY <= (y2+10)) ))
		{
			window.event.cancelBubble = true;
			return; 
		}

		ToolbarMenu.style.display = "none";
		//ToolbarMenu = StartMenu;
		eval("ToolbarMenu = "+strStartMenu+";");
		window.event.cancelBubble = true;
		
		showElement("SELECT");
		showElement("OBJECT");
		
		if (intMouseClickedMenuId>-1)
		{

			var strMenuProperties=MenuDesignProperties[intMouseClickedMenuId].split("|");

			var strMenuName=strMenuProperties[cintPopupMenuName];
		
			document.getElementById("AM_ICP_"+strMenuName).style.backgroundColor=strMenuProperties[cintPopupMenuBgColor];
			
		}
		
		intMouseClickedMenuId=-1;
		
	}
}

function hideElement(elmID)
{
	for (i = 0; i < document.all.tags(elmID).length; i++)
	{
		obj = document.all.tags(elmID)[i];
		if (! obj || ! obj.offsetParent)
			continue;

		// Find the element's offsetTop and offsetLeft relative to the BODY tag.
		objLeft   = obj.offsetLeft;
		objTop    = obj.offsetTop;
		objParent = obj.offsetParent;
		while (objParent.tagName.toUpperCase() != "BODY")
		{
			objLeft  += objParent.offsetLeft;
			objTop   += objParent.offsetTop;
			objParent = objParent.offsetParent;
		}
		// Adjust the element's offsetTop relative to the dropdown menu
		objTop = objTop - y;

		if (x > (objLeft + obj.offsetWidth) || objLeft > (x + ToolbarMenu.offsetWidth))
			;
		else if (objTop > ToolbarMenu.offsetHeight)
			;
		else if (IsMSMenu && (y + ToolbarMenu.offsetHeight) <= 80)
			;
		else
			obj.style.visibility = "hidden";
	}
}

function showElement(elmID)
{
	for (i = 0; i < document.all.tags(elmID).length; i++)
	{
		obj = document.all.tags(elmID)[i];
		if (! obj || ! obj.offsetParent)
			continue;
		obj.style.visibility = "";
	}
}

function formatURL(URLStr, InstrumentStr)
{
	var tempStr = URLStr;

	if (DoInstrumentation && URLStr != "" )
	{
		var ParamPos1 = URLStr.indexOf("?");
		var ParamPos2 = URLStr.lastIndexOf("?");
		var ParamPos3 = URLStr.toLowerCase().indexOf("target=");
		var ParamPos4 = URLStr.indexOf("#");
		var Bookmark  = "";
		var URL = URLStr;
		if (ParamPos4 >= 0)
		{
		 	URL = URLStr.substr(0, ParamPos4);
			Bookmark = URLStr.substr(ParamPos4);
		}
		
		if (ParamPos1 == -1)
			tempStr = "?MSCOMTB=";
		else if (ParamPos1 == ParamPos2 && ParamPos3 == -1)	
			tempStr = "&MSCOMTB=";
		else if (ParamPos1 == ParamPos2 && ParamPos3 != -1)	
			tempStr = "?MSCOMTB=";
		else if (ParamPos1 < ParamPos2)
			tempStr = "&MSCOMTB=";

		tempStr = URL + tempStr + InstrumentStr.replace(" ","%20") + Bookmark;
	}
	return tempStr;
}

function changemouseoveraction(intMenuIndex,blnMenu,intSubMenuIndex)
{
	var strMenuProperties="";
	var strMenuName="";

	strMenuProperties=MenuDesignProperties[intMenuIndex].split("|");
	strMenuName=strMenuProperties[cintPopupMenuName];
	
	if (blnMenu==true)
	{
		if (StrTrim(strMenuProperties[cintPopupMenuMouseBgColor])!="")
			document.getElementById("AM_ICP_"+strMenuName).style.backgroundColor=strMenuProperties[cintPopupMenuMouseBgColor];
	
		if (StrTrim(strMenuProperties[cintPopupMenuMouseOverFontColor])!="")		
			document.getElementById("AM_ICP_"+strMenuName).style.color=strMenuProperties[cintPopupMenuMouseOverFontColor];
	}
	else
	{
	
		if (StrTrim(strMenuProperties[cintPopupMenuSubMenuMouseOverBgColor])!="")
			document.getElementById("AS_ICP_"+strMenuName+"_"+intSubMenuIndex).style.backgroundColor=strMenuProperties[cintPopupMenuSubMenuMouseOverBgColor];
	
		if (StrTrim(strMenuProperties[cintPopupMenuSubMenuMouseOverFontColor])!="")		
			document.getElementById("AS_ICP_"+strMenuName+"_"+intSubMenuIndex).style.color=strMenuProperties[cintPopupMenuSubMenuMouseOverFontColor];
	}
}

function changemouseoutaction(intMenuIndex,blnMenu,intSubMenuIndex)
{
	var strMenuProperties="";
	var strMenuName="";
	
	strMenuProperties=MenuDesignProperties[intMenuIndex].split("|");
	strMenuName=strMenuProperties[cintPopupMenuName];

	if (blnMenu==true)
	{
		if (intMouseClickedMenuId>-1)
		{
			if (StrTrim(strMenuProperties[cintPopupMenuMouseClickedBgColor])!="")		
				document.getElementById("AM_ICP_"+strMenuName).style.backgroundColor=strMenuProperties[cintPopupMenuMouseClickedBgColor];
			else
				if (StrTrim(strMenuProperties[cintPopupMenuBgColor])!="")		
					document.getElementById("AM_ICP_"+strMenuName).style.backgroundColor=strMenuProperties[cintPopupMenuBgColor];
			
		}
		else
		{
			if (StrTrim(strMenuProperties[cintPopupMenuBgColor])!="")		
				document.getElementById("AM_ICP_"+strMenuName).style.backgroundColor=strMenuProperties[cintPopupMenuBgColor];
		}

		if (StrTrim(strMenuProperties[cintPopupMenuFontColor])!="")		
			document.getElementById("AM_ICP_"+strMenuName).style.color=strMenuProperties[cintPopupMenuFontColor];
	}
	else
	{
		if (StrTrim(strMenuProperties[cintPopupMenuSubMenuBgColor])!="")		
			document.getElementById("AS_ICP_"+strMenuName+"_"+intSubMenuIndex).style.backgroundColor=strMenuProperties[cintPopupMenuSubMenuBgColor];

		if (StrTrim(strMenuProperties[cintPopupMenuSubMenuFontColor])!="")		
			document.getElementById("AS_ICP_"+strMenuName+"_"+intSubMenuIndex).style.color=strMenuProperties[cintPopupMenuSubMenuFontColor];
			
	}	
}

function changemouseclickaction(intMenuIndex,blnMenu)
{

	intMouseClickedMenuId=intMenuIndex;
	var strMenuProperties="";
	var strMenuName="";
	
	for(i=0;i<MenuDesignProperties.length;i++)
	{
		
		strMenuProperties=MenuDesignProperties[i].split("|");
		strMenuName=strMenuProperties[cintPopupMenuName];
	
		if(intMenuIndex==i)
		{
			if (StrTrim(strMenuProperties[cintPopupMenuMouseClickedBgColor])!="")		
				document.getElementById("AM_ICP_"+strMenuName).style.backgroundColor=strMenuProperties[cintPopupMenuMouseClickedBgColor];
		}
		else
		{
			if (StrTrim(strMenuProperties[cintPopupMenuBgColor])!="")		
				document.getElementById("AM_ICP_"+strMenuName).style.backgroundColor=strMenuProperties[cintPopupMenuBgColor];
		}
	
	}
}

function StrTrim(StrVar)
{
// ***** Function to trim a string sent and return the resultant string ***
        for (I = 0 ; I < StrVar.length ; I++)
        {
                if ((StrVar.substring(0,1)) == " ")
                {
                        StrVar = StrVar.substring(1,StrVar.length)
                        I = I - 1
                }
        }

        for (I = 0 ; I < StrVar.length ; I++)
        {
                if ((StrVar.substring(StrVar.length - 1,StrVar.length - 0)) == " ")
                {
                        StrVar = StrVar.substring(0,StrVar.length - 1)
                        I = I - 1
                }
        }
        return StrVar
}

function showcount(){
var offsetInfo = ""
    clientInfo = "The x coordinate is: " + window.event.clientX + "\r"
    clientInfo += "The y coordinate is: " + window.event.clientY + "\r"
    


}


