function show() {
	
	var element;
	
	for ( var i = 0; i < arguments.length; i ++ ) {
		
		element = getObject(arguments[i]);
		
		if ( element.tagName == "DIV" ) {
			
			element.style.display = "block";
			
		} else {
			
			element.style.display = "inline";
			
		}
		
	}
	
}


function hide() {
	
	var element;
	
	for ( var i = 0; i < arguments.length; i ++ ) {
		
		element = getObject(arguments[i]);
		
		element.style.display = "none";
		
	}
	
}

function getObject(id) {
	
	var element;
	
	if ( id == "[object]" ) {
		
		element = id;
		
	} else {
		
		element = document.getElementById(id);
		
	}
	
	return element;
	
}

function highlight(node, className) {
	
	if ( supportsHighlighting() ) {
		
		if ( className == null ) {
			
			className = "highlight";
			
		}
		
		/* Using the setAttribute() method because, if we try to access the
		 * property directly, Safari freaks out and seems to change the display
		 * of the element to inline. */
		
		node.setAttribute("oldClassName", node.className);
		
		/* NOTE: We're setting the class name property directly because Firefox
		 * doesn't seem to like setting the class name with the setAttribute()
		 * method. */
		
		if ( node.className != "" ) {
			
			node.className = node.className + " " + className;
			
		} else {
			
			node.className = className;
			
		}
		
	}
	
}

function unhighlight(node) {
	
	if ( supportsHighlighting() ) {
		
		node.className = node.getAttribute("oldClassName");
		
	}
	
}

function supportsHighlighting() {
	
	/* Though we can set arbitrary attributes in Safari, it gives us a hard time
	 * when we try to get the value back out using either getAttribute() or
	 * node.whatever. Until then, we'll just disable the highlighting feature
	 * in Safari. */
	
	if ( navigator.userAgent.indexOf("Safari") == -1 ) {
		
		return true;
		
	} else {
		
		return false;
		
	}
	
}

// Add a trim method to the String class.

String.prototype.trim  = function(str) {
	
	str = this == window ? str : this;
	
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
	
};

String.prototype.stripTags = function() {
	
	this.replace(/<\/?[^>]+>/gi, "");
	
};

String.prototype.escapeHTML = function() {
	
	var div = document.createElement("div");
	
	var text = document.createTextNode(this);
	
	div.appendChild(text);
	
	return div.innerHTML;
	
};

String.prototype.unescapeHTML = function() {
	
	var div = document.createElement("div");
	
	div.innerHTML = this.stripTags();
	
	return div.childNodes[0].nodeValue;
	
};

// Add a find method to the Array object.

Array.prototype.find = function(value, start) {
	
	if ( !start ) {
		
		start = 0;
		
	}
	
	for ( var i = start; i < this.length; i++ ) {
		
		if ( this[i] == value ) {
			
			return i;
			
		}
		
	}
	
	return -1;
		
};

function getSelectedCheckboxes(checkboxes) {
	
	var selectedCheckboxes = new Array();
	
	var pushIfChecked = function(checkbox) {
		
		if ( checkbox.checked ) {
			
			selectedCheckboxes.push(checkbox);
			
		}
		
	};
	
	// Check to see if we have an array of checkboxes or just a single checkbox.
	// If we have a single checkbox, then checkboxes.length will be undefined.
	
	if ( typeof checkboxes.length == "undefined" ) {
		
		pushIfChecked(checkboxes);
		
	} else {
		
		for ( var i = 0; i < checkboxes.length; i++ ) {
			
			pushIfChecked(checkboxes[i]);
			
		}
	}
	
	return selectedCheckboxes;
	
}

function getCheckboxSelectedValues(checkboxes) {
	
	var selectedValues = new Array();
	
	for ( var i = 0; i < checkboxes.length; i++ ) {
		
		var checkbox = checkboxes[i];
		
		if ( checkbox.checked ) {
			
			selectedValues.push(checkbox.value);
			
		}
		
	}
	
	return selectedValues;
	
}


function getCheckboxValues(checkboxes) {
	
	var values = new Array();
	
	for ( var i = 0; i < checkboxes.length; i++ ) {
		
		var checkbox = checkboxes[i]
		
		values.push(checkbox.value);
		
	}
	
	return values;
	
}


function checkAllCheckboxes(checkboxes) {
	
	var checkbox;
	
	for ( var i = 0; i < checkboxes.length; i++ ) {
		
		checkbox = checkboxes[i];
		
		if ( !checkbox.checked ) {
			
			checkbox.checked = true;
			
		}
		
	}
	
}

function uncheckAllCheckboxes(checkboxes) {
	
	var checkbox;
	
	for ( var i = 0; i < checkboxes.length; i++ ) {
		
		checkbox = checkboxes[i];
		
		if ( checkbox.checked ) {
			
			checkbox.checked = false;
			
		}
		
	}
	
}
	
function checkCheckboxes(checkboxes, selectedValues) {
	
	var checkIfExists = function(checkbox) {
		
		if ( selectedValues.find(checkbox.value) != -1 ) {
			
			checkbox.checked = true;
			
		}
		
	};
	
	// Check to see if we have an array of checkboxes or just a single checkbox.
	// If we have a single checkbox, then checkboxes.length will be undefined.
	
	if ( typeof checkboxes.length == "undefined" ) {
		
		checkIfExists(checkboxes);
		
	} else {
		
		for ( var i = 0; i < checkboxes.length; i++ ) {
			
			checkIfExists(checkboxes[i]);
			
		}
		
	}
	
}

