/***************************************************************\
| |\  /|                                                We Put  |
| | >< Hypercosm              demo_page.js              3d      |
| |/  \|                                                To Work |
|***************************************************************|
|                                                               |
|        This file contains javascript code that is used        |
|        on the demo pages to control the sidebar tabs.         |
|                                                               |
|***************************************************************|
|                Copyright (c) 2008 Hypercosm, LLC.             |
\***************************************************************/


var tabIndex = 1;
var tabPath = "";
var tabURLs = [];


function setBackgroundImage(id, imageURL) {
  if (document.layers)
    document[id].background.src = imageURL == 'none' ? null : imageURL;
  else if (document.all)
    document.all[id].style.backgroundImage = imageURL == 'none' ? 'none' : 'url(' + imageURL + ')';
  else if (document.getElementById)
    document.getElementById(id).style.backgroundImage = imageURL == 'none' ? 'none' : 'url(' + imageURL + ')';
}	//setBackgroundImage


function deselectTab(index) {
  switch (index) {
    case 1:
      document.getElementById("tab1Left").src = tabPath + "tab-unselected-left-edge.gif";
      setBackgroundImage("tab1Middle", tabPath + "tab-unselected-middle.gif");
      document.getElementById("tab1Label").className = "tab-unselected";
      document.getElementById("tab1Right").src = tabPath + "tab-unselected-right-middle.gif";
      break;
	  
    case 2:
      document.getElementById("tab2Left").src = tabPath + "tab-unselected-left-middle.gif";
      setBackgroundImage("tab2Middle", tabPath + "tab-unselected-middle.gif")
      document.getElementById("tab2Label").className = "tab-unselected";
      document.getElementById("tab2Right").src = tabPath + "tab-unselected-right-middle.gif";
      break;
	  
    case 3:
      document.getElementById("tab3Left").src = tabPath + "tab-unselected-left-middle.gif";
      setBackgroundImage("tab3Middle", tabPath + "tab-unselected-middle.gif");
      document.getElementById("tab3Label").className = "tab-unselected";
      document.getElementById("tab3Right").src = tabPath + "tab-unselected-right-edge.gif";
      break;
  }
}	// deselectTab


function selectTab(index) {

  // deselect other tabs
  //
  for (i = 1; i <= 4; i++)
    if (i != index)
      deselectTab(i);
  
  // select tab
  //
  tabIndex = index;
  
  switch (index) {
    case 1:
      document.getElementById("tab1Left").src = tabPath + "tab-bottom-selected-left-edge.gif";
      setBackgroundImage("tab1Middle", tabPath + "tab-bottom-selected-middle.gif");
      document.getElementById("tab1Label").className = "tab-selected";
      document.getElementById("tab1Right").src = tabPath + "tab-bottom-selected-right-middle.gif";
      document.getElementById("sidebar").src = tabURLs[0];
      break;
	  
    case 2:
      document.getElementById("tab2Left").src = tabPath + "tab-bottom-selected-left-middle.gif";
      setBackgroundImage("tab2Middle", tabPath + "tab-bottom-selected-middle.gif");
      document.getElementById("tab2Label").className = "tab-selected";
      document.getElementById("tab2Right").src = tabPath + "tab-bottom-selected-right-middle.gif";
      document.getElementById("sidebar").src = tabURLs[1];
      break;
	  
    case 3:
      document.getElementById("tab3Left").src = tabPath + "tab-bottom-selected-left-middle.gif";
      setBackgroundImage("tab3Middle", tabPath + "tab-bottom-selected-middle.gif");
      document.getElementById("tab3Label").className = "tab-selected";
      document.getElementById("tab3Right").src = tabPath + "tab-bottom-selected-right-edge.gif";
      document.getElementById("sidebar").src = tabURLs[2];
      break;
  }
}	// selectTab
