button = new Image();
buttonover = new Image();

index_index = new Image();
index_index.dea = '1';

index_1 = new Image();
index_2 = new Image();
index_3 = new Image();
index_4 = new Image();
index_5 = new Image();



function hide_table(nr) {
 var s, m;
 s = document.getElementById('sub' + nr);
 m = document.getElementById('main' + nr);
     s.style.visibility='hidden';
     (nr < 100) ? m.style.backgroundColor=bgcol_row : m.style.backgroundColor=bgcol_row;
}



function hide_subs(ss) {
 var h, i, j, s, m, as, ass, cnts = 0, cntss = 0; 
 as = new Array();
 ass = new Array();
 tdiv = document.getElementsByTagName("DIV");
 timg = document.getElementsByTagName("IMG");
 ttr = document.getElementsByTagName("TR");
 for (h = 1; h < tdiv.length; h++) 
     (tdiv[h].id.length > 5) ? ass[cntss++] = tdiv[h].id : as[cnts++] = tdiv[h].id;

 if (ss != 'ss') 
  {
    for (i = 0; i < as.length; i++) 
     {
      s = document.getElementById(as[i]);
      m = as[i].substr(3);
      m = document.getElementById('main' + m);
      s.style.visibility = 'hidden';
      m.style.backgroundColor=bgcol_row;
     }
    for (i = 0; i < timg.length; i++) 
     {
      if (timg[i].src == buttonover.src)
         timg[i].src = button.src;
     }
    for (i = 0; i < ttr.length; i++) 
     {
      if (ttr[i].className == 'main2sub' || ttr[i].className == 'mainmenu') 
         ttr[i].style.color = txt_nrm;
     }
  }
 else 
  { 
    for (i = 0; i < ttr.length; i++) 
     {
      if (ttr[i].className == 'sub2sub' || ttr[i].className == 'submenu') 
         ttr[i].style.color = txt_nrm;
     } 
  }

 for (i = 0; i < ass.length; i++) 
     {
      s = document.getElementById(ass[i]);
      m = ass[i].substr(3);
      m = document.getElementById('main' + m);
      s.style.visibility = 'hidden';
      m.style.backgroundColor=bgcol_row;
     }
}



function place_sub(nr, posy, posx) {
 var h, p, s, m, t;
 s = document.getElementById('sub' + nr);
 m = document.getElementById('main' + nr);
 t = document.getElementById('tabsub' + nr);

 if (nr > 100)
    {
     p = document.getElementById('sub' + Math.floor(nr / 100));
     posy=posy - p.offset;
    }

 s.style.visibility='visible';

 h = posy + t.clientHeight;
 if (h > document.body.clientHeight)
    {
     if (nr < 100) s.offset=posy - (document.body.clientHeight - t.clientHeight);
     s.style.top=document.body.clientHeight - t.clientHeight;
     s.style.left=posx;
    }
 else
    { 
     s.style.top=posy;
     s.offset = 0;
    }

 s.style.left=posx;
}



function show_mouseover(trnam)
{
 if (trnam.className == 'mainmenu' || trnam.className == 'main2sub')
 {
  document ['button_' + trnam.id].src = buttonover.src;
  document.index.src = 'buttons/index_' + trnam.id.substr(4) + '.gif';
  index_index.dea = '0';
 }
 trnam.style.color = txt_over;
 trnam.style.backgroundColor = bgcol_over;
}


function show_mouseout(trnam)
{ 
if (trnam.className == 'mainmenu' || trnam.className == 'main2sub')
 {
  document ['button_' + trnam.id].src = button.src;
  index_index.dea = '1';
  setTimeout('show_index_img()', 1000);
 }
 trnam.style.color = txt_nrm;
 trnam.style.backgroundColor = bgcol_row;
}


function show_index_img() {
 if (index_index.dea == '1') {
     document.index.src = index_index.src;
     index_index.dea = '0';
 }
}


