var currmenu = 0;
var currsubmenu = 0;

function showMenu(menu_num) {
  var m_id = "m"+menu_num+"a";
  var obj = document.getElementById(m_id);
  if(obj != null) {
    obj.style.display='block';
    currmenu = menu_num;
  }
}

function hideMenu() {
  var m_id = "m"+currmenu+"a";
  var obj = document.getElementById(m_id);
  if(obj != null) {
    obj.style.display='none';
  }
}

function showSubMenu(submenu_num) {
  var m_id = "m"+submenu_num+"a";
  var obj = document.getElementById(m_id);
  if(obj != null) {
    obj.style.display='block';
    currsubmenu = submenu_num;
  }
}

function hideSubMenu() {
  var m_id = "m"+currsubmenu+"a";
  var obj = document.getElementById(m_id);
  if(obj != null) {
    obj.style.display='none';
  }
}

function getDivHeight(div) {
  var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
  if(rslt != null) {
    return div.offsetHeight;
  } else {
    return div.clientHeight;
  }
}

/*
function getElementsByStyleClass(className) {
  var all = document.all ? document.all :
    document.getElementsByTagName('*');
  var elements = new Array();
  for (var e = 0; e < all.length; e++)
    if (all[e].className == className)
      elements[elements.length] = all[e];
  return elements;
}
*/

function blockWinElm() {
  var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
  if(rslt != null) {
    var hide = getElementsByStyleClass('hide');
    for(var i = 0; i < hide.length; i++) {
      var d = hide[i];
      if(d != null) {
	d.style.visibility = 'hidden';
      }
    }
  }
}

function formatphone(exp, p) {
  var e = document.getElementById(p).value;
  do {
    var d = e;
    e = e.replace(/[^\d\.]/, '');
  } while(e != d);
  e = e.replace(/^([^\.]*\.[^\.]*)\..*/, '$1');
  if (e == '') { e = 0; }
  e = e + "";
  if(e.length < 11) {
    alert("Phone number must be in +31 (0) 67890987 format");
    return false;
  } else {
    var f = "+" + e.substring(0,2) + " (" + e.substring(2,3) + ") " +e.substring(3);
    document.getElementById(p).value = f;
    return true;
  }
}
