function roundCorners()
{
    var divs = document.getElementsByTagName('div');
    var boxen = [];
    for (var i=0; i<divs.length; i++) {
        if (/\brounded\b/.exec(divs[i].className)) {
	    boxen[boxen.length] = divs[i];
	}
    }

    for (i=0; i<boxen.length; i++) {
        boxParent = boxen[i].parentNode;

        // create the container
	roundedBox =
	boxParent.insertBefore(document.createElement("div"), boxen[i]);
	roundedBox.className = boxen[i].className;

	// create the box header
	boxTop =
	roundedBox.appendChild(document.createElement("div"));
	boxTop.className = 'box-top';

	// create a stub box content
	boxContent =
	roundedBox.appendChild(document.createElement("div"));
	boxContent.className = 'box-content';

	// replace the stub box content with the proper div
        roundedBox.replaceChild(boxen[i], boxContent);
	    
	// create the box footer
	boxBottom =
	roundedBox.appendChild(document.createElement("div"));
	boxBottom.className = 'box-bottom';

	// the original .rounded is now .box-content
        boxen[i].className = 'box-content';
	roundedBox.id = boxen[i].id;
	boxen[i].id = "";
    }
}

addLoadEvent(roundCorners);



