imgSel1 = new Image();
imgSel2 = new Image();
imgSel3 = new Image();
imgSel4 = new Image();
imgSel5 = new Image();

imgSel1.src = 'dyn_img/knappkant2.gif';
imgSel2.src = 'dyn_img/vmork.gif';
imgSel3.src = 'dyn_img/rmork.gif';
imgSel4.src = 'dyn_img/knappmork.gif';
imgSel5.src = 'dyn_img/mellanmork.gif';


img1 = new Image();
img2 = new Image();
img3 = new Image();
img4 = new Image();
img5 = new Image();

img1.src = 'dyn_img/knappkant.gif';
img2.src = 'dyn_img/vljus.gif';
img3.src = 'dyn_img/rljus.gif';
img4.src = 'dyn_img/knappljus.gif';
img5.src = 'dyn_img/mellanknapp.gif';


function hooverTab(id)
{
//  if(selectedTab == id)
//    return;

/*
  document.images['ltab'+id].src = imgSel1.src;
  document.images['mtab'+id].src = imgSel2.src;
  document.images['rtab'+id].src = imgSel3.src;
*/

  if(document.getElementById)
  {

    if(id <= 0)
	document.getElementById('tab_knappkant'+id+'_1').style.background = 'url('+imgSel1.src+')';
    else if(id > 0)
	document.getElementById('tab_knappkant'+(id-1)).style.background = 'url('+imgSel1.src+')';

    document.getElementById('tab_knappkant'+id).style.background = 'url('+imgSel1.src+')';



    document.getElementById('tab_l'+id).style.background = 'url('+imgSel2.src+')';
    document.getElementById('tab_r'+id).style.background = 'url('+imgSel3.src+')';
    document.getElementById('tab'+id).style.background = 'url('+imgSel4.src+')';
    document.getElementById('mellan'+id+'_1').style.background = 'url('+imgSel5.src+')';
    document.getElementById('mellan'+id+'_2').style.background = 'url('+imgSel5.src+')';
    document.getElementById('mellan'+id+'_3').style.background = 'url('+imgSel5.src+')';
    document.getElementById('mellan'+id+'_4').style.background = 'url('+imgSel5.src+')';
  }
  else
  {
    document.elements['tab'+id].style.background = 'url('+imgSel4.src+')';
  }

}

function outTab(id)
{
  if(selectedTab == id)
      return;

  hideTab(id);
}

function hideTab(id)
{
/*
  document.images['ltab'+id].src = img1.src;
  document.images['mtab'+id].src = img2.src;
  document.images['rtab'+id].src = img3.src;
*/


  if(document.getElementById)
  {

    if(id <= 0)
	document.getElementById('tab_knappkant'+id+'_1').style.background = 'url('+img1.src+')';
    else if(selectedTab != (id-1) && id > 0)
	document.getElementById('tab_knappkant'+(id-1)).style.background = 'url('+img1.src+')';

    if(selectedTab != (id+1))
    	document.getElementById('tab_knappkant'+id).style.background = 'url('+img1.src+')';



    document.getElementById('tab_l'+id).style.background = 'url('+img2.src+')';
    document.getElementById('tab_r'+id).style.background = 'url('+img3.src+')';
    document.getElementById('tab'+id).style.background = 'url('+img4.src+')';
    document.getElementById('mellan'+id+'_1').style.background = 'url('+img5.src+')';
    document.getElementById('mellan'+id+'_2').style.background = 'url('+img5.src+')';
    document.getElementById('mellan'+id+'_3').style.background = 'url('+img5.src+')';
    document.getElementById('mellan'+id+'_4').style.background = 'url('+img5.src+')';

  }
  else
    document.elements['tab'+id].style.background = 'url('+img4.src+')';


}


function populateSubmenu(id)
{

if(selectedTab != id)
	hideTab(selectedTab);

hooverTab(id);
selectedTab = id;

if(id == null)
{
  alert('hmm');
  return;
}

var data = '';
var count = submenu[id].length;
var tag;

for (var i=0; i<count; i++)
{
  if(submenu[id][i][2] != 1 && submenu[id][i][1].substr(0,4) != "http")
	data += '&nbsp;&nbsp;&nbsp;<a href=' + submenu[id][i][1] + '&tab=' + selectedTab + '><font class=buttonthin>' + submenu[id][i][0] + '</font></a>';
  else
	data += '&nbsp;&nbsp;&nbsp;<a href=' + submenu[id][i][1] + '><font class=buttonthin>' + submenu[id][i][0] + '</font></a>';

}
  document.getElementById('undermenu').innerHTML = data;

}