function getCheckboxLabelsAsText(checkboxes) {
	
	var labelsAsText = new Array();
	
	var labels = getCheckboxLabels(checkboxes);
	
	for ( var i = 0; i < labels.length; i++ ) {
		
		var label = labels[i];
		
		var labelAsText = getLabelAsText(label);
		
		labelsAsText.push(labelAsText);
		
	}
	
	return labelsAsText;
	
}

function getCheckboxLabels(checkboxes) {
	
	var labels = new Array();
	
	for ( var i = 0; i < checkboxes.length; i++ ) {
		
		var checkbox = checkboxes[i];
		
		var label = getCheckboxLabel(checkbox);
		
		labels.push(label);
		
	}
	
	return labels;
	
}

function getCheckboxLabel(checkbox) {
	
	var labels = document.getElementsByTagName("LABEL");
	
	for ( var i = 0; i < labels.length; i++ ) {
		
		var label = labels[i];
		
		if ( label.htmlFor == checkbox.id ) {
			
			return label;
			
		}
		
	}
	
	return "";
	
}

function getCheckboxLabelAsText(checkbox) {
	
	var label = getCheckboxLabel(checkbox);
	
	return getLabelAsText(label);
	
}

function getLabelAsText(label) {
	
	return label.innerHTML.trim();
	
}

function createXmlHttpRequest()
{
	if (window.XMLHttpRequest)
	{
		return new XMLHttpRequest;
	}
	
	try { return new ActiveXObject("MSXML2.XMLHTTP.6.0") } catch(e) {}
	try { return new ActiveXObject("MSXML2.XMLHTTP.3.0") } catch(e) {}
	try { return new ActiveXObject("MSXML2.XMLHTTP")     } catch(e) {}
	try { return new ActiveXObject("Microsoft.XMLHTTP")  } catch(e) {}
	
	throw new Error("Could not find an XMLHttpRequest alternative.");
}

function get(url, callback)
{
	var request = createXmlHttpRequest();
	
	// Add a timestamp to the URL to bypass caching.
	
	if (url.indexOf("?") == -1)
	{
		url += "?";
	}
	else
	{
		url += "&";
	}
	
	var date = new Date();
	
	url += "ts=" + date.valueOf().toString();
	
	// Prepare request.
	
	request.open("GET", url, true);
	
	// Set up our callback function.
	
	if (typeof callback == "function")
	{
		request.onreadystatechange = function()
		{
			if (request.readyState == 4 && request.status == 200)
			{
				if (request.responseText)
				{
					callback(request.responseText);
				}
			}
		};
	}
	
	// Issue the request.
	
	// NOTE: Firefox seems to require the first argument, even if it's null:
	//   
	//   http://blog.bipins.net/?p=56
	
	request.send(null);
}

function dump(object) {
	
	var output = getDumpStructure(object);
	
	var element = createDumpElement();
	
	element.innerHTML = output;
	
	document.body.appendChild(element);
	
}

function getDumpStructure(object) {
	
	var tableStyle = "border-collapse: collapse; border: 1px 1px 0px 1px; border-style: solid; border-color: #dddddd;";
	var labelStyle = "vertical-align: top; background-color: #eeeeee; border-bottom: 1px solid #dddddd;";
	var valueStyle = "border-bottom: 1px solid #dddddd;";
	
	var output = "<table style=\"" + tableStyle + "\">";
	
	for ( var property in object ) {
		
		output = output + "<tr><td style=\"" + labelStyle + "\">" + property.escapeHTML() + "</td><td style=\"" + valueStyle + "\">";
		
		var value = object[property];
		
		if ( property == "style" || property == "currentStyle" ) {
			
			output = output + getDumpStructure(value);
			
		} else if ( property == "innerHTML" || property == "outerHTML" ) {
			
			output = output + "[HTML]";
			
		} else {
			
			if ( value == "[object]" ) {
				
				output = output + "[object]";
				
				if ( "tagName" in value ) {
					
					output = output + " [tagName=" + value.tagName + "]";
					
				}
				
				if ( "id" in value ) {
					
					if ( value.id != "" ) {
						
						output = output + " [id=" + value.id + "]";
						
					}
					
				}
				
				if ( "name" in value ) {
					
					if ( value.name != "" ) {
						
						output = output + " [name=" + value.name + "]";
						
					}
					
				}
				
				if ( "className" in value ) {
					
					if ( value.className != "" ) {
						
						output = output + " [className=" + value.className + "]";
						
					}
					
				}
				
				if ( "length" in value ) {
					
					if ( value.length != "" ) {
						
						output = output + " [length=" + value.length + "]";
						
					}
					
				}
				
			} else if ( value == null ) {
				
				output = output + "<br>";
					
			} else {
				
				output = output + String(value).escapeHTML();
				
			}
			
		}
		
		output = output + "</td></tr>";
		
	}
	
	output = output + "</table>";
	
	return output;
	
}

function createDumpElement() {
	
	var element = document.createElement("TEST");
	
	element.style.backgroundColor = "white";
	
	element.style.border = "1px solid #cccccc";
	
	element.style.clear = "both";
	
	return element;
	
}