function MakeDropDown(div) { var ul = div.getElementsByTagName('UL')[0]; ul.open = false; ul.selectLi = dropdown_selectLi; ul.onclick = dropdown_onclick; ul.selected = dropdown_selected; var li = ul.firstChild; while (li) { if (li.tagName=='LI') { li.onmouseover = dropdown_onmouseover; li.onmouseout = dropdown_onmouseout; } li = li.nextSibling; } } function makeMeDropDown(div) { MakeDropDown(div); div.onclick = null; var e = e || window.event; div.getElementsByTagName('UL')[0].onclick(true); } /* function MakeDropDownAll() { var divs = document.getElementsByTagName('DIV'); for (var i in divs) if (divs[i].className=='dropdown') MakeDropDown(divs[i]); } */ function dropdown_onmouseover() { this.style.backgroundColor = '#DFE9F5'; } function dropdown_onmouseout() { this.style.backgroundColor = ''; } function dropdown_selectLi(li) { //Cierra la lista y selecciona el item var child = this.firstChild; while (child) { if (child.tagName=='LI') child.className = ''; child = child.nextSibling; } li.className = 'selected'; delCSSClass(this,'dropdown_open');// = 'clearfix'; this.open = false; window.ddSelectAction && window.ddSelectAction[this.id] && window.ddSelectAction[this.id](this, li); } function dropdown_onclick(e) { var e = e || window.event; var target = e.srcElement || e.target; if (this.open) { if (target.tagName=='LI') this.selectLi(target); } else { //Abre la lista /*var child = this.firstChild; while (child) { if (child.tagName=='LI') child.className = 'selected'; child = child.nextSibling; }*/ //this.className = 'dropdown_open clearfix'; addCSSClass(this,'dropdown_open'); this.open = true; } } function dropdown_selected() { if (!this.open) { var child = this.firstChild; while (child && (child.className!='selected')) child = child.nextSibling; return child; } else return null; }