// JavaScript Document
reDecimalPt = /^[+-]?((\d+|\d{1,3}(\.\d{3})+)(\,\d*)?|\,\d+)$/;
var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
var reDecimal = reDecimalPt;
eval("reDecimal = reDecimalPt");

// Acionar o Ajax..
function createXMLHttpRequestInstance(){                  
	if (window.XMLHttpRequest) {           
		req = new XMLHttpRequest();    
	} else if (window.ActiveXObject) {
		isIE = true;
		req = new ActiveXObject("Microsoft.XMLHTTP");              
	}        
}

// Contar caractere em uma textarea
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
	{field.value = field.value.substring(0, maxlimit);}
else
	{countfield.value = maxlimit - field.value.length;}
}

// limpa todos os caracteres especiais do campo solicitado
function filtraCampo(campo){
	var s = "";
	var cp = "";
	vr = campo.value;
	tam = vr.length;
	for (i = 0; i < tam ; i++) {  
		if (vr.substring(i,i + 1) != "/" && vr.substring(i,i + 1) != "-" && vr.substring(i,i + 1) != "."  && vr.substring(i,i + 1) != "," ){
		 	s = s + vr.substring(i,i + 1);}
	}
	campo.value = s;
	return cp = campo.value
}

// Abrir opção para enviar mensagem
function mostrarDoisClicks(id){
	objDaughter=document.getElementById(id);
	if (objDaughter.style.display != 'block') {
		objDaughter.style.display='block';
	} else {
		objDaughter.style.display='none';
	}
}

// Abrir nova janela
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Mudar aba de noticias da capa inicial
function MaisDestaques(tp) {
	if (tp == "r") {
		document.getElementById("listarNoticiasRecentes").style.display='block';
		document.getElementById("listarNoticiasMaisLidas").style.display='none';
		document.getElementById("listarNoticiasCapital").style.display='none';
		document.getElementById("listarNoticiasInterior").style.display='none';
	} else if (tp == "m") {
		document.getElementById("listarNoticiasRecentes").style.display='none';
		document.getElementById("listarNoticiasCapital").style.display='none';
		document.getElementById("listarNoticiasInterior").style.display='none';
		document.getElementById("listarNoticiasMaisLidas").style.display='block';		
	} else if (tp == "c") {
		document.getElementById("listarNoticiasRecentes").style.display='none';
		document.getElementById("listarNoticiasMaisLidas").style.display='none';
		document.getElementById("listarNoticiasInterior").style.display='none';
		document.getElementById("listarNoticiasCapital").style.display='block';		
	} else if (tp == "i") {
		document.getElementById("listarNoticiasRecentes").style.display='none';
		document.getElementById("listarNoticiasMaisLidas").style.display='none';
		document.getElementById("listarNoticiasCapital").style.display='none';
		document.getElementById("listarNoticiasInterior").style.display='block';
	}
}

// Limpa valores de um campo
function limpa_string(S){
	// Deixa so' os digitos no numero
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";

	for (var i=0; i<S.length; i++)	{
		digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0)	{
			temp=temp+digito	}
	} //for

	return temp
}

// Área do classificado
function checkFormClassificado(form) {
	nome			= form.nome.value;
	email			= form.email.value;
	cidade			= form.idcidade.value;
	telefone		= form.telefone.value;	
	produto			= form.produto.value;
	descricao		= form.descricao.value;
	preco			= form.preco.value;
	tamanho_preco 	= form.preco.value.length;		
	
	if (nome == "") {
		alert("O nome do vendedor e obrigatorio!");
		form.nome.focus();
		return false;
	}

	if (cidade == "") {
		alert("A cidade e obrigatorio!");
		form.idcidade.focus();
		return false;
	}

	if (email != "") {
	    if (!(er.test(email))) { 
			alert("O campo e-mail deve ser conter um endereço eletronico valido!");
			form.email.focus();
			return false;
   	    }
	} else {
			alert("O campo e-mail deve ser conter um endereço eletronico valido!");
			form.email.focus();
			return false;
	}

	if (limpa_string(telefone) == "" || limpa_string(telefone) == 0) {
		alert("O telefone é obrigatorio e só pode conter números!");
		form.telefone.focus();
		return false;
	}

	if (produto == "") {
		alert("O nome do produto é obrigatório!");
		form.produto.focus();
		return false;
	}
	
	if (!reDecimal.test(preco)) {
		alert("O preço de venda informado está incorreto!");
		form.preco.focus();
		return false;
	}
	

	if (descricao == "") {
		alert("A descricao do produto é obrigatório!");
		form.descricao.focus();
		return false;
	}

	
	return true;
}

function foco_classificado(){
	document.cadclassificado.nome.focus();
}

function formataValor(campo) {
	campo.value = filtraCampo(campo);
	vr = campo.value;
	tam = vr.length;

	if ( tam <= 2 ){ 
 		campo.value = vr ; }
 	if ( (tam > 2) && (tam <= 5) ){
 		campo.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
 	if ( (tam >= 6) && (tam <= 8) ){
 		campo.value = vr.substr( 0, tam - 5 ) + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
 	if ( (tam >= 9) && (tam <= 11) ){
 		campo.value = vr.substr( 0, tam - 8 ) + vr.substr( tam - 8, 3 ) + vr.substr( tam - 5, 3 ) + ',' +  vr.substr( tam - 2, tam ) ; }
 	if ( (tam >= 12) && (tam <= 14) ){
 		campo.value = vr.substr( 0, tam - 11 ) + vr.substr( tam - 11, 3 ) + vr.substr( tam - 8, 3 ) +  vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
 	if ( (tam >= 15) && (tam <= 18) ){
 		campo.value = vr.substr( 0, tam - 14 ) + vr.substr( tam - 14, 3 ) + vr.substr( tam - 11, 3 ) + vr.substr( tam - 8, 3 ) +  vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;}
 		
}
// Fim do classificado

// Cadastro para enviar comentários.
function cadastroComentario(){
	    d = document.formcadastroComentario;
		erro=0;
		
		if (d.nome.value == ""){
			alert("O nome deve ser preenchido!");
			d.nome.focus();
			return false;
		}
		
		if (d.email.value == ""){
			alert("O e-mail deve ser preenchido!");
			d.email.focus();
			return false;
		}

	    if (!(er.test(d.email.value))) { 
			alert("O campo e-mail deve ser conter um endereço eletronico valido!");
			d.email.focus();
			return false;
   	    }

		if (d.senha.value == ""){
			alert("A senha deve ser preenchida!");
			d.senha.focus();
			return false;
		}
		
		if (d.senha.value != d.c_senha.value) {
			alert("A confirmação da senha está da errada!");
			d.c_senha.focus();
			return false;
		}
		
		if (d.endereco.value == ""){
			alert("O endereco deve ser preenchido!");
			d.endereco.focus();
			return false;
		}

		if (d.cidade.value == ""){
			alert("A cidade deve ser preenchida!");
			d.cidade.focus();
			return false;
		}

		if (d.telefone.value == ""){
			alert("O telefone deve ser preenchido!");
			d.telefone.focus();
			return false;
		}

		if (d.profissao.value == ""){
			alert("A profissao deve ser preenchida!");
			d.profissao.focus();
			return false;
		}

		return true;
}

function focoComentario(){
	document.formcadastroComentario.nome.focus();
}

function validaEmail() {
	createXMLHttpRequestInstance();
	var email			= document.getElementById('email').value;
	document.formcadastroComentario.button.disabled = false;
	document.all["carregando"].style.display = "";
	req.onreadystatechange = processaDados;
	req.open("GET","/buscaemail.php?email=" + email, true);  
	req.setRequestHeader("Content-Type", "application/x-www-urlencoded");
	req.send(null);
}

function processaDados() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			if (req.responseXML) {
				processaXMLCLIENTE(req.responseXML);
			}
		}
	}
}

