function navbar(pos) {
  this.navnum = navi.length
  if (pos == undefined || pos == -1) var pos = [[0, ''], -1, -1, [0, '']]
  this.pos = pos
  this.height = 25
  this.border = [0, 0, 2, 0]
  
  this.menu = document.createElement('div')
  this.menu.className = 'navbar navi' + this.navnum
  
  this.update()
  
  wrapper.appendChild(this.menu)
}

navbar.prototype.update = function() {
  for (var i = 0; i < global_directions_length; i++) {
    if (this.pos[i] != -1)
      this.menu.style[global_directions[i]] = this.pos[i][0] + this.pos[i][1]
  }
}

navbar.prototype.support = function(name) {
  posis[name] = this.navnum
  
  if (name == 'dropdowns')
    this.drops = []
}

navbar.prototype.unsupport = function(name) {
  if (posis[name] == undefined) return
  delete posis[name]
  
  if (name == 'dropdowns')
    delete this.dropdowns
  else if (name == 'appboxes')
    delete this.appboxes
}

// DROPDOWN
navbar.prototype.drop = function(name, list) {
  var listlen = list.length
  var wrap = this.append_level(list, name)
  this.dropdowns.appendChild(wrap)
  this.drops[this.drops.length] = [wrap, name, list]
}

navbar.prototype.append_level = function(list, first) {
  var listlen = list.length
  var i, wrap, dtop, type, elem, elema, elemb, spl, title
  
  wrap = document.createElement('div')
  if (first) {
    wrap.className = 'dropdown'
    dtop = document.createElement('div')
    dtop.className = 'top drop' + navi[posis['dropdowns']].drops.length
    dtop.innerHTML = first
    wrap.appendChild(dtop)
  }
  else {
    wrap.className = 'entries'
    elem = document.createElement('div')
    elem.className = 'side'
    wrap.appendChild(elem)
  }
  
  for (i = 0; i < listlen; i++) {
    type = typeof(list[i])
    if (type == 'string') {
      spl = [list[i], 'true']
      if (list[i].indexOf('#') != -1)
        spl = list[i].split('#')
      elem = document.createElement('div')
      elem.className = 'entry'
      elem.rel = spl[1]
      elem.onmouseup = function() {
        navi[posis['dropdowns']].hide_drops()
      }
      elem.innerHTML = spl[0]
      elem.onclick = function() {
        eval('scr.setwindow(\'' + this.innerHTML + '\',' +  this.rel + ')')
      }
      wrap.appendChild(elem)
    }
    else if (type == 'object') {
      elem = document.createElement('div')
      elem.className = 'group'
      elema = document.createElement('div')
      elema.className = 'header'
      elema.innerHTML = list[i][0]
      elem.appendChild(elema)
      elema = this.append_level(list[i][1])
      elem.appendChild(elema)
      wrap.appendChild(elem)
    }
  }
  return wrap
}

navbar.prototype.hide_drops = function() {
  if (!hiding_drops) {
    hiding_drops = true
    var l = this.drops.length
    for (i = 0; i < l; i++) {
      this.drops[i][0].className = 'dropdownh dropdown'
    }
    setTimeout('navi[posis[\'dropdowns\']].hide_drops()', 100)
  }
  else {
    hiding_drops = false
    var l = this.drops.length
    for (i = 0; i < l; i++) {
      this.drops[i][0].className = 'dropdown'
    }
  }
}

navbar.prototype.box = function(name, pos) {
  if (pos == undefined) pos = 'none'
  this[name] = document.createElement('div')
  this[name].className = name
  this[name].style.cssFloat = pos
  this.menu.appendChild(this[name])
  
  if (name == 'clock') {
    this.setclock()
    this.clockinterval = setInterval('navi[posis[\'clock\']].setclock()', 30000)
  }
  if (name == 'abs_scroller') {
    this.abs_scroller.className = 'abs'
    var elem
    elem = document.createElement('div')
    elem.className = 'scrollup'
    elem.onclick = function() {
      navi[posis['appboxes']].abs_scroll(1)
    }
    this.abs_scroller.appendChild(elem)
    elem = document.createElement('div')
    elem.className = 'scrolldown'
    elem.onclick = function() {
      navi[posis['appboxes']].abs_scroll(-1)
    }
    this.abs_scroller.appendChild(elem)
    
    this.menu.style.overflow = 'hidden'
  }
}

navbar.prototype.check_abs_height = function(force) {
  var abs = navi[posis['appboxes']].height
  var rnum = navi[posis['appboxes']].appboxes.scrollHeight
  if (ie) {
    if ((rnum / abs + '').indexOf('.') != -1) rnum += appbox_margin * 2
  }
  var num = rnum / abs
  if (num > 1) {
    navi[posis['appboxes']].appboxes.style.marginRight = abs_scroller_width + 3 + 'px'
    navi[posis['appboxes']].abs_scroller.style.display = 'block'
    if (force) this.abs_scroll(-Math.floor(wnds[scr.wndpos[0]].appbox.offsetTop / abs))
  }
  else {
    navi[posis['appboxes']].appboxes.style.marginRight = '0'
    navi[posis['appboxes']].abs_scroller.style.display = 'none'
    this.abs_scroll(-abs_scrolled)
  }
}

navbar.prototype.abs_scroll = function(am) {
  var abam = abs_scrolled + am * 1
  var abs = this.height
  var rnum = this.appboxes.scrollHeight
  if ((rnum / abs + '').indexOf('.') != -1) rnum += appbox_margin * 2
  var num = rnum / abs
  if (abs_scrolled + am < 1 && abam * -1 < num) {
    abs_scrolled = abam
    this.appboxes.style.marginTop = abs * abs_scrolled + 'px'
  }
}

navbar.prototype.setclock = function() {
  var time = new Date ()
  
  var hours = time.getHours()
  var minutes = time.getMinutes()
  
  hours = (hours < 10 ? "0" : "") + hours
  minutes = (minutes < 10 ? "0" : "") + minutes

  this.clock.innerHTML = hours + ':' + minutes
}