$Compare = {
	
	ToggleOutputForm: function(e)
	{
		var icon = eTarget(e);
		var target = parentNode(icon, "TR");
		if (!target) return false;
		
		var nextSib = nextSibling(target);
		var hidden = (nextSib.style.display == "none") ? true : false;
		
		// Change the collapse icon
		icon.src = (!hidden)
			? '../images/sectionExpand.gif'
			: '../images/sectionCollapse.gif';
		
		while (nextSibling(target))
		{
			target = nextSibling(target);
			var classes = target.className.split(" ");
			for (var i in classes)
			{
				// End of the line
				if (classes[i] == "om_form") return true;
			}
			
			target.style.display = (target.style.display == "none") ? "" : "none";
		}
	},
	
	ShowMore: function(e)
	{
		// Find the target node
		var target = eTarget(e);
		if (!target) return false;
		
		// Find the nextSibling - SPAN element
		var more = nextSibling(target);
			more.className = "";
		var less = nextSibling(more);
			less.className = "";
		
		// Hide the show more link
		target.className = "om_hidden";
	},
	
	ShowLess: function(e)
	{
		// Find the target node
		var target = eTarget(e);
		if (!target) return false;
		
		// Find the nextSibling - SPAN element
		var less = previousSibling(target);
			less.className = "om_hidden";
		var more = previousSibling(less);
			more.className = "";
		
		// Hide the show more link
		target.className = "om_hidden";
	},
	
	ToggleForm: function(e)
	{
		// Find the target node
		var target = eTarget(e);
		if (!target) return false;
		var checked = (target.checked !== undefined) ? target.checked : true;
		
		// Extract the form ID
		var id = target.value;
		if (!id) return false;
		
		// Hide all child node rows
		var row = parentNode(target, "TR");
		var body = parentNode(row, "TBODY");
		var rows = body.getElementsByTagName("TR");
		for (var i in rows)
		{
			if (rows[i].className)
			{
				var classes = rows[i].className.split(" ");
				for (var j in classes)
				{
					if (classes[j] == "form_field_" + id)
					{
						rows[i].style.display = (checked) ? "" : "none";
					}
				}
			}
		}
		
		// Hide the select all options
		var cells = childNodes(row, "TD");
		if (!cells[1]) return;
		var selectall = cells[1].getElementsByTagName("DIV");
		if (selectall[0]) selectall[0].style.display = (checked) ? "" : "none";
	},
	
	SelectAll: function(e, id)
	{
		// Find the parent TBODY tag
		var body = parentNode(eTarget(e), "TBODY");
		
		// Fetch all TR tags inside the tbody
		var rows = body.getElementsByTagName("TR");
		for (var i in rows)
		{
			if (!rows[i].className) continue;
			var classes = rows[i].className.split(" ");
			for (var j in classes)
			{
				if (classes[j] == "form_field_" + id)
				{
					var input = rows[i].getElementsByTagName("INPUT");
					for (var k in input) input[k].checked = "checked";
				}
			}
		}
	},
	
	ClearAll: function(e, id)
	{
		// Find the parent TBODY tag
		var body = parentNode(eTarget(e), "TBODY");
		
		// Fetch all TR tags inside the tbody
		var rows = body.getElementsByTagName("TR");
		for (var i in rows)
		{
			if (!rows[i].className) continue;
			var classes = rows[i].className.split(" ");
			for (var j in classes)
			{
				if (classes[j] == "form_field_" + id)
				{
					var input = rows[i].getElementsByTagName("INPUT");
					for (var k in input) input[k].checked = "";
				}
			}
		}
	}
};