function processaXMLCLIENTE(obj) {
	var nos 	= obj.getElementsByTagName("dadoscliente");
	for (var i=0; i<nos.length;i++) {
			var no = nos[i];
			if (no.childNodes[0].firstChild.nodeValue != "vazio") {
				alert("E-mail já cadastrado. Verifique");
				document.formcadastroComentario.email.value = "";
				document.formcadastroComentario.email.focus();
				document.all["carregando"].style.display = "none";
				document.formcadastroComentario.button.disabled = true;
			} else {
				document.formcadastroComentario.button.disabled = false;
			}
			document.all["carregando"].style.display = "none";
	}
}
// Fim dos comentários


// Inicio Você no rondoniaovivo
function foco_voce(){
	document.cadvoce.nome.focus();
}

function checkFormCadvoce(){
	    d = document.cadvoce;
	
		if (d.nome.value == ""){
			alert("O nome deve ser preenchido!");
			d.nome.focus();
			return false;
		}
		
		if (d.email.value == ""){
			alert("O e-mail deve ser preenchido!");
			d.email.focus();
			return false;
		}

	    if (!(er.test(d.email.value))) { 
			alert("O campo e-mail deve ser conter um endereço eletronico valido!");
			d.email.focus();
			return false;
   	    }

		if (d.telefone.value == ""){
			alert("O telefone deve ser preenchido!");
			d.telefone.focus();
			return false;
		}
		

		if (d.cidade.value == ""){
			alert("A cidade deve ser preenchido!");
			d.cidade.focus();
			return false;
		}

		if (d.titulo.value == ""){
			alert("O título do evento deve ser preenchido!");
			d.titulo.focus();
			return false;
		}

		if (d.data_evento.value == ""){
			alert("A data do evento deve ser preenchida!");
			d.data_evento.focus();
			return false;
		}

		if (d.local.value == ""){
			alert("O local do evento deve ser preenchido!");
			d.local.focus();
			return false;
		}

		if (d.fotografo.value == ""){
			alert("O fotografo deve ser preenchida!");
			d.fotografo.focus();
			return false;
		}

		if (d.arquivo.value == ""){
			alert("O arquivo deve ser selecionado!");
			d.arquivo.focus();
			return false;
		}

		if (d.descricao.value == ""){
			alert("O texto sobre o evento deve ser preenchido!");
			d.descricao.focus();
			return false;
		}

		return true;
}
// Fim do  Você no rondoniaovivo

// Fale conosco
function validacontato(){
	    d = document.formcontato;
		if (d.nome.value == ""){
			alert("O nome deve ser preenchido!");
			d.nome.focus();
			return false;
		}

		if (d.email.value == ""){
			alert("O e-mail deve ser preenchido!");
			d.email.focus();
			return false;
		}

	    if (!(er.test(d.email.value))) { 
			alert("O campo e-mail deve ser conter um endereço eletronico valido!");
			d.email.focus();
			return false;
   	    }

		if (d.mensagem.value == ""){
			alert("A mensagem deve ser preenchida!");
			d.mensagem.focus();
			return false;
		}

		return true;
}

function foco_fale(){
document.formcontato.nome.focus();
}

// Fim dos contatos

// Formulário de contato de classificado
function validacontatoclassificado(){
	    d = document.formcontatoclassificado;
		
		if (d.nome.value == ""){
			alert("O nome deve ser preenchido!");
			d.nome.focus();
			return false;
		}

		if (d.email.value == ""){
			alert("O e-mail deve ser preenchido!");
			d.email.focus();
			return false;
		}

	    if (!(er.test(d.email.value))) { 
			alert("O campo e-mail deve ser conter um endereço eletronico valido!");
			d.email.focus();
			return false;
   	    }

		if (d.horario.value == ""){
			alert("O horario deve ser escolhido!");
			d.horario.focus();
			return false;
		}

		if (d.mensagem.value == ""){
			alert("A mensagem deve ser preenchida!");
			d.mensagem.focus();
			return false;
		}

		return true;
}
// Fim dos classificados

// Enviar Comentarios
function focoComentarios(){
	document.formcontato.mensagem.focus();
}

function validaComentario(){
	    d = document.formComentario;
		if (d.mensagem.value == ""){
			alert("A mensagem deve ser preenchida!");
			d.mensagem.focus();
			return false;
		}

		return true;
}
// Fim dos comentarios

// Valida Login Comentario
function validaloginComentario(){
	    d = document.formloginComentario;

		if (d.email.value == ""){
			alert("O e-mail deve ser preenchido!");
			d.email.focus();
			return false;
		}

	    if (!(er.test(d.email.value))) { 
			alert("O campo e-mail deve ser conter um endereço eletronico valido!");
			d.email.focus();
			return false;
   	    }

		if (d.senha.value == ""){
			alert("A senha deve ser preenchida!");
			d.senha.focus();
			return false;
		}

		return true;
}

function validaesqueceu(){
	    d = document.formesqueceu;
		if (d.receber_email.value == ""){
			alert("O e-mail deve ser preenchido!");
			d.receber_email.focus();
			return false;
		}
		
	    if (!(er.test(d.receber_email.value))) { 
			alert("O campo e-mail deve ser conter um endereço eletronico valido!");
			d.receber_email.focus();
			return false;
   	    }
		return true;
}

function focoLogin(){
document.formloginComentario.email.focus();
}
// Fim Login Comentario

