/* script para abrir uma pagina em popup */
function Abre(url, width, height, rola)	{						
	if (rola==""){rola="yes"}
	window.open(url,"_blank","resizable=no,toolbar=no,status=no,top=" + (window.screen.height - height)/2 + ",left=" + (window.screen.width - width)/2 + ",menubar=no,scrollbars=" + rola + ",width=" + width + ",height=" + height);
}

/* script que insere um flash em uma pagina */
function montaFlash(destino, flavez, width, height, trans, scale, salign){
	var myFlash = 
		'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+flavez+'" align="middle">'+
		'<param name="allowScriptAccess" value="sameDomain" />'+
		'<param name="movie" value="'+flavez+'.swf" />'
	;
	if (trans == "yes"){
		myFlash += '<param name="wmode" value="transparent" />';
		transMoz = 'wmode="transparent"';
	}
	if (salign != ""){
		myFlash += '<param name="salign" value="'+salign+'" />';
		salignMoz = 'salign="'+salign+'"';
	}
	if (scale == "yes"){
		myFlash += '<param name="scale" value="noscale" />';
		scaleMoz = 'scale="noscale"';
	}
	myFlash +=
		'<param name="quality" value="high" />'+
		'<param name="bgcolor" value="#ffffff" />'+
		'<embed src="'+flavez+'.swf" '+scaleMoz+' quality="high" '+transMoz+' bgcolor="#ffffff" '+salignMoz+' width="'+width+'" height="'+height+'" name="empresas" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
		'</object>'
	;
	document.getElementById(destino).innerHTML = myFlash;
}

/* função que valida um e-mail */
function validaMail(objMail){
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(objMail))) 
    { 
		email = false;
	} 
	else{
		email = true;
	}
	return email;
}

/* função que valida o cpf */
function validacpf(s){ 
	//remove marcara cpf		
	for(var i=0;i<s.length;i++){				
		s = s.replace(".","");
		s = s.replace("-","");
	}	

	var i;		
	var c = s.substr(0,9);		 
	var dv = s.substr(9,2);		 
	var d1 = 0;

	for (i = 0; i < 9; i++){ 
		d1 += c.charAt(i)*(10-i); 
	} 
	if (d1 == 0){ 
		return false;
	} 
	d1 = 11 - (d1 % 11);		 
	if (d1 > 9) d1 = 0;

	if (dv.charAt(0) != d1){ 
		return false; 
	} 

	d1 *= 2;

	for (i = 0; i < 9; i++){ 
		d1 += c.charAt(i)*(11-i); 
	} 
	d1 = 11 - (d1 % 11); 
	if (d1 > 9) d1 = 0; 
	if (dv.charAt(1) != d1){ 
		return false; 
	} 
	return true; 
}

/* função que valida o cnpj */
function validaCnpj(cnpj){
	var valida = new Array(6,5,4,3,2,9,8,7,6,5,4,3,2);
	var dig1= new Number;
	var dig2= new Number;
	exp = /\.|\-|\//g;
	cnpj = cnpj.toString().replace( exp, "" );
	var digito = new Number(eval(cnpj.charAt(12)+cnpj.charAt(13)));
	for(i = 0; i<valida.length; i++){
		dig1 += (i>0? (cnpj.charAt(i-1)*valida[i]):0);
		dig2 += cnpj.charAt(i)*valida[i];
	}
	dig1 = (((dig1%11)<2)? 0:(11-(dig1%11)));
	dig2 = (((dig2%11)<2)? 0:(11-(dig2%11)));
	if(((dig1*10)+dig2) != digito){
		return false;
	}else{
		return true;
	}
}

/* ABRE UM POPUP */
function popup(url, width, height, rola)	{						
	if (rola==""){rola="yes"}
	window.open(url,"_blank","resizable=no,toolbar=no,status=no,top=" + (window.screen.height - height)/2 + ",left=" + (window.screen.width - width)/2 + ",menubar=no,scrollbars=" + rola + ",width=" + width + ",height=" + height);
}

<!-- INI - SCRIPTS MAPA GOOGLE -->
function mostraMapa(){
	parent.document.getElementById("iframeMapa").style.display = "block";
	parent.document.getElementById("iframeMapa").style.width = "660px";
	parent.document.getElementById("iframeMapa").style.height = "520px";
}
<!-- FIM - SCRIPTS MAPA GOOGLE -->

