// JavaScript Document
// (c) Stefan Suessner/ Rockin Ram Productions
var lastTabIndexElem = '';
var tabcontentElemName;

var aniActive = null; 
var anired = 0, anigreen = 0, aniblue = 0;

function tc_FadeIn() 
{
  tab = document.getElementById(tabcontentElemName);
  anicolor = "rgb(" + anired + "," + anigreen + "," + aniblue + ")";
  tab.style.backgroundColor = anicolor;
  
  if(anired < 255) anired = anired + 4;
  if(anigreen < 255) anigreen = anigreen + 4;
  if(aniblue < 255) aniblue = aniblue + 4;
  if (anired >= 255 && anigreen >= 255 && aniblue >= 255)
   {   
     window.clearInterval(aniActive);
     //aniActive = null;
   }
}

var aniheight= null; 
var aniheightend = 0;
var anihei = 0;
function tc_heightIn() 
{
  tab = document.getElementById(tabcontentElemName);
  tab.style.height = anihei + "px";
  anihei = anihei + 2;
  if (anihei >= aniheightend)
   {   
     window.clearInterval(aniheight);
     //aniActive = null;
   }
}

// dynamic content
function tc_dynSwitchTab(tabsuffix, tabID, activeClassname, inactiveclassname, fadeStartColor)  // FadeStartColor = '#e0e0f0';  // in HEX
{
  if(lastTabIndexElem == '') lastTabIndexElem = tabsuffix + '_hdr_0';
  var tab = document.getElementById(lastTabIndexElem); 
  if(tab != null)
    tab.className = inactiveclassname;
  
  tabcontentElemName = tabsuffix + 'content';
  var desttab = document.getElementById(tabcontentElemName);
  if(desttab != null)
  {
    desttab.innerHTML = "";
    if(fadeStartColor != '')
    {
      desttab.style.backgroundColor = fadeStartColor;
      desttab.style.Color = fadeStartColor;
      
      if(aniActive) window.clearInterval(aniActive);
      // hex color to rgb
      if (fadeStartColor.charAt(0) == '#')  // remove # if any
        fadeStartColor = fadeStartColor.substr(1,6);
      var re = /^(\w{2})(\w{2})(\w{2})$/;
      var bits = re.exec(fadeStartColor);
      anired = parseInt(bits[1], 16);
      anigreen = parseInt(bits[2], 16);
      aniblue = parseInt(bits[3], 16);
      fr = anired;
      fg = anigreen;
      fb = aniblue;
      aniActive = window.setInterval("tc_FadeIn()", 50);
    }
    lastTabIndexElem = tabsuffix + '_hdr_' + tabID;
  }
  tab = document.getElementById(tabsuffix + '_hdr_' + tabID);
  if(tab != null)
    tab.className = activeClassname;
}

// fixed content
function tc_SwitchTab(tabsuffix, tabID, activeClassname, inactiveclassname, fadeStartColor, tabcount)  // FadeStartColor = '#e0e0f0';  // in HEX
{
  // hide current content tab
  for(var i = 0; i < tabcount; i++)
  {
    var tabhdr = document.getElementById(tabsuffix + '_hdr_' + i);
    if(tabhdr != null)
      tabhdr.className = inactiveclassname;
    var tab = document.getElementById(tabsuffix + 'content' + i);
    if(tab != null)
      tab.style.display = "none";
  }  
  tabcontentElemName = tabsuffix + 'content' + tabID;
  var desttab = document.getElementById(tabcontentElemName);
  if(desttab != null)
  {
    desttab.style.display = "inline";
    if(fadeStartColor != '')
    {
        desttab.style.backgroundColor = fadeStartColor;
        desttab.style.Color = fadeStartColor;
        
        if(aniActive) window.clearInterval(aniActive);
        // hex color to rgb
        if (fadeStartColor.charAt(0) == '#')  // remove # if any
          fadeStartColor = fadeStartColor.substr(1,6);
        var re = /^(\w{2})(\w{2})(\w{2})$/;
        var bits = re.exec(fadeStartColor);
        anired = parseInt(bits[1], 16);
        anigreen = parseInt(bits[2], 16);
        aniblue = parseInt(bits[3], 16);
        fr = anired;
        fg = anigreen;
        fb = aniblue;
        aniActive = window.setInterval("tc_FadeIn()", 50);
    }
  }  
  tab = document.getElementById(tabsuffix + '_hdr_' + tabID);
  if(tab != null)
    tab.className = activeClassname;
}
 



