
var currentAnchor=new Object();
var lastAnchor=new Object();
var currentAnchor2=new Object();
var lastAnchor2=new Object();
var la=0;
var ta=0;
m = new Array();
var mout='';

function killMenus()
  {
  if(!currentAnchor)
    {
    m1=document.getElementById('menu1');
    m1.style.visibility = 'hidden';
    b1=document.getElementById('menuIF');
    b1.style.visibility = 'hidden';
    m2=document.getElementById('menu2');
    m2.style.visibility = 'hidden';
    b2=document.getElementById('menuIF2');
    b2.style.visibility = 'hidden';
    }
  }

function killMenu2()
  {
  m2=document.getElementById('menu2');
  m2.style.visibility = 'hidden';
  b2=document.getElementById('menuIF2');
  b2.style.visibility = 'hidden';
  }

function menuAction1(thisAnchor, al, at, num)
  {
  killMenu2();
  if(num==66){at=at-300;}
  if(num==67){at=at-300;}
  if(num==68){at=at-300;}
  if(num>79){at=at-100;}
  currentAnchor=thisAnchor;
  lastAnchor=thisAnchor; 
  e='m = MenuA'+num+';';
  eval(e);
  mout=mout+'<table cellpadding=0 cellspacing=0\
 class="sidemenuTable" onmouseover="highlight(tr'+num+')" onmouseout="dim(tr'+num+')">';
  if(num<10){dnum='0'+num;}
  else{dnum=num;}
  for(i=0;i<m.length;i++)
    {
    desc=m[i].slice(m[i].indexOf('|')+1, m[i].length);
    code=m[i].slice(0, m[i].indexOf('|'));
    mcount=desc.slice(desc.indexOf('|')+1, desc.length);
    mcount=addCommas(mcount);
    desc=desc.slice(0, desc.indexOf('|'));
    if(code<10){dcode='0'+code;}
    else{dcode=code;}
    if(mcount!='0')
      {
      mout=mout+'<tr name="tr'+num+code+'" id="tr'+num+code+'"\
                   onmouseover="highlight(this)"; onmouseout="dim(this)"><td>\
                <img src="images/leftround.gif" width=10 height=15></td><td><a class="cellLink"\
                onclick="top.location.href=\'index.php?ncat='+dnum+dcode+'\'"\
                onmouseover="\
                status=\'http://www.megawatts.com/v1/index.php?ncat='+dnum+dcode+'\';\
                la=anchorLeft(\'anchorB'+num+code+'\');\
                ta=anchorTop(\'anchorB'+num+code+'\');\
                thisAnchor=document.getElementById(\'anchorB'+num+code+'\');\
                menuAction2(thisAnchor, la, ta, \''+num+'\', \''+code+'\')"\
                onmouseout="\
                status=\'\';\
                currentAnchor=\'\';"\
                style="cursor:default">\
                   '+desc+'&nbsp;<span class=menuCount>('+mcount+' items)</span></a></td><td><span id="anchorB'+num+code+'"\
                name="anchorB'+num+code+'">&nbsp;</span></td><td>\
                <img src="images/rightround.gif" width=10 height=15></td></tr>\n';
      }
    }
  menu1td.innerHTML=mout;
  mout='';
  m1=document.getElementById('menu1');
  b1=document.getElementById('menuIF');
  m1.style.left=al-10;
  b1.style.left=al-10;
  if(window.createPopup){m1.style.left=al;    b1.style.left=al+20;}
  if(window.opera)      {m1.style.left=al-10; b1.style.left=al-10;}
  m1.style.top=at-30;
  b1.style.top=at-19;
  b1.style.width=(m1.offsetWidth-33)+'px';
  b1.style.height=(m1.offsetHeight-25)+'px';
  if (document.all){ b1.style.visibility='visible'; }
  m1.style.zIndex=5;
  b1.style.zIndex=4;
  m1.style.visibility = 'visible'; 
  }

