var RoundCorners = {
	init: function(selector, prefix) {
		function makeCornerDiv(corner) {
			return new Element('div', {'class': prefix+corner});
		}
		
		var aRoundCornerElements = document.getElementsBySelector(selector);
		if (!aRoundCornerElements) return;
		aRoundCornerElements.each(function() {
			var oDiv, oInnerDiv;
			var backgroundStyles = {
				'backgroundColor': $(this).getStyle('backgroundColor') || '',
				'backgroundImage': this.getStyle('backgroundImage') || '',
				'backgroundPosition': this.getStyle('backgroundPosition') || '',
				'backgroundAttachment': this.getStyle('backgroundAttachment') || '',
				'backgroundRepeat': this.getStyle('backgroundRepeat')
			};
			var oBgDiv = new Element('div').setStyle(backgroundStyles);
			this.setStyle({'background': 'transparent'});
			var corners = this.getAttribute('roundCorners').match(/\b[tb][lr]\b/ig).each(function() {
				var oNewDiv = makeCornerDiv(this);
				if (oDiv) { 
					oNewDiv.appendChild(oDiv); 
				}
				else {
					oInnerDiv = oNewDiv;
				}
				oDiv = oNewDiv;
			});
			oBgDiv.appendChild(oDiv);
			this.parentNode.insertBefore(oBgDiv, this);
			oInnerDiv.appendChild(this);
		});
	}
}
