var RoundedBox = { makeRoundedBox: function(element) { var className = element.className.split(" ")[0]; // Create the innermost slice and re-locate the element's nodes to it var inner = document.createElement("div"); inner.className = className + "Inner"; while (element.firstChild) inner.appendChild(element.firstChild); var inner1 = this.createNestedBoxes(className + "Inner"); inner1.firstChild.appendChild(inner); var topBox = this.createNestedBoxes(className + "Top"); var bottomBox = this.createNestedBoxes(className + "Bottom"); element.appendChild(topBox); element.appendChild(inner1); element.appendChild(bottomBox); }, make9GridBox: function(element) { // Create the center slice and re-locate the element's nodes to it var slice = document.createElement("div"); slice.className = element.className + "Center"; while (element.firstChild) slice.appendChild(element.firstChild); element.appendChild(slice); var names = ["TopLeft", "TopRight", "BottomLeft", "BottomRight", "Top", "Left", "Bottom", "Right"]; for (var i in names) { var slice = document.createElement("div"); slice.className = element.className + names[i]; element.appendChild(slice); } }, createNestedBoxes: function(className) { var box1 = document.createElement("div"); box1.className = className + "1"; var box2 = document.createElement("div"); box2.className = className + "2"; box1.appendChild(box2); return box1; } };