function scrolldoor(){ } scrolldoor.prototype = { sd : function(menus,divs,openclass,closeclass){ var _this = this; if(menus.length != divs.length) { alert("菜单层数量和内容层数量不一样!"); return false; } for(var i = 0 ; i < menus.length ; i++) { _this.$(menus[i]).value = i; _this.$(menus[i]).onmouseover = function(){ for(var j = 0 ; j < menus.length ; j++) { _this.$(menus[j]).classname = closeclass; _this.$(divs[j]).style.display = "none"; } _this.$(menus[this.value]).classname = openclass; _this.$(divs[this.value]).style.display = "block"; } } }, $ : function(oid){ if(typeof(oid) == "string") return document.getelementbyid(oid); return oid; } } window.onload = function(){ var sdmodel = new scrolldoor(); sdmodel.sd(["m01","m02"],["c01","c02"],"sd01","sd02"); sdmodel.sd(["m03","m04"],["c03","c04"],"sd01","sd02"); sdmodel.sd(["m05","m06"],["c05","c06"],"sd01","sd02"); sdmodel.sd(["m07","m08"],["c07","c08"],"sd01","sd02"); sdmodel.sd(["m09","m10"],["c09","c10"],"sd01","sd02"); sdmodel.sd(["m11","m12"],["c11","c12"],"sd01","sd02"); }