var submenuData = Array();
var hideMenuInterval = -1;
function showMenu(menuItem) {
   var subMenuDiv = document.getElementById("submenuContainer");
   var splash = document.getElementById("splashDark");
   
   if (submenuData[menuItem].length > 0) {
     var htmlCode = '<ul class="imageSubmenu">';
     for (var i = 0; i < submenuData[menuItem].length; i++) {
       htmlCode += '<li><a href="' + submenuData[menuItem][i]["url"] + '"> ›' +   submenuData[menuItem][i]["name"] + "</a></li>";
     }
     htmlCode += '<ul class="imageSubmenu">';
     subMenuDiv.innerHTML = htmlCode;
     subMenuDiv.style.display = "block";
     
  	 splash.style.display = "block";
   } else {
    subMenuDiv.style.display = "none";
    splash.style.display = "none";
   }
   //console.log("showMenu");
}


function hideMenuTimeout() {
  //console.log("hideMenuTimeout");
  var subMenuDiv = document.getElementById("submenuContainer");
  subMenuDiv.style.display = "none";
  subMenuDiv.innerHTML = "";
  var splash = document.getElementById("splashDark");
  splash.style.display = "none";
  hideMenuInterval = -1;
  
}

function clearMenuInterval() {
  //console.log("clearMenuInterval");
  if (hideMenuInterval != -1) {
    clearTimeout(hideMenuInterval);
    hideMenuInterval = -1;
  }
}

function hideMenu() {
  hideMenuInterval = setTimeout("hideMenuTimeout()", 100);
  //console.log("hideMenu " + hideMenuInterval);
}

function placeSplash() {
  var splash = document.getElementById("splashDark");
  
  var w = window.document.body.clientWidth;
  if (w < 795) {
    w = 795;
  }
  splash.style.left = ((w - 795) / 2 + 540) + "px";
  //splash.style.display = "block";
}

function playMenuSound() {
  var thissound= document.getElementById('menuClick');
  thissound.Play();
}

