Chris@76: // The purpose of this code is to fix the height of overflow: auto blocks, because some browsers can't figure it out for themselves. Chris@76: function smf_codeBoxFix() Chris@76: { Chris@76: var codeFix = document.getElementsByTagName('code'); Chris@76: for (var i = codeFix.length - 1; i >= 0; i--) Chris@76: { Chris@76: if (is_webkit && codeFix[i].offsetHeight < 20) Chris@76: codeFix[i].style.height = (codeFix[i].offsetHeight + 20) + 'px'; Chris@76: Chris@76: else if (is_ff && (codeFix[i].scrollWidth > codeFix[i].clientWidth || codeFix[i].clientWidth == 0)) Chris@76: codeFix[i].style.overflow = 'scroll'; Chris@76: Chris@76: else if ('currentStyle' in codeFix[i] && codeFix[i].currentStyle.overflow == 'auto' && (codeFix[i].currentStyle.height == '' || codeFix[i].currentStyle.height == 'auto') && (codeFix[i].scrollWidth > codeFix[i].clientWidth || codeFix[i].clientWidth == 0) && (codeFix[i].offsetHeight != 0)) Chris@76: codeFix[i].style.height = (codeFix[i].offsetHeight + 24) + 'px'; Chris@76: } Chris@76: } Chris@76: Chris@76: // Add a fix for code stuff? Chris@76: if ((is_ie && !is_ie4) || is_webkit || is_ff) Chris@76: addLoadEvent(smf_codeBoxFix); Chris@76: Chris@76: // Toggles the element height and width styles of an image. Chris@76: function smc_toggleImageDimensions() Chris@76: { Chris@76: var oImages = document.getElementsByTagName('IMG'); Chris@76: for (oImage in oImages) Chris@76: { Chris@76: // Not a resized image? Skip it. Chris@76: if (oImages[oImage].className == undefined || oImages[oImage].className.indexOf('bbc_img resized') == -1) Chris@76: continue; Chris@76: Chris@76: oImages[oImage].style.cursor = 'pointer'; Chris@76: oImages[oImage].onclick = function() { Chris@76: this.style.width = this.style.height = this.style.width == 'auto' ? null : 'auto'; Chris@76: }; Chris@76: } Chris@76: } Chris@76: Chris@76: // Add a load event for the function above. Chris@76: addLoadEvent(smc_toggleImageDimensions); Chris@76: Chris@76: // Adds a button to a certain button strip. Chris@76: function smf_addButton(sButtonStripId, bUseImage, oOptions) Chris@76: { Chris@76: var oButtonStrip = document.getElementById(sButtonStripId); Chris@76: var aItems = oButtonStrip.getElementsByTagName('span'); Chris@76: Chris@76: // Remove the 'last' class from the last item. Chris@76: if (aItems.length > 0) Chris@76: { Chris@76: var oLastSpan = aItems[aItems.length - 1]; Chris@76: oLastSpan.className = oLastSpan.className.replace(/\s*last/, 'position_holder'); Chris@76: } Chris@76: Chris@76: // Add the button. Chris@76: var oButtonStripList = oButtonStrip.getElementsByTagName('ul')[0]; Chris@76: var oNewButton = document.createElement('li'); Chris@76: setInnerHTML(oNewButton, '' + oOptions.sText + ''); Chris@76: Chris@76: oButtonStripList.appendChild(oNewButton); Chris@76: } Chris@76: Chris@76: // Adds hover events to list items. Used for a versions of IE that don't support this by default. Chris@76: var smf_addListItemHoverEvents = function() Chris@76: { Chris@76: var cssRule, newSelector; Chris@76: Chris@76: // Add a rule for the list item hover event to every stylesheet. Chris@76: for (var iStyleSheet = 0; iStyleSheet < document.styleSheets.length; iStyleSheet ++) Chris@76: for (var iRule = 0; iRule < document.styleSheets[iStyleSheet].rules.length; iRule ++) Chris@76: { Chris@76: oCssRule = document.styleSheets[iStyleSheet].rules[iRule]; Chris@76: if (oCssRule.selectorText.indexOf('LI:hover') != -1) Chris@76: { Chris@76: sNewSelector = oCssRule.selectorText.replace(/LI:hover/gi, 'LI.iehover'); Chris@76: document.styleSheets[iStyleSheet].addRule(sNewSelector, oCssRule.style.cssText); Chris@76: } Chris@76: } Chris@76: Chris@76: // Now add handling for these hover events. Chris@76: var oListItems = document.getElementsByTagName('LI'); Chris@76: for (oListItem in oListItems) Chris@76: { Chris@76: oListItems[oListItem].onmouseover = function() { Chris@76: this.className += ' iehover'; Chris@76: }; Chris@76: Chris@76: oListItems[oListItem].onmouseout = function() { Chris@76: this.className = this.className.replace(new RegExp(' iehover\\b'), ''); Chris@76: }; Chris@76: } Chris@76: } Chris@76: Chris@76: // Add hover events to list items if the browser requires it. Chris@76: if (is_ie7down && 'attachEvent' in window) Chris@76: window.attachEvent('onload', smf_addListItemHoverEvents);