// MENU CUSTOMIZATION block starts here //

//menuBgColor= "";// defined in datafile.js so that you can have multiple color for differnt links
menuBorderColor		= "white";
menuOverBgColor		= "white";

fontsize			= "11px";
fontName			= "arial";
normalFontColor 	= "white";
mouseOverFontColor	= "navy";

keepParentHighlighted= true;		// for IE only
menuWidth			= 112;
waitTime			= 500;
leftTextSpace		="3px;"

borderType		= "border:1px solid #000066";
//borderType		= "";
// MENU CUSTOMIZATION block ends here


var ns6=(!document.all && document.getElementById);
var ie=(document.all)

if(ns6) tdStyle = " style='padding-left:"+leftTextSpace+";text-align:left;cursor:pointer;"
if(ie)	tdStyle = " style='padding-left:"+leftTextSpace+";text-align:left;cursor:hand;" +borderType;

fontStyle   = " style='font-weight:normal;font-family:"+fontName+";font-size:"+fontsize+";color:"+normalFontColor +";text-decoration:none;' "

flag=0;
var timer2="";
var timer1="";
var myParentTD=null;
var canHideParentMenu=true;

currentCategory="";
mouseFunctions = ""
currentBgColor="";
currentFontColor="";
tableText="";
var isChildVisible=false;


function showLayer(whichMenu,whichTD)
{
	superMenuNormal();

	clearTimeout(timer1);
	try{
		if(divArray) hideContainerStat(divArray);
	}catch(e){}
	currentMenu=eval(whichMenu);
	//menuWidth			= 112;
	//menuWidth			= 130;
	menuWidth			= 148;

	//tableText = "<Table cellpadding=0 cellspacing=1 bgcolor="+menuBorderColor+" width=112px>\n";
	tableText = "<Table  cellpadding=0 cellspacing=1 bgcolor="+menuBorderColor+" width="+menuWidth+">\n";

	// menu structure
	// [0] - top position
	// [1] - left position
	// [2] - 
	// [3] - menu background color
	// [4] - menu item text
	// [5] - menu link item 
	// [6] - flag if with sub menu (1 if with sub menu otherwise, another menu item)
	// [7] - sub menu item id
	//       if with child menu, increment of 3 + 1 else increment of 1 + 1
	
	for(i=4;i<currentMenu.length;i++)
	{
		var hasChild=null;											//new line
		var childMenuImage ="";
		if(currentMenu[i+2] == 1 )
		{
			if(ns6)
				hasChild = "childNodes=" + currentMenu[i+3]		//new line
			else
				hasChild = "hasChild=" + currentMenu[i+3]		//new line

			childMenuImage = "<img src='http://www.ascovalvenet.com/ASCOValveNet/Common/rightArrow.gif' border=0 align=right valign=absmiddle>"

		}
		uniqueIdentifier=whichMenu+i;

		clickFunctions = " onclick=document.location.href='"+currentMenu[i+1]+"' "
		mouseFunctions = " onmouseover=javascript:changeColor('"  +uniqueIdentifier +"') onmouseout=javascript:changeColorToNormal('"  +uniqueIdentifier +"') "
		tableText+= "\n<tr>\n\t<td height=18 id=td" +uniqueIdentifier+ " bgcolor="+currentMenu[3] + mouseFunctions +clickFunctions+ tdStyle+ "' " +hasChild + " >"
		tableText+= "<span id=link"+uniqueIdentifier+fontStyle+">" +   childMenuImage + currentMenu[i] +  "</span>"
		tableText+= "</td>\n</tr>";
		
		if(hasChild!=null) i=i+3;		//new line
		else							//new line
		i++;
		
	}
	tableText+= "</table>"

	dhtmlMenuLeftPos = whichTD.offsetLeft;
	if(dhtmlMenuLeftPos==0)
		{
			dhtmlMenuLeftPos=dhtmlMenuLeftPos+0.5;
	}
	if(dhtmlMenuLeftPos>0)
	{
		menuParentWidth = whichTD.clientWidth;
		difference  = menuParentWidth - menuWidth;
		dhtmlMenuLeftPos = dhtmlMenuLeftPos + parseInt(difference/2)
	}
	
	if(ns6)
	{
		document.getElementById("menuLayer").innerHTML=tableText
		document.getElementById("menuLayer").style.top=currentMenu[0]
		document.getElementById("menuLayer").style.left=dhtmlMenuLeftPos;
		document.getElementById("menuLayer").style.left= dhtmlMenuLeftPos; 
		document.getElementById("menuLayer").style.display="block"
		document.getElementById("menuLayer").style.visibility="visible"
	}
	else if(ie)
	{
		menuLayer.innerHTML = tableText
		menuLayer.style.top=currentMenu[0];
		menuLayer.style.left=dhtmlMenuLeftPos
		//menuLayer.style.left=currentMenu[1]
		menuLayer.style.display="block"
		menuLayer.style.visibility="visible"
		currentCategory=whichTD.id;
	}
	canHideParentMenu=false;
}

function setFlag()
{
	if(ie && keepParentHighlighted) 	//keep static HTML menu highlighted
	{
		document.all[currentCategory].style.backgroundColor="white"
		document.all[currentCategory].style.color="#000066"
	}
	canHideParentMenu=false;
	clearTimeout(timer1);
}
function disableFlag()
{
	canHideParentMenu=true;
	timer1=setTimeout("closeMe()",waitTime);
}

function closeMe()
{
	superMenuNormal();
	if(ns6)
	{
		document.getElementById("menuLayer").style.visibility="hidden"
		document.getElementById("menuLayer").style.display="none"
	}
	else if(ie)
	{
		menuLayer.style.visibility="hidden"
		menuLayer.style.display="none"
	}


	try{
		if(divArray) showContainerStat(divArray);
	}catch(e){}
}

