slideMenu = new createSlideMenu("slideMenu")

//Variables to set:
slideMenu.menuy=98 //The top placement of the menu.
slideMenu.menux=0 //The left placement of the menu
slideMenu.useImages = 1 //Are you using images or not?
slideMenu.pxspeed=100 //The pixel speed of the animation
slideMenu.timspeed=0 //The timer speed of the animation
slideMenu.inset =0 //How much the selected elements should pop to the left
//slideMenu.arrow="clArrow"

//Needed dummy classes
slideMenu.bgClass =     "slideMenuBG"
slideMenu.txtClass = "slideMenuText"

//Level properties - ALL properties have to be spesified in level 0
//This works the same way as the CM4 script (if you have seen it)
slideMenu.level[0] = new slideMenu_makeLevel(
  left = 0,
  width = 170,
  height = 25,
  between = 0,
  className = "clSlideMenu0",
  classNameA = "clA0",
  regImage = "images/button_lave_nove/nove_top.gif",
  roundImg = "images/button_lave_nove/nove_top.gif",
  roundImg2 = "",
  subImg = "",
  subRound= "")

slideMenu.level[1] = new slideMenu_makeLevel(0,170,31,0,"clSlideMenu1","clA1","images/button_lave_nove/nove_sub1.png","images/button_lave_nove/nove_rozbalene_sub1.png","images/button_lave_nove/nove_sub1.png","images/button_lave_nove/nove_nerozbalene_sub1.png", "images/button_lave_nove/nove_nerozbalene_sub1.png")
slideMenu.level[2] = new slideMenu_makeLevel(0,170,40,0,"clSlideMenu2","clA2","images/button_lave_nove/nove_sub3.png","images/button_lave_nove/nove_sub3.png","images/button_lave_nove/nove_sub3.png", "images/button_lave_nove/nove_sub3.png", "images/button_lave_nove/nove_sub3.png")
//slideMenu.level[3] = new slideMenu_makeLevel(0,170,26,0,"clSlideMenu3","clA3","level3_regular.gif","level3_round2.gif","level3_round.gif","level3_sub.gif","level3_sub_round.gif")
//slideMenu.level[4] = new slideMenu_makeLevel(0,170,19,2,"clSlideMenu4","clA4","level4_regular.gif", "level4_round2.gif","level4_round.gif","level4_sub.gif", "level4_sub_round.gif")

//Image preload --- leave this
for(var i=0;i<slideMenu.level;i++){
  var l = slideMenu.level[i]
  new preLoadBackgrounds(l.regImage,l.roundImg,l.roundImg2,l.subImg,l.subRound)
}

createSlideMenu.prototype.init1 = createSlideMenu.prototype.init;

createSlideMenu.prototype.getBtnImgPath = function(i, s) {
  return 'images/button_lave_nove/nove_'+(i+1)+s+'.jpg';
}

createSlideMenu.prototype.init = function() {
  this.init1();

  for (var i=0; i<this.topmenus.length; i++) {
    var imgs = new preLoadBackgrounds(
      this.getBtnImgPath(i, 'i'),
      this.getBtnImgPath(i, 'a'),
      this.getBtnImgPath(i, 'e'))
    var topMenu = this.menus[this.topmenus[i]]
    topMenu.imgs = imgs;
    topMenu.o.bgImg(imgs[0].src);
    topMenu.o.evnt.el = topMenu;
    topMenu.o.evnt.el.menu = this;
    topMenu.o.evnt.el.topindex = i;
    topMenu.o.evnt.onclick = this.level0click;
    topMenu.o.evnt.onmouseover = this.level0mover;
    topMenu.o.evnt.onmouseout = this.level0mout;
  }

  this.onmoveup   = "this.level0movedup(this)";
  this.onmovedown = "this.level0moveddown(this)";
}

createSlideMenu.prototype.level0click = function() {
  if (this.el.lnk != '#') {
    document.location.href = this.el.lnk;
    return;
  }
  var act = this.el.menu.active[0];
  this.el.menu.switchMenu(this.el.num);
  if (act != -1 && act != this.el.num) {
    var actMenu = this.el.menu.menus[act]
    actMenu.o.bgImg(actMenu.imgs[0].src);
  }
}

createSlideMenu.prototype.level0mover = function() {
  this.el.o.bgImg(this.el.imgs[1].src);

  if (window.event) {
    this.el.menu.clientX = window.event.clientX;
    this.el.menu.clientY = window.event.clientY;
  }
}

createSlideMenu.prototype.level0mout = function() {
  var ch = this.el.menu.active[0] == this.el.num ? 2 : 0;
  this.el.o.bgImg(this.el.imgs[ch].src);
  if (window.event) {
    this.el.menu.clientX = window.event.clientX;
    this.el.menu.clientY = window.event.clientY;
  }
}

createSlideMenu.prototype.level0movedup = function(m) {
  if (!document.elementFromPoint) return;

  var e = document.elementFromPoint(m.clientX, m.clientY);
  if (e.tagName == 'TD') {
    e = e.offsetParent
    if (e.offsetParent) e = e.offsetParent;
  }
  if (!e.el || e.el.num != m.active[0]) {
    var el = m.menus[m.active[0]];
    el.o.bgImg(el.imgs[2].src);
  }
}

createSlideMenu.prototype.level0moveddown = function(m) {
  if (m.openQueue && m.openQueue.length) {
    m.switchMenu(m.openQueue[0]);
    m.openQueue = m.openQueue.slice(1);
  }
}

createSlideMenu.prototype.activate = function(id) {
  for (i=0; i<this.menus.length; i++) {
    if (this.menus[i].mid == id) {
      var mi = this.menus[i];
      var p = new Array()
      p[0] = i;
      while (mi.parent != -1) {
        p[p.length] = mi.parent;
        mi = this.menus[mi.parent];
      }
      p = p.reverse();

      for (var j=0; j<p.length; j++) {
        this.going = 0;
        this.switchMenu(p[j]);
      }
      //this.openQueue = p.slice(1);
      break;
    }
  }
}
