/*
addEvent function found at http://www.scottandrew.com/weblog/articles/cbs-events
*/
function addEvent(obj, evType, fn) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, true);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}

/*
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) {
	// Create the div elements needed for the top of the box
	d=createElement("div");
	d.className="trcorner"; // The outer div needs a class name
	obj.insertBefore(d,obj.firstChild);
}

function insertBottom(obj) {
	// Create the div elements needed for the bottom of the box
	d=createElement("div");
	d.className="blcorner"; // The outer div needs a class name
	obj.appendChild(d);
}

function initCB()
{
	// Find all div elements
	var divs = document.getElementsByTagName('div');
	var cbDivs = [];
	for (var i = 0; i < divs.length; i++) {
	// Find all div elements with fancybox in their class attribute while allowing for multiple class names
		if (/\bfancybox\b/.test(divs[i].className))
			cbDivs[cbDivs.length] = divs[i];
	}
	// Loop through the found div elements
	var thediv;
	for (var i = 0; i < cbDivs.length; i++) {
		thediv = cbDivs[i];
		insertTop(thediv);
		insertBottom(thediv);
	}
}

if(document.getElementById && document.createTextNode)
{
	addEvent(window, 'load', initCB);
}
// JavaScript Document
