
window.onload = roundedCorners;

function roundedCorners() {
  var divs = document.getElementsByTagName('h2');
  var rounded_divs = [];
 
  /* First locate all divs with 'side_menu_rounded_title' in their class attribute */
  for (var i = 0; i < divs.length; i++) {
    if (divs[i].className == "side_menu_rounded_title") {
      rounded_divs[rounded_divs.length] = divs[i];
    }
  }
 
  /* Now add additional divs to each of the divs we have found */
  for (var i = 0; i < rounded_divs.length; i++) {
    var original = rounded_divs[i];
    var originalText;
    
    /* Get the text value of the original header */
    for (var x = 0; x < original.childNodes.length; x++) {
      if (original.childNodes[x].nodeType == '3') {
        originalText = original.childNodes[x].nodeValue;
      }
    }
    
    
    /* Now create the outer-most div */
    var tr = document.createElement('div');
    tr.className = 'rounded2';
   
    /* Swap out the original (we'll put it back later) */
    original.parentNode.replaceChild(tr, original);
   
    /* Create the two other inner nodes */
    var tl = document.createElement('div');
    var br = document.createElement('div');
    var newDiv = document.createElement('div');

    var textNode = document.createTextNode(originalText);
    newDiv.appendChild(textNode);
   
    /* Now glue the nodes back in to the document */
    tr.appendChild(tl);
    tl.appendChild(br);
    br.appendChild(newDiv);
    //br.appendChild(original); 
  }
}