function drawmenu(){ if(!document.getelementbyid("nav")){ return false; } var objarr = document.getelementbyid("nav").getelementsbytagname("h2"); for(var x = 0; x < objarr.length; x++){ var obj = objarr[x].parentnode; var objul = obj.getelementsbytagname("ul")[0]; if (!objul) { continue; } else { var objli = objul.getelementsbytagname("li"); type(); } } function type(){ obj.onmouseover = show(objul); obj.onmouseout = hide(objul); function show(_obj){ return function(){ _obj.classname = "clearfix typeul block"; //修正li的宽度值及定位值 var pleft=_obj.clientwidth; if (pleft > 100){ //var cli = clearwhitespaces(_obj); for (var c=0; c<_obj.childnodes.length;c++){ var cli = _obj.childnodes[c]; if(cli.nodename.tolowercase() == "li"){ cli.style.width = pleft + "px"; if(cli.getelementsbytagname("ul")[0]){ cli.getelementsbytagname("ul")[0].style.left = pleft +"px"; } } } } //end column.nodename.tolowercase() == "div" } } function hide(_obj){ return function(){ _obj.classname = "clearfix typeul"; } } for(var i = 0; i < objli.length; i++){ var liul = objli[i].getelementsbytagname("ul")[0]; if (!liul){ continue; }else{ typeshow(); } } function typeshow(){ objli[i].onmouseover = showul(objli[i]); objli[i].onmouseout = hideul(objli[i]); } function showul(_obj){ return function(){ _obj.getelementsbytagname("ul")[0].classname = "block clearfix"; //修正li的宽度值及定位值 var obj_ul = _obj.getelementsbytagname("ul")[0]; var lipleft = obj_ul.clientwidth; if (lipleft > 100){ //var uli = cleanwhitespaces(obj_ul); for (var u=0; u