//Variaveis de controle
var menuOffDelay = 400;
var delayHide;
var buttonID = null;
var current = null;
var contentName;
var outElem = null;
var showItem = true;

function remove_tab_content(itemid)
{ //interface for hiding a tab (plus remove all tab content)
  var thetab=document.getElementById(itemid);
  if (thetab!=null)
    while( thetab.hasChildNodes() )
	  thetab.removeChild( thetab.lastChild );
}

function mouse_out(id)
{
  showItem = false;
  outElem = id;
 //alert(outElem);
}

function select_item(itemID, cName)
{
  buttonID = itemID;
  contentName = cName;
  showItem = true;
  clearTimeout( delayHide );
  delayHide = setTimeout( 'delayedHide()', menuOffDelay );
  return true;
}

/**
 *
 * @access public
 * @return void
 **/
function delayedHide()
{

  if (buttonID!=current && showItem)
  {
    if (current!=null)
  	  document.getElementById('menu-'+current).className = '';
    document.getElementById('menu-'+buttonID).className = 'selected';
    current = buttonID;
  //  remove_tab_content(contentName);
    xajax_show_content(buttonID,contentName);
  }
}
