/************************************


created         : Thursday 21st May 2009 
copyright       : Darren George Web Development
author          : darren george
version         : NA
************************************/

var current_tab = "";
var current_content = "";
                          
window.onload = InitialiseTabs;
  
  
//IE does not support the getElementsByClassName js fn
//so we manually create one so that all browsers can
//safely manipulate this fn
document.getElementsByClassName = function(clsName)
  {
  var retVal = new Array();
  var elements = document.getElementsByTagName("*");
  for(var i = 0;i < elements.length;i++)
    {
    if(elements[i].className.indexOf(" ") >= 0)
      {
      var classes = elements[i].className.split(" ");
      for(var j = 0;j < classes.length;j++)
        {
        if(classes[j] == clsName)
          {
          retVal.push(elements[i]);
          }
        }
      }
    else if(elements[i].className == clsName)
      {
      retVal.push(elements[i]);
      }
    }
                            
  return retVal;
  }
                          
                          
function InitialiseTabs()
  {
  //first hide each and every tab
  crates = document.getElementsByClassName("crate");
  for(i=0; i<crates.length; i++)
    {
    crates[i].style.display = "none";
    }                          
                              
  //now show the first tab
  ShowSelectedTab(first_tab, first_content);
  }
                                               
function HideCurrentTab()
  {
  //first set the current tab back to white bg
  //with blue link text
  current_tab.style.backgroundColor = "#FFFFFF";
  current_tab.style.color = "#0072BB";
    
  //now hide the content that is currently on screen
  current_content.style.display = "none";                          
  }
                          
function ShowSelectedTab(tabName, contentName)
  {
  //first update the current_tab and current_content vars
  current_tab = document.getElementById(tabName);
  current_content = document.getElementById(contentName);
                            
  //now set the current tab to blue bg with
  //white link text
  current_tab.style.backgroundColor = "#0072BB";
  current_tab.style.color = "#FFFFFF";
                            
  //now show the content of the new tab
  current_content.style.display = "block";                                                                              
  }
  
function SelectTab(tabName, contentName)
  {
  HideCurrentTab();
  ShowSelectedTab(tabName, contentName);
  }
