function countItems (item) { var i = 0; while (this.getElements(item + i)) { i=i+1; } return i; } function getElements(itemId) { var returnVal = null; if (typeof itemId != 'undefined'){ if (itemId) { var objValue = document.getElementById(itemId); if (typeof objValue != 'undefined'){ if (objValue) { returnVal = objValue; } } } } return returnVal; } function addEvent (objTarget, strType, objFunction) { if ( objTarget.addEventListener ) { objTarget.addEventListener(strType, objFunction, true); return true; } else if ( objTarget.attachEvent ) { var bResult = objTarget.attachEvent('on' + strType, objFunction); return bResult; } else { return false; } } Function.prototype.bind = function(object) { var __method = this; return function(event) { return __method.call(object, event || window.event); } } // rollup menu rollupMenu = function () {}; rollupMenu.prototype.makeLayer = function (eSource) { var objSource = eSource.srcElement ? eSource.srcElement : eSource.target; var objBox = null; if (typeof this.strRollLayerId != 'undefined'){ if (this.strRollLayerId) { objBox = getElements(this.strRollLayerId); } } if (typeof objBox != 'undefined'){ if (objBox) { if (objBox.style) { objBox.style.display = "inline"; } } } } rollupMenu.prototype.toggleDisplay = function (eSource) { var objSource = eSource.srcElement ? eSource.srcElement : eSource.target; var objBox = null; if (typeof this != 'undefined'){ if (this) { if (this.strRollLayerId){ objBox = getElements(this.strRollLayerId); } } } if (typeof objSource.id != 'undefined'){ if (objSource.id) { strSourceId = objSource.id; if (strSourceId.indexOf(this.strRollBtnId) < 0) { if (typeof objBox != 'undefined'){ if (objBox) { if (objBox.style) { objBox.style.display = "none"; } } } } } } } rollupMenu.prototype.toggleTrigger = function() { addEvent(getElements(this.strRollBtnId), 'click', this.makeLayer.bind(this)); addEvent(document.body, 'mouseover', this.toggleDisplay.bind(this)); } // tab switching tabMenu = function () {}; tabMenu.prototype.bringToFront = function (eSource) { var objSource = eSource.srcElement ? eSource.srcElement : eSource.target; strId = objSource.id; intOfString = strId.substring(strId.length-1,strId.length); intElements = countItems(strId.substring(0,strId.length-1)); for (var i=0; i < intElements; i++) { objWin = getElements(this.strWindowId + i); objTab = getElements(this.strTabId + i); if (objWin) { if (objWin.style) { if (i == parseInt(intOfString)) { objWin.className = this.strImageClassOn; objTab.className = this.strTabClassOn; } else { objWin.className = this.strImageClassOff; objTab.className = this.strTabClassOff; } } } } } tabMenu.prototype.toggleTrigger = function() { intElements = countItems(this.strTabId); for (i=0; i < intElements; i++) { addEvent(getElements(this.strTabId+i), 'click', this.bringToFront.bind(this)); } }