//////////////////////////////////////////////////////////////////////////



//SOLICITACAO DO COMPONENTE DO BROWSER (AJAX)



//////////////////////////////////////////////////////////////////////////







function GetXmlHttpObject()



{



var xmlHttp=null;



try



  {



  // Firefox, Opera 8.0+, Safari



  xmlHttp=new XMLHttpRequest();



  }



catch (e)



  {



  // Internet Explorer



  try



    {



    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");



    }



  catch (e)



    {



    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");



    }



  }



return xmlHttp;



}







//////////////////////////////////////////////////////////////////////////



// Consulta de AJAX



//////////////////////////////////////////////////////////////////////////



function puxacidade(estado) {

	if (estado=='')	{

		alerte('Selecione um ESTADO v&aacute;lido.');

		return;

	}else{

		var pPagina		=	'http://www.jacasei.com.br/ca/megajax.php?todo=novo_estado&estado='+document.pag.novo_estado.value + '&sid='+Math.random();

		// alert(pPagina);

		if(document.getElementById) { // Para os browsers complacentes com o DOM W3C.

				var Ajax = GetXmlHttpObject(); // Inicia o Ajax.

				if (Ajax==null)

				  {

				  alerte("Your browser does not support AJAX!");

				  return;

				  }

				Ajax.open("GET", pPagina, true); // fazendo a requisicao

				Ajax.onreadystatechange = function() {

					if(Ajax.readyState == 1) { // Quando estiver carregando, exibe: carregando...

						alerte('Consultando Cidades...');
					}

					if(Ajax.readyState == 4) { // Quando estiver tudo pronto.

						if(Ajax.status == 200) {	

							var xmlDoc= Ajax.responseXML.documentElement;

							document.getElementById("mostracidade").style.display='block';

							var cidades = xmlDoc.getElementsByTagName("cidade");
							
							//Apaga tudo menos o primeiro...
							while (document.getElementById("novo_cidade").options.length > 1){
								document.getElementById("novo_cidade").options[1]=null;
							}
							
							// coloca todas as cidades
							xxx=0;
							for (var c in cidades){

								if (cidades[xxx].childNodes[2].childNodes[0].nodeValue!='') {
									yyy=document.getElementById("novo_cidade").options.length++;
									
									document.getElementById("novo_cidade").options[yyy].text = cidades[xxx].childNodes[2].childNodes[0].nodeValue;
									document.getElementById("novo_cidade").options[yyy].value = cidades[xxx].childNodes[0].childNodes[0].nodeValue;
									desalerte();
								}
								xxx++;
							}
							
						}

					}

				}

				Ajax.send(null);

		}

	}

}

function wiz_puxacidade(estado) {

	if (estado=='')	{

		alert('Selecione um ESTADO v&aacute;lido.');

		return;

	}else{

		var pPagina		=	'http://www.jacasei.com.br/ca/megajax.php?todo=novo_estado&estado='+estado + '&sid='+Math.random();

		// alert(pPagina);

		if(document.getElementById) { // Para os browsers complacentes com o DOM W3C.

				var Ajax = GetXmlHttpObject(); // Inicia o Ajax.

				if (Ajax==null)

				  {

				  alert("Your browser does not support AJAX!");

				  return;

				  }

				Ajax.open("GET", pPagina, true); // fazendo a requisicao

				Ajax.onreadystatechange = function() {

					if(Ajax.readyState == 1) { // Quando estiver carregando, exibe: carregando...

						// alert('Consultando Cidades...');
					}

					if(Ajax.readyState == 4) { // Quando estiver tudo pronto.

						if(Ajax.status == 200) {	

							var xmlDoc= Ajax.responseXML.documentElement;

							document.getElementById("wiz_cidade").style.display='block';

							var cidades = xmlDoc.getElementsByTagName("cidade");
							
							//Apaga tudo menos o primeiro...
							while (document.getElementById("wiz_cidade").options.length > 1){
								document.getElementById("wiz_cidade").options[1]=null;
							}
							
							// coloca todas as cidades
							xxx=0;
							for (var c in cidades){

								if (cidades[xxx].childNodes[2].childNodes[0].nodeValue!='') {
									yyy=document.getElementById("wiz_cidade").options.length++;
									
									document.getElementById("wiz_cidade").options[yyy].text = cidades[xxx].childNodes[2].childNodes[0].nodeValue;
									document.getElementById("wiz_cidade").options[yyy].value = cidades[xxx].childNodes[0].childNodes[0].nodeValue;
								}
								xxx++;
							}
							
						}

					}

				}

				Ajax.send(null);

		}

	}

}