function show_mainmenu(item, pos, tekst, subs, loc) {
var item, pos, tekst, subs, loc;

// item = begin, mid, line, end  mid is menuitem
// pos = position
// tekst = text to display
// subs = "yes" in case of submenus or reference to html in case of single menuitem
// loc = "new", "top" or "", location

if (item == "begin") 
{
document.write('<DIV CLASS=posmain><TABLE WIDTH=200 BGCOLOR=#' + bgcol_row + ' BORDER=0 CELLPADDING=0 CELLSPACING=0><TR HEIGHT=1 BGCOLOR=#' + bgcol_border + '><TD COLSPAN=6></TD></TR>');
}

if (item == "mid") 
{
document.write('<TR HEIGHT=' + rowheight + ' CLASS=');
(subs == "yes") ? document.write('main2sub') : document.write('mainmenu');
document.write(' ID=main' + pos + ' onmouseover="hide_subs(\'all\'); show_mouseover(this); ');

if (subs == "yes") 
   {document.write(' place_sub(' + pos + ', ' + (pos * (eval(rowheight)) + 1 + eval(postop)) + ', ' + suboffset + ')">');}
else
   {
    document.write('" onmouseout="show_mouseout(this);" onclick="');
    if (loc == 'top')
       document.write('top.location.href=\'' + subs + '\'">');
    if (loc == 'new')
       document.write('window.open(\'' + subs + '\' , \'' + tekst + '\')">');
    if (loc == '')
       document.write('parent.main.location.href=\'' + subs + '\'">');
   }

document.write('<TD WIDTH=1 BGCOLOR=#' + bgcol_border + '></TD>');
document.write('<TD WIDTH=20><IMG NAME="button_main' + pos + '" SRC="buttons/button.gif"></TD>');
document.write('<TD>' + tekst + '</TD>');
document.write('<TD WIDTH=15>');
if (subs == "yes") {document.write('<IMG SRC="mmi.gif">');}
document.write('<TD>');
document.write('<TD WIDTH=1 BGCOLOR=#' + bgcol_border + '></TD></TR>');
}

if (item == "line") 
{
document.write('<TR HEIGHT=1><TD COLSPAN=6 BGCOLOR=#' + bgcol_border + '></TD></TR>');
}

if (item == "end")
{
document.write('<TR HEIGHT=1 BGCOLOR=#' + bgcol_border + '><TD COLSPAN=6></TD></TR></TABLE></DIV>');
}
}



