var timer=null;

function SwitchWidget(obj)
{
   if (timer != null)
   {
      clearTimeout(timer);
   }
   if(document.getElementById)
   {
      var x = obj;
      var ar = document.getElementById("tabFrame").getElementsByTagName("div");
      for (var i=0; i<ar.length; i++)
      {
         if (ar[i].className == "toggle")
         {
            if (ar[i].id == x)
            {
               pauseComp(1);
               ar[i].style.display = "block";
            }
            else
            {
               ar[i].style.display = "none";
            }
         }
      }
   }
   timer = setTimeout("hideMenu()", 10000);
}

//a function just delay the menu switch for the specified milliseconds (passed in 'millis'), 1 by default
function pauseComp(millis)
{
   date = new Date();
   var curDate = null;
   do { var curDate = new Date(); } 
   while(curDate-date < millis);
}

function cancelTimer()
{
   if (timer != null)
   {
      clearTimeout(timer);
   }
}

function hideMenu()
{
   var ar = document.getElementById("tabFrame").getElementsByTagName("div");
   for (var i=0; i<ar.length; i++)
   {
      if (ar[i].className == "toggle")
      {
         ar[i].style.display = "none";
      }
   }
   if (timer != null)
   {
      clearTimeout(timer);
   }
}
