//
// cbl.js
// 25 Maio 2004

// level1Index = 0;  defined in calling html
level2Index = -1

htmlPath = location.pathname;
if (htmlPath.charAt(htmlPath.length - 1) == "/")
  htmlPath += "index.html";
if (typeof(level1Path) == 'undefined') {
  level1Path = htmlPath.substring(0, (htmlPath.indexOf("/", 1)) + 1);
  if (level1Path == "")
    level1Path = "/";  // Fix case of being at root and need redirect
}
if (typeof(level2Path) == 'undefined') {
  level2Path = htmlPath.substring(0, (htmlPath.indexOf("/", level1Path.length)) + 1);
  if (level2Path == "")
    level2Path = level1Path;
}

if (!window.saveInnerWidth) {
  window.onresize = resizeNetscape;
  window.saveInnerWidth = window.innerWidth;
  window.saveInnerHeight = window.innerHeight;
}

// Preload some images for faster tab navigation

  imageList = new Array();
  imageList[0] = new Image();
  imageList[0].src = "images/tabs_on_leftend.gif";
  imageList[1] = new Image();
  imageList[1].src = "images/tabs_off_leftend.gif";
  imageList[2] = new Image();
  imageList[2].src = "images/tabs_on_leftmid.gif";
  imageList[3] = new Image();
  imageList[3].src = "images/tabs_off_mid.gif";
  imageList[4] = new Image();
  imageList[4].src = "images/tabs_on_rightmid.gif";
  imageList[5] = new Image();
  imageList[5].src = "images/tabs_on_rightend.gif";
  imageList[6] = new Image();
  imageList[6].src = "images/tabs_off_rightend.gif";

// Define tab values, and any sub-tabs

  tabList = new Array();
  tabList[0] = new level1Tab('Home',                             'index.html');
  tabList[0].level2[0] = new level2Tab('Home',                   'index.html');
  tabList[0].level2[1] = new level2Tab('CDs Editados',           'cdseditados.html');
  tabList[0].level2[2] = new level2Tab('Direcção',               'direccao.html');
  tabList[0].level2[3] = new level2Tab('Sobre o site...',        'sobreosite.html');
	
  tabList[1] = new level1Tab('MP3',                              'mp3.html');
  tabList[1].level2[0] = new level2Tab('Ouça-nos em MP3',        'mp3.html');

  tabList[2] = new level1Tab('Historial',                        'historial.html');
  tabList[2].level2[0] = new level2Tab('Historial',              'historial.html');
  tabList[2].level2[1] = new level2Tab('Actuações',              'actuacoes.html');

  tabList[3] = new level1Tab('Festival Infanto-juvenil',         '6festival.html');
  tabList[3].level2[0] = new level2Tab('III Festival',           '3festival.html');
  tabList[3].level2[1] = new level2Tab('IV Festival',            '4festival.html');
  tabList[3].level2[2] = new level2Tab('V Festival',             '5festival.html');
  tabList[3].level2[3] = new level2Tab('VI Festival',            '6festival.html');

  tabList[4] = new level1Tab('Imagens',                          'imagens.html');
  tabList[4].level2[0] = new level2Tab('Coro Borboleta Linda',   'imagens.html');
  tabList[4].level2[1] = new level2Tab('Warner Bros. Park',      'wbp_pag1.html');
  tabList[4].level2[2] = new level2Tab('Praça da Alegria',       'pracadaalegria.html');
  tabList[4].level2[3] = new level2Tab('Swatch Fraldinhas',      'swatchf.html');

level1Index = 0;

  for (i = 0; i < tabList.length; i++)
    if (level1Path == tabList[i].path) {
      level1Index = i;
      break;
    }
  if (level1Index != -1) {
    for (i = 0; i < tabList[level1Index].level2.length; i++)
      if (level2Path == tabList[level1Index].level2[i].path) {
        level2Index = i;
        break;
      }
  }


function level1Tab(name, path) {                      // Define a main tab
  this.name   = name;
  this.path   = path;
  this.level2 = new Array();
}

function level2Tab(name, path) {                      // Define a sub-tab
  this.name   = name;
  this.path   = path;
}

