var closeTimeout =100 //timeout for hiding divbox
var selfPos = true //make your divbarpos and divbox self disposed
var overBox = ''
var timerID


function openbox(x) {
  paintLayer('mnubarpos' + x, active = true)
  showLayer('divbox' + x)
  for (i = 0; i < menu.length; i++)  if (i != x) closebox(i, 0)  
  overBox = 'divbox' + x
}

function closebox(x, timeout) {
  paintLayer('mnubarpos' + x, active = false)
  clearTimeout(timerID)
  if (timeout == 0) hideLayer('divbox' + x)
  else timerID = setTimeout('hideLayer("divbox' + x + '")', closeTimeout)
  overBox = ''
  window.status = defaultStatus
}

function over(x){
  overBox = 'divbox' + x
}

function openboxpos(x, y) {
  paintLayer('mnuboxpos' + x + '_' + y, active = true)
}

function closeboxpos(x, y) {
  window.status = defaultStatus
  paintLayer('mnuboxpos' + x + '_' + y, active = false)
}

function paintLayer(layerID, active) {
  if (layer = document.all[layerID]) {
    if (active) {
      layer.style.backgroundColor="#505090";
    } else {
      layer.style.backgroundColor="transparent";
    }
  }
}

function showLayer(layerID) {
  if (layer = document.all[layerID]) layer.style.visibility = 'visible'
}

function hideLayer(layerID) {
  if (layer = document.all[layerID] && (overBox != layerID)) document.all[layerID].style.visibility = 'hidden'
}