// Busca Vídeo
function validabuscavideo(){
	    d = document.busca_video;
		if (d.descricao.value.length < 3){
			alert("O critério de pesquisa deve ser preenchido !");
			d.descricao.focus();
			return false;
		}
		return true;
}
// Fim dos Vídeos

// Busca Topo
function validabuscatopo(){
	    d = document.busca_topo;
		if (d.descricao.value.length < 3){
			alert("O critério de pesquisa deve ser preenchido !");
			d.descricao.focus();
			return false;
		}
		return true;
}
// Fim dos Topo

// Data do site..
hoje = new Date()
dia = hoje.getDate()
dias = hoje.getDay()
mes = hoje.getMonth()
ano = hoje.getFullYear()

if (dia < 10)
		dia = "0" + dia

function CriaArray (n) {
this.length = n }

NomeDia = new CriaArray(7)
NomeDia[0] = "Domingo"
NomeDia[1] = "Segunda"
NomeDia[2] = "Terça"
NomeDia[3] = "Quarta"
NomeDia[4] = "Quinta"
NomeDia[5] = "Sexta"
NomeDia[6] = "Sábado"

NomeMes = new CriaArray(12)
NomeMes[0] = "Janeiro"
NomeMes[1] = "Fevereiro"
NomeMes[2] = "Mar&ccedil;o"
NomeMes[3] = "Abril"
NomeMes[4] = "Maio"
NomeMes[5] = "Junho"
NomeMes[6] = "Julho"
NomeMes[7] = "Agosto"
NomeMes[8] = "Setembro"
NomeMes[9] = "Outubro"
NomeMes[10] = "Novembro"
NomeMes[11] = "Dezembro"
//
function WriteDate() {
	document.write (dia + " de " + NomeMes[mes] + " de " + ano)
}

// Busca Você
function validabuscavoce(){
	    d = document.busca_voce;
		if (d.descricao.value.length < 3 || d.descricao.value == "Digite aqui o texto" ){
			alert("O critério de pesquisa deve ser preenchido !");
			d.descricao.focus();
			return false;
		}
		return true;
}
// Fim dos Você


// Dados da Enquete
var xmlhttp = getXmlHttpRequest();
var d=document;

function getXmlHttpRequest() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest(); } 
		
		else if (window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP"); 
	}
}


