var x,y;
function getWindowWidth()
{
  if (self.innerHeight) // all except Explorer
  {
    x = self.innerWidth;
    y = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight)
    // Explorer 6 Strict Mode
  {
    x = document.documentElement.clientWidth;
    y = document.documentElement.clientHeight;
  }
  else if (document.body) // other Explorers
  {
    x = document.body.clientWidth;
    y = document.body.clientHeight;
  }
}  

function hideMenu(menuID)
{
  document.getElementById("subMenu["+menuID+"]").style.display="none";
}
function resetHideMenu() { clearTimeout(menuTimer); }
function beginHideMenu(menuID) { resetHideMenu();menuTimer = setTimeout("hideMenu("+menuID+")",500); }
function menuOver(menuID,showSub)
{
  resetHideMenu();
  for (myCount=1;myCount<=menuNum;myCount++)
  {
    if (myCount != menuID)
    {
      document.getElementById("subMenu["+myCount+"]").style.display="none";
    }
  }
  if (showSub == 1) { document.getElementById("subMenu["+menuID+"]").style.display="block"; }
}

function MouseEffect(event)
{
  switch( event.type )
  {
    case "mouseover":
    {
      if(document.all)
      {
        window.event.srcElement.style.backgroundColor = '#F2EEE2';
        window.event.srcElement.style.border = '1px solid #EBE6D3';
      }
      else
      {
        event.currentTarget.style.backgroundColor = '#F2EEE2';
        event.currentTarget.style.border = '1px solid #EBE6D3';
      }
      break;
    }
    case "mouseout":
    {
      if(document.all)
      {
        window.event.srcElement.style.backgroundColor = '#EBE6D3';
        window.event.srcElement.style.border = '1px solid #FFFFFF';
      }
      else
      {
        event.currentTarget.style.BackgroundColor = '#EBE6D3';
        event.currentTarget.style.border = '1px solid #FFFFFF';
      }          
      break;
    }
    default:break;
  }
}

function MouseSubEffect(event)
{
  switch( event.type )
  {
    case "mouseover":
    {
      if(document.all)
      {
        window.event.srcElement.style.backgroundColor = '#EBE6D3';
      }
      else
      {
        event.currentTarget.style.backgroundColor = '#EBE6D3';
      }
      break;
    }
    case "mouseout":
    {
      if(document.all)
      {
        window.event.srcElement.style.backgroundColor = '#F2EEE2';
      }
      else
      {
        event.currentTarget.style.BackgroundColor = '#F2EEE2';
      }          
      break;
    }
    default:break;
  }
}

function loadLink(newPage)
{
  window.location.href=newPage;
}

function positionMenu()
{
  var newLeft = (x/2) - 252;
  if (newLeft < 138) { newLeft = 143; }
  for (myCount=1;myCount<=menuNum;myCount++) { document.getElementById("subMenu["+myCount+"]").style.left= newLeft+"px"; }
}

function initPage()
{
  getWindowWidth();
  positionMenu();
}
