
var blnDisply,blnClick,oLastTd,oLastTable;
blnDisply = false;
blnClick = false;

function displayMenu(oTd) {
//set the onclick open/close menu 

  if (!blnDisply) {
	blnClick = true;
	blnDisply = true;
	showMenu(oTd);
  }
  else {
	blnClick = false;
	blnDisply = false;
	hideMenu();
  }
}

function showMenu(oTd) {
//this function hide all the open menus and open the related div to the top menu
  
  hideMenu();
  if (blnClick==true || blnDisply==true) {
    intDivId = oTd.id;
    oDiv = eval('document.all.div_' + intDivId)
    oDiv.style.left = oTd.getBoundingClientRect().left-4;
    oDiv.style.top = oTd.getBoundingClientRect().top+24;//21
    oDiv.style.width = 96;////////add by roi///////////////////////
    oDiv.style.display='';
  }
} 

function hideMenu() {
//hide all open divs
  var NodeList;
  
  NodeList = xmldoc.documentElement.selectNodes("//menu");
  for (i=0;i<NodeList.length;i++) {
	if (NodeList.item(i).getAttribute("isLeaf")==0) {
		intDivId = NodeList.item(i).getAttribute("id")
		oDiv = eval('document.all.div_' + intDivId)
		oDiv.style.display='none';
	}
  }
}
 
function changeMenuStyle(oTr) {
//set the class for on mouse over/out for the side menu

  if (oTr.className=='clsMenuItemUnSelected') {
	oTr.className='clsSelectedMenuItem';
  }
  else {
	oTr.className='clsMenuItemUnSelected';
  }
}

function changeTopLineStyle(oTd) {
//set the class for on mouse over/out for the top line buttons

  if (oTd.className=='clsTopLineUnSelected') {
	oTd.className='clsTopLineSelectedItem';
  }
  else {
	oTd.className='clsTopLineUnSelected';
  }
}

function showHideSideDiv(oTd) {
//hide and show the side menu items
  var intDivId;

  hideSideDiv(oTd);
  if (oTd.isLeaf==0) {
	intDivId = oTd.id;
	oDiv = eval('document.all.div_' + intDivId)
	oDiv.style.left = oTd.getBoundingClientRect().left-242;///rigth+1
	oDiv.style.top = oTd.getBoundingClientRect().top-4;//-5
	oDiv.style.width = 220;//add by roi

	oDiv.style.display='';
  }
}

function hideSideDiv(oTd) {
//hide the side menu items
//strCurDivPath hold the path of open div

  var strCurDivPath,intDivId,NodeList;
  strCurDivPath = oTd.parentElement.parentElement.parentElement.parentElement.divPath + '_';
  NodeList = xmldoc.documentElement.selectNodes("//menu") 
  for (i=0;i<NodeList.length;i++) {
	if (NodeList.item(i).getAttribute("isLeaf")==0) {
  	  intDivId = NodeList.item(i).getAttribute("id")
	  if (strCurDivPath.search('_' + intDivId + '_')==-1) {
		oDiv = eval('document.all.div_' + intDivId)
		oDiv.style.display='none';
	  }
	}
  }
}

function hideOnBodyClick() {
//hide the divs on body click
  var oTr;
  
  oTr=event.srcElement.parentElement.id;
  if(oTr != "topLine") {
	hideMenu();
	blnClick = false;
	blnDisply = false;
  }  
  else {
	if (blnClick==true) {
	  event.srcElement.className='clsTopLineSelectedItem';
	}	
	else {
	  event.srcElement.className='clsTopLineUnSelected';
	}	
  }
}