<!-- INI - SCRIPTS DAS ABAS -->
function mudaAbaMenu(aba){
	//se for a home
	if(aba==1){
		mostraHomeInt("none");
	}

	//percorrendo as 6 abas do menu
	for(i=1;i<=6;i++){
		//se não for a aba que deve ser marcada
		if(i!=aba){
			document.getElementById("abaMenu"+i).className = "abaDesmarcada";
		}else{
			document.getElementById("abaMenu"+i).className = "abaMarcada";
		}
	}
}
function mudaAbaPesq(aba){
	//percorrendo as 3 abas do menu
	for(i=1;i<=3;i++){
		//se não for a aba que deve ser marcada
		if(i!=aba){
			document.getElementById("abaPesq"+i).className = "abaPesqDesmarcada";
			document.getElementById("div_pesquisa"+i).style.display = "none";
		}else{
			document.getElementById("abaPesq"+i).className = "abaPesqMarcada";
			document.getElementById("div_pesquisa"+i).style.display = "block";
		}
	}
}
function mudaAbaPesq2(aba){
	//percorrendo as 3 abas do menu
	for(i=1;i<=3;i++){
		//se não for a aba que deve ser marcada
		if(i!=aba){
			document.getElementById("abaPesq2"+i).className = "abaPesqDesmarcada";
			document.getElementById("div_pesquisa2"+i).style.display = "none";
		}else{
			document.getElementById("abaPesq2"+i).className = "abaPesqMarcada";
			document.getElementById("div_pesquisa2"+i).style.display = "block";
		}
	}
}
<!-- FIM - SCRIPTS DAS ABAS -->

function buscaVagas(form){
	if(form.inputPesq.value==""){
		alert("Por favor, preencha o campo de pesquisa!!!");
		form.inputPesq.focus();
		return false;
	}
	var vaga = form.inputPesq.value;
	consultaAjaxText('ctrlImplementa.php','acao=buscarVagas&vaga='+vaga,'post','conteudo','carregando...');
	return false;
}
function buscaCurriculos(form){
	if(form.inputPesq.value==""){
		alert("Por favor, preencha o campo de pesquisa!!!");
		form.inputPesq.focus();
		return false;
	}
	var curriculo = form.inputPesq.value;
	consultaAjaxText('ctrlImplementa.php','acao=buscarCurriculos&curriculo='+curriculo,'post','conteudo','carregando...');
	return false;
}
function buscaEmpresas(form){
	if(form.inputPesq.value==""){
		alert("Por favor, preencha o campo de pesquisa!!!");
		form.inputPesq.focus();
		return false;
	}
	var empresa = form.inputPesq.value;
	consultaAjaxText('ctrlImplementa.php?acao=buscarEmpresas&empresa='+empresa,'','post','conteudo','carregando...');
	return false;
}
function mostraVaga(){
	var divVaga = document.getElementById("lv_conteudo_va");
	divVaga.style.display = "";
}
function fechaVaga(){
	var divVaga = document.getElementById("lv_conteudo_va");
	divVaga.style.display = "none";
}
function mudaVagasDest(acao){
	var qtdeVagasDest = document.getElementById("qtdeVagasDest");
	var vagaDestAtual = document.getElementById("vagaDestAtual");
	var newVaga;
	
	//verificando se vai avançar ou voltar
	if(acao=="avancar"){
		newVaga = parseInt(vagaDestAtual.value)+1;			
	}else if(acao=="voltar"){
		newVaga = parseInt(vagaDestAtual.value)-1;
		
		if(newVaga<0){
			newVaga = 0;
		}
	}
	
	vagaDestAtual.value = newVaga;
	
	//mudando a vaga a ser mostrada
	for(i=0;i<qtdeVagasDest.value;i++){
		//mostra a vaga atual
		if(i==newVaga){
			document.getElementById("vagaDestaque"+i).style.display = "block";	
		}
		//oculta as outras vagas
		else{
			document.getElementById("vagaDestaque"+i).style.display = "none";
		}
	}
	
	//se for a ultima 
	if(newVaga==(qtdeVagasDest.value-1)){
		vagaDestAtual.value = -1;
	}			
}

function ocultaMostraDiv(div){
	objDiv = document.getElementById(div);
	if(objDiv.style.display=="none"){
		objDiv.style.display = "";
	}else{
		objDiv.style.display = "none";
	}

}

function mostraHomeInt(newStatus) {
	//mostra ou oculta a div com os banners
	document.getElementById("bannerFloat").style.display = newStatus;
	
	//mostra ou oculta o botão
	document.getElementById("btnCadCurriculo").style.display = newStatus;
	
	//mostra ou oculta o botão
	document.getElementById("conteudo").style.display = newStatus;
}

