// Variable initialization =====================================================================

var arrLabName = [ "Queen's Center for Biomedical Research",
  "Laboratory of Cell & Molecular Signaling", 
  "Laboratory of Cell & Molecular Signaling", 
  "Laboratory of Adriana Sumoza-Toledo",
  "Laboratory of John Starkus" ];

var arrLabShort = ["qcbr", "lcms", " ", "atoledo", "jstarkus"];

var blnHeaderFade = true;   // for header animation


// Functions ===================================================================================

function fnBuildMainDesign(intLabID, intPageID) {
  var strHTML = "<div id='desDecor0'></div>";                // for main decors
  strHTML += "<div id='desPage" + intPageID + "'></div>";    // Page dependent decors

  switch (intLabID) {   // to add addtional main decors if needed
    case 1:
      document.getElementById("mainFooterContent").innerHTML += "<div id='desDecor1'></div>";
    break;

    case 2:
      document.getElementById("mainFooterContent").innerHTML += "<div id='desDecor1'></div>";
    break;

    case 3:
      document.getElementById("mainFooterContent").innerHTML += "<div id='desDecor1'></div>";
    break;

    default:
    break;
  }

  document.getElementById("mainBodyContent").innerHTML +=  strHTML;
}


function fnFillCommonSections(intLabID, intPageID) {
  document.getElementById("labTitle").innerHTML = "<h1>"+arrLabName[intLabID]+"</h1>";
  fnBuildMainMenuContent(intLabID);
  fnBuildSubMenuContent(intLabID, intPageID);
  fnBuildMainFooterInfo(intLabID);
  fnBuildMainDesign(intLabID, intPageID);   // this should ALWAYS be the last item
}


function fnBuildMainHeaderContent() {
  var strHTML = "<a href='http://www.queensmedicalcenter.net' target='_blank'>";
  strHTML += "<img src='/_includes/images/header0.jpg' id='headerImageOne'>";
  strHTML += "<img src='/_includes/images/header1.jpg' id='headerImageTwo'>";
  strHTML += "</a><div id='mainHeaderQCBR'>Center for Biomedical Research";
  strHTML += "<BR>1356 Lusitana St, UH Tower 8<BR>Honolulu, HI 96813</div>";
  document.getElementById("mainHeaderContent").innerHTML =  strHTML;
}


function fnBuildMainMenuContent(intLabID) {
  var arrMenu = [];
  arrMenu = [
    ["QCBR", "/index.html"],
    ["Reinhold Penner", "/LCMS/index.html"],
    ["Andrea Fleig", "/LCMS/index.html"],
    ["Adriana Sumoza-Toledo", "/atoledo/index.html"],
    ["John Starkus", "/jstarkus/index.html"]
  ];

  var strHTML = "<nav><ul>";

  for (i=0; i < arrMenu.length; i++ ) {
    if (i == 2 && intLabID == 1) {
      strHTML += "<li class='active'>";
    } else {      
      if (intLabID == i) {
        strHTML += "<li class='active'>";
      } else {
        strHTML += "<li>";
      }
    }

    strHTML += "<a href='" +arrMenu[i][1]+ "'>" +arrMenu[i][0]+ "</a></li>";
  }  

  strHTML += "</ul></nav>";
  document.getElementById("mainMenuContent").innerHTML =  strHTML;
}


function fnBuildSubMenuContent(intLabID, intSelected) {
  var arrSubMenu = [];
  
  switch(intLabID) {
    case 0:
      arrSubMenu = [
        ["Home", "/index.html"],
        ["Colleagues", "/QCBR/members.html"],
        ["News", "/QCBR/news.html"],
        ["Publications", "/QCBR/publications.html"],
        ["Gallery", "/QCBR/gallery.html"],
        ["Directions", "/QCBR/directions.html"]
      ];
    break;

    case 1:
      arrSubMenu = [
        ["Home", "/LCMS/index.html"],
        ["About Us", "/LCMS/about.html"],
        ["Members", "/LCMS/members.html"],
        ["News", "/LCMS/news.html"],
        ["Publications", "/LCMS/publications.html"],
        ["Gallery", "/LCMS/gallery.html"],
        ["Directions", "/LCMS/directions.html"]
      ];
    break;

    case 2:
      arrSubMenu = [
        ["Home", "/LCMS/index.html"],
        ["About Us", "/LCMS/about.html"],
        ["Members", "/LCMS/members.html"],
        ["News", "/LCMS/news.html"],
        ["Publications", "/LCMS/publications.html"],
        ["Gallery", "/LCMS/gallery.html"],
        ["Directions", "/LCMS/directions.html"]
      ];
    break;

    case 3:
      arrSubMenu = [
        ["Home", "/atoledo/index.html"],
        ["About Us", "/atoledo/about.html"],
        ["Members", "/atoledo/members.html"],
        ["News", "/atoledo/news.html"],
        ["Publications", "/atoledo/publications.html"],
        ["Gallery", "/atoledo/gallery.html"],
        ["Directions", "/atoledo/directions.html"]
      ];
    break;
    
    case 4:
      arrSubMenu = [
        ["Home", "/jstarkus/index.html"],
        ["Members", "/jstarkus/members.html"],
        ["News", "/jstarkus/news.html"],
        ["Publications", "/jstarkus/publications.html"],
        ["Gallery", "/jstarkus/gallery.html"],
        ["Directions", "/jstarkus/directions.html"]
      ];
    break;
  }
  
  var strHTML = "<ul>";

  for (i=0; i < arrSubMenu.length; i++ ) {
    if (intSelected == i) {
      strHTML += "<li class='active'>";
    } else {
      strHTML += "<li>";
    }
    strHTML += "<a href='" +arrSubMenu[i][1]+ "'>" +arrSubMenu[i][0]+ "</a></li>";
  }  

  strHTML += "</ul>";
  
  if (intLabID > 0 && intLabID < 3) {
    strHTML = "<div id='imgOsci'><img src='/LCMS/images/OsciAnim.gif' width='120' heigh='70'></div>" + strHTML;
  }
  
  document.getElementById("subMenuContent").innerHTML =  strHTML;
}

function fnBuildMainFooterInfo(intLabID) {
  var strHTML = "<p>Copyright 2011. " + arrLabName[intLabID];
  strHTML += ", The Queen's Medical Center. All Rights Reserved.</p>";
  document.getElementById("mainFooterInfo").innerHTML = strHTML;
}



// Other Functions =============================================================================
function fnAnimateMainHeaderContent() {
  blnHeaderFade = !blnHeaderFade;
 if (blnHeaderFade) {
    $('#headerImageTwo').fadeOut(1500);
 } else {
    $('#headerImageTwo').fadeIn(1500);
 }
}



// Onload ======================================================================================

window.onload = function() {
  fnBuildMainHeaderContent();

  $('#headerImageOne').fadeIn(1);
  setInterval("fnAnimateMainHeaderContent()", 5000);
}

function fnModalClick(strModalName) {
  $('#'+strModalName).modal();
  return false;
}

