var currentMainMenu = null;
var currentSubMenu = null;
var currentSubMenuRow = null;
var menuImages = new Array(6);
var menuRollImages = new Array(6);
var currentRollMenuIndex = -1;

var staticMenuIndex = -1;
var staticSubMenuRow = null;

var staticMenusStr  = ';';

function init()
{
	menuRollImages[0] = 'images/aboutOver.gif';
	menuRollImages[1] = 'images/productOver.gif';
	menuRollImages[2] = 'images/technoOver.gif';
	menuRollImages[3] = 'images/newsOver.gif';
	menuRollImages[4] = 'images/investorsOver.gif';
	menuRollImages[5] = 'images/careerOver.gif';
	menuRollImages[6] = 'images/homeOver.gif';

	menuImages[0] = 'images/aboutReg.gif';
	menuImages[1] = 'images/productReg.gif';
	menuImages[2] = 'images/technoReg.gif';
	menuImages[3] = 'images/newsReg.gif';
	menuImages[4] = 'images/investorsReg.gif';
	menuImages[5] = 'images/careerReg.gif';	
	menuImages[6] = 'images/homeReg.gif';
	for (i=0;i<6;i++)
	{
		aimage = new Image();
		aimage.src = menuRollImages[i];
		
		aimage2 = new Image();
		aimage2.src = menuImages[i];				
	}
	
	var s = window.location.toString();
	var i = s.lastIndexOf('/');
	this.apagename = s.substr(i+1);
	initMenu();
	
}

function initMenu()
{
	for (var i = 1; i < 30; i++)	
	{
		var amenu = document.getElementById('subMenu'+i);
		if (amenu != null)
		{
		  var j = amenu.innerHTML.indexOf('changeLocation(\'');
		  while (j > 0)
		  {
		    j += 16;
		    k = amenu.innerHTML.indexOf('\'', j);
		    var s = amenu.innerHTML.substring(j, k);
		    if (s==this.apagename)
		    {
		      amenu.style.display = '';		            
		      var amenuimage = document.getElementById('menu'+i);
		      amenuimage.style.cursor = '';
		      //amenuimage.onmouseover();		      
		      highlightMenu(i);
		      staticMenuIndex = i;
		      for (var l = j; l > 0; l--)
		      {
		        if (amenu.innerHTML.substr(l, 3).toLowerCase()=='id=')
		        {
		          k = amenu.innerHTML.indexOf('>', l+5);
		          s = amenu.innerHTML.substring(l+3, k).toLowerCase();
		          highlightSubMenuRow(s.substr(10));
              staticSubMenuRow = document.getElementById(s);
	      
	      /*
	      if (staticSubMenuRow.previousSibling != null)
	      {
		      alert(staticSubMenuRow.previousSibling.id);
		      staticSubMenuRow.previousSibling.style.display = '';
	      }
	      */
              if (this.apagename.toLowerCase()=='pipeline.asp')
              {                
                document.getElementById('subMenu202').style.display = '';
              }
			  
			  else if ((this.apagename.toLowerCase()=='dpb99.asp') || (this.apagename.toLowerCase()=='spd421.asp') || (this.apagename.toLowerCase()=='dp109.asp') || (this.apagename.toLowerCase()=='dp155.asp') || (this.apagename.toLowerCase()=='dp388.asp'))
		      {
				highlightSubMenuRow(6, true);
				 showSubMenu(202, true);
		      }
			  
	      else if ((this.apagename.toLowerCase()=='directors.asp') || (this.apagename.toLowerCase()=='managment.asp'))
	      {
		highlightSubMenuRow(3, true);
		 showSubMenu(200, true);
	      }
	      else if (this.apagename.toLowerCase()=='marketsize.asp')
	      {
		highlightSubMenuRow(4, true);
		 showSubMenu(201, true);	      
	      }	      
	      
	      /*
              else
              {
                document.getElementById('pipelinemenus').style.display = 'none';
              }*/
		          break;
		        }
		      }		      
		      return;
		    }
		    j = amenu.innerHTML.indexOf('changeLocation(\'', k);
		  }
		}
	}
}		  

function highlightSubMenuRow(index, forever)
{
	/*if (currentSubMenuRow != null)
	{
		currentSubMenuRow.style.color = '#002366';
		currentSubMenuRow.childNodes[0].childNodes[0].style.display = 'none';
	}*/
	
	//alert(staticMenusStr + '----' + index);
	if (staticMenusStr.indexOf(';subMenuRow' + index + ';') > -1)
	{
		return;
	}
	
	clearMenuRoll();
	
	currentSubMenuRow = document.getElementById('subMenuRow'+index);
	currentSubMenuRow.style.color = '#FB9D00';
	if (currentSubMenuRow.className != 'BIGMENUROW')
	{
		currentSubMenuRow.childNodes[0].childNodes[0].style.display = '';	
	}
	
	if (forever==true)
	{
		staticMenusStr += currentSubMenuRow.id + ';';
		currentSubMenuRow = null;
	}
}

function highlightMenu(index)
{
	clearMenuRoll();
	document.getElementById('menu'+index).src = menuRollImages[index-1];
	currentRollMenuIndex = index;
}

function clearMenuRoll()
{
	if (currentRollMenuIndex != -1)
	{
	  if (currentRollMenuIndex != staticMenuIndex)
	  {
		  document.getElementById('menu'+currentRollMenuIndex).src = menuImages[currentRollMenuIndex-1];	
		}
		currentRollMenuIndex = -1;
	}
	
	if (currentSubMenuRow != null)
	{
	  if (currentSubMenuRow != staticSubMenuRow)
	  {
		  currentSubMenuRow.style.color = '#002366';
		  if (currentSubMenuRow.className != 'BIGMENUROW')
		  {
		  	currentSubMenuRow.childNodes[0].childNodes[0].style.display = 'none';
		  }
		 }
		currentSubMenuRow = null;
	}	
	
	if (currentMainMenu != null)
	{
		currentMainMenu.style.color = '#002366';
	}	
}

function showSubMenu(index, forever)
{
	if (currentSubMenu != null)
	{
		currentSubMenu.style.display = 'none';
		if (currentSubMenu==document.getElementById('subMenu'+index))
		{
			currentSubMenu = null;
			return;
		}
	}
	currentSubMenu = document.getElementById('subMenu'+index);
	currentSubMenu.style.display = '';
	if (currentSubMenu.parentElement.parentElement != null)
	{
		currentSubMenu.parentElement.parentElement.style.display = '';
	}
	
	if (forever==true)
	{
		currentSubMenu = null;
	}
}

function highlightMainMenu(index)
{
	clearMenuRoll();
	currentMainMenu = document.getElementById('mainMenu'+index);
	currentMainMenu.style.color = '#FB9D00';
}

function changeLocation(aurl)
{
	window.location = aurl;
}

function openPopUp(aurl)
{
	window.open(aurl, '', 'noresize=1,width=511,height=425,menubar=0,scroll=0,resize=0');
}