var last_span = 0;
var cur_time = 0;
var oldcolor = '';

function show_span(id, div_id)
{
      if(last_span != 0 && last_span != div_id)
      {
            document.getElementById(last_span).style.visibility = 'hidden';
      }

      document.getElementById(div_id).style.visibility = 'visible';

      last_span = div_id;

      if(cur_time != 0)
      {
            clearTimeout(cur_time);
      }
      
      obj = document.getElementById(id);
      for(i=obj, x=0, y=0; i; i = i.offsetParent)
      {
            x += i.offsetLeft;
            if(i.offsetTop > 0)
            {
                  y += i.offsetTop;
            }
      }      
      document.getElementById(div_id).style.top = y+'px';
}

function hide_span(div_id)
{
      document.getElementById(div_id).style.visibility = 'hidden';      
}


function set_span(div_id)
{      
      document.getElementById(div_id).style.visibility = 'visible';
      if(cur_time != 0)
      {
            clearTimeout(cur_time);
      }
}

function clear_span(div_id)
{
      cur_time = 0;
      hide_span(div_id, 500);
}


function set_span_td(div_id, td_id)
{      
      document.getElementById(div_id).style.visibility = 'visible';
      if(cur_time != 0)
      {
            clearTimeout(cur_time);
      }

      oldcolor = document.getElementById(td_id).style.backgroundColor;
      document.getElementById(td_id).style.backgroundColor = 'rgb(33, 37, 46)';
}

function clear_span_td(td_id)
{
      document.getElementById(td_id).style.backgroundColor = oldcolor;
}


function timer_span(div_id, time)
{
      cur_time = setTimeout("hide_span('"+ div_id +"')", time);      
}