function callcpc() {

	if (document.pag.wiz_categoria.value=='') {
		alert('Selecione uma Categoria obter sugestão de CPC');
		document.pag.wiz_categoria.focus();
		return;
	}
	
	if (document.pag.wiz_estado.value=='') {
		alert('Selecione um Estado para obter sugestão de CPC');
		document.pag.wiz_estado.focus();
		return;
	}
	
	if (document.pag.wiz_cidade.value=='') {
		alert('Selecione uma Cidade para obter sugestão de CPC');
		document.pag.wiz_cidade.focus();
		return;
	}

	var pPagina		=	'http://www.jacasei.com.br/ca/megajax.php?todo=wizard_cpc&cidade='+document.pag.wiz_cidade.value+'&categoria='+document.pag.wiz_categoria.value + '&sid='+Math.random();
	
	//document.getElementById("wizminicpc").innerHTML=pPagina;
	
		//alert(pPagina);

		if(document.getElementById) { // Para os browsers complacentes com o DOM W3C.
				var Ajax = GetXmlHttpObject(); // Inicia o Ajax.
				if (Ajax==null)
				  {
					  alert ("Your browser does not support AJAX!");
					  return;
				  }
				Ajax.open("GET", pPagina, true); // fazendo a requisicao
				//Ajax.setRequestHeader("Connection", "close");
				Ajax.onreadystatechange = function() {
					if(Ajax.readyState == 1) { // Quando estiver carregando, exibe: carregando...
					}

					if(Ajax.readyState == 4) { // Quando estiver tudo pronto.
						if(Ajax.status == 200) {	
							var xmlDoc= Ajax.responseXML.documentElement;
							alert('O CPC para a primeira posição nesta cidade é de R$ '+xmlDoc.getElementsByTagName("cpcsugerido")[0].childNodes[0].nodeValue);
							document.getElementById("wizminicpc").innerHTML	=	"R$ " + xmlDoc.getElementsByTagName("cpcmin")[0].childNodes[0].nodeValue;
							document.pag.wiz_cpc.value							=	xmlDoc.getElementsByTagName("cpcsugerido")[0].childNodes[0].nodeValue;
							document.pag.wiz_cpc_min.value						=	xmlDoc.getElementsByTagName("cpcmin")[0].childNodes[0].nodeValue;
						}
					}
				}
				Ajax.send(null);
		}
}







/* /// FUNCAO QUE VALIDA DADOS //*/



function limpex(strlimp){



	



	strlimp= strlimp.replace(/(\.|\(|\)|\/|\-| )+/g,'');



	return strlimp;



}



function valida_cpf(cpf)



{



	  cpf=limpex(cpf);



      var numeros, digitos, soma, i, resultado, digitos_iguais;



      digitos_iguais = 1;



      if (cpf.length < 11)



            return false;



      for (i = 0; i < cpf.length - 1; i++)



            if (cpf.charAt(i) != cpf.charAt(i + 1))



                  {



                  digitos_iguais = 0;



                  break;



                  }



      if (!digitos_iguais)



            {



            numeros = cpf.substring(0,9);



            digitos = cpf.substring(9);



            soma = 0;



            for (i = 10; i > 1; i--)



                  soma += numeros.charAt(10 - i) * i;



            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;



            if (resultado != digitos.charAt(0))



                  return false;



            numeros = cpf.substring(0,10);



            soma = 0;



            for (i = 11; i > 1; i--)



                  soma += numeros.charAt(11 - i) * i;



            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;



            if (resultado != digitos.charAt(1))



                  return false;



            return true;



            }



      else



            return false;



}



function valida_cnpj(cnpj)