function show_submenu(item, pos, tekst, subs) {
var item, pos, tekst, subs;

// item = begin, mid, end  mid is menuitem
// pos = position
// tekst = text to display
// subs = "yes" in case of submenus (then pos is larger than 100 e.g. 602=mainmenu 6 submenu 2) or reference to html in case of single menuitem

if (item == "begin") 
{
document.write('<DIV ID=sub' + pos + ' CLASS=possub>');
document.write('<TABLE ID=tabsub' + pos + ' WIDTH=200 BORDER=0 CELLPADDING=0 CELLSPACING=0>');
document.write('<TR>');
document.write('<TD WIDTH=25 onmouseover="sub' + pos + '.style.visibility=\'hidden\'"></TD>');
document.write('<TD>');
document.write('<TABLE WIDTH=150 BGCOLOR=#' + bgcol_row + ' BORDER=0 CELLPADDING=0 CELLSPACING=0>');
document.write('<TR HEIGHT=1 BGCOLOR=#' + bgcol_bordersub + '><TD COLSPAN=4></TD></TR>');
}

if (item == "mid")
{
if (subs == "yes")
   {
    document.write('<TR HEIGHT=' + rowheightsub + ' CLASS=sub2sub ID=main' + pos);
   document.write(' onmouseover="hide_subs(\'ss\'); show_mouseover(this);');
    document.write(' place_sub(' + pos + ', ' + ((pos.substr(0,1) * eval(rowheight)) + 1 + eval(postop) + ((pos.substr(1) * eval(rowheightsub)) + 1)) + ', ' + subsuboffset + ');">'); 
   }
else
   {
    document.write('<TR HEIGHT=' + rowheightsub + ' CLASS=submenu onmouseover="hide_subs(\'ss\'); show_mouseover(this);" ');
    document.write('" onmouseout="show_mouseout(this);" onclick="');
    if (pos == 'top')
       document.write('top.location.href=\'' + subs + '\'">');
    if (pos == 'new')
       document.write('window.open(\'' + subs + '\' , \'' + tekst + '\')">');
    if (pos == '')
       document.write('parent.main.location.href=\'' + subs + '\'">');
   }

document.write('<TD WIDTH=1 BGCOLOR=#' + bgcol_bordersub + '></TD>');
document.write('<TD WIDTH=6></TD>');
 if (subs == "yes")
   {
    document.write('<TD><IMG SRC="mmi.gif" ALIGN="right">' + tekst + '</TD>');
   }
 else
   {
    document.write('<TD>' + tekst + '</TD>');
   }
document.write('<TD WIDTH=1 BGCOLOR=#' + bgcol_bordersub + '></TD>');
document.write('</TR>');
}

if (item == "line") 
{
document.write('<TR HEIGHT=1><TD COLSPAN=4 BGCOLOR=#' + bgcol_bordersub + '></TD></TR>');
}

if (item == "end") 
{
document.write('<TR HEIGHT=1><TD COLSPAN=4 BGCOLOR=#' + bgcol_bordersub + '></TD></TR>');
document.write('</TABLE>');
document.write('</TD>');
document.write('</TR>');
document.write('</TABLE>');
document.write('</DIV>');
}
}




function show_subsubmenu(item, pos, tekst, subs) {
var item, pos, tekst, subs;

// item = begin, mid, end  mid is menuitem
// pos = position
// tekst = text to display
// subs = "yes" in case of submenus (then pos is larger than 100 e.g. 602=mainmenu 6 submenu 2) or 
// reference to html in case of single menuitem

if (item == "begin") 
{
document.write('<DIV ID=sub' + pos + ' CLASS=possub>');
document.write('<TABLE ID=tabsub' + pos + ' WIDTH=145 BORDER=0 CELLPADDING=0 CELLSPACING=0>');
document.write('<TR>');
document.write('<TD WIDTH=10 onmouseover="sub' + pos + '.style.visibility=\'hidden\'"></TD>');
document.write('<TD>');
document.write('<TABLE WIDTH=125 BGCOLOR=#' + bgcol_row + ' BORDER=0 CELLPADDING=0 CELLSPACING=0>');
document.write('<TR HEIGHT=1 BGCOLOR=#' + bgcol_bordersubsub + '><TD COLSPAN=4></TD></TR>');
}

if (item == "mid")
{
document.write('<TR HEIGHT=' + rowheightsubsub + ' CLASS=submenu onmouseover="show_mouseover(this);" ');
document.write('onmouseout="show_mouseout(this);" ');
document.write('onclick="parent.main.location.href=\'' + subs + '\'">');
document.write('<TD WIDTH=1 BGCOLOR=#' + bgcol_bordersubsub + '></TD>');
document.write('<TD WIDTH=6></TD>');
document.write('<TD>' + tekst + '</TD>');
document.write('<TD WIDTH=1 BGCOLOR=#' + bgcol_bordersubsub + '></TD>');
document.write('</TR>');
}

if (item == "line") 
{
document.write('<TR HEIGHT=1><TD COLSPAN=4 BGCOLOR=#' + bgcol_bordersubsub + '></TD></TR>');
}

if (item == "end") 
{
document.write('<TR HEIGHT=1><TD COLSPAN=4 BGCOLOR=#' + bgcol_bordersubsub + '></TD></TR></TABLE>');
document.write('</TR>');
document.write('<TD COLSPAN=4></TD></TR></TABLE></DIV>');
}
}

