/*
- classes object stores all the class names you want to apply corners to
- assign an array of extensions to add to the base class name
- these will be inserted inside the base element wrapping from the inside to the outside
- ie. the outermost div will the last one created from the array
*/

var classes = new Object();
classes.rounded = ['br', 'bl', 'tr', 'tl', 'r', 'l', 'b', 't'];
 
/* without firstLoad, returning to the page would result in repeated and unecessary multiple cornering */
var firstLoad = false;
function setCorners()
{
	if (firstLoad) { return; }
	firstLoad = true;
	for (i=0;i<document.getElementsByTagName("div").length; i++)
	{
		var className = document.getElementsByTagName("div").item(i).className;
		if (classes[className]) {
			var inner = document.getElementsByTagName("div").item(i).innerHTML;
			var classArray = classes[className];

			for (var j in classArray)
			{
			        inner = divWrap(inner, className + '-' + classArray[j]);
			}
			document.getElementsByTagName("div").item(i).innerHTML = inner;
		}
	}
}
 
function divWrap(value, className)
{
	return '<div class="' + className + '">' + value + '</div>';
}
 
window.onload = setCorners;

