
/**
*菜单的构造,需要绑定到onload
*/
startList = function() {
if (document.all&&document.getElementById) {
dropmenuRoot = document.getElementById("dropmenu");
   for (i=0; i<dropmenuRoot.childNodes.length; i++) {
    node = dropmenuRoot.childNodes[i];
    if (node.nodeName=="LI") {
     node.onmouseover=function() {
     this.className+=" over";
     //开始灌水
       for(j=0;j<this.childNodes.length;j++){
       if (this.childNodes[j].nodeName=="UL"){
        if (this.childNodes[j].childNodes[0].nodeName=="LI"){
         if (this.offsetLeft+this.childNodes[j].childNodes.length*
            this.childNodes[j].childNodes[0].offsetWidth-dropmenuRoot.offsetLeft>
            dropmenuRoot.offsetWidth)
        { 
        //菜单的长度
        var len=this.childNodes[j].childNodes.length*
            this.childNodes[j].childNodes[0].offsetWidth; 
        //给ul设置宽度如果子菜单比较多，大于容器的宽度，那么ul的宽度就是容器的宽度
//        (len>dropmenuRoot.offsetWidth) ? this.childNodes[j].style.width=
//            776+"px" : this.childNodes[j].style.width=len+"px"; 
//        len =this.offsetLeft+len-dropmenuRoot.offsetLeft-dropmenuRoot.offsetWidth;
//        (len>this.offsetLeft-dropmenuRoot.offsetLeft) ? this.childNodes[j].style.marginLeft=
//            -(this.offsetLeft-dropmenuRoot.offsetLeft) : this.childNodes[j].style.marginLeft=
//            -len+"px";        
        }
        }
       }
      }
    }
    //灌水完毕
    node.onmouseout=function() {
     this.className=this.className.replace(" over", "");
    }
   }
}
}
}
window.onload=startList;


