var lastSubmenuShown = '';

function show_submenu(submenuId)
{
   var submenu = document.getElementById(submenuId);
   
   submenu.style.display = 'block';
   lastSubmenuShown = submenuId;
}

function hide_submenu(submenuId)
{
   var submenu = document.getElementById(submenuId);
   submenu.style.display = 'none';
}

function toggle_submenu(submenuId)
{
   var submenu = document.getElementById(submenuId);
   var prevSubmenu = document.getElementById(lastSubmenuShown);
   
   if (submenuId == lastSubmenuShown)
   {
      // reverse the state
      if (submenu.style.display == 'none')
         show_submenu(submenuId);
      else
         hide_submenu(submenuId);
   }
   else
   {
      // hide previous submenu if there is one
      if (lastSubmenuShown != '')
      {
         hide_submenu(lastSubmenuShown);
      }
      
      // show the clicked submenu
      show_submenu(submenuId);
   }
}

function incrementImg(count, maxCount, slideshowId, ext)
{
   if (count == maxCount) count = 1;
   document.getElementById(slideshowId).src = "/theme/img/slideshow/" + slideshowId + "/" + count + "." + ext;
   
   setTimeout("incrementImg("+(count + 1)+", "+maxCount+", '"+slideshowId+"', '"+ext+"')", 5000);
}

