/*
createElement function found at http://simon.incutio.com/archive/2003/06/15/javascriptWithXML
*/
function createElement(element)
{
	if (typeof document.createElementNS != 'undefined')
	{
		return document.createElementNS('http://www.w3.org/1999/xhtml', element);
	}
	if (typeof document.createElement != 'undefined')
	{
		return document.createElement(element);
	}
	return false;
}

function insertTop(obj, findDiv)
{
	// Create the two div elements needed for the top of the box
	d=createElement("div");
	if (browser.versionMinor=="6") d.className=String(findDiv+"bt2");
   else d.className=String(findDiv+"bt"); // The outer div needs a class name
   d2=createElement("div");
   d.appendChild(d2);
	obj.insertBefore(d,obj.firstChild);
}

function insertBottom(obj, findDiv)
{
	// Create the two div elements needed for the bottom of the box
	d=createElement("div");
	if (browser.versionMinor=="6") d.className=String(findDiv+"bb2");
   else d.className=String(findDiv+"bb"); // The outer div needs a class name
   d2=createElement("div");
   d.appendChild(d2);
	obj.appendChild(d);
}

function initCB(findDiv)
{
   if (findDiv == "") return;

	// Find all div elements
	var divs=document.getElementsByTagName('div');
	var cbDivs=[];
	var theDiv=new RegExp(findDiv, "");
	for (var i=0; i<divs.length; i++)
	{
	   // Find all div elements with cbb in their class attribute while allowing for multiple class names
		if (theDiv.test(divs[i].className))
		{
			cbDivs[cbDivs.length]=divs[i];
		}
	}
	// Loop through the found div elements
	var thediv, outer, i1, i2;

	for (var i=0; i<cbDivs.length; i++)
	{
	   // Save the original outer div for later
		thediv=cbDivs[i];
	   // Create a new div, give it the original div's class attribute, and replace 'cbb' with 'cb'
		outer=createElement('div');
		outer.className=thediv.className;
		outer.className=thediv.className.replace(theDiv, String(findDiv+'cb'));
	   // Change the original div's class name and replace it with the new div
		if (browser.versionMinor=="6") thediv.className=String(findDiv+'i32');
	   else thediv.className=String(findDiv+'i3');
		thediv.parentNode.replaceChild(outer, thediv);
	   // Create two new div elements and insert them into the outermost div
		i1 = createElement('div');
		if (browser.versionMinor=="6") i1.className=String(findDiv+'i12');
	   else i1.className=String(findDiv+'i1');
		outer.appendChild(i1);
		i2 = createElement('div');
		if (browser.versionMinor=="6") i2.className=String(findDiv+'i22');
		else i2.className=String(findDiv+'i2');
		i1.appendChild(i2);
	   // Insert the original div
		i2.appendChild(thediv);
	   // Insert the top and bottom divs
		insertTop(outer, findDiv);
		insertBottom(outer, findDiv);

      //This fixes problems with adding a margin orb
      outer.style.marginLeft   = thediv.style.marginLeft;
      outer.style.marginRight  = thediv.style.marginRight;
      outer.style.marginTop    = thediv.style.marginTop;
      outer.style.marginBottom = thediv.style.marginBottom;
      thediv.style.marginLeft   = "0px";
      thediv.style.marginRight  = "0px";
      thediv.style.marginTop    = "0px";
      thediv.style.marginBottom = "0px";

      //this fixes problems with padding-bottom in IE.
      i1.style.height = thediv.offsetHeight + "px";
	}
//alert(i1.childNodes.length);
}

function womOn() { window.onload=womGo; }
function womGo() { for(var i=0;i<woms.length;i++) eval(woms[i]); }
function womAdd(func) { woms[woms.length]=func; }
var woms=new Array();
