/**
 * Toggles the current tab in display.
 */
function toggleTab(id) {
  if (!id) id = 1;
  var tabtitle = document.getElementById("tab-title-bar");
  if (tabtitle) {
    var links = tabtitle.getElementsByTagName("a");
    for (var i = 0; i < links.length; i++) {
      if (links[i].name && links[i].name != ('tab' + id)) {
        var content = document.getElementById("tabcontent" + (i+1));
        if (content) {
          content.style.display = "none";
	      links[i].className = "";
        }
      }
      else {
        links[i].className = "selected";
      }
    }
    var tbcont = document.getElementById("tabcontent" + id);
    if (tbcont) tbcont.style.display = "block";
  }
}

/**
 * Displays the first tab once the page has loaded.
 */
function initTabs() { toggleTab(1); }
if (window.attachEvent) { window.attachEvent("onload", initTabs); } 
else { window.addEventListener("load", initTabs, false); }


/**
 * Switches to the selected tab on product pages.
 */
function switchToTab(tabID) {
  var tabTitles = $$('tab-title');
  var tabContent = $$('tab-content');
  if (!tabContent) {
    tabContent = $$('tab-content2');
  }
  if (tabTitles && tabContent) {
	var newTabID = "tab" + tabID;
	var newContentID = "cont" + tabID;
	 
    var allTabs = tabTitles.getElementsByTagName("A");
	for (var i = 0; i < allTabs.length; i++) {
	  allTabs[i].className = allTabs[i].getAttribute("id") == newTabID ? "sel" : "nosel";
	}
	
	var allContent = tabContent.getElementsByTagName("DIV");
	for (var i = 0; i < allContent.length; i++) {
	  allContent[i].className = allContent[i].getAttribute("id") == newContentID ? "tcblock" : "tcnone";
	}
  }
}

function $$(elem){
	return document.getElementById(elem);
}