/* global event handlers =========================================================================== */ function xqbitsxMouseDown(e) { if (xqbitsxDropdownOpen) xqbitsxDD.mouseDownBody(e); if (xqbitsxOverlayMenuOpen) xqbitsxOverlayMouseDownBody(e); return true; } /* end global event handlers =========================================================================== */ /* styled overlay menus =========================================================================== */ var xqbitsxOverlayOpenId = ""; var xqbitsxOverlayClickedId = ""; var xqbitsxOverlayMenuOpen = false; // Map menu id's to button classes, for determining later on if the current menu // is one with non-default behavior. var xqbitsxOverlayClass = []; function xqbitsxInitOverlay() { document.body.onmousedown = xqbitsxMouseDown; // Overlay menus with default behavior xqbitsxAddOverlayEvents("xqbitsxOverlayLnk"); // Add code here for overlay menus with non-default behavior } function xqbitsxShowOverlay(menuId) { if ($(menuId)) { // If the menu is already open, close it if ($(menuId).style.display == "block") { $(menuId).style.display = "none"; } else { $(menuId).style.display = "block"; xqbitsxOverlayOpenId = menuId; xqbitsxOverlayMenuOpen = true; xqbitsxOverlayClickedId = ""; } } // Add code here for overlay menus with non-default behavior } function xqbitsxHideOverlay(menuId) { if ($(menuId)) { $(menuId).style.display = "none"; xqbitsxOverlayOpenId = ''; xqbitsxOverlayMenuOpen = false; } // Add code here for overlay menus with non-default behavior } function xqbitsxGetOverlayMenuId(btn) { // Get the id parameter from href="javascript:foo('myId')" return btn.href.substring(btn.href.indexOf("'") + 1, btn.href.lastIndexOf("'")); } function xqbitsxAddOverlayEvents(btnClass) { var btnArray = document.getElementsByClassName(btnClass); for (var i = 0; i < btnArray.length; i++) { // button var btn = btnArray[i]; btn.onmousedown = xqbitsxOverlayMouseDownBtn; // menu var menuId = xqbitsxGetOverlayMenuId(btn); if ($(menuId)) { $(menuId).onmousedown = xqbitsxOverlayMouseDownMenu; } // Store the button class associated with the menu id xqbitsxOverlayClass[menuId] = btnClass; // Mac Safari image-rollover bug if ((navigator.userAgent.indexOf("Safari") != -1) && (navigator.userAgent.indexOf("Mac") != -1)) { // If xqbitsxImgSwap() is called by the onmouseout event if (btn.onmouseout.toString().indexOf("xqbitsxImgSwap") != -1) { // Make onclick call the onmouseout event handler btn.onclick = function onclick() { this.onmouseout(); return true; }; } } } } function xqbitsxOverlayMouseDownBtn(e) { // Get the menu id var menuId = xqbitsxGetOverlayMenuId(this); xqbitsxOverlayClickedId = menuId; return true; } function xqbitsxOverlayMouseDownMenu(e) { // Get the menu id xqbitsxOverlayClickedId = this.id; return true; } function xqbitsxOverlayMouseDownBody(e) { // Close the open overlay menu, unless the mouse is inside the menu // or the menu button. if (xqbitsxOverlayOpenId != xqbitsxOverlayClickedId) { xqbitsxHideOverlay(xqbitsxOverlayOpenId); } xqbitsxOverlayClickedId = ""; return true; } /* end styled overlay menus =========================================================================== */ /* styled dropdowns =========================================================================== */ var xqbitsxDropdownOpen = false; // xqbitsx dropdown menu (JavaScript object literal) var xqbitsxDD = { curId: "", // id of currently-open dropdown ignoreMouseDownBody: false, menus: [], rowHeight: 17, combinedBorderWidth: 20, scrollbarWidth: 18, minMenuWidth: 105, maxMenuWidth: 700, defaultMenuWidth: 205, defaultRowWidth: 150, combinedRowLRPad: 18, scrollbarRPad: 12, buildDisabledDropdown: function(menuId, buttonWidth, buttonClass, hiddenListSuffix) { // default parameters if (!buttonWidth) buttonWidth = 140; if (!buttonClass) buttonClass = 'xqbitsxDDWireLtg'; var wrapId = menuId + "_wrap"; var listId = menuId + "_list" + (hiddenListSuffix ? '_' + hiddenListSuffix : ''); if ($(wrapId) && $(listId)) { // hide the $(listId).style.display = "none"; var displayedValue = new Array(); var internalValue = new Array(); var disabledRow = new Array(); var listItems = $(listId).options; for (var i=0;i numVisibleRows) { visibleRowsHeight = numVisibleRows * this.rowHeight; rowWidth -= 10; } var leftBgStyle = 'background:#fff url() 0 0 no-repeat;'; var rightBgStyle = 'background:url() 100% 0 no-repeat;'; switch (buttonClass) { case 'xqbitsxDDWire': leftBgStyle = 'background:#fff url() 0 0 no-repeat;'; rightBgStyle = 'background:url() 100% 0 no-repeat;'; break; case 'xqbitsxBlkBgWhtBox': leftBgStyle = 'background:#fff url(http://www.qbits.ca/images/buttonbbl1.gif) 0 0 no-repeat;'; rightBgStyle = 'background:url(http://www.qbits.ca/images/buttonbbr1.gif) 100% 0 no-repeat;'; break; } // build content for the menu var strContent = "\n\n\n\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += ' '+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += ' '+"\n"; strContent += ' '+"\n"; strContent += ' '+"\n"; strContent += ' '+"\n"; strContent += ' '+"\n"; strContent += ' '+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+buttonText+'
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n\n"; strContent += '
'+"\n\n"; strContent += '
'+"\n"; strContent += "\n\n"; // draw the new content $(wrapId).innerHTML = strContent; // capture mousedown document.body.onmousedown = xqbitsxMouseDown; }//else id of select not found [ abort ] }, buildOverlay: function(menuId, menuWidth, numVisibleRows, dx, dy) { // default parameters if (!menuWidth) menuWidth = this.defaultMenuWidth; if (!numVisibleRows) numVisibleRows = 10; if (menuWidth < this.minMenuWidth) menuWidth = this.minMenuWidth; if (menuWidth > this.maxMenuWidth) menuWidth = this.maxMenuWidth; var leftPos = -20; var topPos = 1; if (dx) leftPos += dx; if (dy) topPos += dy; var wrapId = menuId + "_wrap"; var listId = menuId + "_list"; var titleId = menuId + "_title"; if ($(wrapId) && $(titleId) && $(listId)) { // hide the list $(listId).style.display = "none"; var title = $(titleId).innerHTML; // Get the displayed value for each select option var listItems = $(listId).getElementsByTagName('li'); var displayedList = new Array(); for (var i=0;i numVisibleRows) { visibleRowsHeight = numVisibleRows * this.rowHeight; rowWidth -= 10; } // build content for the menu var strContent = "\n\n\n\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+title+'
'+"\n"; strContent += '
'+"\n"; strContent += '
    '+"\n"; for (var i=0;i'+"\n"; } strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += '
'+"\n"; strContent += "\n\n"; // draw the new content $(wrapId).innerHTML = strContent; // capture mousedown document.body.onmousedown = xqbitsxMouseDown; }//else id of select not found [ abort ] }, select: function(index, displayedValue, internalValue) { if ($(this.curId)) { var menuId = this.curId; // close the dropdown this.close(); // change the displayed dropdown value (button text) if ($(menuId + '_Val')) { $(menuId + '_Val').innerHTML = displayedValue; } // set the first row of the menu to the current value if ((this.menus[menuId].updateFirstRow) && $(menuId + '_hdnVal')) { $(menuId+'_hdnVal').innerHTML = '' + displayedValue + ''; } var listId = this.menus[menuId].listId; if ($(listId)) { // if the value has changed if ($(listId).selectedIndex != index) { // set the index of the selected option for the invisible