// Arquivo de Configuração JavaScipt

//Menu
function horizontal() 
{ 
   var navItems = document.getElementById("barra").getElementsByTagName("li"); 
    
   for (var i=0; i<navItems.length; i++) { 
      if((navItems[i].className == "menuvertical")) 
      { 
         if(navItems[i].getElementsByTagName('ul')[0] != null) 
         { 
            navItems[i].onmouseover=function() {this.getElementsByTagName('ul')[0].style.display="block";this.style.backgroundColor = "#f9f9f9";} 
            navItems[i].onmouseout=function() {this.getElementsByTagName('ul')[0].style.display="none";this.style.backgroundColor = "#FFFFFF";} 
         } 
      } 
   } 
}    

function abrePopUp(url,altura)
{   
	window.open(url,'Popup','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height='+altura);   
}  

function abrePopUp2(url,altura)
{   
	window.open(url,'Popup','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=550,height='+altura);   
}   

function limpar (objeto, msg) 
{
    if (objeto.value == msg)objeto.value = '';
}

function mostrar (objeto, msg) 
{
    if (objeto.value == '')objeto.value = msg;
}

function Foco() 
{
	document.getElementById('enter').pagina_p.focus()
	document.getElementById('enter').pagina_p.select() 
} 

function displayWindow(theURL,winName,width,height,features) //Esta função aqui é para o pop-up abrir no centro, está funcionando legal
{ 
    var window_width = width;
    var window_height = height;
    var newfeatures= features;
    var window_top = (screen.height-window_height)/2;
    var window_left = (screen.width-window_width)/2;
    newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',features=' + newfeatures + '');
    newWindow.focus();
}

//Ínicio das funções das máscaras.

function mascara(o,f)
{
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara()
{
    v_obj.value=v_fun(v_obj.value)
}

function leech(v)
{
    v=v.replace(/o/gi,"0")
    v=v.replace(/i/gi,"1")
    v=v.replace(/z/gi,"2")
    v=v.replace(/e/gi,"3")
    v=v.replace(/a/gi,"4")
    v=v.replace(/s/gi,"5")
    v=v.replace(/t/gi,"7")
    return v
}

function soNumeros(v)
{
    return v.replace(/\D/g,"")
}

function format_telefone(v)
{
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}

function format_data(v)
{
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/(\d{2})(\d)/,"$1/$2")    //Coloca barra entre o segundo e o terceiro dígitos
	v=v.replace(/(\d{2})(\d)/,"$1/$2")    //Coloca barra entre o quarto e o quinto dígitos
	return v
}

function format_cep(v)
{
    v=v.replace(/\D/g,"")                //Remove tudo o que não é dígito
    v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse é tão fácil que não merece explicações
    return v
}

//Fim das funções da máscaras.

