function getElementById(id)
{
	if ( document.getElementById )
	{
		return document.getElementById(id);
	}
	else if ( document.all )
	{
		return document.all[id];
	}
	else if ( document.layers )
	{
		return document.layers[id];
	}
	else
	{
		alert("object not found");
	}
}
function validate(formname)
{
	var form = getElementById(formname);
	var errors = "";
	for ( i in window.fields )
	{
		fieldName = fields[i]['name'];
		id = fields[i]['name'];
		var validation = fields[i]['validation'];
		var length = fields[i]['maxlength'];
		field = form[id];
		if ( field.value.length == 0 )
		{
			field.style.background = 'red';
			errors += fieldName +" can not be empty\n";
		}
		else if ( field.value.length > length)
		{
			field.style.background = 'red';
			errors += fieldName +" is to long\n";
		}
		else if ( field.value.match(validation) == null )
		{
			field.style.background = 'red';
			errors += fieldName +" is invalid\n";
		}
		else
		{
			
		}
	}
	if ( errors.length != 0 )
	{
		alert("Please Correct The Following Errors:\n"+errors);
		return false;
	}
	else
	{
        	return true;
	}
}