function AbreJanela(file, window, larg,  altura){
    msgWindow=open(file,window,'width=' + larg + ',height='  + altura + ',top=0,left=0');
    msgWindow.focus();
    msgWindow.moveTo(screen.width/2-larg/2,screen.height/2-altura/2-20);
}


function limite(limite){ 
var tt = document.getElementById("depoimento").value.length;          
var resta = limite - tt; 
var y = event.keyCode; //8 = backspace 
	if( (resta < 0) && (y != 8) ){
	alert("Erro! O número de caracteres foi ultrapassado.");		
	resta = 0;
	return false;
	}
var restam = limite - tt
	if(restam < 0){
	restam = 0;
	}	
document.getElementById("faltam").innerHTML = "Restam: "+ (restam) +" caractéres";
}


function validaDepoimento(){
	if(document.getElementById("nome").value.length < 5){
	alert("o nome deve ter no mínimo 5 caractéres.");
	return false;
	}

	if(document.getElementById("nome").value.replace(/ /g,"").length == 0){
	alert("o nome deve ter no mínimo 5 caractéres.");
	return false;
	}	
	
	if(document.getElementById("email_depoimento").value.length < 5){
	alert("E-mail inválido.");
	return false;
	}

	if(document.getElementById("email_depoimento").value.replace(/ /g,"").length == 0){
	alert("E-mail inválido.");
	return false;
	}

	if(document.getElementById("depoimento").value.lenght > 200){
	alert("O depoimento deve conter no máximo 200 caractéres.");
	return false;
	}

	if(document.getElementById("depoimento").value.replace(/ /g,"").length == 0){
	alert("O depoimento deve conter no máximo 200 caractéres.");
	return false;
	}
}
