if(typeof addEvent != 'function') function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener){
	 elm.addEventListener(evType, fn, useCapture);
	 return true;s
	} else if (elm.attachEvent){
	 var r = elm.attachEvent("on"+evType, fn);
	 return r;
	} else if("load" == evType && elm == window && fn != window.onload ) {
	 var oldonload = window.onload;
	   if (typeof window.onload != 'function') {
	     window.onload = fn;
	   } else {
	     window.onload = function() {
	       oldonload();
	       fn();
	     }
	   }  
	} else {
	    return false;
	 //alert("Handler could not be added");
	}
}

/*
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 initCB()
{
	// Find all div elements
	var divs = document.getElementsByTagName('*');
	var cbDivs = [];
	for (var i = 0; i < divs.length; i++) {
	// Find all div elements with cbb in their class attribute while allowing for multiple class names
		if (/\bcbb\b/.test(divs[i].className))
			cbDivs[cbDivs.length] = divs[i];
	}
	// Loop through the found div elements
	var thediv, outer, i1, i2;
	var oRegExp = new RegExp("(^|\\s)cbb(\\s|$)");
	for (var i = 0; i < cbDivs.length; i++) {
	// Save the original outer div for later
		thediv = cbDivs[i];
	// 	Create a new div, give it the original div's class attribute, and replace 'cbb' with 'cb'
		outer = createElement('div');
		outer.className = thediv.className;
		outer.className = thediv.className.replace(oRegExp, '$1cb$2');
		//outer.className = thediv.className.replace('cbb', 'cb');
	// Change the original div's class name and replace it with the new div
		thediv.className = '';
		if (thediv.getAttribute("id")) {
			tempId = thediv.id;
			thediv.setAttribute('id', tempId+"_inner");
			outer.setAttribute('id', '');
			outer.id = tempId;
		}		
		last = outer;
		//var classNames = ["tl", "t", "tr", "l", "r", "bl", "b", "br"];
		for(var j = 0;j<7;j++) {
			inner = createElement('div');
			inner.className = "cb"+j;
			last.appendChild(inner);
			last = inner;
		}
		thediv.parentNode.replaceChild(outer, thediv);
		last.appendChild(thediv);
	}
}

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