function valida_curriculum() 
{
	var viaja = document.getElementById('s');
	var viaja2 = document.getElementById('n');
	
	if (document.getElementById('curriculum').nome.value == "")
	{
		alert("O campo [Nome] não foi preenchido.");
		document.getElementById('curriculum').nome.focus();
	}
	else if (document.getElementById('curriculum').sexo.value == "0")
	{
		alert("O campo [Sexo] não foi preenchido.");
		document.getElementById('curriculum').sexo.focus(); 
	}
	else if (document.getElementById('curriculum').nascimento.value == "")
	{
		alert("O campo [Nascimento] não foi preenchido.");
		document.getElementById('curriculum').nascimento.focus(); 
	}
	else if (document.getElementById('curriculum').estado_civil.value == "0")
	{
		alert("O campo [Estado Civil] não foi preenchido.");
		document.getElementById('curriculum').estado_civil.focus(); 
	}
	else if (document.getElementById('curriculum').endereco.value == "")
	{
		alert("O campo [Endereço] não foi preenchido.");
		document.getElementById('curriculum').endereco.focus();
	}
	else if (document.getElementById('curriculum').bairro.value == "")
	{
		alert("O campo [Bairro] não foi preenchido.");
		document.getElementById('curriculum').bairro.focus(); 
	}
	else if (document.getElementById('curriculum').cidade.value == "")
	{
		alert("O campo [Cidade] não foi preenchido.");
		document.getElementById('curriculum').cidade.focus(); 
	}
	else if (document.getElementById('curriculum').estado.value == "0")
	{
		alert("O campo [Estado] não foi preenchido.");
		document.getElementById('curriculum').estado.focus(); 
	}
	else if (document.getElementById('curriculum').cep.value == "")
	{
		alert("O campo [Cep] não foi preenchido.");
		document.getElementById('curriculum').cep.focus(); 
	}
	else if (document.getElementById('curriculum').pais.value == "")
	{
		alert("O campo [País] não foi preenchido.");
		document.getElementById('curriculum').pais.focus(); 
	}
	else if (document.getElementById('curriculum').telefone.value == "")
	{
		alert("O campo [Telefone] não foi preenchido.");
		document.getElementById('curriculum').telefone.focus(); 
	}
	else if (document.getElementById('curriculum').email.value == "")
	{
		alert("O campo [E-mail] não foi preenchido.");
		document.getElementById('curriculum').email.focus(); 
	}
	else if (document.getElementById('curriculum').nacionalidade.value == "")
	{
		alert("O campo [Nacionalidade] não foi preenchido.");
		document.getElementById('curriculum').nacionalidade.focus(); 
	}
	else if (document.getElementById('curriculum').especial.value == "0")
	{
		alert("O campo [Necessidade Especial] não foi preenchido.");
		document.getElementById('curriculum').especial.focus(); 
	}
	else if (document.getElementById('curriculum').instituicao.value == "")
	{
		alert("O campo [Instituição] não foi preenchido.");
		document.getElementById('curriculum').instituicao.focus(); 
	}
	else if (document.getElementById('curriculum').tipo_curso.value == "0")
	{
		alert("O campo [Tipo de Curso] não foi preenchido.");
		document.getElementById('curriculum').tipo_curso.focus(); 
	}
	else if (document.getElementById('curriculum').situacao_atual.value == "0")
	{
		alert("O campo [Situação Atual] não foi preenchido.");
		document.getElementById('curriculum').situacao_atual.focus(); 
	}
	else if (document.getElementById('curriculum').mes_conclusao.value == "0")
	{
		alert("O campo [Mês de Conclusão] não foi preenchido.");
		document.getElementById('curriculum').mes_conclusao.focus(); 
	}
	else if (document.getElementById('curriculum').ano_conclusao.value == "0")
	{
		alert("O campo [Ano de Conclusão] não foi preenchido.");
		document.getElementById('curriculum').ano_conclusao.focus(); 
	}
	else if (document.getElementById('curriculum').nivel.value == "0")
	{
		alert("O campo [Nível] não foi preenchido.");
		document.getElementById('curriculum').nivel.focus(); 
	}
	else if (document.getElementById('curriculum').area.value == "0")
	{
		alert("O campo [Área] não foi preenchido.");
		document.getElementById('curriculum').area.focus(); 
	}
	else if (viaja.checked == false && viaja2.checked == false)
	{
		alert("O campo [Viajar a trabalho] não foi preenchido.");
	}
	else if (document.getElementById('curriculum').idioma.value != "0" && (document.getElementById('curriculum').idioma_leitura.value == "0" || document.getElementById('curriculum').idioma_escrita.value == "0" || document.getElementById('curriculum').idioma_conversacao.value == "0"))
	{
		alert("O campo [Idioma] não foi preenchido totalmente.");
		document.getElementById('curriculum').idioma.focus(); 
	}
	else if (document.getElementById('curriculum').idioma2.value != "0" && (document.getElementById('curriculum').idioma_leitura2.value == "0" || document.getElementById('curriculum').idioma_escrita2.value == "0" || document.getElementById('curriculum').idioma_conversacao2.value == "0"))
	{
		alert("O campo [Idioma2] não foi preenchido totalmente.");
		document.getElementById('curriculum').idioma2.focus(); 
	}
	else if (document.getElementById('curriculum').idioma3.value != "0" && (document.getElementById('curriculum').idioma_leitura3.value == "0" || document.getElementById('curriculum').idioma_escrita3.value == "0" || document.getElementById('curriculum').idioma_conversacao3.value == "0"))
	{
		alert("O campo [Idioma3] não foi preenchido totalmente.");
		document.getElementById('curriculum').idioma3.focus(); 
	}
	else
	{
		window.open('','curriculum','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=150');
		//jan=displayWindow('','newsletter','400','200',''); //opções do popup
		document.getElementById('curriculum').target = "curriculum";
		document.getElementById('curriculum').submit();
	}
}
