var constraints = new Array( /^[a-z\s]{3,20}$/i, //Name
							 /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z0-9]([a-z0-9_\.]*)@([a-z0-9_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i, //Email
							 /^[a-z0-9\s]{1,30}$/i, //Subject
							 /^[a-z0-9\s.!@,()]{10,600}$/i, //Message
							 /^jkvbg$/i ); //Verify

function validate( elId )//, element )
{
	try{
	element = document.getElementById( "in" + elId );

	if( isValid( constraints[ elId ], element.value ) )
	{
		showValid( true, elId );
		return true;
	
	}else{
		showValid( false, elId );
		return false;
	}
	}catch(err){ /*alert( err );*/ }
}

function isValid( constraint, value )
{	
	return constraint.test( value );
}

function showValid( state, elId )
{
	try{
		if( state )
			document.getElementById( "el" + elId ).src = "images/status/valid.gif";
		else{
			document.getElementById( "el" + elId ).src = "images/status/invalid.gif";
		}
	}catch(err){}//Element is hidden

}

function lock( element )
{
	//element.disabled = true;
}

function validateForm()
{
	valid = true;
	for( i = 0; i < constraints.length; i++ )
	{
		if( !validate( i ) )
			valid = false;
	}
	return valid;
}