{



	cnpj=limpex(cnpj);



  	var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;



      digitos_iguais = 1;



      if (cnpj.length < 14 && cnpj.length < 15)



            return false;



      for (i = 0; i < cnpj.length - 1; i++)



            if (cnpj.charAt(i) != cnpj.charAt(i + 1))



                  {



                  digitos_iguais = 0;



                  break;



                  }



      if (!digitos_iguais)



            {



            tamanho = cnpj.length - 2



            numeros = cnpj.substring(0,tamanho);



            digitos = cnpj.substring(tamanho);



            soma = 0;



            pos = tamanho - 7;



            for (i = tamanho; i >= 1; i--)



                  {



                  soma += numeros.charAt(tamanho - i) * pos--;



                  if (pos < 2)



                        pos = 9;



                  }



            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;



            if (resultado != digitos.charAt(0))



                  return false;



            tamanho = tamanho + 1;



            numeros = cnpj.substring(0,tamanho);



            soma = 0;



            pos = tamanho - 7;



            for (i = tamanho; i >= 1; i--)



                  {



                  soma += numeros.charAt(tamanho - i) * pos--;



                  if (pos < 2)



                        pos = 9;



                  }



            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;



            if (resultado != digitos.charAt(1))



                  return false;



            return true;



            }



      else



            return false;



} 







////////////////////////////////



function Mascara(tipo, campo, teclaPress) {



    if (window.event)



    {



        var tecla = teclaPress.keyCode;



    } else {



        tecla = teclaPress.which;



    }







    var s = new String(campo.value);



    // Remove todos os caracteres à seguir: ( ) / - . e espaço, para tratar a string denovo.



    s = s.replace(/(\.|\(|\)|\/|\-| )+/g,'');







    tam = s.length + 1;







    if ( tecla != 9 && tecla != 8 ) {



		



		



        switch (tipo)



        {



        case 'CPF' :



            if (tam > 3 && tam < 7)



                campo.value = s.substr(0,3) + '.' + s.substr(3, tam);



            if (tam >= 7 && tam < 10)



                campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,tam-6);



            if (tam >= 10 && tam < 12)



                campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,3) + '-' + s.substr(9,tam-9);



        break;







        case 'CNPJ' :







            if (tam > 2 && tam < 6)



                campo.value = s.substr(0,2) + '.' + s.substr(2, tam);



            if (tam >= 6 && tam < 9)



                campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,tam-5);



            if (tam >= 9 && tam < 13)



                campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,tam-8);



            if (tam >= 13 && tam < 15)



                campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,4)+ '-' + s.substr(12,tam-12);



        break;







        case 'TEL' :



            if (tam > 2 && tam < 4)



                campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,tam);



            if (tam >= 7 && tam < 11)



                campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,4) + '-' + s.substr(6,tam-6);



        break;







        case 'DATA' :



            if (tam > 2 && tam < 4)



                campo.value = s.substr(0,2) + '/' + s.substr(2, tam);



            if (tam > 4 && tam < 11)



                campo.value = s.substr(0,2) + '/' + s.substr(2,2) + '/' + s.substr(4,tam-4);



        break;



        



        case 'CEP' :



            if (tam > 5 && tam < 7)



                campo.value = s.substr(0,5) + '-' + s.substr(5, tam);



        break;



		



		case 'VALOR' :



		// Em caso de moeda a coisa é diferente...



		s = s.replace(/R/g,'');



		s = s.replace(/\$/g,'');



		s = s.replace(/\,/g,'');



		tam = s.length + 1;



		



            if (tam > 0 && tam < 7)



                campo.value = s.substr(0,(tam-3)) + ',' + s.substr((tam-3),2);



			if (tam ==7)



                campo.value = s.substr(0,(tam-6)) + '.' + s.substr((tam-6),(tam-4)) + ',' + s.substr((tam-3),2);			



			if (tam ==8)



                campo.value = s.substr(0,(tam-6)) + '.' + s.substr((tam-6),(tam-5)) + ',' + s.substr((tam-3),2);			



			if (tam ==9)



                campo.value = s.substr(0,(tam-6)) + '.' + s.substr((tam-6),(tam-6)) + ',' + s.substr((tam-3),2);			



        }



    }



}







function Precifica(xcampo, xteclaPress){



	Mascara('VALOR',xcampo, xteclaPress);



	upkey('preco');



}







// Adaptação do Cödigo Original para JC



function Mascarax(xcampo, xteclaPress){
	if (document.pag.wiz_tipo.options[document.pag.wiz_tipo.selectedIndex].value=='pf') {
		return Mascara('CPF',xcampo, xteclaPress);
	}else{
		return Mascara('CNPJ',xcampo, xteclaPress);
	}
}







