function changeTab(tabNum) {
  for(i=1; i<6; i++) {
    mainElementId = 'tab'+i+'main';
    tabId = 'tab'+i;
    currDivId = 'tab'+i+'div';
    if(i==tabNum) {
      document.getElementById(mainElementId).style.display = 'block';
      document.getElementById(tabId+'div').style.color = '#000000';
      document.getElementById(tabId).style.background = 'url(images/fliptabbkghighlight.gif) repeat-x top';

      document.getElementById(tabId).style.borderTop = '1px #999999 solid';
      document.getElementById(tabId).style.borderRight = '1px #999999 solid';
      document.getElementById(tabId).style.borderLeft = '1px #999999 solid';
      document.getElementById(tabId).style.borderBottom = '0px';
    } else {
      document.getElementById(mainElementId).style.display = 'none';
      document.getElementById(tabId+'div').style.color = '#006AB9';
      document.getElementById(tabId).style.background = 'transparent';
      document.getElementById(tabId).style.borderBottom = '1px #999999 solid';

      document.getElementById(currDivId).style.borderLeft = '1px #CCCCCC solid';
      if(i==1) {
        document.getElementById(tabId).style.borderTop = '1px #CCCCCC solid';
        document.getElementById(tabId).style.borderRight = '0px';
        document.getElementById(tabId).style.borderLeft = '1px #CCCCCC solid';
      } else if(i==2) {
        document.getElementById(tabId).style.borderTop = '1px #CCCCCC solid';
        document.getElementById(tabId).style.borderRight = '0px';
        document.getElementById(tabId).style.borderLeft = '0px';
      } else if(i==3) {
        document.getElementById(tabId).style.borderTop = '1px #CCCCCC solid';
        document.getElementById(tabId).style.borderRight = '0px';
        document.getElementById(tabId).style.borderLeft = '0px';
      } else if(i==4) {
        document.getElementById(tabId).style.borderTop = '1px #CCCCCC solid';
        document.getElementById(tabId).style.borderRight = '0px';
        document.getElementById(tabId).style.borderLeft = '0px';
      } else if(i==5) {
        document.getElementById(tabId).style.borderTop = '1px #CCCCCC solid';
        document.getElementById(tabId).style.borderRight = '1px #CCCCCC solid';
        document.getElementById(tabId).style.borderLeft = '0px';
      }
    }
  }
  if(tabNum == 5) {
    currDivId = 'tab'+tabNum+'div';
    document.getElementById(currDivId).style.borderLeft = '0px';
  } else {
    currDivId = 'tab'+tabNum+'div';
    document.getElementById(currDivId).style.borderLeft = '0px';
    nextTabNum = tabNum + 1;
    nextDivId = 'tab'+nextTabNum+'div';
    document.getElementById(nextDivId).style.borderLeft = '0px';

  }
  document.getElementById('tab1div').style.borderLeft = '0px';
}


function addTab(tabId, tabs) {
  var numTabs = tabs.length;
  tabs[numTabs] = tabId;
}

var blindDownObj;

function selectTab(selectedTabId, tabs, tabUrl) {

  var numTabs = tabs.length;
  var lastTab = numTabs - 1;
  var selectedTabIndex = -2;

  for(i=0; i<numTabs; i++) {
    var tabId = tabs[i];
    var tabContentId = tabId + 'content';
    var tabDivId = tabId + 'div';

    var tabDivObj     = document.getElementById(tabDivId);
    var tabContentObj = document.getElementById(tabContentId);
    var aTab          = document.getElementById(tabId);

    if(tabId==selectedTabId) {
      selectedTabIndex = i;
      tabContentObj.style.display = 'block';
      //blindDownObj = tabContentObj;
      //setTimeout("doBlindDown()", 1000);
      tabDivObj.style.color = '#000000';
      aTab.style.background = 'url('+tabUrl+') repeat-x top';

      tabDivObj.style.borderLeft = '0px';
      aTab.style.borderTop = '1px #999999 solid';
      aTab.style.borderRight = '1px #999999 solid';
      aTab.style.borderLeft = '1px #999999 solid';
      aTab.style.borderBottom = '0px';
    } else {
      tabContentObj.style.display = 'none';
      //if(tabContentObj.style.display != 'none') {
      //  new Effect.BlindUp(tabContentObj);
      //}
      tabDivObj.style.color = '#006AB9';

      //We don't need the left border in the first box. Also, we don't need it in the box to
      //right of the selected box.
      if((i>0) && ((selectedTabIndex+1)!=i)) {
        tabDivObj.style.borderLeft = '1px #CCCCCC solid';
      } else {
        tabDivObj.style.borderLeft = '0px';
      }
      aTab.style.background = 'transparent';
      aTab.style.borderBottom = '1px #999999 solid';
      if(i==0) {
        //If the first tab isn't selected, we have to handle the border differently.
        aTab.style.borderTop = '1px #CCCCCC solid';
        aTab.style.borderRight = '0px';
        aTab.style.borderLeft = '1px #CCCCCC solid';
      } else if(i==lastTab) {
        //If the first tab isn't selected, we have to handle the border differently.
        aTab.style.borderTop = '1px #CCCCCC solid';
        aTab.style.borderRight = '1px #CCCCCC solid';
        aTab.style.borderLeft = '0px';
      } else {
        aTab.style.borderTop = '1px #CCCCCC solid';
        aTab.style.borderRight = '0px';
        aTab.style.borderLeft = '0px';
      }
    }
  }
  return;
}

function selectInnerTab(selectedTabId, tabs) {
  var numTabs = tabs.length;
  var lastTab = numTabs - 1;

  for(i=0; i<numTabs; i++) {
    var tabId = tabs[i];
    var tabContentId = tabId + 'content';
    var tabDivId = tabId + 'div';

    var tabDivObj    = document.getElementById(tabDivId);
    var tabContentObj = document.getElementById(tabContentId);

    if(tabId==selectedTabId) {
      //tabContentObj.style.display = 'block';
      blindDownObj = tabContentObj;
      setTimeout("doBlindDown()", 1000);
    } else {
      //tabContentObj.style.display = 'none';
      if(tabContentObj.style.display != 'none') {
        new Effect.BlindUp(tabContentObj);
      }
    }


  }
  return;
}

function doBlindDown() {
  new Effect.BlindDown(blindDownObj);
}

function activateTabs(flightDivId, selectedTabId, tabGroup, tabUrl) {
  new Effect.BlindDown(document.getElementById(flightDivId));
  selectTab(selectedTabId, tabGroup, tabUrl);
  return;
}

