﻿CurrTab = "";

function init_tabs() {
  NavObj = document.getElementById("tabs");
  Obj = document.getElementById("tab_wrapper");
  // Only required because Firefox don't understand outerHTML
  temp_element = document.createElement("div");
  temp_element2 = document.createElement("div");
  first_id = "";
  for ( i=0; i<Obj.childNodes.length; i++ ) {
    if (Obj.childNodes[i].nodeType == 1 && Obj.childNodes[i].nodeName == "DIV" && Obj.childNodes[i].className == "tab_content") {
      if ( first_id != "") {
        Obj.childNodes[i].style.display = "none";
      }
      for ( a=0; a<Obj.childNodes[i].childNodes.length; a++ ) {
        if ( Obj.childNodes[i].childNodes[a].nodeType == 1 && Obj.childNodes[i].childNodes[a].nodeName == "DIV" && Obj.childNodes[i].childNodes[a].className == "tab_passive" ) {
          if ( first_id == "" ) {
            first_id = Obj.childNodes[i].childNodes[a].id.replace(/tabid_/,"");
            CurrTab = Obj.childNodes[i].childNodes[a];
          }
          temp_element.appendChild(Obj.childNodes[i].childNodes[a].cloneNode(true));
          Obj.childNodes[i].removeChild(Obj.childNodes[i].childNodes[a]);
        }
        if (Obj.childNodes[i].childNodes[a].nodeType == 1 && Obj.childNodes[i].childNodes[a].nodeName == "DIV" && Obj.childNodes[i].childNodes[a].className == "rc1") {
            rightObj = document.getElementById("rightcontent");
            temp_element2.appendChild(Obj.childNodes[i].childNodes[a].cloneNode(true));
            rightObj.innerHTML = temp_element2.innerHTML;
            Obj.childNodes[i].removeChild(Obj.childNodes[i].childNodes[a]);
        }
      }
    }
  }
  NavObj.innerHTML = temp_element.innerHTML;
  switch_tab(first_id);
}

function switch_tab(ID) {
  CurrTab.className = "tab_passive";
  document.getElementById(CurrTab.id + "_ref").className = "tablink";
  CurrTab = document.getElementById("tabid_" + ID);
  CurrTab.className = "tab_active";
  document.getElementById(CurrTab.id + "_ref").className = "tablinkactive";
  Obj = document.getElementById("tab_wrapper");
  for ( i=0; i<Obj.childNodes.length; i++ ) {
    if (Obj.childNodes[i].nodeType == 1 && Obj.childNodes[i].nodeName == "DIV" && Obj.childNodes[i].className == "tab_content") {
      if (Obj.childNodes[i].id == "tab_content_" + ID) {
        Obj.childNodes[i].style.display = "block";
      } else {
        Obj.childNodes[i].style.display = "none";
      }
    }
  }  
}

function ShowMovie(FlashFile, w, h) {
  var so = new SWFObject(FlashFile, "player", w, h, "7", "#000000");
      so.addParam("quality", "high");
      so.addParam("scale", "default");
      so.addParam("align", "left");
      so.addParam("menu", false);
      so.addParam("salign", "LT");
      so.addParam("wmode", "transparent");
      so.addParam("flashVars", "autostart=0");
      so.write("TabFlashContent");
}

function ShowFlashContent(URL, ID, Width, Height) {
  document.getElementById("FlashDescription").innerHTML = document.getElementById(ID).innerHTML;
  ShowMovie(URL, Width, Height);
}

function initFirstMovie() {
  Obj = document.getElementById("MovieList");
  for (i = 0; i < Obj.childNodes.length; i++) {
    if (Obj.childNodes[i].nodeType == 1 && Obj.childNodes[i].nodeName == "LI") {
      for (a = 0; a < Obj.childNodes[i].childNodes.length; a++) {
        if (Obj.childNodes[i].childNodes[a].nodeType == 1 && Obj.childNodes[i].childNodes[a].nodeName == "A") {
          var RegExp = /^function [_a-zA-Z][_a-zA-Z0-9]*\s?\(.*?\)\s*\{\s*([\s\S]*);\s*\}$/i;
          var str = Obj.childNodes[i].childNodes[a].onclick.toString().match(RegExp);
          eval(str[1]);
          break;
        }
      }
      break;
    }
  }
}