function mudaNotDest(){
	var qtdeNotDest  = document.getElementById("qtdeNotDest");
	var notDestAtual = document.getElementById("notDestAtual");
	var newNot;
	
	//avancando a noticia
	newNot = parseInt(notDestAtual.value)+1;					
	
	notDestAtual.value = newNot;
	
	//mudando a vaga a ser mostrada
	for(i=0;i<qtdeNotDest.value;i++){
		//mostra a noticia atual
		if(i==newNot){
			document.getElementById("notDest"+i).style.display = "block";	
		}
		//oculta as outras noticias
		else{
			document.getElementById("notDest"+i).style.display = "none";
		}
	}
	
	//se for a ultima 
	if(newNot==(qtdeNotDest.value-1)){
		notDestAtual.value = -1;
	}			
}

function dispara(){
	setInterval("mudaVagasDest('avancar')", 3500);
	setInterval("mudaNotDest()", 3000);
}

/*function forcaSenha(str,div){
	var tam  = str.length;
	if(/^[a-zA-z0-9]+$/.test(str)){
		document.getElementById(div).className = "forte";
		document.getElementById(div).style.width = "150px";
	}else if(tam >= 5 && tam!=0){
		document.getElementById(div).className = "media";
		document.getElementById(div).style.width = "100px";
	}else if(tam < 5 && tam!=0){
		document.getElementById(div).className = "fraca";
		document.getElementById(div).style.width = "50px";
	}else if(tam == 0){
		document.getElementById(div).className = "";
	}
}*/
function verNivelSenha(valor,div) {
	
	if (valor && valor.length > 5) {
		
		//Nivel Forte
		var letras_numero 				= /^[a-zA-Z0-9]+$/;
		var letras_especial 			= /^[a-zA-Z-+*.,;:>'"¨°?ºª§¬¢£³²¹~ `´\\<{}\/!|\@#$%\]\[&()\^]+$/;
		var numero_letrabaixa_especial 	= /^[0-9a-z-+*.,;:>'"¨°?ºª§¬¢£³²¹~ `´\\<{}\/!|\@#$%\]\[&()\^]+$/;
		var numero_letraalta_especial 	= /^[0-9A-Z-+*.,;:>'"¨°?ºª§¬¢£³²¹~ `´\\<{}\/!|\@#$%\]\[&()\^]+$/;
		var todos 						= /^[a-zA-Z0-9-+*.,;:>'"¨°?ºª§¬¢£³²¹~ `´\\<{}\/!|\@#$%\]\[&()\^]+$/;
		
		if (letras_numero.test(valor) ||
			letras_especial.test(valor) ||
			numero_letrabaixa_especial.test(valor) ||
			numero_letraalta_especial.test(valor) ||
			todos.test(valor)
		) {
			
			document.getElementById(div).className = "forte";
			document.getElementById(div).style.width = "150px";
			
		} else {
			
			document.getElementById(div).className = "media";
			document.getElementById(div).style.width = "100px";
			
		}
		
		//Nivel Medio
		var letras 					= /^[a-zA-Z]+$/;
		var letrabaixa_numero 		= /^[a-z0-9]+$/;
		var letraalta_numero 		= /^[A-Z0-9]+$/;
		var letrabaixa_especial 	= /^[a-z-+*.,;:>'"¨°?ºª§¬¢£³²¹~ `´\\<{}\/!|\@#$%\]\[&()\^]+$/;
		var letraalta_especial 		= /^[A-Z-+*.,;:>'"¨°?ºª§¬¢£³²¹~ `´\\<{}\/!|\@#$%\]\[&()\^]+$/;
		var numero_especial 		= /^[0-9-+*.,;:>'"¨°?ºª§¬¢£³²¹~ `´\\<{}\/!|\@#$%\]\[&()\^]+$/;
			
		if (letras.test(valor) ||
			letrabaixa_numero.test(valor) ||
			letraalta_numero.test(valor) || 
			letrabaixa_especial.test(valor) ||
			letraalta_especial.test(valor) ||
			numero_especial.test(valor)
		) {
			
			document.getElementById(div).className = "media";
			document.getElementById(div).style.width = "100px";
		} 
	
		//Nivel Fraco
		var letrabaixa 	= /^[a-z]+$/;
		var letraalta 	= /^[A-Z]+$/;
		var numero 		= /^[0-9]+$/;
		var especial 	= /^[-+*.,;:>'"¨°?ºª§¬¢£³²¹~ `´\\<{}\/!|\@#$%\]\[&()\^]+$/;
	
		if (letrabaixa.test(valor) || 
			letraalta.test(valor) || 
			numero.test(valor) ||
			especial.test(valor)
		) {
			
			document.getElementById(div).className = "fraca";
			document.getElementById(div).style.width = "50px";
		}
		
	} else {
		
		document.getElementById(div).className = "";
		
	}
	
}

function validaFrmAltSenhaCandidato(form){
	if(form.senha_antiga.value==""){
		alert("Por favor, preencha o campo SENHA ANTIGA!");
		form.senha_antiga.focus();
		return false;
	}
	if(form.nova_senha.value==""){
		alert("Por favor, preencha o campo NOVA SENHA!");
		form.nova_senha.focus();
		return false;
	}
	if(form.confirmacao.value==""){
		alert("Por favor, preencha o campo CONFIRMAÇÃO DE SENHA!");
		form.confirmacao.focus();
		return false;
	}
	if(form.nova_senha.value!=form.confirmacao.value){
		alert("A senha nova é diferente da confirmação");
		form.nova_senha.value="";
		form.confirmacao.value="";
		form.nova_senha.focus();
		return false;
	}
	if(form.status.value==0){
		alert("A senha antiga não conferi!");
		form.senha_antiga.value = "";
		form.senha_antiga.focus();
		return false;
	}
	consultaAjaxText('ctrlImplementa.php','acao=alteraSenha&senha='+form.nova_senha.value,'post','conteudo','carregando...');
}

function comparaSenha(senha,div){
		consultaAjaxTextNoLoad('ctrlImplementa.php','acao=verificaSenha&senha='+senha,'post',div,'');
}

function submitFrmAutoriza(){
		var id = document.getElementById("id").value;
		var foto1 = document.getElementById("foto1");
		var telefone1 = document.getElementById("telefone1");
		var endereco1 = document.getElementById("endereco1");
		var curriculo1 = document.getElementById("curriculo1");
		if(foto1.checked==true){
			var foto = 1;
		}else{
			var foto = 0;	
		}
		if(telefone1.checked==true){
			var telefone = 1;
		}else{
			var telefone = 0;	
		}
		if(endereco1.checked==true){
			var endereco = 1;
		}else{
			var endereco = 0;	
		}
		if(curriculo1.checked==true){
			var curriculo = 1;
		}else{
			var curriculo = 0;	
		}
		consultaAjaxText('ctrlImplementa.php','acao=altAutoriza&id='+id+'&foto='+foto+'&telefone='+telefone+'&endereco='+endereco+'&curriculo='+curriculo,'post','conteudo','carregando...');
		return false;
}

function submitFrmDeficiencia(form){
	var possui1 = document.getElementById("possui1");
	if(possui1.checked==true){
		var possui = 1;
	}else{
		var possui = 0;
	}
	
	consultaAjaxText('ctrlImplementa.php','acao=altDeficiencia&id='+form.id.value+'&possui='+possui+'&tipo='+form.tipo.value+'&descricao='+form.descricao.value,'post','conteudo','Aguarde Carregando...');
	return false;
}

function verificaPossui(value){
	var tipo = document.getElementById("tipo");
	var descricao = document.getElementById("descricao");
	if(value==1){
		tipo.disabled = "";
		descricao.disabled = "";
		tipo.focus();
	}else{
		tipo.value = "0";
		descricao.value = "";
		tipo.disabled = "disabled";
		descricao.disabled = "disabled";
	}
}

function onloadDeficiencia(){
	var possui = document.getElementById("possui0");
	var tipo = document.getElementById("tipo");
	var descricao = document.getElementById("descricao");
	if(possui.checked==true){
		tipo.value = "0";
		descricao.value = "";
		tipo.disabled = "disabled";
		descricao.disabled = "disabled";
	}
}

function moeda(z){  
	v = z.value;
	v=v.replace(/\D/g,"")  //permite digitar apenas números
	v=v.replace(/[0-9]{12}/,"")   //limita pra máximo 999.999.999,99
	v=v.replace(/(\d{1})(\d{8})$/,"$1.$2")  //coloca ponto antes dos últimos 8 digitos
	v=v.replace(/(\d{1})(\d{5})$/,"$1.$2")  //coloca ponto antes dos últimos 5 digitos
	v=v.replace(/(\d{1})(\d{1,2})$/,"$1,$2")    //coloca virgula antes dos últimos 2 digitos
	z.value = v;
}