//alert('entrou no js');
function MaxLenTextArea(max,campo,mostraCont) {
        if (mostraCont) {
                var spanCont = document.getElementById('spanContagem');
        }
        var texto = campo.value;
        var cont = max - texto.length;
        if (cont < 0) {
                texto = texto.substr(0,max);
                campo.value = texto;
                cont = max - texto.length;
        }
        if (mostraCont) {
                spanCont.innerHTML = cont;
        }
}

function verifica(form){
	
	if ( document.getElementById('nome').value == "" ){
		alert('Preencha o campo Nome!');
		document.getElementById('nome').focus();
		return false;
	}
	if ( document.getElementById('email').value == "" ){
		alert('Preencha o campo Email!');
		document.getElementById('email').focus();
		return false;
	}else{
		if(validateEmail(document.getElementById('email').value) == false){
			alert('Email incorreto!');
			document.getElementById('email').focus();
			return false;
		}
	}	
	if(document.getElementById('depoimento').value == ""){
		alert('Preencha o campo Depoimento!');
		document.getElementById('depoimento').focus();
		return false;
	}
	
}

function validateEmail(email) {
	if (typeof(email) != "string") {
		return false;
	} else if (!email.match(/^[A-Za-z0-9]+([_.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_.-][A-Za-z0-9]+)*\.[A-Za-z0-9]{2,4}$/)) {
		return false;
	}
	return true;
}

function vEmail(){

	mail1=document.getElementById('email').value;
	x=mail1.indexOf('@');
	z=mail1.indexOf('.');
	
	if (document.getElementById('email').value == ""){
		alert('Informe o seu e-mail !');
		document.getElementById('email').focus();
		return false;
	}
	
	if( x < 0 ) {
		alert('E-mail incorreto.');
		document.getElementById('email').focus();
		return false;
	}else{
		if(mail1.length == (x+1) || mail1.substring(x+1,x+2) == '.' || mail1.substring(x-1,x) == '.' || z == -1){
			alert('E-mail incorreto.');
			document.getElementById('email').focus();
			return false;
		}
		y=mail1.indexOf(';');
		if (y != -1){
			alert('E-mail incorreto.');
			document.getElementById('email').focus();
			return false;
		}
		s=mail1.indexOf(' ');
		if (s != -1){
			alert('E-mail incorreto.');
			document.getElementById('email').focus();
			return false;
		}
		a = mail1.length
		if (mail1.substring(a, a-1) == '.' ){
			alert('E-mail incorreto.');
			document.getElementById('email').focus();
			return false;
		}
		y1=  mail1.length;
		if (mail1.substring(y1-3,y1-2) != '.'){
			if (mail1.substring(y1-4,y1-3) != '.'){
					alert('E-mail incorreto.');
					document.getElementById('email').focus();
					return false;
			}
		}
	}
	
	return true;
}


	
	

