
function roundedCorners(type) {
	// Get all the div tags
	var divs = document.getElementsByTagName('div');
	// A list of all the tags that will be added in.  The prefix will be added to create a class name (ie ContentBorderTL)
	// (The last one is a child of the previous, etc)
	var classSuffix = ["BorderTL", "BorderTR", "BorderBL", "BorderBR", "BorderL", "BorderR", "BorderContent"];
	for (var i = 0; i < divs.length; i++) {
		// Should this div be curved? If it starts with it, yes
		if (divs[i].className.substring(0, 6) == "curved") {
			var name = divs[i].className.substring(6, divs[i].className.length);
			var classes = new Array();
			for (var j = 0; j < classSuffix.length; j++) {
				classes[j] = name + classSuffix[j];
			}
			transform(divs[i], classes);
		}
	}
}

// Sets some stuff up so we can replace the nodes
function transform(original, classNames) {
	// Rename the text using the last element
	original.className = classNames.pop();
	
	// The parent of the content
	var parent = original.parentNode;
	
	// Build a new branch off the parent
	createTag(parent, classNames, original);
}

// Build the tag off oldTag, and name it according to tagNames
function createTag(oldTag, tagNames, finale) {
	// Create the tag
	var tag = document.createElement('div');
	// Get the last name from the array
	var name = tagNames.shift();
	// Apply the name, then append to it parent
	tag.className = name;
	oldTag.appendChild(tag);
	
	// If that's it, add on the finale and start going back
	if (tagNames.length == 0) {
		tag.appendChild(finale);
		return;
	} else {
	// else do some more then return yourself as the root of this branch
		createTag(tag, tagNames, finale);
		return;
	}
}

window.onload = roundedCorners;