// Exclui todos os espaçoes do inicio e do final da string

function valida_form()
{
	var elemento = document.cadastro;
	
	if (trim(elemento.nome.value) == '') 
	{
		alert("Campo NOME obrigatório");
		return false;
	}
	if (trim(elemento.sobrenome.value) == '') 
	{
		alert("Campo SOBRENOME obrigatório");
		return false;
	}
	if (trim(elemento.email.value) == '') 
	{
		alert("Campo EMAIL obrigatório");
		return false;
	}
	if (trim(elemento.c_email.value) == '') 
	{
		alert("Campo CONFIRMAR EMAIL obrigatório");
		return false;
	}
	if (trim(elemento.email.value) != trim(elemento.c_email.value)) 
	{
		alert("O email informado não confere com o confirmado");
		return false;
	}
	if (trim(elemento.username.value) == '') 
	{
		alert("Campo LOGIN obrigatório");
		return false;
	}
	if (trim(elemento.new_password.value) == '') 
	{
		alert("Campo SENHA obrigatório");
		return false;
	}
	if (trim(elemento.password_confirm.value) == '') 
	{
		alert("Campo CONFIRMAR SENHA obrigatório");
		return false;
	}
	if (trim(elemento.new_password.value) != trim(elemento.password_confirm.value)) 
	{
		alert("A senha informada difere da confirmada");
		return false;
	}
	
	if(elemento.acordo.checked==false)
	{
		alert("Para prosseguir, é preciso estar de acordo com os termos da Política de Privacidade");
		return false;				
	}
	return true;

	function trim(str)
	{	
		while (str.charAt(0) == " ")
		{
			str = str.substr(1,str.length -1);
		}
	
		while (str.charAt(str.length-1) == " ")
		{
			str = str.substr(0,str.length-1);
		}
		return str;
	}
}

function win_termos()
{
	window.open("termo.php", 'termo', 'width=400, height=300, scrollbars=yes');
}
