var _Forms = new FormValidatorList();

FormValidatorList.prototype.Add		= Add;
FormValidatorList.prototype.Validate = Validate;
FormValidatorList.prototype.GetItem	= GetItem

function FormValidatorList()
{
	this.Items = new Array();
}

function Add(newItem)
{
	this.Items.push(newItem);
}

function GetItem(val)
{
//	alert(val);
//	for (index = 0; index < this.Items.length; index++)
//		alert(index + "-" + this.Items[index].Type);
	// check to see if val is string or integer
	if (parseInt(val) != val)
	{
//		alert("string");
		// string
		for (index = 0; index < this.Items.length; index++)
			if (this.Items[index].Type == val) return this.Items[index];
	}
	else
	{
//		alert("integer");
		// integer
		return this.Items[val];
	}
	alert('Form doesn\'t exist');
	return null;
}
function Validate()
{
	success	= true;
	if (arguments.length == 0)
	{
		// Validate all forms
		for (index = 0; index < this.Items.length; index++)
			if(!this.Items[index].Validate())
			{
				success = false;
				break;
			}
	}
	else
	{
		// Validate requested forms
		for (index = 0; index < arguments.length; index++)
		{
			if(!this.GetItem(arguments[index]).Validate())
			{
				success = false;
				break;
			}
		}
	}
	return success;
}

function ValidateForm()
{
	return _Forms.Validate();
}