function level1Display() {
  var i, j;
  var imageLeft   = "";
  var imageRight  = imageList[6].src;
  var tabName     = "";
  var tabClass    = "";
  var textClass   = "";
  var thisPath    = level1Path;
  var urlLink     = "";
  var urlName     = "";
  var urlPath     = "";
  var priorTab    = false;
  var tempVal     = "";

    document.writeln('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
    document.writeln('<tr>');
    document.writeln('<td rowspan="2">');

    document.writeln('<img src="images/cbl_s11.jpg" border="0">');

    document.writeln('</td>');

//
//    document.writeln('<td valign="top" align="right" valign="top"><img src="images/cbl_s.jpg"><img src="images/download_icon_2.gif"><img src="images/download_icon_2_space.gif"></td>');
    document.writeln('<td valign="top" align="right" valign="top"><table><tr><td><font color=red size=+1>A Criança que canta descobre a beleza da vida&nbsp;&nbsp;</td><td><!-- <img src="images/cbl_s.jpg"> --></td></tr></table></td>');
//    document.writeln('<table border="1" cellpadding="0" cellspacing="0">');
//    document.writeln('<tr>');

//    document.writeln('</tr>');
//    document.writeln('</table>');
//    document.writeln('</td>');

//

    document.writeln('</tr>');
    document.writeln('<tr>');
    document.writeln('<td colspan="2" valign="bottom" align="right">');
    document.writeln('<table border="0" cellpadding="0" cellspacing="0">');
    document.writeln('<tr>');

// Display the tabs across the screen, highlighting the one we're sitting on at present

    for (i=0; i<tabList.length; i++) {
      tabName = tabList[i].name;
      tabPath = tabList[i].path;

//      if (thisPath == tabPath) { // Highlight tab that relates to where we are
      if (i == xtab1) {
        imageLeft = imageList[2].src;
        if (i == 0) {imageLeft = imageList[0].src;}  // Special case for first tab
        textClass = "CblNav1Selected";
        tabClass  = "CblBGColorDark";
        if ((i+1) == tabList.length) {imageRight = imageList[5].src;}
        priorTab = true;
      } else {
        imageLeft = imageList[3].src;
        if (priorTab) {
          imageLeft = imageList[4].src;
          priorTab = false;
        }
        if (i == 0) {imageLeft = imageList[1].src;}  // Special case for first tab
        textClass = "CblNav1Enabled";
        tabClass  = "CblBGAccentDark";
      }

      document.writeln('<td><img src="' + imageLeft + '" border="0"></td>');
      urlLink = '<a href="' + tabPath + '"><font class="' + textClass + '">' + tabName + '</font></a>';
      document.writeln('<td class="' + tabClass + '" nowrap>&nbsp;' + urlLink + '&nbsp;</td>');
    }

    document.writeln('<td><img src="' + imageRight + '" border="0"></td>');
    document.writeln('</tr>');
    document.writeln('</table>');
    document.writeln('</td>');
    document.writeln('</tr>');

// Begin level2 (sub-tab) layout

    document.writeln('<tr>');
    document.writeln('<td colspan="2" background="images/top_rightback.gif" nowrap align="left">');
    document.writeln('<table border="0" cellpadding="0" cellspacing="0" align="left" background="images/top_leftback.gif">');
    document.writeln('<tr>');
    document.writeln('<td background="images/top_rightback.gif" align="left">');
    document.writeln('<img src="images/top_leftend.gif" border="0"></td>');

// Display list of level2 tabs if any exist.  Highlight ourselves for our path if applicable

      for (var i=0; i<tabList[level1Index].level2.length; i++) {
        urlName = tabList[level1Index].level2[i].name;
        urlPath = tabList[level1Index].level2[i].path;
        if (i) {
          document.writeln('<td><img src="images/top_separator.gif" border="0"></td>');
        }
        tempVal = "CblNav2Enabled";

//        if (level2Path == urlPath)
        if (i == xtab2)
          tempVal = "CblNav2Selected";
        document.writeln('<td nowrap> ' + '<a href="' + urlPath + '">' +
                         '<font class="' + tempVal + '">' + urlName + '</font></a> </td>');
      }

// Close off level 2, display final portion with search field, then close this table

    document.writeln('<td><img src="images/top_divider.gif" border="0"></td>');
    document.writeln('</tr>');
    document.writeln('</table>');
    document.writeln('</td>');
    document.writeln('<td background="images/top_rightback.gif" align="right">');
    document.writeln('<img src="images/top_rightend.gif" border="0"></td>');
    document.writeln('</tr>');
    document.writeln('<tr>');
    document.writeln('<td background="images/search_back.gif" height="45" valign="top" align="left" nowrap>');
    document.writeln('<img src="images/search_left.gif" border="0"><sup>');
//    document.writeln('<font class="CblHeaderBox">"A Criança que Canta Descobre a Beleza da Vida"</font>');
    document.writeln('<td background="images/search_back.gif" height="45" align="right" nowrap>&nbsp;');
//    document.writeln('<font class="CblDarkHeaderSub">www.borboletalinda.com</font>');
    document.writeln('Rua dos Lusíadas,n.º8,2.º Dt.º 2735-402 CACÉM<br>');
    document.writeln('<IMG border=0 src="images/phone.jpg" width=16>&nbsp;934085351&nbsp;<IMG border=0 src="images/mail.gif">&nbsp;<b>email: </b><A href="mailto:coro.cbl@iol.pt">coro.cbl@iol.pt</A>');

    document.writeln('</td>');
    document.writeln('<td background="images/search_back.gif" height="45" valign="top" align="right">');
    document.writeln('<img src="images/search_end.gif" border="0"></td>');
    document.writeln('</tr>');
    document.writeln('</table>');
//    document.writeln('<br>');
}


function headerDisplay(msg1, msg2) {
  if (typeof(msg1) == 'undefined')
    msg1 = '';
  if (typeof(msg2) == 'undefined')
    msg2 = '';

  msg = msg1 + '<br>' + msg2;
  document.writeln('<center><h1>&nbsp;' + msg + '</h1></center><img src="images/mbeigedot.gif" border="0" width="100%" height="1" align="top">');
}

function footerDisplay() {
  document.writeln('<img src="images/mbeigedot.gif" border="0" width="99%" height="1" align="top"><center><a>borboletalinda.com.sapo.pt - Maio de 2004</a><br><img src="images/cbl_s.jpg" border=0></center>');
}

function resizeNetscape() {
  if (saveInnerWidth != window.innerWidth || saveInnerHeight != window.innerHeight)
    setTimeout('location.reload()', 5);
}

function devDisplay() {
  document.writeln('<center><img src="images/atwork.jpg" border="0" align="top"></center>');
}

function sepline() {
  document.write('<img src="images/mbeigedot.gif" border="0" width="100%" height="1" align="top">');
}


// -----
