function tabview_aux(TabViewId, id)
{
  var TabView = document.getElementById(TabViewId);

  // ----- Tabs -----

  var Tabs = TabView.firstChild;
  while (Tabs.className != "Tabs" ) Tabs = Tabs.nextSibling;

  var Tab = Tabs.firstChild;
  var i   = 0;

  do
  {
    if (Tab.tagName == "A")
    {
      i++;
      //Tab.href      = "javascript:tabview_switch('"+TabViewId+"', "+i+");";
      Tab.className = (i == id) ? "Active" : "";
      Tab.blur();
    }
  }
  while (Tab = Tab.nextSibling);

  // ----- Pages -----

  var Pages = TabView.firstChild;
  while (Pages.className != 'Pages') Pages = Pages.nextSibling;

  var Page = Pages.firstChild;
  var i    = 0;
  var height=205;
  var width="100%";

  do
  {
    if (Page.className == 'Page')
    {
      // height = Pages.style.height;
      // width = Pages.style.width;

      i++;
      if (Pages.offsetHeight) Page.style.height = (Pages.offsetHeight-2)+"px";
      Page.style.overflow = "auto";
      

      // This was modified to ensure that flash objects (audio,etc) continued
      // to play when user switches tabs. When flash objects are put into non-
      // displayed part of the page, both ie7 and firefox stop allocating resources
      // to it, which causes the player to stop
      //Page.style.display  = (i == id) ? 'block' : 'none';

      if (i == id) { 
	Page.style.width=width;
	Page.style.height=height;
	Page.style.visibility="visible";
      }

      else { 
	Page.style.width="0px";
	Page.style.height="0px";
	Page.style.visiblity="hidden";
      }
    }
  }
  while (Page = Page.nextSibling);
}

// ----- Functions -------------------------------------------------------------

function tabview_switch(TabViewId, id) { tabview_aux(TabViewId, id); }

function tabview_initialize(TabViewId) { tabview_aux(TabViewId,  1); }
