// Written by: Marc Hollins & Debbie Whitcomb
// Last Updated: August 29, 2003

// $Author: whitcomb $ 
// $Revision: 1.2 $ 

function removeName(el, name) {
  var i, curList, newList;

  if (el.className == null) { return; }

  // Remove the given class name from the element's className property.
  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++) {
    if (curList[i] != name) {
      newList.push(curList[i]);
    }
  el.className = newList.join(" ");
  }
}

function SelectTab(tabId) {
  var elem, tabelem;
  var elList, i, row;

  tabelem = (document.getElementById) ? document.getElementById(tabId) :
           ((document.all) ? document.all[tabId] : null);
						 
  if (tabelem == null) { return; }
	
  if (tabelem.parentNode.id == "tabArea1") { 
    row = 1; 
  } else {
    if (tabelem.parentNode.id == "tabArea2") { 
      row = 2; 
    } else { 
      row = 3; 
    }
  }

  // remove all active tabs.
  elList = document.getElementsByTagName("A");
  for (i = 0; i < elList.length; i++) {
    removeName(elList[i], "activeTab");
    if (row==1) {
      if (elList[i].parentNode.id == "tabArea2") {
        elList[i].style.paddingBottom = 22;
      } else {
      if (elList[i].parentNode.id == "tabArea3") {
    	  elList[i].style.paddingBottom = 42;
        } else {
  	      elList[i].style.paddingBottom = 2;
        }
      }
    } else {
      if (row==2) {
        if (elList[i].parentNode.id == "tabArea1") {
          elList[i].style.paddingBottom = 42;
        } else {
          if (elList[i].parentNode.id == "tabArea2") {
            elList[i].style.paddingBottom = 2;
          } else {
            elList[i].style.paddingBottom = 22;
          }
        }
      }	else {
        if (elList[i].parentNode.id == "tabArea3") {
          elList[i].style.paddingBottom = 2;
        } else {
          if (elList[i].parentNode.id == "tabArea1") {
            elList[i].style.paddingBottom = 22;
          } else {
            elList[i].style.paddingBottom = 42;
          }
        }
      }
    }
  }

  if (row==1) {
    elem = (document.getElementById) ? document.getElementById("tabArea1") : 
          ((document.all) ? document.all["tabArea1"] : null);
    elem.style.top = 45;
    elem.style.zIndex = 104;
    elem = (document.getElementById) ? document.getElementById("tabArea2") : 
          ((document.all) ? document.all["tabArea2"] : null);
    elem.style.top = 25;
    elem.style.zIndex = 102;
    elem = (document.getElementById) ? document.getElementById("tabArea3") : 
          ((document.all) ? document.all["tabArea3"] : null);
    elem.style.top = 5;
    elem.style.zIndex = 100;
  } else {
    if (row==2) {
      elem = (document.getElementById) ? document.getElementById("tabArea1") : 
            ((document.all) ? document.all["tabArea1"] : null);
      elem.style.top = 5;
      elem.style.zIndex = 100;
      elem = (document.getElementById) ? document.getElementById("tabArea2") : 
            ((document.all) ? document.all["tabArea2"] : null);
      elem.style.top = 45;
      elem.style.zIndex = 104;
      elem = (document.getElementById) ? document.getElementById("tabArea3") : 
            ((document.all) ? document.all["tabArea3"] : null);
      elem.style.top = 25;
      elem.style.zIndex = 102;
  	}	else {
      elem = (document.getElementById) ? document.getElementById("tabArea1") : 
            ((document.all) ? document.all["tabArea1"] : null);
      elem.style.top = 25;
      elem.style.zIndex = 102;
      elem = (document.getElementById) ? document.getElementById("tabArea2") : 
            ((document.all) ? document.all["tabArea2"] : null);
      elem.style.top = 5;
      elem.style.zIndex = 100;
      elem = (document.getElementById) ? document.getElementById("tabArea3") : 
            ((document.all) ? document.all["tabArea3"] : null);
      elem.style.top = 45;
      elem.style.zIndex = 104;
    }
  }
	
  tabelem.className += " activeTab";
  tabelem.style.paddingBottom = 6;
  tabelem.blur();	
}

