// Copyright © 2008-2010 Visual Devise 2009. All rights reserved.
var round = {
	init : function() {
	// Check that the browser supports the DOM methods used
		if (!document.getElementById || !document.createElement || !document.appendChild) return false;
		var oElement, oOuter, oI1, oI2, tempId;
	// Find all elements with a class name of round
		var arrElements = document.getElementsByTagName('*');
		var oRegExp = new RegExp("(^|\\s)round(\\s|$)");
		for (var i=0; i<arrElements.length; i++) {
	// Save the original outer element for later
			oElement = arrElements[i];
			if (oRegExp.test(oElement.className)) {
	// 	Create a new element and give it the original element's class name(s) while replacing 'round' with 'rounded'
				oOuter = document.createElement('div');
				oOuter.className = oElement.className.replace(oRegExp, '$1rounded$2');
	// Give the new div the original element's id if it has one
				if (oElement.getAttribute("id")) {
					tempId = oElement.id;
					oElement.removeAttribute('id');
					oOuter.setAttribute('id', '');
					oOuter.id = tempId;
				}
	// Change the original element's class name and replace it with the new div
				oElement.className = 'mb';
				oElement.parentNode.replaceChild(oOuter, oElement);
	// Create two new div elements and insert them into the outermost div
				//oI1 = document.createElement('div');
				//oI1.className = 'i1';//
				//oOuter.appendChild(oI1);
				//oI2 = document.createElement('div');
				//oI2.className = 'i2';//
				//oI1.appendChild(oI2);
	// Insert the original element
				//oI2.appendChild(oElement);
				oOuter.appendChild(oElement); //added
	// Insert the top and bottom divs
				round.insertTop(oOuter);
				round.insertBottom(oOuter);
			}
		}
	},
	insertTop : function(obj) {
		var oOuter, oInner, oInner2; //added oInner2
	// Create the two div elements needed for the top of the box
		oOuter=document.createElement("div");//need
		oOuter.className="tb"; // The outer div needs a class name //need
	    oInner=document.createElement("div");
		oInner2=document.createElement("div");	//added	
		oInner.appendChild(oInner2); //added
	    oOuter.appendChild(oInner);
	    //oOuter.appendChild(oInner);
		obj.insertBefore(oOuter,obj.firstChild);
	},
	insertBottom : function(obj) {
		var oOuter, oInner, oInner2; //added oInner2
	// Create the two div elements needed for the bottom of the box
		oOuter=document.createElement("div"); //need
		oOuter.className="bb"; // The outer div needs a class name //need
	    oInner=document.createElement("div"); //added
		oInner2=document.createElement("div"); //added
		oInner.appendChild(oInner2); //added
	    oOuter.appendChild(oInner);
		obj.appendChild(oOuter);
	},
	// addEvent function
	addEvent : function(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]);
		}
	}
};

round.addEvent(window, 'load', round.init);