//Vazio
function isEmpty(eString)
{
	// make sure the field contains some kind of data.
	if(eString == null || eString == "") return isValid = true;
	else return isValid = false;
}

//Retirar espaços em branco
function trimWhitespace( strText )
{
	// remove leading spaces
	while ( strText.substring(0,1) == ' ' )
	{
		strText = strText.substring(1, strText.length);
	}
	// remove trailing spaces
	while ( strText.substring(strText.length-1, strText.length) == ' ' )
	{
		strText = strText.substring(0, strText.length-1);
	}
	return strText;
}

function sendContact()
{
	var emailRE = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i;
	var error = false;
	
	var name = document.getElementById('name');
	if (isEmpty(trimWhitespace(name.value)))
	{
		name.style.backgroundColor = 'red';
		error = true;
	}
	else name.style.backgroundColor = '#E5E5E5';
	
	var email = document.getElementById('email');
	if (email.value.match(emailRE)==null)
	{
		email.style.backgroundColor = 'red';
		error = true;
	}
	else email.style.backgroundColor = '#E5E5E5';
	
	var remarks = document.getElementById('remarks');
	if (isEmpty(trimWhitespace(remarks.value)))
	{
		remarks.style.backgroundColor = 'red';
		error = true;
	}
	else remarks.style.backgroundColor = '#E5E5E5';
	
	if (!error) document.getElementById('contact').submit();
}