// === Rounded Corners ================================================================================================ /* The following adds several additional divs to any element labeled with the class "rounded" This allows us to add rounded corners to the site without lots of extraneous markup in the content/XHTML for each corner image This will work on all modern browsers, and will degrade to a simple square box on older browsers or people with js disabled. */ function applyRoundedCorners() { roundedCorners('box-effect'); roundedCorners('header-effect'); } function clearInnerHTML(obj) { // so long as obj has children, remove them while(obj.firstChild) obj.removeChild(obj.firstChild); } function roundedCorners(theClassName) { var arrRoundedElements = getElementsByClassName(document, 'div', theClassName); //place all instances of the rounded class into an array for (var i = 0; i < arrRoundedElements.length; i++) { //loop through array from above var original = arrRoundedElements[i]; var cornerClasses = ['rounded-content','rounded-top','rounded-right', 'rounded-left','rounded-topLeft','rounded-topRight','rounded-bottom','rounded-bottomRight','rounded-bottomLeft']; //class names of all the divs we're attaching var totalDivs = cornerClasses.length - 1; if (theClassName == 'header-effect'){ totalDivs = totalDivs - 3; //if this is a 'tab' leave off the last 3 divs (creates a square bottom of box) } //NOTE: myDiv* is a dynamically created varible, which is why it's needs to be a property of the window object window["myDiv0"] = document.createElement('div'); //create outer div window["myDiv0"].className = original.className.replace(theClassName, 'rounded-js'); //rename the original class to rounded-js, still carrying over all the other class names original.parentNode.replaceChild(window["myDiv0"], original); // swap out the original content with our new outer most div original.className = cornerClasses[0]; //change the name of the original classname to whats assigned to 0, aka rounded-content from cornerClasses //create nodes var currentNode = 0; //node we are currently working with, starts with the one we created above for (var j = 1; j <= totalDivs; j++) { window["myDiv" + j] = document.createElement('div'); //generate div and assign it to a variable named myDiv# window["myDiv" + j].className = cornerClasses[j]; //give that a class name window["myDiv" + currentNode].appendChild(window["myDiv" + j]); //append new div to currentNode currentNode++; } window["myDiv" + totalDivs].appendChild(original); //finally, insert the original content into the last div we created } } // === Global Functions =============================================================================================== //retreives all classes with a certain name and places them in an array: function getElementsByClassName(oElm, strTagName, strClassName) { if(!oElm.getElementsByTagName) {return false; } //check for exisitence of getElementsByTagName var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName); var arrReturnElements = new Array(); strClassName = strClassName.replace(/\-/g, "\\-"); var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)"); var oElement; for(var i=0; i