//*****************  BEGIN NAV *************************
//When mousing over a nav element
function showmenu(elmnt,elementID){
  document.getElementById(elementID).className = 'onMouseOverTab';

  //validate if the tab elmnt contains drop down menu to show
  if(document.getElementById(elmnt)){
     document.getElementById(elmnt).style.visibility="visible";
  }

  //Align drop down menu for last tab
  if(elmnt=='MAS'){
          
      //Determine if last tab contains drop down menu, if it does, then adjust it to align to the right
    if(document.getElementById(elmnt) != null){
      var lastTabWidth = document.getElementById(elmnt).offsetWidth;
        var adjustValue  = determineOffSetLeftLastTab();
      document.getElementById(elmnt).style.left = 980 - lastTabWidth + (adjustValue) +'px';
    }  
    //alert(testing);
  }


}

//When mousing out a nav element
function hidemenu(elmnt,elementID,typeBkg){
  //variable type refers to the yellow or dark bkg
  var onMouseOutBkgType = '';  

  if((typeBkg=='yellow') || (typeBkg=='')){
      onMouseOutBkgType = 'navRowYellow';  
  }
  else{
      onMouseOutBkgType = 'navRowDark';  
  } 

  document.getElementById(elementID).className = onMouseOutBkgType;

  //validate if the tab elmnt contains drop down menu to hide
  if(document.getElementById(elmnt)){
            document.getElementById(elmnt).style.visibility="hidden";
  }
  
}

//Determine adjusting layout for last tab
function determineOffSetLeftLastTab(){
      browser_type = navigator.appName;
      var adjustValue = 0;
      //IE, Opera
      if ((browser_type == "Microsoft Internet Explorer") || (browser_type == "Opera")) {
        adjustValue = 1;
      }
      //Mozilla, Netscape, Safari
      else if (browser_type == "Netscape") {
        adjustValue = 0;
      } else {
        adjustValue = 0;
      }
     return adjustValue;
}

//Call MouseOnMouseOutNavElmts function for each tab in FSE, depending on single-column or multiple-column drop downs
function FSEActivateMouseOnAndOut(){
  MouseOnMouseOutNavElmts('FUTBOL','multiple');
  MouseOnMouseOutNavElmts('BEISBOL','single');
  MouseOnMouseOutNavElmts('BASKETBALL','single');
  MouseOnMouseOutNavElmts('NFL','single');
  //MouseOnMouseOutNavElmts('OLIMPICOS','single');
  MouseOnMouseOutNavElmts('TORNEOSFUTBOL','single');
  MouseOnMouseOutNavElmts('BOXEO','single');
  MouseOnMouseOutNavElmts('MOTOR','single');
  MouseOnMouseOutNavElmts('TENIS','single');
  MouseOnMouseOutNavElmts('GOLF','single');
  MouseOnMouseOutNavElmts('JUEGOS','single');
  MouseOnMouseOutNavElmts('VIDEO','single');
  MouseOnMouseOutNavElmts('TV','single');
  MouseOnMouseOutNavElmts('MOBILE','single');
  MouseOnMouseOutNavElmts('TIENDA','single');
  MouseOnMouseOutNavElmts('REVISTA','single');
  MouseOnMouseOutNavElmts('MAS','single');
}

//Call MouseOnMouseOutNavElmts function for each tab in FSLA, depending on single-column or multiple-column drop downs
function FSLAActivateMouseOnAndOut(){
  MouseOnMouseOutNavElmts('FUTBOL','multiple');
  MouseOnMouseOutNavElmts('BEISBOL','single');
  MouseOnMouseOutNavElmts('BASKETBALL','single');
  MouseOnMouseOutNavElmts('NFL','single');
  //MouseOnMouseOutNavElmts('OLIMPICOS','single');
  MouseOnMouseOutNavElmts('JUEGOS','single');
  MouseOnMouseOutNavElmts('VIDEO','single');
  MouseOnMouseOutNavElmts('TORNEOSFUTBOL','single');
  MouseOnMouseOutNavElmts('MAS','single');
}

//Call MouseOnMouseOutNavElmts function for each tab in FSLASC, depending on single-column or multiple-column drop downs
function FSLASCActivateMouseOnAndOut(){
  MouseOnMouseOutNavElmts('FUTBOL','multiple');
  MouseOnMouseOutNavElmts('BEISBOL','single');
  MouseOnMouseOutNavElmts('BASKETBALL','single');
  MouseOnMouseOutNavElmts('NFL','single');
  //MouseOnMouseOutNavElmts('OLIMPICOS','single');
  MouseOnMouseOutNavElmts('JUEGOS','single');
  MouseOnMouseOutNavElmts('VIDEO','single');
  MouseOnMouseOutNavElmts('TORNEOSFUTBOL','single');
  MouseOnMouseOutNavElmts('MAS','single');
}

//Creates onmouseover and onmouseout effect whithout writting js functions to every single td
function MouseOnMouseOutNavElmts(id,dropDownType) {
  if(document.getElementById(id) != null) {//validates if the element exists in {fse,fsla,fslasc}_nav_config.jsp
    //**** Onmouseover and onmouseout effect for single-column drop down menus ******
    if(dropDownType=='single') {
      dropDownContentSingle       = document.getElementById(id).getElementsByTagName('td');
      dropDownTotalContentSingle  = dropDownContentSingle.length;
   
      for (i=0; i<dropDownTotalContentSingle; i++) {
        //Mousing over an element
        dropDownContentSingle[i].onmouseover = function() {
        //valide if the td is a header, example: Latin america, Europe, Posiciones, etc
        if (this.className.indexOf('subMenuElementSubTitle') == -1) {
          this.className = 'elementOnMouseOver';
        }  
      }
      //Mousing out an element
      dropDownContentSingle[i].onmouseout = function() {
        //valide if the td is a header, example: Latin america, Europe, Posiciones, etc
          if (this.className.indexOf('subMenuElementSubTitle') == -1) {
            this.className = 'subMenuElement';
          }
        }
      }  
    } //**** Onmouseover and onmouseout effect for multiple-column drop down menus ******
    else {
      dropDownContentMultiple     = document.getElementById(id).getElementsByTagName('table');
      dropDownTotalContentMultiple  = dropDownContentMultiple.length;
        for(i=0; i<dropDownTotalContentMultiple; i++) {
          SubNodeContent      = dropDownContentMultiple[i].getElementsByTagName('td');
          SubNodeTotalContent = SubNodeContent.length;
          for (j=0; j<SubNodeTotalContent; j++) {
            //Mousing over an element
            SubNodeContent[j].onmouseover = function() {
            //valide if the td is a header, example: Latin america, Europe, Posiciones, etc
            if (this.className.indexOf('subMenuElementSubTitle') == -1) {
              this.className = 'elementOnMouseOver';
            }  
          }
          //Mousing out an element
           SubNodeContent[j].onmouseout = function(){
             //valide if the td is a header, example: Latin america, Europe, Posiciones, etc
             if (this.className.indexOf('subMenuElementSubTitle') == -1) {
               this.className = 'subMenuElement';
             }
          }
        }
      }
    }  
  }
}


//*****************  END NAV *************************