//--->Função para verificar se o valor digitado é número...<---



function digitos(event){



    if (window.event) {



        // IE



        key = event.keyCode;



    } else if ( event.which ) {



        // netscape



        key = event.which;



    }



    if ( key != 8 || key != 13 || key < 48 || key > 57 )



        return ( ( ( key > 47 ) && ( key < 58 ) ) || ( key == 8 ) || ( key == 13 ) );



    return true;



}



//////////////////////////////////////////////////////







function checkcpc(){



	if (document.pag.wiz_categoria.value!='' && document.pag.wiz_cidade.value!='' && document.pag.wiz_cpc.value=='0,00'){



	callcpc();



	}



}











function calogin(){



if (document.pag.login_email.value==''){



	alert('Informe o e-mail');



	document.pag.login_email.focus();



	return;



}



if (document.pag.login_senha.value==''){



	alert('Informe a senha');



	document.pag.login_senha.focus();



	return;



}



document.pag.method='POST';



document.pag.submit();



}



function cawizard(va){



	document.pag.todo.value=va;



	document.pag.method='GET';



	document.pag.submit();



}



function capasse(){



/*



if (document.pag.wiz_pagamento[0].checked==false && document.pag.wiz_pagamento[1].checked==false){



	alert('Escolha uma forma de Pagamento');



	document.pag.wiz_pagamento[0].focus();



	return;



}



*/



if (document.pag.wiz_categoria.value==''){



	alert('Escolha uma Categoria onde o seu anúncio será exibido');



	document.pag.wiz_categoria.focus();



	return;



}

if (document.pag.wiz_estado.value==''){


	
	alert('Escolha o Estado onde atua a sua empresa');



	document.pag.wiz_estado.focus();



	return;



}

if (document.pag.wiz_cidade.value==''){


	
	alert('Escolha a Cidade onde atua a sua empresa');



	document.pag.wiz_cidade.focus();



	return;



}



if (document.pag.wiz_anuncio_titulo.value==''){



	alert('Digite um Título para o seu anúncio');



	document.pag.wiz_anuncio_titulo.focus();



	return;



}



if (document.pag.wiz_anuncio_descricao.value==''){



	alert('Digite uma Descrição para o seu anúncio');



	document.pag.wiz_anuncio_descricao.focus();



	return;



}



if (document.pag.wiz_cpc.value==''){



	alert('Digite o CPC que deseja pagar em cada clique recebido');



	document.pag.wiz_cpc.focus();



	return;



}



if (document.pag.wiz_exibe[0].checked==false && document.pag.wiz_exibe[1].checked==false){



	alert('Escolha uma forma de Exibição (Site ou Telefone)');



	document.pag.wiz_exibe[0].focus();



	return;



}



if (document.pag.wiz_exibe[0].checked==true && document.pag.wiz_site.value==''){



	alert('Informe o endereço do seu site com http://');



	document.pag.wiz_site.focus();



	return;



}



if (document.pag.wiz_exibe[0].checked==true && check_it(document.pag.wiz_site.value)==false){



	alert('Informe a URL com http://');



	document.pag.wiz_site.focus();



	return;



}



if (document.pag.wiz_exibe[1].checked==true && document.pag.wiz_tel.value==''){



	alert('Informe o seu telefone com DDD');



	document.pag.wiz_tel.focus();



	return;



}



document.pag.action='http://www.jacasei.com.br/ca/';



document.pag.todo.value='novaconta';



document.pag.method='post';



document.pag.submit();



}



function check_it(theurl) {



     var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/



     if (tomatch.test(theurl))



     {



         return true;



     }



     else



     {



         return false; 



     }



}