function changeColor(givenID)
{
	if(ns6)
	{
		currentBgColor   = document.getElementById("td"+givenID).style.backgroundColor
		currentFontColor = document.getElementById("link"+givenID).style.color

		document.getElementById("td"+givenID).style.backgroundColor= menuOverBgColor
		document.getElementById("link"+givenID).style.color=mouseOverFontColor

		document.getElementById("td"+givenID).style.border = "1px solid #000066";
		if(document.getElementById("td"+givenID).childNodes!=null)
		{
			myParentTD = givenID;
			var subMenu = document.getElementById("td"+givenID).attributes["childNodes"].value
			showChild(subMenu);
		}
	}
	else
	{
		currentBgColor   = document.all["td"+givenID].style.backgroundColor;
		currentFontColor = document.all["link"+givenID].style.color

		document.all["td"+givenID].style.backgroundColor=menuOverBgColor
		document.all["link"+givenID].style.color=mouseOverFontColor

		document.all["td"+givenID].style.border = "1px solid #000066";
		if(document.all["td"+givenID].hasChild!=null)
		{
			myParentTD = givenID;
			showChild(document.all["td"+givenID].hasChild);
		}
	}
}

function changeColorToNormal(givenID)
{
	if(ns6)
	{
		document.getElementById("td"+givenID).style.backgroundColor=currentBgColor
		document.getElementById("link"+givenID).style.color=currentFontColor
	}
	else
	{
		document.all["td"+givenID].style.backgroundColor=currentBgColor;
		document.all["link"+givenID].style.color=currentFontColor;
	}

	if(document.all["td"+givenID].hasChild!=null || document.getElementById("td"+givenID).childNodes!=null)
	{
		isChildVisible=false;
		hideChildMenu();
	}
}

function showChild(givenArray)
{
	var hasChildArray = eval(givenArray);

	childTableText = "<Table cellpadding=0 cellspacing=1 bgcolor="+menuBorderColor+" width="+menuWidth+">\n";

	for(i=4;i<hasChildArray.length;i++)
	{
		uniqueIdentifier="subChild"+givenArray+i;

		clickFunctions = " onclick=document.location.href='"+hasChildArray[i+1]+"' "
		mouseFunctions = " onmouseover=javascript:changeColor('"  +uniqueIdentifier +"')  onmouseout=javascript:changeColorToNormal('"  +uniqueIdentifier +"') "
		childTableText+= "\n<tr>\n\t<td height=18 id=td" +uniqueIdentifier+ " bgcolor="+hasChildArray[3] + mouseFunctions +clickFunctions+ tdStyle+ "'>"
		childTableText+= "<span id=link"+uniqueIdentifier+fontStyle+ ">" +  hasChildArray[i] + "</span>"
		childTableText+= "</td>\n</tr>";
		i++;
	}
	childTableText+= "\n</table>";

	if(ie)
	{
		subMenuLayer.innerHTML = childTableText;
		//alert(currentMenu[0] + parseInt(document.all["td"+myParentTD].offsetTop))
		subMenuLayer.style.top=currentMenu[0] + parseInt(document.all["td"+myParentTD].offsetTop);
		//subMenuLayer.style.top=hasChildArray[0];
		subMenuLayer.style.left= (parseInt(menuLayer.style.left) + 110 + hasChildArray[1]);
		subMenuLayer.style.display="block"
		subMenuLayer.style.visibility="visible"
	}
	else
	{
		subMenuLayer.innerHTML = childTableText;
		//alert(currentMenu[0] + parseInt(document.all["td"+myParentTD].offsetTop))
		subMenuLayer.style.top=currentMenu[0] + parseInt(document.getElementById("td"+myParentTD).offsetTop);
		subMenuLayer.style.left= (parseInt(menuLayer.style.left) + 110 + hasChildArray[1]);
		subMenuLayer.style.display="";
		subMenuLayer.style.visibility="visible"
	}

	isChildVisible=true;

}


function keepParentMenuVisible()
{
	isChildVisible=true;
	clearTimeout(timer2);
	try{		//for the sake of VERY VERY FAST mouse MOVEMENT
	document.all["td"+myParentTD].style.backgroundColor=menuOverBgColor
	document.all["link"+myParentTD].style.color=mouseOverFontColor
	document.all["td"+myParentTD].style.border = "1px solid #000066";
	}catch(e){}
	setFlag();
}


function hideChildMenu()
{
	isChildVisible=false;
	canHideParentMenu=true;
	timer2=setTimeout("killChildMenu()",100);
}
function killChildMenu()
{
	if(isChildVisible==true) return;

	isChildVisible=false;
	try{		//for the sake of VERY VERY FAST mouse MOVEMENT
		if (ie)
		{
			document.all["td"+myParentTD].style.backgroundColor=currentBgColor;
			document.all["link"+myParentTD].style.color=currentFontColor;
			document.all["td"+myParentTD].style.border = "1px solid #000066";
		}
		else
		{
			document.getElementById("td"+myParentTD).style.backgroundColor=currentBgColor;
			document.getElementById("link"+myParentTD).style.color=currentFontColor;
			document.getElementById("td"+myParentTD).style.border = "1px solid #000066";
		}
	}catch(e){}
	subMenuLayer.style.display="none";
	subMenuLayer.style.visibility="hidden";

	if(canHideParentMenu==true) closeMe();
}

function superMenuNormal()
{
	if(ie && keepParentHighlighted && currentCategory!="")	 //disable static HTML menu highlighted
	{
		document.all[currentCategory].style.backgroundColor=""
		document.all[currentCategory].style.color=""
	}
}