/*****************************************************
* JavaScript rounded corner technique from this web article:
* http://atomized.org/2005/03/rounded-corners-with-css-and-javascript/
* With some modifications to the CSS and JavaScript.
*****************************************************/

/**
 * RoundBox support
 *
 * @copyright   (c) 2005 WebSprockets, LLC
 * @author      Ian Eure
 * @license     LGPL
 */
	
/**
 * Initialize a RoundBox
 *
 * @param   HTMLElement  box RoundBox element to initialize
 * @return  void
 */
function initBox(box)
{
	var tl = document.createElement('div');
	tl.className = 'corner';
	var tr = document.createElement('div');
	tr.className = 'corner';
	var bl = document.createElement('div');
	bl.className = 'corner';
	var br = document.createElement('div');
	br.className = 'corner';

	/* Roben's addition
	Big hack, this is a easy-to-write but woe-fully-inefficient solution to the difficult 
	of make new nodes in the DOM inside of a tag, but *outside of that tags content* 
	(this is where the cleaner solution of using appendChild doesn't work).
	*/
	br.innerHTML = box.innerHTML;
	box.innerHTML = "";


	box.appendChild(tl);
	tl.appendChild(tr);
	tr.appendChild(bl);
	bl.appendChild(br);


}
	
/**
 * Initialize all boxes on a page
 *
 * This initializes any div with a class of 'roundbox'
 *
 * @return  void
 */
function initBoxes()
{
    var boxen = document.getElementsByTagName('div');
    for (var i = 0; i < boxen.length; i++) {
        if (boxen[i].className == 'rounded') {
            initBox(boxen[i]);
        }
    }
}

initBoxes();
// window.onload = initBoxes;