function res_enquete(op)	{
	id_p = document.enquete.id_p.value;
	id_r = document.enquete.id_r.value;
	
	xmlhttp.open("GET", '/enquete.php?todo='+op+'&id_p='+id_p+'&id_r='+id_r, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	xmlhttp.setRequestHeader("Pragma", "no-cache");

	xmlhttp.onreadystatechange = function() {
	
	   if (xmlhttp.readyState==1) {
			d.getElementById("enqueteInternoBox").innerHTML = "<img src='/imagens/carregando.gif' />";
	   }
	
	   if (xmlhttp.readyState==4) {
		 if(xmlhttp.status == 200) {

			d.getElementById("enqueteInternoBox").innerHTML = xmlhttp.responseText;
			}
			
		else {
			d.getElementById("enqueteInternoBox").innerHTML = "Erro:" + xmlhttp.status;
		}	
	   }
	  }	
	xmlhttp.send(null);

}

function voto(id)	{
	document.enquete.id_r.value = id;
}

function votar_enquete()	{
	if (document.enquete.id_r.value == "") {
		alert("Por favor, selecione uma opcao!");
		return false;
     }	else {
		res_enquete('votar'); 
	 }
	 
	 return true;
}

function parcial()	{
		res_enquete('parcial'); 
}

function voltar_enquete()	{
	xmlhttp.open("GET", '/voltar_enquete.php', true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	xmlhttp.setRequestHeader("Pragma", "no-cache");

	xmlhttp.onreadystatechange = function() {
	
	   if (xmlhttp.readyState==1) {
			d.getElementById("enqueteInternoBox").innerHTML = "<img src='/imagens/carregando.gif' />";
	   }
	
	   if (xmlhttp.readyState==4) {
		 if(xmlhttp.status == 200) {

			d.getElementById("enqueteInternoBox").innerHTML = xmlhttp.responseText;
			}
			
		else {
			d.getElementById("enqueteInternoBox").innerHTML = "Erro:" + xmlhttp.status;
		}	
	   }
	  }	
	xmlhttp.send(null);

}
// fim da enquete

// Janela
    function openPergunta(news){
		var url = '/enviarComentario.php?news='+news;
        respostaWindow=dhtmlmodal.open('RespostaBox', 'iframe', url, 'Enviar Comentário', 'width=450px,height=485px,center=1,resize=0,scrollbars=no','recal');                         
        
        return false;                
    }             

    function openDenuncia(clas){
		var url = '/denunciarClassificado.php?clas='+clas;
        respostaWindow=dhtmlmodal.open('RespostaBox', 'iframe', url, 'Denunciar Classificado', 'width=450px,height=485px,center=1,resize=0,scrollbars=no','recal');                         
        
        return false;                
    }             

	function reloadPage(){   
	   javascript:location.reload();   
	}  
// Fim da Janela

// Janela
    function openIndicar(news){
		var url = '/indicar.php?news='+news;
        respostaWindow=dhtmlmodal.open('RespostaBox', 'iframe', url, 'Indicar Notícia', 'width=450px,height=580px,center=1,resize=0,scrollbars=no','recal');                         
        
        return false;                
    }             
// Fim da Janela

// Validar formulário de envio de noticias
function validaEnviar(){
	//validar descricao da posto
	d = document.enviarnoticia;
	
	if (d.nome_destinatario.value == ""){
		alert("O nome do seu amigo deve ser preenchido!");
		d.nome_destinatario.focus();
		return false;
	}

	//validar email
	if (!(er.test(d.email_destinatario.value))) { 
		alert("O campo e-mail do seu amigo deve ser preenchido!");
		d.email_destinatario.focus();
		return false;
	}
	
	if (d.nome.value == ""){
		alert("O campo seu nome deve ser preenchido!");
		d.nome.focus();
		return false;
	}

	//validar email
	if (!(er.test(d.email_remetente.value))) { 
		alert("O campo e-mail do seu amigo deve ser preenchido!");
		d.email_remetente.focus();
		return false;
	}

	return true;
}

// Fim da validação

// Busca Classificado
function validabuscaclassificado(){
	    d = document.busca_classificado;
		if ((d.descricao.value.length < 3 || d.descricao.value == "Digite aqui o texto") && d.ct.value == "" ){
			alert("Voce deve escolher um criterio de busca!");
			d.descricao.focus();
			return false;
		}
		return true;
}
// Fim dos Você


function validaGuia() {
	d = document.cadguia;
	var conta = 0;

	if (d.titulo.value == "") {
		alert("O título é obrigatorio!");
		d.titulo.focus();
		return false;
	}

	if (d.tipo_guia.value == "") {
		alert("Você deve selecionar um tipo de Custo");
		d.posicao.focus();
		return false;
	}

	if (d.tipo_guia.value == "Gold") {
		
		if (d.noticia_interna.checked) {
			conta++;
		}

		if (d.leitura_noticia.checked) {
			conta++;
		}

		if (d.inicial_classificado.checked) {
			conta++;
		}
		
		if (d.caderno_interno.checked) {
			conta++;
		}

		if (d.visualizacao_classificado.checked) {
			conta++;
		}

		if (d.video.checked) {
			conta++;
		}

		if (conta != 2) {
			alert("Você deve selecionar 2 categorias");
			d.noticia_interna.focus();
			return false;
		}
		
	}

	return true;
}

function mostraPosicao(opcao) {
	objDaughter=document.getElementById("selecionaPosicao");
	if (opcao == "Gold") {
		document.getElementById("posicao1").checked=false;
		objDaughter.style.display='block';		
	} else {
		document.getElementById("posicao").checked=false;
		objDaughter.style.display='none';				
	}
	document.cadguia.tipo_guia.value = opcao;;
}

function foco_guia(){
	document.cadguia.titulo.focus();
}

function formataCampo(campo, Mascara, evento) { 
    var boleanoMascara; 

    var Digitato = evento.keyCode;
    exp = /\-|\.|\/|\(|\)| /g
    campoSoNumeros = campo.value.toString().replace( exp, "" ); 
   
    var posicaoCampo = 0;     
    var NovoValorCampo="";
    var TamanhoMascara = campoSoNumeros.length;; 

    if (Digitato != 8) { // backspace 
        for(i=0; i<= TamanhoMascara; i++) { 
            boleanoMascara  = ((Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".")
                                || (Mascara.charAt(i) == "/")) 
            boleanoMascara  = boleanoMascara || ((Mascara.charAt(i) == "(") 
                                || (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " ")) 
            if (boleanoMascara) { 
                NovoValorCampo += Mascara.charAt(i); 
                  TamanhoMascara++;
            }else { 
                NovoValorCampo += campoSoNumeros.charAt(posicaoCampo); 
                posicaoCampo++; 
              }            
          }     
        campo.value = NovoValorCampo;
          return true; 
    }else { 
        return true; 
    }
}
//adiciona mascara de data
function MascaraData(data){
    if(mascaraInteiro(data)==false){
        event.returnValue = false;
    }    
    return formataCampo(data, '00/00/0000', event);
}
function mascaraInteiro(){
    if (event.keyCode < 48 || event.keyCode > 57){
        event.returnValue = false;
        return false;
    }
    return true;
}

function MascaraCep(cep){
        if(mascaraInteiro(cep)==false){
        event.returnValue = false;
    }    
    return formataCampo(cep, '00.000-000', event);
}

function focoLink(){
	document.cadlink.nome.focus();
}

// Validar formulário de envio de noticias
function validaLink(){
	//validar descricao da posto
	d = document.cadlink;
	
	if (d.nome.value == ""){
		alert("O nome deve ser preenchido!");
		d.nome.focus();
		return false;
	}

	//validar email
	if (!(er.test(d.email.value))) { 
		alert("O campo e-mail do seu amigo deve ser preenchido!");
		d.email.focus();
		return false;
	}
	
	if (d.telefone.value == ""){
		alert("O campo telefone deve ser preenchido!");
		d.telefone.focus();
		return false;
	}

	if (d.titulo.value == ""){
		alert("O título do link deve ser preenchido!");
		d.titulo.focus();
		return false;
	}

	if (d.url.value == ""){
		alert("O endereço do site/link deve ser preenchido!");
		d.url.focus();
		return false;
	}

	if (d.texto.value == ""){
		alert("O texto sobre o link deve ser preenchido!");
		d.texto.focus();
		return false;
	}

	return true;
}

// Busca Guia
function validabuscaGuia(){
	    d = document.busca_guia;
		if (d.descricao.value.length < 3){
			alert("O critério de pesquisa deve ser preenchido !");
			d.descricao.focus();
			return false;
		}
		return true;
}

function validabuscaGuiaInicial(){
	    d = document.busca_guia;
		if ((d.descricao.value.length < 3) && (d.cat.value == "")) {
			alert("O critério de pesquisa deve ser preenchido ou selecionar uma categoria!");
			d.descricao.focus();
			return false;
		}
		return true;
}



function geraTwitter()	{
	xmlhttp.open("GET", 'inc_twitter.php', true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	xmlhttp.setRequestHeader("Pragma", "no-cache");

	xmlhttp.onreadystatechange = function() {
	
	   if (xmlhttp.readyState==1) {
			d.getElementById("twitter").innerHTML = "<img src='imagens/indicator.gif' />";
	   }
	
	   if (xmlhttp.readyState==4) {
		 if(xmlhttp.status == 200) {

			d.getElementById("twitter").innerHTML = xmlhttp.responseText;
			}
			
		else {
			d.getElementById("twitter").innerHTML = "Erro:" + xmlhttp.status;
		}	
	   }
	  }	
	xmlhttp.send(null);
}


// Cadastro para enviar comentários.
function cadastroTorpedo(){
	    d = document.formTorpedo;
		erro=0;
		
		if (d.de.value == ""){
			alert("O nome deve ser preenchido!");
			d.de.focus();
			return false;
		}
		
		if (d.email.value == ""){
			alert("O e-mail deve ser preenchido!");
			d.email.focus();
			return false;
		}

	    if (!(er.test(d.email.value))) { 
			alert("O campo e-mail deve ser conter um endereço eletronico valido!");
			d.email.focus();
			return false;
   	    }

		if (d.cidade.value == ""){
			alert("O cidade deve ser preenchida!");
			d.cidade.focus();
			return false;
		}

		if (d.mensagem.value == ""){
			alert("A mensagem deve ser preenchida!");
			d.mensagem.focus();
			return false;
		}
		return true;
}


// Janela
function openRadio(titulo, pagina){
	var url = '/'+pagina;
	respostaWindow=dhtmlmodal.open('RespostaBox', 'iframe', url, titulo, 'width=705px,height=500px,center=1,resize=0,scrollbars=no','recal');
	return false;                
}             
// Fim da Janela


function mascara_data(data,campo){ 
  var mydata = ''; 
  mydata = mydata + data; 
  
  if (mydata.length == 2){ 
	  mydata = mydata + '/'; 
	  document.getElementById(campo).value = mydata; 
  } 
  if (mydata.length == 5){ 
	  mydata = mydata + '/'; 
	  document.getElementById(campo).value = mydata; 
  } 
} 

function verifica_data (campo, valor) { 

	dia = limpa_string(valor.substring(0,2)); 
	mes = limpa_string(valor.substring(3,5)); 
	ano = limpa_string(valor.substring(6,10)); 
	
	situacao = ""; 
	// verifica o dia valido para cada mes 
	if ((dia < 01)||(dia < 01 || dia > 30) && (  mes == 04 || mes == 06 || mes == 09 || mes == 11 ) || dia > 31) { 
		situacao = "falsa"; 
	} 
	
	// verifica se o mes e valido 
	if (mes < 01 || mes > 12 ) { 
		situacao = "falsa"; 
	} 
	
	// verifica se e ano bissexto 
	if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { 
		situacao = "falsa"; 
	} 
	
	if (valor == "") { 
		situacao = "falsa"; 
	} 
	
	if (situacao == "falsa") { 
		alert("A data é invalida!");
		document.getElementById(campo).focus();		
		return false;
	} 

	return true;
} 


// JavaScript Document
function validaPasso1(form) {
	var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	var nome			= document.getElementById('nome').value;
	var estado_civil	= document.getElementById('estado_civil').value;	
	var data_nascimento	= document.getElementById('data_nascimento').value;
	var cpf				= document.getElementById('cpf').value;
	var endereco		= document.getElementById('endereco').value;
	var bairro			= document.getElementById('bairro').value;
	var idcidade		= document.getElementById('idcidade').value;
	var iduf			= document.getElementById('iduf').value;
	var cep				= document.getElementById('cep').value;
	var email			= document.getElementById('email').value;
	var tamanho_email  	= document.getElementById('email').value.length;
	
	if (nome == "") {
		alert("A nome é obrigatório!");
		document.getElementById('nome').focus();
		return false;
	}
	

	preencheu = false;
	botoes = form.sexo.length;
	for (i=0;i<botoes;i++) {
		if (form.sexo[i].checked) {
			preencheu = true;
			break; 
		}
	}
	
	if (!preencheu) {
		alert("O sexo é obrigatório!");
		document.getElementById('sexo').focus();
		return false;
	}

	if (estado_civil == "") {
		alert("O estado civil é obrigatório!");
		document.getElementById('estado_civil').focus();
		return false;
	}

	if (!verifica_data('data_nascimento',data_nascimento))
			return false;
	
	if (limpa_string(cpf) == "") {
		alert("O cpf é obrigatorio e só pode conter números!");
		document.getElementById('cpf').focus();
		return false;
	}
	
	if (!ValidarCPF(curriculum.cpf)) {
		document.getElementById('cpf').focus();
		return false;
	}
	
	if (endereco == "") {
		alert("O endereço é obrigatório!");
		document.getElementById('endereco').focus();
		return false;
	}

	if (bairro == "") {
		alert("O bairro é obrigatório!");
		document.getElementById('bairro').focus();
		return false;
	}

	if (iduf == "") {
		alert("É obrigatorio escolher um estado!");
		document.getElementById('iduf').focus();
		return false;
	}


	if (idcidade == "") {
		alert("O cidade é obrigatório!");
		document.getElementById('idcidade').focus();
		return false;
	}


	if (cep == "") {
		alert("O cep é obrigatório!");
		document.getElementById('cep').focus();
		return false;
	}

	if (tamanho_email <= 0) {
		alert("O campo e-mail deve ser conter um endereço eletronico valido!");
		document.getElementById('email').focus();
		return false;
	} else {
		if (!(er.test(email))) { 
			alert("O campo e-mail deve ser conter um endereço eletronico valido!");
			document.getElementById('email').focus();
			return false;
		}
	}

	return true;
}

function focoCurriculum1(){
	document.curriculum.nome.focus();
}

function focoCurriculum2(){
	document.curriculum.nivel.focus();
}

function focoCurriculum3(){
	document.curriculum.ultima_nome_empresa.focus();
}

function focoCurriculum4(){
	document.curriculum.id_primeira_funcao.focus();
}

function confirmaCurriculo(form) {
	concordo		= form.concordo.checked;
	if (concordo == "") {
		alert("Voce deve concordar com os termos da inscricao!");
		form.concordo.focus();
		return false;
	}
	return true;
}

function Dadosb(campo,arquivo,valor) {
//verifica se o browser tem suporte a ajax
	try {
    	ajax = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(ex) {
			try {
				ajax = new XMLHttpRequest();
			} catch(exc) {
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
	}
	if(ajax) {
		document.curriculum.elements[campo].options.length = 1;
		idOpcao  = document.getElementById("opcoes");
		ajax.open("POST", ""+arquivo+"", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function() {
			
//enquanto estiver processando...emite a msg de carregando
		if(ajax.readyState == 1) {
			idOpcao.innerHTML = "Carregando...!";   
		}
//após ser processado - chama função processXML que vai varrer os dados
		if(ajax.readyState == 4 ) {
			if(ajax.responseXML) {
				processXMLb(campo,ajax.responseXML);
			} else {
//caso não seja um arquivo XML emite a mensagem abaixo
				idOpcao.innerHTML = "Selecione o Item Acima.";
			}
		}
	}
//passa o código do estado escolhido
	var params = "consulta="+valor;
//	alert(params);
	ajax.send(params);
	}
}
  
function processXMLb(campo,obj){
      //pega a tag cidade

      var dataArray   = obj.getElementsByTagName("opc");

	  //total de elementos contidos na tag cidade
	  if(dataArray.length > 0) {
	     //percorre o arquivo XML paara extrair os dados
         for(var i = 0 ; i < dataArray.length ; i++) {
            var item = dataArray[i];
			//contéudo dos campos no arquivo XML
			var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
			var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
			
	        idOpcao.innerHTML = "Selecione uma Opção";
			
			//cria um novo option dinamicamente  
			var novo = document.createElement("option");
			    //atribui um ID a esse elemento
			    novo.setAttribute("id", "opcoes");
				//atribui um valor
			    novo.value = codigo;
				//atribui um texto
			    novo.text  = descricao;
				document.curriculum.elements[campo].options.add(novo);
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "Seleciona uma Opção Abaixo";
	}	  
}

//valida o CPF digitado
function ValidarCPF(Objcpf){
    var cpf = Objcpf.value;
    exp = /\.|\-/g
    cpf = cpf.toString().replace( exp, "" ); 
    var digitoDigitado = eval(cpf.charAt(9)+cpf.charAt(10));
    var soma1=0, soma2=0;
    var vlr =11;
    
    for(i=0;i<9;i++){
        soma1+=eval(cpf.charAt(i)*(vlr-1));
        soma2+=eval(cpf.charAt(i)*vlr);
        vlr--;
    }    
    soma1 = (((soma1*10)%11)==10 ? 0:((soma1*10)%11));
    soma2=(((soma2+(2*soma1))*10)%11);
    
    var digitoGerado=(soma1*10)+soma2;
    if(digitoGerado!=digitoDigitado) {
        alert('Atenção: CPF Inválido!');
		return false;
	}
		
	return true;
}

function ValidaCNPJ(cnpj) { 
  var i = 0; 
  var l = 0; 
  var strNum = ""; 
  var strMul = "6543298765432"; 
  var character = ""; 
  var iValido = 1; 
  var iSoma = 0; 
  var strNum_base = ""; 
  var iLenNum_base = 0; 
  var iLenMul = 0; 
  var iSoma = 0; 
  var strNum_base = 0; 
  var iLenNum_base = 0; 
 
  if (cnpj == "") 
        return false; 
 
  l = cnpj.length; 
  for (i = 0; i < l; i++) { 
        caracter = cnpj.substring(i,i+1) 
        if ((caracter >= '0') && (caracter <= '9')) 
           strNum = strNum + caracter; 
  }; 
 
  if(strNum.length != 14) 
        return false; 
 
  strNum_base = strNum.substring(0,12); 
  iLenNum_base = strNum_base.length - 1; 
  iLenMul = strMul.length - 1; 
  for(i = 0;i < 12; i++) 
        iSoma = iSoma + 
		parseInt(strNum_base.substring((iLenNum_base-i),(iLenNum_base-i)+1),10) * 
		parseInt(strMul.substring((iLenMul-i),(iLenMul-i)+1),10); 
 
  iSoma = 11 - (iSoma - Math.floor(iSoma/11) * 11); 
  if(iSoma == 11 || iSoma == 10) 
        iSoma = 0; 
 
  strNum_base = strNum_base + iSoma; 
  iSoma = 0; 
  iLenNum_base = strNum_base.length - 1 
  for(i = 0; i < 13; i++) 
        iSoma = iSoma + 
		parseInt(strNum_base.substring((iLenNum_base-i),(iLenNum_base-i)+1),10) * 
		parseInt(strMul.substring((iLenMul-i),(iLenMul-i)+1),10) 
 
  iSoma = 11 - (iSoma - Math.floor(iSoma/11) * 11); 
  if(iSoma == 11 || iSoma == 10) 
        iSoma = 0; 
  strNum_base = strNum_base + iSoma; 
  if(strNum != strNum_base) 
        return false; 
 
  return true; 
 
}



// JavaScript Document
function validaBuscaCurr(form) {
	var funcao			= document.getElementById('funcao').value;
	var iduf			= document.getElementById('iduf').value;
	var idcidade		= document.getElementById('idcidade').value;
	var sexo			= document.getElementById('sexo').value;
	
	if (funcao == "" && idcidade == "" && sexo == "") {
		alert("Você deve escolher pelo menos 1 critério de busca!");
		document.getElementById('funcao').focus();
		return false;
	}

	return true;
}

// JavaScript Document
function validaBuscaVaga(form) {
	var funcao			= document.getElementById('funcao').value;
	var iduf			= document.getElementById('iduf').value;
	var idcidade		= document.getElementById('idcidade').value;
	
	if (funcao == "" && idcidade == "") {
		alert("Você deve escolher pelo menos 1 critério de busca!");
		document.getElementById('funcao').focus();
		return false;
	}

	return true;
}

function loginCur() {
	var cpf 		  = limpa_string(document.getElementById('cpfCurriculo').value);
	var dataCurriculo = document.getElementById('dataCurriculo').value;
	
	if (!ValidarCPF(loginCurriculum.cpfCurriculo)) {
		document.getElementById('cpfCurriculo').focus();
		return false;
	}
	
	if (!verifica_data('dataCurriculo',dataCurriculo))
			return false;
			
	return true;
}

function altCurriculum(form) {
	var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	var nome			= document.getElementById('nome').value;
	var sexo			= document.getElementById('sexo').value;
	var data_nascimento	= document.getElementById('data_nascimento').value;
	var endereco		= document.getElementById('endereco').value;
	var bairro			= document.getElementById('bairro').value;
	var idcidade		= document.getElementById('idcidade').value;
	var iduf			= document.getElementById('iduf').value;
	var cep				= document.getElementById('cep').value;
	var email			= document.getElementById('email').value;
	var tamanho_email  	= document.getElementById('email').value.length;
	var id_primeira_funcao	= document.getElementById('id_primeira_funcao').value;

	if (nome == "") {
		alert("A nome é obrigatorio!");
		document.getElementById('nome').focus();
		return false;
	}
	
	if (sexo == "") {
		alert("A sexo é obrigatorio!");
		document.getElementById('sexo').focus();
		return false;
	}

	if (!verifica_data('data_nascimento',data_nascimento))
			return false;
	
	if (endereco == "") {
		alert("O endereço é obrigatorio!");
		document.getElementById('endereco').focus();
		return false;
	}

	if (bairro == "") {
		alert("O bairro é obrigatorio!");
		document.getElementById('bairro').focus();
		return false;
	}

	if (iduf == "") {
		alert("O estado é obrigatorio!");
		document.getElementById('iduf').focus();
		return false;
	}

	if (idcidade == "") {
		alert("A cidade é obrigatorio!");
		document.getElementById('idcidade').focus();
		return false;
	}


	if (cep == "") {
		alert("O cep é obrigatorio!");
		document.getElementById('cep').focus();
		return false;
	}

	if (tamanho_email <= 0) {
		alert("O campo e-mail deve ser conter um endereço eletronico valido!");
		document.getElementById('email').focus();
		return false;
	} else {
		if (!(er.test(email))) { 
			alert("O campo e-mail deve ser conter um endereço eletronico valido!");
			document.getElementById('email').focus();
			return false;
		}
	}

	if (id_primeira_funcao == "") {
		alert("A primeira função deve ser escolhida!");
		document.getElementById('id_primeira_funcao').focus();
		return false;
	}
	
	return true;
}

function focoaltCur(){
	document.curriculum.nome.focus();
}

function loginCurEmp() {
	var identificacao 		  = limpa_string(document.getElementById('identificacao').value);
	var senhaLogin 			= document.getElementById('senhaLogin').value;
	
	if (!identificacao) {
		alert("Você deve preencher o CPF/CNPJ!");
		document.getElementById('identificacao').focus();
		return false;
	}
	
	if (!senhaLogin) {
		alert("Você deve preencher a senha!");
		document.getElementById('senhaLogin').focus();
		return false;
	}
	
	return true;
}



function mostraLogin(valor) {
	if (valor == "1") {
		document.getElementById("loginCurriculum").style.display='block';
		document.getElementById("loginEmpresa").style.display='none';
	} else if (valor == "2") {
		document.getElementById("loginEmpresa").style.display='block';
		document.getElementById("loginCurriculum").style.display='none';
	}
}


function validaempresaCurriculum(form) {
	var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	var cpf_cnpj		= document.getElementById('cpf_cnpj').value;
	var tamanho_cpf_cnpj= document.getElementById('cpf_cnpj').value.length;
	var nome_fantasia	= document.getElementById('nome_fantasia').value;
	var razao_social	= document.getElementById('razao_social').value;
	var idcidade		= document.getElementById('idcidade').value;
	var email			= document.getElementById('email').value;
	var tamanho_email  	= document.getElementById('email').value.length;
	var senha			= document.getElementById('senha').value;
	var c_senha			= document.getElementById('c_senha').value;
	var contato			= document.getElementById('contato').value;
	var cep				= document.getElementById('cep').value;
	
	
	if (limpa_string(cpf_cnpj) == "") {
		alert("O cpf/cnpj é obrigatorio e só pode conter números!");
		document.getElementById('cpf_cnpj').focus();
		return false;
	}
	
	if (tamanho_cpf_cnpj == 11) {
		if (!ValidarCPF(empresaCurriculum.cpf_cnpj)) {
			document.getElementById('cpf_cnpj').focus();
			return false;
		}
	} else {
		if (!ValidaCNPJ(cpf_cnpj)) {
			alert("O CNPJ informado é invalido!");
			document.getElementById('cpf_cnpj').focus();
			return false;
		}
		
	}
	
	
	if (nome_fantasia == "") {
		alert("A nome fantasia é obrigatorio!");
		document.getElementById('nome_fantasia').focus();
		return false;
	}


	if (razao_social == "") {
		alert("A razão social é obrigatorio!");
		document.getElementById('razao_social').focus();
		return false;
	}

	if (tamanho_email <= 0) {
		alert("O campo e-mail deve ser conter um endereço eletronico valido!");
		document.getElementById('email').focus();
		return false;
	} else {
		if (!(er.test(email))) { 
			alert("O campo e-mail deve ser conter um endereço eletronico valido!");
			document.getElementById('email').focus();
			return false;
		}
	}

	if (senha == "") {
		alert("A senha deve ser preenchida!");
		document.getElementById('senha').focus();
		return false;
	}


	if (senha != c_senha) {
		alert("A confirmação da senha esta diferente da senha!");
		document.getElementById('c_senha').focus();
		return false;
	}

	if (idcidade == "") {
		alert("A cidade é obrigatorio!");
		document.getElementById('idcidade').focus();
		return false;
	}


	if (cep == "") {
		alert("O cep é obrigatorio!");
		document.getElementById('cep').focus();
		return false;
	}


	if (contato == "") {
		alert("O nome da pessoa de contato deve ser preenchido!");
		document.getElementById('contato').focus();
		return false;
	}
	
	
	var id_funcao_curriculum		= document.getElementById('id_funcao_curriculum').value;
	var nivel						= document.getElementById('nivel').value;
	var salario						= document.getElementById('salario').value;
	var horario_trabalho			= document.getElementById('horario_trabalho').value;
	var contatoVaga					= document.getElementById('contatoVaga').value;
	
	if (id_funcao_curriculum == "") {
		alert("Você deve selecionar uma função principal!");
		document.getElementById('id_funcao_curriculum').focus();
		return false;
	}

	if (nivel == "") {
		alert("O nível de escolaridade é obrigátorio!");
		document.getElementById('nivel').focus();
		return false;
	}

	if (salario == "") {
		alert("O salário deve ser preenchido!");
		document.getElementById('salario').focus();
		return false;
	}

	if (horario_trabalho == "") {
		alert("O horário de trabalho deve ser preenchido!");
		document.getElementById('horario_trabalho').focus();
		return false;
	}

	if (contatoVaga == "") {
		alert("O nome da pessoa de contato desta vaga ser preenchido!");
		document.getElementById('contatoVaga').focus();
		return false;
	}
	
	return true;
}

function fococadEmp(){
	document.empresaCurriculum.cpf_cnpj.focus();
}

function fococadEmpAlt(){
	document.empresaCurriculum.nome_fantasia.focus();
}

function Dadosba(campo,arquivo,valor) {
//verifica se o browser tem suporte a ajax
	try {
    	ajax = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(ex) {
			try {
				ajax = new XMLHttpRequest();
			} catch(exc) {
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
	}
	if(ajax) {
		document.empresaCurriculum.elements[campo].options.length = 1;
		idOpcao  = document.getElementById("opcoes");
		ajax.open("POST", ""+arquivo+"", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function() {
			
//enquanto estiver processando...emite a msg de carregando
		if(ajax.readyState == 1) {
			idOpcao.innerHTML = "Carregando...!";   
		}
//após ser processado - chama função processXML que vai varrer os dados
		if(ajax.readyState == 4 ) {
			if(ajax.responseXML) {
				processXMLba(campo,ajax.responseXML);
			} else {
//caso não seja um arquivo XML emite a mensagem abaixo
				idOpcao.innerHTML = "Selecione o Item Acima.";
			}
		}
	}
//passa o código do estado escolhido
	var params = "consulta="+valor;
//	alert(params);
	ajax.send(params);
	}
}
  
function processXMLba(campo,obj){
      //pega a tag cidade

      var dataArray   = obj.getElementsByTagName("opc");

	  //total de elementos contidos na tag cidade
	  if(dataArray.length > 0) {
	     //percorre o arquivo XML paara extrair os dados
         for(var i = 0 ; i < dataArray.length ; i++) {
            var item = dataArray[i];
			//contéudo dos campos no arquivo XML
			var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
			var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
			
	        idOpcao.innerHTML = "Selecione uma Opção";
			
			//cria um novo option dinamicamente  
			var novo = document.createElement("option");
			    //atribui um ID a esse elemento
			    novo.setAttribute("id", "opcoes");
				//atribui um valor
			    novo.value = codigo;
				//atribui um texto
			    novo.text  = descricao;
				document.empresaCurriculum.elements[campo].options.add(novo);
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "Seleciona uma Opção Abaixo";
	}	  
}


function validaempresaCurriculumAlt(form) {
	var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	var nome_fantasia	= document.getElementById('nome_fantasia').value;
	var razao_social	= document.getElementById('razao_social').value;
	var idcidade		= document.getElementById('idcidade').value;
	var email			= document.getElementById('email').value;
	var tamanho_email  	= document.getElementById('email').value.length;
	var senha			= document.getElementById('senha').value;
	var c_senha			= document.getElementById('c_senha').value;
	var contato			= document.getElementById('contato').value;
	var cep				= document.getElementById('cep').value;
	
	
	if (nome_fantasia == "") {
		alert("A nome fantasia é obrigatorio!");
		document.getElementById('nome_fantasia').focus();
		return false;
	}


	if (razao_social == "") {
		alert("A razão social é obrigatorio!");
		document.getElementById('razao_social').focus();
		return false;
	}

	if (tamanho_email <= 0) {
		alert("O campo e-mail deve ser conter um endereço eletronico valido!");
		document.getElementById('email').focus();
		return false;
	} else {
		if (!(er.test(email))) { 
			alert("O campo e-mail deve ser conter um endereço eletronico valido!");
			document.getElementById('email').focus();
			return false;
		}
	}
	
	if (senha) {
		if (senha == "") {
			alert("A senha deve ser preenchida!");
			document.getElementById('senha').focus();
			return false;
		}
	
	
		if (senha != c_senha) {
			alert("A confirmação da senha esta diferente da senha!");
			document.getElementById('c_senha').focus();
			return false;
		}
	}

	if (idcidade == "") {
		alert("A cidade é obrigatorio!");
		document.getElementById('idcidade').focus();
		return false;
	}


	if (cep == "") {
		alert("O cep é obrigatorio!");
		document.getElementById('cep').focus();
		return false;
	}


	if (contato == "") {
		alert("O nome da pessoa de contato deve ser preenchido!");
		document.getElementById('contato').focus();
		return false;
	}

	return true;
}

function validavagaEmp(form) {
	var id_funcao_curriculum		= document.getElementById('id_funcao_curriculum').value;
	var nivel						= document.getElementById('nivel').value;
	var salario						= document.getElementById('salario').value;
	var horario_trabalho			= document.getElementById('horario_trabalho').value;
	var contatoVaga					= document.getElementById('contatoVaga').value;
	
	if (id_funcao_curriculum == "") {
		alert("Você deve selecionar uma função principal!");
		document.getElementById('id_funcao_curriculum').focus();
		return false;
	}

	if (nivel == "") {
		alert("O nível de escolaridade é obrigátorio!");
		document.getElementById('nivel').focus();
		return false;
	}

	if (salario == "") {
		alert("O salário deve ser preenchido!");
		document.getElementById('salario').focus();
		return false;
	}

	if (horario_trabalho == "") {
		alert("O horário de trabalho deve ser preenchido!");
		document.getElementById('horario_trabalho').focus();
		return false;
	}

	if (contatoVaga == "") {
		alert("O nome da pessoa de contato desta vaga ser preenchido!");
		document.getElementById('contatoVaga').focus();
		return false;
	}
	
	return true;
}

function focovagaEmp(){
	document.empresaCurriculum.id_funcao_curriculum.focus();
}


function paginaCurr(pagina) {
	try {
    	ajax = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(ex) {
			try {
				ajax = new XMLHttpRequest();
			} catch(exc) {
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
	}
	if(ajax) {
		exibeResultado  = document.getElementById("curriLista");
		ajax.open("POST", "paginaCurriclum.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function() {
		if(ajax.readyState == 1) {
			exibeResultado.innerHTML = "<img src='/imagens/carregando.gif' />";
		}
		if(ajax.readyState == 4 ) {
			if(ajax.status == 200) { 
				var resultado = ajax.responseText; // Coloca o retornado pelo Ajax nessa variável 
				exibeResultado.innerHTML = resultado;
			} else { 
				exibeResultado.innerHTML = "Erro: ."; 
			} 
		}
	}
	var params = "pagina="+pagina;
	ajax.send(params);
	}
}


function paginaVaga(pagina) {
	try {
    	ajax = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(ex) {
			try {
				ajax = new XMLHttpRequest();
			} catch(exc) {
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
	}
	if(ajax) {
		exibeResultado  = document.getElementById("curriVagas");
		ajax.open("POST", "paginaVaga.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function() {
		if(ajax.readyState == 1) {
			exibeResultado.innerHTML = "<img src='/imagens/carregando.gif' />";
		}
		if(ajax.readyState == 4 ) {
			if(ajax.status == 200) { 
				var resultado = ajax.responseText; // Coloca o retornado pelo Ajax nessa variável 
				exibeResultado.innerHTML = resultado;
			} else { 
				exibeResultado.innerHTML = "Erro: ."; 
			} 
		}
	}
	var params = "pagina="+pagina;
	ajax.send(params);
	}
}


function Dadosbac(campo,arquivo,valor) {
//verifica se o browser tem suporte a ajax
	try {
    	ajax = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(ex) {
			try {
				ajax = new XMLHttpRequest();
			} catch(exc) {
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
	}
	if(ajax) {
		document.cadclassificado.elements[campo].options.length = 1;
		idOpcao  = document.getElementById("opcoes");
		ajax.open("POST", ""+arquivo+"", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.onreadystatechange = function() {
			
//enquanto estiver processando...emite a msg de carregando
		if(ajax.readyState == 1) {
			idOpcao.innerHTML = "Carregando...!";   
		}
//após ser processado - chama função processXML que vai varrer os dados
		if(ajax.readyState == 4 ) {
			if(ajax.responseXML) {
				processXMLbac(campo,ajax.responseXML);
			} else {
//caso não seja um arquivo XML emite a mensagem abaixo
				idOpcao.innerHTML = "Selecione o Item Acima.";
			}
		}
	}
//passa o código do estado escolhido
	var params = "consulta="+valor;
//	alert(params);
	ajax.send(params);
	}
}
  
function processXMLbac(campo,obj){
      //pega a tag cidade

      var dataArray   = obj.getElementsByTagName("opc");

	  //total de elementos contidos na tag cidade
	  if(dataArray.length > 0) {
	     //percorre o arquivo XML paara extrair os dados
         for(var i = 0 ; i < dataArray.length ; i++) {
            var item = dataArray[i];
			//contéudo dos campos no arquivo XML
			var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
			var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
			
	        idOpcao.innerHTML = "Selecione uma Opção";
			
			//cria um novo option dinamicamente  
			var novo = document.createElement("option");
			    //atribui um ID a esse elemento
			    novo.setAttribute("id", "opcoes");
				//atribui um valor
			    novo.value = codigo;
				//atribui um texto
			    novo.text  = descricao;
				document.cadclassificado.elements[campo].options.add(novo);
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "Seleciona uma Opção Abaixo";
	}	  
}