function menuAction2(thisAnchor, al, at, num, num2)
  {
  currentAnchor=thisAnchor;
  lastAnchor=thisAnchor;   
  e='m = MenuB'+num+num2+';';
  eval(e);
  if(m.length)
    {
    mout = mout + '<table cellpadding=0 cellspacing=0\
     class="sidemenuTable"\
     onmouseover="highlight(tr'+num+');highlight(tr'+num+num2+')"\
     onmouseout="dim(tr'+num+');dim(tr'+num+num2+')">';
    for(i=0;i<m.length;i++)
      {
      desc=m[i].slice(m[i].indexOf('|')+1, m[i].length);
      code=m[i].slice(0, m[i].indexOf('|'));
      mcount=desc.slice(desc.indexOf('|')+1, desc.length);
      mcount=addCommas(mcount);
      desc=desc.slice(0, desc.indexOf('|'));
      if(mcount!='0')
        {
        mout = mout+'<tr name="tr'+code+'" id="tr'+code+'"\
                   onmouseover="highlight(this)"; onmouseout="dim(this)"><td>\
                <img src="images/leftround.gif" width=10 height=15></td><td><a class="cellLink"\
                onclick="top.location.href=\'index.php?ncat=pf-'+code+'\'"\
                onmouseover="\
                status=\'http://www.megawatts.com/v1/index.php?ncat=pf-'+code+'\';\
                la=anchorLeft(\'anchorB'+code+'\');\
                ta=anchorTop(\'anchorB'+code+'\');\
                thisAnchor=document.getElementById(\'anchorB'+code+'\');"\
                onmouseout="\
                status=\'\';\
                currentAnchor=\'\';"\
                style="cursor:default">\
                   '+desc+'&nbsp;<span class=menuCount>('+mcount+' items)</span></a></td><td>\
                <span id="anchorB'+code+'" name="anchorB'+code+'">&nbsp;\
                </span></td><td>\
                <img src="images/rightround.gif" width=10 height=15></td></tr>';
        }
      }
    mout=mout+'\
  </table>';
    menu2td.innerHTML=mout;
    m2=document.getElementById('menu2');
    b2=document.getElementById('menuIF2');
    m2.style.left=al-10;
    b2.style.left=al-10;
    if(window.createPopup){m2.style.left=al-10; b2.style.left=al+10;}
    if(window.opera)      {m2.style.left=al-10; b2.style.left=al-10;}
    m2.style.top=at-30;
    b2.style.top=at-19;
    b2.style.width=(m2.offsetWidth-33)+'px';
    b2.style.height=(m2.offsetHeight-25)+'px';
    m2.style.visibility = 'visible';
    m2.style.zIndex=7;
    b2.style.zIndex=6;
    m1.style.visibility = 'visible';
    if (document.all){ b2.style.visibility='visible'; }
    mout='';
    }
  }

function showTab()
  {
  tabl=anchorLeft('rightTopCorner');
  tabl=tabl-550;
  topTab.style.left=tabl;
  topTab.style.visibility='visible';
  topInfo.style.left=tabl+20;
  topInfo.style.visibility='visible';
  }

function anchorLeft(myAnchor)
  {
  thisAnchor=document.getElementById(myAnchor);
  var ol=thisAnchor.offsetLeft;
  while ((thisAnchor=thisAnchor.offsetParent) != null) { ol += thisAnchor.offsetLeft; }
  return ol;
  }

function anchorTop(myAnchor)
  {
  thisAnchor=document.getElementById(myAnchor);
  var ot=thisAnchor.offsetTop;
  while((thisAnchor=thisAnchor.offsetParent) != null) { ot += thisAnchor.offsetTop; }
  return ot;
  }

function highlight(var1)
  {
  var1.style.backgroundColor='#849CAA';
  var1.style.color='#FFFFFF';
  }
function dim(var1)
  {
  var1.style.backgroundColor='';
  var1.style.color='';
  }


function addCommas(nStr)
  {
  nStr += '';
  x = nStr.split('.');
  x1 = x[0];
  x2 = x.length > 1 ? '.' + x[1] : '';
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(x1)) 
    {
    x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
  return x1 + x2;
  }
