function getobj(mtxt)
{
  if(document.getElementById)
    m = document.getElementById(mtxt);
  else if(document.all)
    m = document.all[mtxt];
  else if(document.layers)
    m = document.layers[mtxt];
  else
    alert("problem with finding object by id");
  return m;
}

function findMenuPos(el, txt)
{
  if( !this.dom && document.layers )
  {   /*Netscape 4*/
    x = document.layers[txt].pageX;
    y = document.layers[txt].pageY;
  }
  else
  {   /*other browsers*/
    x=0; y=0;
    var temp;
    if(el && el.offsetParent)
    {
      temp = el;
      while(temp.offsetParent)
      { /*Looping parent elements to get the offset of them as well*/
        temp=temp.offsetParent;
        x+=temp.offsetLeft;
        y+=temp.offsetTop;
      }
    }
    x+=el.offsetLeft;
    y+=el.offsetTop;
  }
  return [x,y];
}

var dbg = "";

var __menu_sub = "";
var __menu_tmout = "";

function menuMouseIn(obj, txt, $bgcolor)
{
  dbg += "menuMouseIn;";
  clearTimeout(__menu_tmout);
  if( __menu_sub ) __menu_sub.style.visibility = 'hidden';
  obj.style.backgroundColor = $bgcolor;
  obj.style.cursor = 'pointer';
  window.status = txt;
}

function menuMouseOut(obj, $bgcolor)
{
  dbg += "menuMouseOut;";
  obj.style.backgroundColor = $bgcolor;
  obj.style.cursor = 'normal';
  window.status = '';
}

function menuSubOpen(obj, id, pom, $bgcolor)
{
  dbg += "menuSubOpen;";
  clearTimeout(__menu_tmout);
  if( __menu_sub ) __menu_sub.style.visibility = 'hidden';
  menuMouseIn(obj, '', $bgcolor);
  sub = getobj(id);
  if( pom==1 )
  {
    pos = findMenuPos(obj);
    pos[1] += 20;
  }
  else
    pos = [obj.offsetWidth-3, obj.offsetTop+2];
  sub.style.left = pos[0] + 'px';
  sub.style.top = pos[1] + 'px';
  sub.style.visibility = 'visible';
}

function menuSubClose(obj, id, pom, $bgcolor)
{
  dbg += "menuSubClose;";
  menuMouseOut(obj,$bgcolor);
  if(pom==1)
  {
    __menu_sub = getobj(id);
    __menu_tmout = setTimeout("__menu_sub.style.visibility = 'hidden'", 500);
  }
  else
  {
    var sub = getobj(id);
    sub.style.visibility = 'hidden';
  }
}

function show(id){
	$(id).style.display = "block";
}

function hide(id){
	  
	$(id).style.display = "none";
}

function change_class(object,new_class_name,old_class_name){
	Element.removeClassName(object,old_class_name);
	Element.addClassName(object,new_class_name);
}