﻿function SwitchContactColor() {
  Obj = document.getElementById("Contacts");
  x = 1
  for (i=0; i<Obj.childNodes.length; i++) {
    if (Obj.childNodes[i].nodeType == 1 && Obj.childNodes[i].nodeName == "DIV") {
      if ( x - 2 > 0 ) {
        Obj.childNodes[i].className += " Bright";
      }
      x++;
      if ( (x - 2) > 2 ) { x = 1; }
    }
  }
}

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");
  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]);
        }
      }
    }
  }
  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";
      }
    }
  }  
}