
CorneredBoxes = {
	toCornerClass : "BoxSuround",
	CornerDoneClass: "completed",
	ContentClass: "BoxContent",
	HeaderClass: "BoxHeader",
	FooterClass: "BoxFooter",
	initialize : function()
	{
		var arrElms = document.getElementsByClassName(this.toCornerClass);
		var tmpArr = [];
		
		var header = undefined;
		var footer = undefined;
		var content = undefined;
		var elm = undefined;
		for ( var i = 0; i <  arrElms.length; i++)
		{
			elm = arrElms[i];
			
			if (! Element.hasClassName(elm, this.CornerDoneClass))
			{
				var tmpArr = [];
				
				var header = undefined;
				var footer = undefined;
				var content = undefined;
				
				tmpArr = elm.getElementsByClassName(this.HeaderClass);
				if ( tmpArr.length > 0)
					header = tmpArr[0];
				
				tmpArr = elm.getElementsByClassName(this.FooterClass);
				if ( tmpArr.length > 0)
					footer= tmpArr[0];
				
				
				var tmpTable = document.createElement("table");
				var tmpElm = document.createElement("tbody");
				var tmpTR = document.createElement("tr");
				var tmpTD = document.createElement("td");
				var tmpContent = {};
				tmpTable.cellPadding = 0;
				tmpTable.cellSpacing = 0;
				
				Element.addClassName(tmpTD, "topLeft");
				tmpTR.appendChild(tmpTD);
				
				tmpTD = document.createElement("td");
				Element.addClassName(tmpTD, "top");
				if ( header )
				{
					tmpTD.appendChild(header);
				}
				
				tmpTR.appendChild(tmpTD);					
				tmpTD = document.createElement("td");
				Element.addClassName(tmpTD, "topRight");
				tmpTR.appendChild(tmpTD);
				tmpElm.appendChild(tmpTR);
				
				tmpTR = document.createElement("tr");
				tmpTD = document.createElement("td");
				Element.addClassName(tmpTD, "left");
				tmpTR.appendChild(tmpTD);
				tmpTD = document.createElement("td");
				Element.addClassName(tmpTD, "content");
				tmpContent = tmpTD;
				tmpTR.appendChild(tmpTD);					
				tmpTD = document.createElement("td");
				Element.addClassName(tmpTD, "right");
				tmpTR.appendChild(tmpTD);
				tmpElm.appendChild(tmpTR);
				
				tmpTR = document.createElement("tr");
				tmpTD = document.createElement("td");
				Element.addClassName(tmpTD, "bottomLeft");
				tmpTR.appendChild(tmpTD);
				tmpTD = document.createElement("td");
				Element.addClassName(tmpTD, "bottom");
				if ( footer )
				{
					tmpTD.appendChild(footer);
				}
				tmpTR.appendChild(tmpTD);					
				tmpTD = document.createElement("td");
				Element.addClassName(tmpTD, "bottomRight");
				tmpTR.appendChild(tmpTD);
				tmpElm.appendChild(tmpTR);
				
				tmpTable.appendChild(tmpElm);
				Element.insert(elm,  {
					before: tmpTable
				});	
				//Element.addClassName(tmpElm, this.roundedCornerLeftClass);
				
				
				tmpContent.appendChild(elm);
				Element.addClassName(elm, this.CornerDoneClass);
				var type = elm.getAttribute("type");				
				if ( type != "" && type)
					Element.addClassName(tmpTable, type)
			}
		}
	}
	
}

Event.observe(window, "load", CorneredBoxes.initialize.bindAsEventListener(CorneredBoxes));
