// helper script for candy coloured tables
// allows multiple functions attached to the window.onload event
if ( typeof( addLoadEvent ) == "undefined" ) {
	function addLoadEvent(f) { var old = window.onload; if (typeof window.onload != 'function') { window.onload = f; } else { window.onload = function() { old(); f();} } }
}

addLoadEvent( fInitCandyColouredTables );

function fInitCandyColouredTables() {
	var oTables = document.getElementsByTagName("table");
	var oTable, i = 0;
	
	while ( oTable = oTables[ i++ ] ) {
		if ( oTable.className.indexOf( "candyColoured" ) != -1 ) {
			new cCandyTable( oTable );
		}
	}
}

function cCandyTable( oTable ) {
	if ( !oTable ) {return;}
	var oParent = oTable.parentNode;
	if ( oParent.tagName.toLowerCase() == "div" && oParent.className == "candyContent" ) {
		var oTopLeft = document.createElement("div");
		oTopLeft.className = "tl";
		oParent.appendChild( oTopLeft );
		var oTopRight = document.createElement("div");
		oTopRight.className = "tr";
		oParent.appendChild( oTopRight );
		var oBottomLeft = document.createElement("div");
		oBottomLeft.className = "bl";
		oParent.appendChild( oBottomLeft );
		var oBottomRight = document.createElement("div");
		oBottomRight.className = "br";
		oParent.appendChild( oBottomRight );
	}
}

