for(var x = 1; x < 7; x++) { var menuid = document.getElementById("menu"+x); menuid.num = x; type(); } function type() { var menuh2 = menuid.getElementsByTagName("h2"); var menuul = menuid.getElementsByTagName("table"); var menuli = menuul[0].getElementsByTagName("tr"); menuh2[0].onmouseover = show; menuh2[0].onmouseout = unshow; menuul[0].onmouseover = show; menuul[0].onmouseout = unshow; function show() { menuul[0].className = "clearfix typeul block" } function unshow() { menuul[0].className = "typeul" } for(var i = 0; i < menuli.length; i++) { menuli[i].num = i; var liul = menuli[i].getElementsByTagName("table")[0]; if(liul) { typeshow() } } function typeshow() { menuli[i].onmouseover = showul; menuli[i].onmouseout = unshowul; } function showul() { menuli[this.num].getElementsByTagName("table")[0].className = "block"; } function unshowul() { menuli[this.num].getElementsByTagName("table")[0].className = ""; } }