var height = 22; // height of the menu headers
var iheight = 20; // height of the menu_items

var bgc = "" // background color of the item
var tc = "#7E6977" // text color of the item

var over_bgc = "";
var over_tc = "#FF0000";

var speed = 20;
var timerID = "";
var N = (document.all) ? 0 : 1; // 0=IE 1=NS
var width = 210;
var open_item=-1;

function color(obj) {
 document.getElementById(obj).style.backgroundColor = over_bgc;
 document.getElementById(obj).style.color = over_tc;
}

function uncolor(obj) {
 document.getElementById(obj).style.backgroundColor = bgc;
 document.getElementById(obj).style.color = tc;
}

function pull_down(nr) {
if (timerID == "") {
  if (timerID != "") clearTimeout(timerID);
  if (self_menu[nr+1][2] == 0) {
// This item is not already down
    if (open_item!=-1) {
      self_menu[open_item+1][2] = 0;
      epull_up(open_item, 0);
	}
    self_menu[nr+1][2] = 1;
    open_item=nr;
    epull_down(nr,0);
  } else {
// This item is already down
    self_menu[nr+1][2] = 0;
    epull_up(nr, 0);
    open_item = -1;
  }
}
}


function epull_down(nr,x) {
  panel_height=self_menu[nr+1][1];
  dx=parseInt(Math.sqrt((panel_height-x)/3));
  if (dx<1) dx=1;
//  dx=2;
  x+=dx;
  name = "down" + (nr+1);
  obj = document.getElementById(name).style.clip = "rect(0px "+width+"px "+x+"px 0px)";
  for (i=nr+2;i<self_menu.length;i++) {
    name = "down" + i;
    obj = document.getElementById(name);
    obj.style.top = parseInt(obj.style.top)+dx+"px";
  }
  if(x < panel_height) timerID = setTimeout("epull_down("+nr+","+x+")",speed);
  else timerID = ""; 
}

function epull_up(nr, x) {
 if (x==0) x = self_menu[nr+1][1];
 name = "down" + (nr+1);
 dx=parseInt(Math.sqrt(x/3));
 if (dx<1) dx=1;
// dx=2;
 x-=dx;
 obj = document.getElementById(name).style.clip = "rect(0px "+width+"px "+x+"px 0px)";
 for (i=nr+2;i<self_menu.length;i++) {
  name = "down" + i;
  obj = document.getElementById(name);
  obj.style.top = parseInt(obj.style.top)-dx+"px";
 }
 if(x > 0) timerID = setTimeout("epull_up("+nr+","+x+")",speed);
 else timerID = "";
}