var isFirefox = (navigator.userAgent.indexOf( "Firefox")>=0);


function getElementX(theElement) {
  var x = 0;
  while(theElement) {
    x += theElement.offsetLeft;
	theElement = theElement.offsetParent;
  
  }

  return x;
}




function setOpacity(theOpacity,theElement) {

    if(!isFirefox) {
		theElement.style.filter="alpha(opacity=0)";
	    theElement.filters.alpha.opacity = theOpacity;
	
	}  else {
	
	    theElement.style.MozOpacity = theOpacity/100;
	}
	
  

}



function getElementY(theElement) {
  var y = 0;
  while(theElement) {
    y += theElement.offsetTop;
	theElement = theElement.offsetParent;
  
  }

  return y;
  }
  
  
  
  
function showMenu(menuId,menuHeaderId) {
      hideAllMenus();
      var menuHeaderEl = document.getElementById(menuHeaderId);
	  
      var x = getElementX(menuHeaderEl) - 4;
	  
	  var y = 0;
	  
	  y = getElementY(menuHeaderEl) + menuHeaderEl.offsetHeight - 4;
	 
      
	  openDialogWithXY(menuId,x,y)
}
  
  
  
  
  
  function hideAllMenus() {
    closeDialog('menuHome');
	closeDialog('menuProducts');
	closeDialog('menuServices');
	closeDialog('menuClients');
	closeDialog('menuDownload');
	closeDialog('menuNews');
	closeDialog('menuHelp');
	
  }
  
  
  function clearAllMenuItems(menuTable) {
    var allRows  = menuTable.rows;
	for(var i = 0; i < allRows.length; i++) {
	  var theCell = allRows[i].cells[0];
	  theCell.className = 'styleMenuItemTD';
	  theCell.firstChild.className = 'styleMenuItemFont';
	}
  }
  
  function hightlightMenuItem(selectedCell){
  
  
    var menuTable = selectedCell.parentNode.parentNode;
	
	clearAllMenuItems(menuTable);
	
	/*
    var allRows  = menuTable.rows;
	for(var i = 0; i < allRows.length; i++) {
	  var theCell = allRows[i].cells[0];
	  theCell.className = 'styleMenuItemTD';
	  theCell.firstChild.className = 'styleMenuItemFont';
	}
	*/
    
	selectedCell.className = 'styleMenuItemTDSelected';
	selectedCell.firstChild.className = 'styleMenuItemFontSelected';

  
  }
  
  
  function openDialogWithXY(dialogId,x,y) {
   
	var theObj = document.getElementById(dialogId);
	var layer = theObj.style;
	if(layer.visibility == "visible") return;
	
	layer.visibility = "visible";
	

	layer.left = x + "px";
   	layer.top  = y + "px";

}



function closeDialog(dialogId) {
  
	var theObject = document.getElementById(dialogId);
	var theStyle = theObject.style;
    theStyle.visibility = "hidden";
}

	
