var SubItems = new Array();//Holds all subitems in the page
var candidate;             //Subitem queried to die 


function HideSub(source)
{
  var theSub;
  theSub = document.getElementById(source);
  theSub.style.visibility = "hidden";
}


function HideAll(source)
{
  var i;
	for(i = 0; i < SubItems.length; ++i)
	{
    if (source!=SubItems[i])
    {
      HideSub(SubItems[i]);
    }
	}
}


function ShowSub(source)
{
  clearTimeout(candidate);
  candidate = null;
  HideAll(source);
  var theSub = document.getElementById(source);
  theSub.style.visibility = "visible";
}


function QueryDeath(source)
{
  candidate = setTimeout("HideSub('"+source+"')", 1000);
}


function QueryLife(source)
{
  if (candidate!=null)
  {
    clearTimeout(candidate);
    candidate = null;
  }
}


function RegisterSub(gName)
{
	var i;
	for(i = 0; i < SubItems.length; ++i)
	{
		if(gName == SubItems[i])
			return false;
	}
  SubItems[SubItems.length] = gName;
	return true;
}


function UnregisterSub(gName)
{
	var i;
	for(i = 0; i < SubItems.length; ++i)
	{
		if(gName == SubItems[i])
    {
      SubItems[i] = "";
    }
	}
  PackSubs();
}


function PackSubs()
{
  SubItems.sort();
	var i;
	for(i = 0; i < SubItems.length; ++i)
	{
		if(gName == "")
    {
      SubItems.length = i;
      return;
    }
		
	}
}