//----------------------------------------------------------------------

function extendFullWidth( menu, menuContainerWidth, menuBorderWidth )
{
  var arrayLI = menu.getElementsByTagName("li");
  var i = 0; var j = 0; var k = 0;
  
  for ( i=0; i<arrayLI.length; i++ ) {
    if ( arrayLI[i].className.match(/Tab/i) ) {
      j = getPageX(arrayLI[i]) + arrayLI[i].offsetWidth;
      k++;
    }
  }

  var filler = menuContainerWidth + getPageX(menu) - j;

  if ( filler > 0 ) {
    for ( i=0; i<arrayLI.length; i++ ) {
      if ( arrayLI[i].className.match(/Tab/i) ) {
        arrayLI[i].style.width = ( parseInt( getWidth(arrayLI[i]) ) + Math.round(filler / k) ) + "px";
        // alert( arrayLI[i].style.width );
        filler -= Math.round(filler / k);
        k--;
      }
    }
  }
}

//----------------------------------------------------------------------

function Menu()
{
  var menu = document.getElementById("Menu");
  var menuContainerWidth = 980;
  var menuBorderWidth = 0;

  if ( menu ) {
    //extendFullWidth( menu, menuContainerWidth, menuBorderWidth );

    var arrayLI = menu.getElementsByTagName("li");

    for ( var i=0; i<arrayLI.length; i++ ) {
      if ( arrayLI[i].className.match(/Tab/i) ) {
        //alert( getPageX(arrayLI[i]) );
        arrayLI[i].onmouseover = function() {
          switch( this.id ) {
            case "MenuTabL" :
              this.className = "HiLiteL Tab";
              break;
              
            case "MenuTabR" :
              this.className = "HiLiteR Tab";
              break;
              
            default :
              this.className = "HiLiteM Tab";
              break;
          }
          
          var menuDropDown = this.getElementsByTagName("ul")[0];

          if ( menuDropDown ) {
            menuDropDown.style.top = this.offsetHeight - menuBorderWidth - ( ( window.ActiveXObject )? 0 : 6 );  // a hack!
            menuDropDown.style.display = "block";
            
            //if ( parseInt( getWidth(menuDropDown) ) < this.offsetWidth )
            //  menuDropDown.style.width = this.offsetWidth + "px";

            var thisOffsetX = getPageX(this);

            if ( (thisOffsetX + menuDropDown.offsetWidth) > (menuContainerWidth + menu.offsetLeft - menuBorderWidth) )
              menuDropDown.style.left = ( (menuContainerWidth + menu.offsetLeft - menuBorderWidth) - (thisOffsetX + menuDropDown.offsetWidth) ) + "px";
							menuDropDown.style.left = "0px";
							//alert('menuDropDown.style.left=' + menuDropDown.style.left)
							
            // Patch for IE6/5.x-Select-Ignore-zIndex-Problem
            if ( window.ActiveXObject )
              insertIE6iFrame( menuDropDown );
          }
        };

        arrayLI[i].onmouseout = function() {
          switch( this.id ) {
            case "MenuTabL" : this.className = "Tab"; break;
            case "MenuTabR" : this.className = "Tab"; break;
            default : this.className = "Tab";
          }
          
          this.getElementsByTagName("a")[0].className = "";
          var menuDropDown = this.getElementsByTagName("ul")[0];

          if ( menuDropDown ) {
            menuDropDown.style.display = "none";

            // Patch for IE6/5.x-Select-Ignore-zIndex-Problem
            if ( window.ActiveXObject )
              removeIE6iFrame( menuDropDown );
          }
        };
      }  // if ( arrayLI[i].className.match(/Tab/i) )
      else if ( arrayLI[i].parentNode.className.match(/DropDown/i) ) {
        arrayLI[i].onmouseover = function() {
          this.className = "HiLite";
        }

        arrayLI[i].onmouseout = function() {
          this.className = "";
        }
      }
      
    }  // for ( var i=0; i<arrayLI.length; i++ )
    
  }
}
