/** Transparent custom corners and borders from:
    http://www.456bereastreet.com/archive/200505/transparent_custom_corners_and_borders/
**/

/*
addEvent function found at http://www.scottandrew.com/weblog/articles/cbs-events
*/
function addEvent(obj, evType, fn) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, true);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+evType, fn); 
		return r;
	} else {
		return false;
	}
}

/*
createElement function found at http://simon.incutio.com/archive/2003/06/15/javascriptWithXML
*/
function createElement(element) {
	if (typeof document.createElementNS != 'undefined') {
		return document.createElementNS('http://www.w3.org/1999/xhtml', element);
	}
	if (typeof document.createElement != 'undefined') {
		return document.createElement(element);
	}
	return false;
}

function insertTop(obj) {
	// Create the two div elements needed for the top of the box
	d=createElement("div");
	d.className="bt"; // The outer div needs a class name
    d2=createElement("div");
    d.appendChild(d2);
	obj.insertBefore(d,obj.firstChild);
}

function insertBottom(obj) {
	// Create the two div elements needed for the bottom of the box
	d=createElement("div");
	d.className="bb"; // The outer div needs a class name
    d2=createElement("div");
    d.appendChild(d2);
	obj.appendChild(d);
}

function initCB()
{
	var thediv = document.getElementById("box");
// 	Create a new div, give it the original div's class attribute, and replace 'cbb' with 'cb'
	var outer = createElement('div');
	outer.className = thediv.className;
	outer.className = thediv.className.replace('cbb', 'cb');
// Create 
	thediv.className = 'i2';
	thediv.parentNode.replaceChild(outer, thediv);
	var i1 = createElement('div');
	i1.className = 'i1';
	outer.appendChild(i1);
	i1.appendChild(thediv);
	insertTop(outer);
	insertBottom(outer);
}

if(document.getElementById && document.createTextNode)
{
	addEvent(window, 'load', initCB);
}
