
// ---------- Super Compatible Tabs - original from JavaScript.com (I think). Extensively enhanced and expanded by John Mounsey 2008
// ---------- Tested on all major PC browsers (from IE6.x onwards..)

var scrollingPanelAdjustment = 1;

// This value kicks in IF a panel needs to scroll. The precise amount will vary depending on the base and padding of the panels.. {Jnm}
// If the "Page" block operates with borders (and not a background image) then this value should probably be set to 1 {Jnm}



function panels_aux(panelsId, id)
{
  var panels = document.getElementById(panelsId);

  // ----- Tabs -----

  var Tabs = panels.firstChild;
  while (Tabs.className != "theTabs" ) Tabs = Tabs.nextSibling;

  var Tab = Tabs.firstChild;
  var i   = 0;

  do
  {
    if (Tab.tagName == "A")
    {
      i++;
      Tab.href      = "javascript:changeTab('"+panelsId+"', "+i+");";
      Tab.className = (i == id) ? "current" : "";
      Tab.blur();
    }
  }
  while (Tab = Tab.nextSibling);

  // ----- Pages -----

  var Pages = panels.firstChild;
  while (Pages.className != 'Pages') Pages = Pages.nextSibling;

  var Page = Pages.firstChild;
  var i    = 0;

  do
  {
    if (Page.className == 'Page')
    {
      i++;
      //if (Pages.offsetHeight) Page.style.height = 190;
      Page.style.display  = (i == id) ? 'block' : 'none';
    }
  }
  while (Page = Page.nextSibling);
}



// ----- other Functions -----------------------------------------------------

function changeTab(panelsId, id)
	{
	panels_aux(panelsId, id);
	}



// ----- Choose default panel to open (panel # set on .html page. E.g. index.html?tab=3)

function setupTabs(panelsId,defaultTab)
	{
	panels_aux(panelsId,defaultTab);
	}

