<!--
var validations = new Array();
// Define which validations to perform. Each array item
// holds the form field to validate, and the validation
// to be applied. This is the only party you need to
// customize in order to use the script in a new page!
validations[0]=['document.correio.nome', 'notblank'];
validations[1]=['document.correio.email', 'validemail'];
validations[2]=['document.correio.mensagem', 'notblank'];
// Customize above array when used with a new page.
function isEmpty(s){
	if (s == null || s.length == 0)
	return true;
// The test returns true if there is at least one non-
// whitespace, meaning the string is not empty. If the
// test returns true, the string is empty.
	return !/\S/.test(s);
	}
function looksLikeEmail(field){
	var s = field.value;
	if (isEmpty(s)){
alert('Preencha o campo email');
	//window.document.cadastrousuario.verifica.value='Preencha o campo email!';
	field.focus();
	return false;
	}
	if (/[^@]+@\w+/.test(s))
	return true;
//
alert('Preencha o campo email corretamente.');
//	window.document.cadastrousuario.verifica.value='Email em formato inválido!';
	field.focus();
	return false;
	}
function isInteger(field){
	var s = field.value;
	if (isEmpty(s)){
  alert('Preencha o campo nome');
	//window.document.cadastrousuario.verifica.value='Preencha o campo '+ field.name +'!';
	field.focus();
	return false;
	}
	if (!(/^-?\d+$/.test(s))){
//	window.document.cadastrousuario.verifica.value='Preencha o campo '+ field.name +'!';
	field.focus();
	return false;
	}
return true;
}

function validate(){
	//checa sempre antes se o campo de senha corresponde à confirmacao
	//inicia o lopp com as demais confirmacões
		var i;
		var checkToMake;
		var field;
		for (i = 0; i < validations.length; i++){
			field = eval(validations[i][0]);
			checkToMake = validations[i][1];
			switch (checkToMake){
			case 'notblank': if (isEmpty(field.value)){
			alert('Preencha o campo '+ field.name + '.');
			//window.document.cadastrousuario.verifica.value='Preencha o campo '+ field.name +'!';
			field.focus();
			return false;
			}
			break;
			case 'validemail': if (!looksLikeEmail(field))
			return false;
			break;
			case 'isnumber': if (!isInteger(field))
			return false;
			}
	}
return true;

}


//-->

