function parseDescendantsOfNodeAndAssignFunctionToEventOfClass(targetClassPassed, targetEventPassed, handlerFunctionPassed, rootId)
{
	var parseChildNodes = function(currentNode)
	{
		if ((typeof(currentNode) == "object") && (currentNode !== null) && (typeof(currentNode.childNodes) != "undefined"))
		{
			if(doesNodeContainClass(currentNode))
			{
				assignHandlerToEvent(currentNode);
			}
			
			var childCount = currentNode.childNodes.length;
			for (var i = 0 ; i < childCount ; i++)
			{
				parseChildNodes(currentNode.childNodes[i]);
			}
		}
	}
	
	var doesNodeContainClass = function(currentNode)
	{
		var containsClass = false;
		if ((typeof(currentNode.className) == "string") && (currentNode.className != ""))
		{
			var targetClassIndex = currentNode.className.toLowerCase().indexOf(targetClass);
			if (targetClassIndex > -1)
			{
				containsClass = true;
			}
		}
		return containsClass;
	}
	
	var assignHandlerToEvent = function(currentNode)
	{
		debug.line("AssignHandlerToEvent() : " + currentNode.id);
		var tempFunction = function()
		{
			return handlerFunction(currentNode);
		}	
				
		switch (targetEvent)
		{
			case "onblur":
				currentNode.onblur = tempFunction;
				break;
			case "onchange":
				currentNode.onchange = tempFunction;
				break;
			case "onclick":
				currentNode.onclick = tempFunction;
				break;
			case "ondblclick":
				currentNode.ondblclick = tempFunction;
				break;
			case "onfocus":
				currentNode.onfocus = tempFunction;
				break;
			case "onkeydown":
				currentNode.onkeydown = tempFunction;
				break;
			case "onkeypress":
				currentNode.onkeypress = tempFunction;
				break;
			case "onkeyup":
				currentNode.onkeyup = tempFunction;
				break;
			case "onload":
				currentNode.onload = tempFunction;
				break;
			case "onmousedown":
				currentNode.onmousedown = tempFunction;
				break;
			case "onmousemove":
				currentNode.onmousemove = tempFunction;
				break;
			case "onmouseout":
				currentNode.onmouseout = tempFunction;
				break;
			case "onmouseover":
				currentNode.onmouseover = tempFunction;
				break;
			case "onmouseup":
				currentNode.onmouseup = tempFunction;
				break;
			case "onreset":
				currentNode.onreset = tempFunction;
				break;
			case "onselect":
				currentNode.onselect = tempFunction;
				break;
			case "onsubmit":
				currentNode.onsubmit = tempFunction;
				break;
			case "onunload":	
				currentNode.onunload = tempFunction;
				break;
		}		
	}
	
	var targetClass = "";
	var targetEvent = "";
	var handlerFunction = null;
	
	if ((typeof(targetClassPassed) != "string") || (targetClassPassed == ""))
	{
		alert("targetClassPassed was not type string or was empty");
	}
	else if ((typeof(targetEventPassed) != "string") || (targetEventPassed == ""))
	{
		alert("targetEventPassed was not type string or was empty");
	}
	else if (typeof(handlerFunctionPassed) != "function")
	{
		alert("handlerFunctionPassed was not type function");
	}
	else
	{
		targetClass = targetClassPassed.toLowerCase();
		targetEvent = targetEventPassed.toLowerCase();
		handlerFunction = handlerFunctionPassed;
		
		var eventIsValid = false;
		switch (targetEvent)
		{
			case "onblur":
			case "onchange":
			case "onclick":
			case "ondblclick":
			case "onfocus":
			case "onkeydown":
			case "onkeypress":
			case "onkeyup":
			case "onload":
			case "onmousedown":
			case "onmousemove":
			case "onmouseout":
			case "onmouseover":
			case "onmouseup":
			case "onreset":
			case "onselect":
			case "onsubmit":
			case "unload":
				eventIsValid = true;
				break;	
		}
		
		if (eventIsValid)
		{
			var rootNode = null;
			if ((typeof(rootId) != "string") || (rootId == ""))
			{
				rootNode = document.body;
			}
			else
			{
				rootNode = document.getElementById(rootId);
			}
			
			if (rootNode !== null)
			{
				parseChildNodes(rootNode);
			}
		}
	}
}

function handleColorboxCall(id, opacityValue)
{
	if ((typeof(id) == "string") && (id != ""))
	{
		/* COLORBOX APPEARS TO BE ABLE TO TOLERATE BEING PASSED AN UNDEFINED OPACITY
		VALUE BUT I GENERALLY TRY TO AVOID CREATING OR PROPOGATING THEM THROUGH CODE */
		if ((typeof(opacityValue) != "number") || (opacityValue < 0.0) || (opacityValue > 1.0))
		{
			opacityValue = 0.4;
		}
		
		var link = "#" + id + "-link";
		var content = "#" + id + "-content";
		
		var jOb = jQuery.noConflict();		
		jOb("document").ready(function() {
			jQuery(link).colorbox({
					inline:true, 
					href:content, 
					opacity: opacityValue
			});
		});
	}
	return false;
}

function assignColorboxCalls(baseId, rootId)
{
	if ((typeof(baseId) == "string") && (baseId != ""))
	{			
		var contentId = baseId + "-content";
		var linkClass = baseId + "-link";
		var contentNode = document.getElementById(contentId);
		if (contentNode !== null)
		{
			contentId = "#" + contentId;
			var handlerFunction = function()
			{
				var jOb = jQuery.noConflict();		
				jOb["colorbox"]({inline:true, href:contentId
					});
				return false;
			}
			
			parseDescendantsOfNodeAndAssignFunctionToEventOfClass(linkClass, "onclick", handlerFunction, rootId);
		} 
	}
}
