var Form = function() { 
	// If the context is global, return a new object
	if ( window == this )
		return new Form();

};

Form.fn = Form.prototype = {
	errorMessage: "",
		
	showErrors: function(sibling)
	{
		var errors;
		var heading;
		var list;
		
		if (document.getElementById('errorlist'))
			list = document.getElementById('errorlist');
		else
		{
			errors = document.createElement('div');
			errors.className = "error";
			heading = document.createElement('h2');
			heading.innerHTML = "There was a problem with the following fields:";
			list = document.createElement('ul');
			list.id = "errorlist";
			errors.appendChild(heading);
			errors.appendChild(list);
		} // else
			
		list.innerHTML = Form.errorMessage;	
		if (!document.getElementById('errorlist'))	
			document.getElementById('primary_content').insertBefore(errors, sibling);

		// Scroll to the top
		scroll(0,0);
	}, // showErrors
	
	isEmpty: function(input)
	{
		isEmpty = false;
		if (input.value == '')
			isEmpty = true
		
		return isEmpty;
	} , // isEmpty
	
	addError: function(message)
	{
		Form.errorMessage = Form.errorMessage + "<li>" + message + "</li>";
	}, // addError
	
	clearErrors: function()
	{
		Form.errorMessage = "";
	} // clearErrors
	

};

Form.extend = Form.fn.extend = function() {
	// copy reference to target object
	var target = arguments[0],
		a = 1;

	// extend Form itself if only one argument is passed
	if ( arguments.length == 1 ) {
		target = this;
		a = 0;
	}
	var prop;
	while (prop = arguments[a++])
		// Extend the base object
		for ( var i in prop ) target[i] = prop[i];

	// Return the modified object
	return target;
};