function check_mail(themail) {



     var tomatch= /[A-Za-z0-9]\@[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/



     if (tomatch.test(themail))



     {



         return true;



     }



     else



     {



         return false; 



     }



}



function upkey(uk_campo){



	if (uk_campo=='titulo'){



		document.getElementById("sim_titulo").innerHTML		=	document.pag.wiz_anuncio_titulo.value;



	}



	if (uk_campo=='descricao'){



		document.getElementById("sim_descricao").innerHTML	=	document.pag.wiz_anuncio_descricao.value;



	}



	if (uk_campo=='preco'){



		if (document.pag.wiz_anuncio_preco.value=='')



			document.getElementById("sim_preco").innerHTML='';



		else



			document.getElementById("sim_preco").innerHTML		=	'R$ ' + document.pag.wiz_anuncio_preco.value;



	}



	if (uk_campo=='catcid'){
		//alert("_"+document.pag.wiz_cidade.value+"_"+document.pag.wiz_categoria.value);
		if (document.pag.wiz_cidade.value==''||document.pag.wiz_categoria.value==''){
			cc='';
		}else{
			cc=(document.pag.wiz_cidade.options[document.pag.wiz_cidade.selectedIndex].text + ' > ' + document.pag.wiz_categoria.options[document.pag.wiz_categoria.selectedIndex].text);
		}
		//alert(cc);
		document.getElementById("sim_catcid").innerHTML=cc;
	}
	
	if (uk_campo=='wiz_estado'){
		wiz_puxacidade(document.getElementById("wiz_estado").options[document.getElementById("wiz_estado").selectedIndex].text);
	}



	if (uk_campo=='novo_categoria'){



		if (document.pag.novo_categoria.options[document.pag.novo_categoria.selectedIndex].text!='Escolha uma categoria...'){



			cc=document.pag.novo_categoria.options[document.pag.novo_categoria.selectedIndex].text;



		}else{



			cc='';



		}



		document.getElementById("simula-categ").innerHTML=cc;



	}

	

	if (uk_campo=='novo_estado'){

		

		puxacidade(document.pag.novo_estado.options[document.pag.novo_estado.selectedIndex].text);

		

	}

	



	if (uk_campo=='novo_titulo'){



		document.getElementById("simula-titulo").innerHTML		=	document.pag.novo_titulo.value;



	}



	if (uk_campo=='novo_descricao'){



		document.getElementById("simula-descricao").innerHTML	=	document.pag.novo_descricao.value;



	}







}







function cafim(cafimvar){


	if (document.pag.wiz_tipo.options[document.pag.wiz_tipo.selectedIndex].value=='pf'){
	
			if (document.pag.wiz_nomerazao.value==''){
				alert('Informe o seu Nome Completo');
				document.pag.wiz_nomerazao.focus();
				return;
			}
	
			if (document.pag.wiz_cpfcnpj.value==''){
				alert('Informe o seu CPF');
				document.pag.wiz_cpfcnpj.focus();
				return;
			}
	
			if (valida_cpf(document.pag.wiz_cpfcnpj.value)==false){
				alert('O CPF foi informado errado ou contém erros. Favor corrigir.');
				document.pag.wiz_cpfcnpj.focus();
				return;
			}
	
	}else{
	
			if (document.pag.wiz_nomerazao.value==''){
				alert('Informe a Razão Social da sua empresa');
				document.pag.wiz_nomerazao.focus();
				return;
			}
	
			if (document.pag.wiz_cpfcnpj.value==''){
				alert('Informe o CNPJ da sua empresa');
				document.pag.wiz_cpfcnpj.focus();
				return;
			}
	
			if (valida_cnpj(document.pag.wiz_cpfcnpj.value)==false){
				alert('O CNPJ foi informado errado ou contém erros. Favor corrigir.');
				document.pag.wiz_cpfcnpj.focus();
				return;
			}
	}



	if (cafimvar=='full') {



		if (document.pag.wiz_conta_email.value==''){
	
	
	
			alert('Informe um e-mail para Cadastro');
	
	
	
			document.pag.wiz_conta_email.focus();
	
	
	
			return;
	
	
	
		}
	
	
	
		if (check_mail(document.pag.wiz_conta_email.value)==false){
	
	
	
			alert('Informe um e-mail válido');
	
	
	
			document.pag.wiz_conta_email.focus();
	
	
	
			return;
	
	
	
		}
	
	
	
		if (document.pag.wiz_conta_senha.value==''){
	
	
	
			alert('Informe uma senha para sua nova conta');
	
	
	
			document.pag.wiz_conta_senha.focus();
	
	
	
			return;
	
	
	
		}
	
	
	
		var senha=document.pag.wiz_conta_senha.value;
	
	
	
		if (senha.toString().length < 6){
	
	
	
			alert('A senha deve conter no mínimo 6 dígitos');
	
	
	
			document.pag.wiz_conta_senha.focus();
	
	
	
			return;
	
	
	
		}
	
	
	
		if (document.pag.wiz_conta_confirma.value==''){
	
	
	
			alert('Digite novamente a senha no campo Confirma');
	
	
	
			document.pag.wiz_conta_confirma.focus();
	
	
	
			return;
	
	
	
		}
	
	
	
		if (document.pag.wiz_conta_confirma.value!=document.pag.wiz_conta_senha.value){
	
	
	
			alert('As senhas digitadas não conferem. Digite novamente a senha no campo confirma');
	
	
	
			document.pag.wiz_conta_confirma.value='';
	
	
	
			document.pag.wiz_conta_confirma.focus();
	
	
	
			return;
	
	
	
		}



	}
	document.pag.todo.value='criaconta';
	document.pag.method='post';
	document.pag.submit();
}



function cadtipo(){

if (document.pag.wiz_tipo.options[document.pag.wiz_tipo.selectedIndex].value=='pf'){
	document.getElementById("cadnomerazao").innerHTML='Nome:';
	document.getElementById("cadcpfcnpj").innerHTML='CPF:';
}else{
	document.getElementById("cadnomerazao").innerHTML='Razão Social:';
	document.getElementById("cadcpfcnpj").innerHTML='CNPJ:';
}



}







/* Funcoes da CA HOME */







function goform(forme){



if (forme=='home'){



	if (document.caform.ca_periodo[0].checked==false&&document.caform.ca_periodo[1].checked==false) {



	alert('Escolha um tipo de filtro');



	document.caform.ca_periodo[0].focus();



	return;



	}



	if (document.caform.ca_periodo[1].checked==true) {



		if (document.caform.ca_periodo_d1.value=='') {



			alert("Informe a data inicial do período.");



			document.caform.ca_periodo_d1.focus();



			return;



		}



		if (document.caform.ca_periodo_d2.value=='') {



			alert("Informe a data final do período.");



			document.caform.ca_periodo_d2.focus();



			return;



		}



	}



	document.caform.submit();



}



}







function doanuncio(vardo){



	if (vardo=='osall'){



		var cks = document.getElementsByName("os");



		if (document.caform.osall.checked==true) {



			for (var x=0;x<cks.length;x++){			



				document.caform.os[x].checked=true;



			}



		}else{



			document.caform.osall.checked=false;



			for (var x=0;x<cks.length;x++){			



				document.caform.os[x].checked=false;



			}



		}



	}



	if (vardo=='pausar'||vardo=='ativar'||vardo=='excluir'){



		var cks = document.getElementsByName("os");



		i='';



			if (cks.length==1){



				if (document.caform.os.checked==true) {



						i = document.caform.os.value;



				};



			}else{



				for (var x=0;x<cks.length;x++){			



					if (document.caform.os[x].checked==true) {



						if (i!=''){ 



							i=i+'|';



						}



						i = i + document.caform.os[x].value;



					};



				}



			}



		if (i=='') {



			alert('Escolha uma oferta para '+vardo+'.');



			return;



		}



		document.caform.action='/ca/executar';



		document.caform.todo.value=vardo;



		document.caform.process.value=i;



		document.caform.submit();



	}







}

function alerte($mensagem){

	document.getElementById("avisomensagem").innerHTML=$mensagem;

	document.getElementById("novoaviso").style.display='block';

}

function desalerte(){
	document.getElementById("novoaviso").style.display='none';
}

function novocapasse(valor){



	desalerte();


	if (document.pag.novo_categoria.value==''){
		alerte('Escolha uma categoria onde vai anunciar...');
		document.pag.novo_categoria.focus();
		return;
	}
	
	if (document.pag.novo_estado.value==''){
		alerte('Escolha o estado onde atua...');
		document.pag.novo_estado.focus();
		return;
	}
	
	if (document.pag.novo_estado.value!=''&&document.pag.novo_cidade.value==''){
		alerte('Escolha a cidade onde atua...');
		document.pag.novo_cidade.focus();
		return;
	}


	if (document.pag.novo_titulo.value==''){
		alerte('Digite um T&iacute;tulo para o seu an&uacute;ncio');
		document.pag.novo_titulo.focus();
		return;
	}



	if (document.pag.novo_descricao.value==''){
		alerte('Digite uma Descri&ccedil;&atilde;o para o seu an&uacute;ncio');
		document.pag.novo_descricao.focus();
		return;
	}



	if (document.pag.novo_exibe[0].checked==false && document.pag.novo_exibe[1].checked==false){

		alerte('Escolha uma forma de Exibi&ccedil;&atilde;o (Site ou Telefone)');

		document.pag.novo_exibe[0].focus();

		return;



	}



	if (document.pag.novo_exibe[0].checked==true && document.pag.novo_site.value==''){



		alerte('Informe o endere&ccedil;o do seu site com http://');



		document.pag.novo_site.focus();



		return;



	}



	if (document.pag.novo_exibe[0].checked==true && check_it(document.pag.novo_site.value)==false){



		alerte('Informe a URL com http://');



		document.pag.novo_site.focus();



		return;



	}



	if (document.pag.novo_exibe[1].checked==true && document.pag.novo_tel.value==''){



		alerte('Informe o seu telefone com DDD');



		document.pag.novo_tel.focus();



		return;



	}



	if (document.pag.novo_cpc.value==''){



		alerte('Digite o CPC que deseja pagar em cada clique recebido');



		document.pag.novo_cpc.focus();



		return;



	}



	document.pag.action='http://www.jacasei.com.br/ca/executar';
	
	if (valor=='editar') {
		document.pag.todo.value='editaranuncio';
	}else{
		document.pag.todo.value='novoanuncio';
	}

	document.pag.method='get';

	document.pag.submit();



}

function upfoto()

{

window.open("http://www.jacasei.com.br/ca/ferramentas?todo=upload", "Upload de Foto", "height = 200, width = 400");
}


function novocallcpc() {

	if (document.pag.novo_categoria.value=='')	{

		alerte('Selecione uma Categoria para obter sugest&atilde;o de CPC');

		return;

	}else{

		var pPagina		=	'http://www.jacasei.com.br/ca/megajax.php?todo=novo_cpc&categoria='+document.pag.novo_categoria.value + '&sid='+Math.random();

		if(document.getElementById) { // Para os browsers complacentes com o DOM W3C.

				var Ajax = GetXmlHttpObject(); // Inicia o Ajax.

				if (Ajax==null)

				  {

				  alerte("Your browser does not support AJAX!");

				  return;

				  }

				Ajax.open("GET", pPagina, true); // fazendo a requisicao

				Ajax.onreadystatechange = function() {

					if(Ajax.readyState == 1) { // Quando estiver carregando, exibe: carregando...

						alerte('Consultando CPC...');

					}

					if(Ajax.readyState == 4) { // Quando estiver tudo pronto.

						if(Ajax.status == 200) {	

							var xmlDoc= Ajax.responseXML.documentElement;

							alerte('O CPC sugerido para a primeira posi&ccedil;&atilde;o &eacute; de R$ '+xmlDoc.getElementsByTagName("cpcmax")[0].childNodes[0].nodeValue);



							document.getElementById("cpcmin").innerHTML	=	"R$ " + xmlDoc.getElementsByTagName("cpcmin")[0].childNodes[0].nodeValue;

							document.pag.novo_cpc.value							=	xmlDoc.getElementsByTagName("cpcmax")[0].childNodes[0].nodeValue;

							document.pag.novo_cpc_min.value						=	xmlDoc.getElementsByTagName("cpcmin")[0].childNodes[0].nodeValue;

						}

					}

				}

				Ajax.send(null);

		}

	}

}

function pagar(){
	
	v=0;
	if (document.pag.pagamento_valor[0].checked) {
		v=1;
	}
	if (document.pag.pagamento_valor[1].checked) {
		v=1;
	}
	if (document.pag.pagamento_valor[2].checked) {
		v=1;
	}
	if (document.pag.pagamento_valor[3].checked) {
		v=1;
	}
	if (document.pag.pagamento_valor[4].checked) {
		v=1;
	}
	if (document.pag.pagamento_valor[5].checked) {
		v=1;
	}
	if (document.pag.pagamento_valor[6].checked) {
		v=1;
	}

	if (v==0) {
		alert('Escolha o valor do pagamento...');
		document.pag.pagamento_valor.focus();
		return;
	}
	
	document.pag.submit();
}
