function addEvent( obj, type, fn )
{
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

/*
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, color) {
	// Create the two div elements needed for the top of the box
	d=createElement("div");
	d.className="top_" + color; // The outer div needs a class name
    d2=createElement("div");
    d.appendChild(d2);
	obj.insertBefore(d,obj.firstChild);
}

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

function initCB()
{
	// Find all div elements
	var divs = document.getElementsByTagName('div');
	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 (/\bcontent_grey\b/.test(divs[i].className)) {
			divs[i].color = 'grey';
			cbDivs[cbDivs.length] = divs[i];
		} else if (/\bcontent_white\b/.test(divs[i].className)) {
			divs[i].color = 'white';
			cbDivs[cbDivs.length] = divs[i];
		} else if (/\bcontent_container\b/.test(divs[i].className)) {
			divs[i].color = 'container';
			cbDivs[cbDivs.length] = divs[i];
		}
		
	}
	// Loop through the found div elements
	var thediv, outer, lborder, rborder;
	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('cbb', 'all');
	// Change the original div's class name and replace it with the new div
		thediv.className = 'content_wrapper_' + cbDivs[i].color;
		thediv.parentNode.replaceChild(outer, thediv);
	// Create two new div elements and insert them into the outermost div
		lborder = createElement('div');
		lborder.className = 'lborder_' + cbDivs[i].color;
		outer.appendChild(lborder);
		rborder = createElement('div');
		rborder.className = 'rborder_' + cbDivs[i].color;
		lborder.appendChild(rborder);
	// Insert the original div
		rborder.appendChild(thediv);
	// Insert the top and bottom divs
		insertTop(outer, cbDivs[i].color);
		insertBottom(outer, cbDivs[i].color);
	}
}

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

function show(name) {
	var elem = document.getElementById(name);
	elem.style.display = ((elem.style.display=='none') || (elem.style.display=='')) ? 'block' : 'none';
	return true;
}

function ChangeService(main_div, new_page)
	{
		var main_div = document.getElementById(main_div);
		var child_divs = main_div.getElementsByTagName('div');
		for (i = 0; i <= child_divs.length; i++)
		{
			if (document.getElementById('services_'+i))
			{
				document.getElementById('services_'+i).style.display = 'none';
			}
		}
		var show_div = document.getElementById('services_'+new_page);
		show_div.style.display = 'Block';
	}

