//*****************  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=='FSCSHOP'){
          
      //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 dro 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 Foxsoccer, depending on single-column or multiple-column drop downs
function FSCActivateMouseOnAndOut(){
  MouseOnMouseOutNavElmts('FOXSPORTS.COM','single');
  MouseOnMouseOutNavElmts('FOXSOCCER','multiple');
  MouseOnMouseOutNavElmts('USA','multiple');
  MouseOnMouseOutNavElmts('ENGLAND','multiple');
  MouseOnMouseOutNavElmts('EUROPE','multiple');
  MouseOnMouseOutNavElmts('LATINAMERICA','multiple');
  MouseOnMouseOutNavElmts('CHAMPIONSLEAGUE','single');
  MouseOnMouseOutNavElmts('JAPAN','single');
  MouseOnMouseOutNavElmts('WORLDCUP','multiple');
  MouseOnMouseOutNavElmts('FSCTV','multiple');
  MouseOnMouseOutNavElmts('VIDEO','multiple');
  MouseOnMouseOutNavElmts('FANTASY','single');
  MouseOnMouseOutNavElmts('COMMUNITY','single');
  MouseOnMouseOutNavElmts('FSCSHOP','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 fsc_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: FA Cup, Premier League, Ligue 1, 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: FA Cup, Premier League, Ligue 1, 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: FA Cup, Premier League, Ligue 1, 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: FA Cup, Premier League, Ligue 1, etc
             if (this.className.indexOf('subMenuElementSubTitle') == -1) {
               this.className = 'subMenuElement';
             }
          }
         }
      }
  }  
 }
}
//*****************  END NAV *************************
