
//Validar Formuário de Envio de Currículos
function ValidaCV()
{
	if(document.formCV.nome.value == ''){
		document.getElementById('msgErro').innerHTML = 'Campo Nome em branco.';
		document.getElementById('msgErro').style.display = 'block';
		document.formCV.nome.focus();
	}
	else if(!ValidaEmail(document.formCV.email.value)){
		document.getElementById('msgErro').innerHTML = 'Campo Email inválido.';
		document.getElementById('msgErro').style.display = 'block';
		document.formCV.email.focus();
	}
	else if(document.formCV.contato.value == ''){
		document.getElementById('msgErro').innerHTML = 'Campo Contato em branco.';
		document.getElementById('msgErro').style.display = 'block';
		document.formCV.contato.focus();
	}
	else if(document.formCV.cv.value == ''){
		document.getElementById('msgErro').innerHTML = 'Campo Currículo em branco.';
		document.getElementById('msgErro').style.display = 'block';
		document.formCV.cv.focus();
	}
	else{
		document.formCV.action = 'envia_email.asp?cod=cv';
		document.formCV.submit();
	}
}

//Validar Formuário de Contato
function ValidaCTT()
{
	if(document.formCTT.nome.value == ''){
		document.getElementById('msgErro').innerHTML = 'Campo Nome em branco.';
		document.getElementById('msgErro').style.display = 'block';
		document.formCTT.nome.focus();
	}
	/*else if(document.formCTT.empresa.value == ''){
		document.getElementById('msgErro').innerHTML = 'Campo Empresa em branco.';
		document.getElementById('msgErro').style.display = 'block';
		document.formCTT.empresa.focus();
	}
	else if(document.formCTT.tel.value == '' && document.formCTT.cel.value == ''){
		document.getElementById('msgErro').innerHTML = 'Campo Telefone em branco.';
		document.getElementById('msgErro').style.display = 'block';
		document.formCTT.tel.focus();
	}*/
	else if(!ValidaEmail(document.formCTT.email.value)){
		document.getElementById('msgErro').innerHTML = 'Campo Email inválido.';
		document.getElementById('msgErro').style.display = 'block';
		document.formCTT.email.focus();
	}
	else if(document.formCTT.msg.value == ''){
		document.getElementById('msgErro').innerHTML = 'Campo Mensagem em branco.';
		document.getElementById('msgErro').style.display = 'block';
		document.formCTT.msg.focus();
	}
	else{
		document.formCTT.action = 'envia_email.asp?cod=ctt';
		document.formCTT.submit();
	}
}

//Validar Email
function ValidaEmail(mail)
{
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){ 
                    return true; 
                }
    }else{
        return false;
        }
}