/* Copyright 2009-2010 Taco Software. All rights reserved.
 * http://tacosw.com
 *
 * This file is part of the Component Library included in Taco HTML Edit.
 * Licensed users of Taco HTML Edit may modify and use this source code 
 * for their web development (including commercial projects), as long as 
 * this copyright notice is retained.
 *
 * The contents of this file may not be published in a format intended
 * for access by other humans, so you may not put code examples on a
 * web site with all or part of the contents of this file, and you may
 * not publish the contents of this file in a printed format.
 */


function tswInsetDropShadowInit()
{
	var divs = document.getElementsByTagName('div');
	for(var i=0; i<divs.length; i++)
	{
		if(divs[i].className != null && 
		   divs[i].className.length >= 18 &&
		   divs[i].className.substr(0,18) == 'tswInsetDropShadow' &&
		   divs[i].className != 'tswInsetDropShadowContent')
		{
			tswInsetDropShadowInitDiv(divs[i]);
		}
	}
}

tswUtilsAddEventHandler(window, "load", tswInsetDropShadowInit);

/*Create a table that looks like this:
 
 <table class="tswInsetDropShadow">
 <tbody class="tswInsetDropShadowMedium">
 <tr class="tswInsetDropShadowTop">
 <td class="tswInsetDropShadowLeft"></td>
 <td class="tswInsetDropShadowCenter"></td>
 <td class="tswInsetDropShadowRight"></td>
 </tr>
 <tr class="tswInsetDropShadowMiddle">
 <td class="tswInsetDropShadowLeft"></td>
 <td class="tswInsetDropShadowCenter">
 <div class="tswInsetDropShadowMedium">
 </div>
 </td>
 <td class="tswInsetDropShadowRight"></td>
 </tr>
 <tr class="tswInsetDropShadowBottom">
 <td class="tswInsetDropShadowLeft"></td>
 <td class="tswInsetDropShadowCenter"></td>
 <td class="tswInsetDropShadowRight"></td>
 </tr>
 </tbody>
 </table>
 
 */

function tswInsetDropShadowInitDiv(div)
{
	var table = document.createElement('table');
	table.cellSpacing = 0;
	table.cellPadding = 0;
	table.border = 0;
	table.className = 'tswInsetDropShadow';
	table.id = div.id + '_table';
	
	var tBody = document.createElement('tbody');
	table.appendChild(tBody);
	
	table.tBodies[0].className = div.className;
	
	var row = table.tBodies[0].insertRow(-1);
	row.className = 'tswInsetDropShadowTop';
	tswInsetDropShadowCreateCells(row);
	
	var row = table.tBodies[0].insertRow(-1);
	row.className = 'tswInsetDropShadowMiddle';
	tswInsetDropShadowCreateCells(row);
	
	var row = table.tBodies[0].insertRow(-1);
	row.className = 'tswInsetDropShadowBottom';
	tswInsetDropShadowCreateCells(row);
	
	div.parentNode.insertBefore(table,div);
	table.tBodies[0].rows[1].cells[1].appendChild(div.parentNode.removeChild(div));
	div.className += ' tswInsetDropShadowContent';
}

function tswInsetDropShadowCreateCells(row)
{
	var cell = row.insertCell(-1);
	cell.className = 'tswInsetDropShadowLeft';
	cell = row.insertCell(-1);
	cell.className = 'tswInsetDropShadowCenter';
	cell = row.insertCell(-1);
	cell.className = 'tswInsetDropShadowRight';
}

/* The checksum below is for internal use by Taco HTML Edit, 
   to detect if a component file has been modified.
   TacoHTMLEditChecksum: A79B5827 */
