function getAbsPos(el) {
var x=0;
   var y=0;
   for (;el;el = el.offsetParent) {
      x+= el.offsetLeft;
      y+= el.offsetTop;
   }
   
   return {x:x,y:y};

}


var active_subs = new Object;
var timer_started = new Object;	
var delay = 600;
var curtimer = new Object;

function activate_submenu(pid,sid,botpos,width,un) {
  clearTimeout(timer_started[sid]);
  if(active_subs[sid]) return true;
//  if(un) { 
     for (var k in active_subs) { 
        if (active_subs[k]) deactivate_submenu(k);
     }
//  }
  var place = document.getElementById(pid);
  var sub = document.getElementById(sid);
  var pos = getAbsPos(place);
//alert('pos=' + pos.x + ' ' + pos.y);
  var ie = navigator.appName.match(/Explorer/);
//  sub.style.top = pos.y + (ie ? 2 : 0);

  sub.style.position = 'absolute';
  sub.style.top = (pos.y + (ie ? 0 : 0) + (botpos ? place.clientHeight + (ie ? -20 :0 ) : 0)) + 'px';
  sub.style.left = (pos.x) + 'px';
//alert('ss=' + sub.style.position + ' ' + sub.style.top + ' ' + sub.style.left);
//var pp = getAbsPos(sub);
//alert('pp=' + pp.x + ' ' + pp.y);
//  sub.style.border='1px solid red';
//  sub.style.width = place.clientWidth+(ie ? 2 : -20);
    sub.style.width = width ? width : (place.clientWidth + 'px');
 
  sub.style.display='block';
  sub.style.visibility = 'visible';
  active_subs[sid]=true;
  return false;
}
function deactivate_submenu(sid) { 
  var sub = document.getElementById(sid);
  sub.style.display='none';
  sub.style.visibility = 'hidden';
  active_subs[sid]=false;
  return false;
}

function timer_open(pid, sid) {
	curtimer = setTimeout("activate_submenu('"+pid+"','"+sid+"')", delay);
}

function timer_close(sid) {
	curtimer = setTimeout("deactivate_submenu('"+sid+"')", delay);
}

function clear_timer(pid, sid)	{
	clearTimeout(curtimer);
}

