<!--
	function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
	if ( selObj.options[selObj.selectedIndex].value != "" ) {
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		selObj.selectedIndex=0;
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function valida_mail(valor) {
	prim = valor.indexOf("@")
	if(prim < 2) return false;
	if(valor.indexOf("@",prim + 1) != -1) return false
	if(valor.indexOf(".") < 1) return false;
	if(valor.indexOf("zipmeil.com") > 0) return false;
	if(valor.indexOf("hotmeil.com") > 0) return false;
	if(valor.indexOf(".@") > 0) return false;
	if(valor.indexOf("@.") > 0) return false;
	if(valor.indexOf(".com.br.") > 0) return false;
	if(valor.indexOf("/") > 0) return false;
	if(valor.indexOf("[") > 0) return false;
	if(valor.indexOf("]") > 0) return false;
	if(valor.indexOf("(") > 0) return false;
	if(valor.indexOf(")") > 0) return false;
	if(valor.indexOf("..") > 0) return false;
	if(valor.indexOf(",") > 0) return false;
	return true;

}

function valida_num( numero ) {
	for ( var i = 0; i < numero.length ; i++ )
		if ( numero.substring(i, i+1) < '0' || numero.substring(i, i+1) > '9'  ) 
			return true;
	return false;
}

function valida_fale( form1 ) {
	if ( form1.nome.value == "" ) {
		alert("Por favor, digite o seu nome.");
		form1.nome.focus();
		return false;
	}
	if ( form1.area.value == "" ) {
		alert("Por favor, escolha a área/setor.");
		form1.area.focus();
		return false;
	}
	if ( form1.retorno.value == "" ) {
		alert("Por favor, escolha a forma de retorno.");
		form1.retorno.focus();
		return false;
	}
	if ( form1.retorno.value == "E-mail" && form1.email.value == "" ) {
		alert("Por favor, digite o seu e-mail para retorno.");
		form1.email.focus();
		return false;
	}
	if ( form1.retorno.value == "E-mail" && !valida_mail(form1.email.value) ) {
		alert("Por favor, um e-mail válido para retorno.");
		form1.email.focus();
		return false;
	}
	if ( form1.retorno.value == "Telefone" && form1.telefone.value == "" ) {
		alert("Por favor, digite o seu telefone para retorno.");
		form1.telefone.focus();
		return false;
	}
	if ( form1.retorno.value == "Endereço" && form1.endereco.value == "" ) {
		alert("Por favor, digite o seu endereço para retorno.");
		form1.endereco.focus();
		return false;
	}
	if ( form1.retorno.value == "Endereço" && form1.cep.value == "" ) {
		alert("Por favor, digite o seu cep para retorno.");
		form1.cep.focus();
		return false;
	}
	if ( form1.retorno.value == "Endereço" && valida_cep(form1.cep.value) ) {
		alert("Por favor, digite um cep válido no formato 99999-99.");
		form1.cep.focus();
		return false;
	}
	if ( form1.descricao.value == "" ) {
		alert("Por favor, digite a descrição.");
		form1.descricao.focus();
		return false;
	}
	return true;
}

function newsletter(email,nome) {
	janela=window.open('/novosite/popup/send_newsletter.php?email='+email+'&nome='+nome,'NewsLetter','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=390,height=300,left=20,top=20')
}

function midia(codigo) {
	janela=window.open('/novosite/popup/midia.php?codigo='+codigo,'CMI_NA_MIDIA','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=390,height=300,left=20,top=20')
}

function valida_newsletter () {
	if ( document.newsletter.nome.value == "" ) {
		alert("Por favor, digite o seu nome.");
		document.newsletter.nome.focus();
		return false;
	}
	if ( document.newsletter.email.value == "" ) {
		alert("Por favor, digite o seu e-mail.");
		document.newsletter.email.focus();
		return false;
	}
	if ( !valida_mail(document.newsletter.email.value) ) {
		alert("Por favor, um e-mail válido.");
		document.newsletter.email.focus();
		return false;
	}
	newsletter(document.newsletter.email.value,document.newsletter.nome.value);
	document.newsletter.email.value = "";

	document.newsletter.nome.value = "";
	return false;
}

function valida_login ( ){
	if ( document.loga.email.value == "" ) {
		alert("Por favor, digite o seu e-mail.");
		document.loga.email.focus();		
		return false;
	}
	if ( !valida_mail(document.loga.email.value) ) {
		alert("Por favor, digite um e-mail válido.");
		document.loga.email.focus();		
		return false;
	}
	if ( document.loga.senha.value == "" ) {
		alert("Por favor, digite a sua senha.");
		document.loga.senha.focus();		
		return false;
	}
	return true;
}

function envia_senha (){
	if ( document.loga.email.value == "" ) {
		alert("Por favor, digite o seu e-mail.");
		document.loga.email.focus();		
		return;
	}
	if ( !valida_mail(document.loga.email.value) ) {
		alert("Por favor, digite um e-mail válido.");
		document.loga.email.focus();		
		return;
	}
	document.loga.action = "envia_senha.php";
	document.loga.submit();
	return;
}
function envia_senha_cadastro(email){
	if ( !valida_mail(email) ) {
		alert("Por favor, digite um e-mail válido.");
		return;
	}
	document.cadastro.action = "../home/envia_senha.php";
	document.cadastro.submit();
	return;
}

function valida_cep( CEP ) {
	if ( CEP.length != 9 ) return true;
	if ( CEP.indexOf("-" )!= 5 ) return true;
	for ( var i = 0; i < CEP.length ; i++ ) {
		if ( CEP.substring(i, i+1) >= '0' && CEP.substring(i, i+1) <= '9'  ) {		
			if ( i == 5 ) return true;
		}
		else { 
			if ( i != 5 )  return true;
		}
	}
	return false;
}

function valida_data ( data ) {
	
	if ( data.length != 10 ) return true;

	var dia = data.substring(0,1) +  data.substring(1,2);
	var mes = data.substring(3,4) +  data.substring(4,5);
	var ano = data.substring(6,7) +  data.substring(7,8) + data.substring(8,9) +  data.substring(9,10);
	
	if ( valida_num(dia) ) return true;
	if ( valida_num(mes) ) return true;
	if ( valida_num(ano) ) return true;
	
	//alert(dia+"/"+mes+"/"+ano);
	
	if ( mes > 12 || mes < 1 ) return true;
	
	if ( dia < 1 ) return true;
	
	if ( ano < 1 ) return true;
	
	if ( ( mes == 1 || mes == 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 12 ) && dia > 31  ) return true;
	
	if ( ( mes == 4 || mes == 6 || mes == 9 || mes == 11 ) && dia > 30  ) return true;
	
	if (  mes == 2 && (ano%4) == 0  && dia > 29  ) return true;
	
	if (  mes == 2 && (ano%4) != 0  && dia > 28  ) return true;
	
	return false;
}

function valida_data_2 ( data ) {
	
	if ( data.length != 5 ) return true;

	var dia = data.substring(0,1) +  data.substring(1,2);
	var mes = data.substring(3,4) +  data.substring(4,5);
	
	if ( valida_num(dia) ) return true;
	if ( valida_num(mes) ) return true;	
	
	if ( mes > 12 || mes < 1 ) return true;
	
	if ( dia < 1 ) return true;
	
	if ( ( mes == 1 || mes == 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 12 ) && dia > 31  ) return true;
	
	if ( ( mes == 4 || mes == 6 || mes == 9 || mes == 11 ) && dia > 30  ) return true;
	
	if (  mes == 2  && dia > 29  ) return true;
	
	return false;
}

function CGC_OK(Numero_CGC) 
{
  var Parcela;
  var Quociente;
  var Resto;
  var Soma;
  var Fator;
  var I;
  var C1;
  var C2;
  var dv1;
  var dv2;
    
  //Verificação dos dois digitos finais em relação ao número completo
  C1 = parseInt(Numero_CGC.substring(12, 13));  //13º caracter = primeiro dígito verificador
  C2 = parseInt(Numero_CGC.substring(13, 14));  //14º caracter = segundo dígito verificador
    
  //Verificação do primeiro dígito (C1)
  Soma = 0;
  Parcela = 0;
  Fator = 0;
	
  for(I=1; I<=12; I++)
  {
    if(I < 9)
    {
      Fator = I + 1;
	}
	else
	{
      Fator = I - 7;
    }

    Parcela = Fator * parseInt(Numero_CGC.substring(12 - I, 12 - I + 1));
    Soma = Soma + Parcela;
  } //fechando o "for".
    
  dv1 = (Soma % 11); 
  dv1 = 11 - dv1;

  if(dv1 > 9)
  {
    dv1 = 0;
  }
    
  if(C1 != dv1)
  {
    return false;
  }
    
  //Verificação do segundo dígito (C2)
  Soma = 0;
  Parcela = 0;
  Fator = 0;

  for(I=1; I<=13; I++)
  {
     if(I < 9)
     {
        Fator = I + 1;
     }	  
     else
     {
       Fator = I - 7;
     }	  
     Parcela = Fator * parseInt(Numero_CGC.substring(13 - I, 13 - I + 1));
     Soma = Soma + Parcela;
  }
	 
  dv2 = (Soma % 11);
  dv2 = 11 - dv2;
  
  if(dv2 > 9)
  {
    dv2 = 0;
  }

  if(C2 != dv2)
  {
    return false;
  }
return true;
}

function CPF_OK(Numero_CPF) 
{
  var Parcela;
  var Quociente;
  var Resto;
  var Soma;
  var Fator;
  var I;
  var C1;
  var C2;
  var dv1;
  var dv2;
    
  //Verificação dos dois digitos finais em relação ao número completo
  C1 = parseInt(Numero_CPF.substring(9, 10));  //10º caracter = primeiro dígito verificador
  C2 = parseInt(Numero_CPF.substring(10, 11)); //11º caracter = segundo dígito verificador
    
  //Verificação do primeiro dígito (C1)
  Soma = 0;
  Parcela = 0;
  Fator = 0;
	
  for(I=1; I<=9; I++)
  {
    Fator = I + 1;

    Parcela = Fator * parseInt(Numero_CPF.substring(9 - I, 9 - I + 1));
    Soma = Soma + Parcela;
  } //fechando o "for".
    
  dv1 = (Soma % 11); 
  dv1 = 11 - dv1;

  if(dv1 >9 )
  {
    dv1 = 0;
  }
    
  if(C1 != dv1)
  {
    return false;
  }
    
  //Verificação do segundo dígito (C2)
  Soma = 0;
  Parcela = 0;
  Fator = 0;

  for(I=1; I<=10; I++)
  {
    Fator = I + 1;
  
    Parcela = Fator * parseInt(Numero_CPF.substring(10 - I, 10 - I + 1));
    Soma = Soma + Parcela;
  }
	 
  dv2 = (Soma % 11);
  dv2 = 11 - dv2;
  
  if(dv2 > 9)
  {
    dv2 = 0;
  }

  if(C2 != dv2)
  {
    return false;
  }
return true;
}

function valida_nome_cadastro(element){
	if ((document.cadastro.nome_cadastro[1].checked == true) && (isblank(element.value)) ){
		alert("Você precisa preencher o nome de fantasia!");
		focus(element);		
		return false;
	}
}

function valida_cnpj(elemento) {

AuxCPFCGC = elemento.value;
var checkOK = "0123456789";

 if (elemento.value == "" || elemento.value == null || AuxCPFCGC.length != 14 )
  {
    alert("CNPJ deve conter 14 dígitos!");
    elemento.focus();
    return(false);
  }

  for (i = 1; i <= AuxCPFCGC.length ; i++) 
  {
    if (AuxCPFCGC.substring(i-1,i) == " ")
    {
      elemento.focus();	  
      alert("O campo CNPJ não pode conter espaços!");
      return(false);
    }
  }

var checkStr = AuxCPFCGC;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("O CNPJ deve conter apenas números.");
    elemento.focus();
    return(false);
  }
 
    if (!CGC_OK(AuxCPFCGC))
    {
      elemento.focus();
      alert("Número de CNPJ testado e entendido como inválido!");
      return(false);
    }
return(true);

}

// onchange cnpj!!
function pessoa_juridica(cnpj,cpf){
	if (isblank(cnpj.value)){
		cpf.disabled = false;
	}else{
		cpf.disabled = true;
	}
}

function pessoa_fisica(cnpj,cpf,razao,inscricao){
	if (isblank(cpf.value)){
		cnpj.disabled = false;
		inscricao.disabled = false;

	}else{
		cnpj.disabled = true;
		razao[0].checked = true;
		inscricao.disabled = true;
		inscricao.value = "";
	}
}

function pessoa_fisicaf(cnpj,cpf,razao,inscricao){
	if (isblank(cnpj.value)){
		cpf.disabled = false;
		razao[0].checked = true;
		inscricao.disabled = true;
		inscricao.value = "";
	}else{
		cpf.disabled = true;
		inscricao.disabled = false;
	}
}

function pessoa_juridicaf(cnpj,cpf){
	if (isblank(cpf.value)){
		cnpj.disabled = false;
	}else{
		cnpj.disabled = true;
	}
}

function valida_cpf(elemento) {

AuxCPFCGC = elemento.value;
var checkOK = "0123456789";

 if (elemento.value == "" || elemento.value == null || AuxCPFCGC.length != 11 )
  {
    alert("CPF deve conter 11 dígitos!");
    elemento.focus();
    return(false);
  }

  for (i = 1; i <= AuxCPFCGC.length ; i++) 
  {
    if (AuxCPFCGC.substring(i-1,i) == " ")
    {
      elemento.focus();	  
      alert("O campo CPF não pode conter espaços!");
      return(false);
    }
  }

var checkStr = AuxCPFCGC;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("O CPF deve conter apenas números.");
    elemento.focus();
    return(false);
  }
 
    if (!CPF_OK(AuxCPFCGC))
    {
      elemento.focus();
      alert("Número de CPF testado e entendido como inválido!");
      return(false);
    }
return(true);

}

function valida_cnpj_novo(elemento) {

AuxCPFCGC = elemento.value;
var checkOK = "0123456789";

 AuxCPFCGC = AuxCPFCGC.replace( "/", "" );
 AuxCPFCGC = AuxCPFCGC.replace( ".", "" );
 AuxCPFCGC = AuxCPFCGC.replace( ".", "" );
 AuxCPFCGC = AuxCPFCGC.replace( "-", "" );

 if (AuxCPFCGC == "" || AuxCPFCGC == null || AuxCPFCGC.length != 14 )
  {
    alert("CNPJ deve conter 14 dígitos!");
    elemento.focus();
    return(false);
  }

  for (i = 1; i <= AuxCPFCGC.length ; i++) 
  {
    if (AuxCPFCGC.substring(i-1,i) == " ")
    {
      elemento.focus();	
	  alert("O CNPJ deve ser nesse formato 999.999.999-99.");
      return(false);
    }
  }

var checkStr = AuxCPFCGC;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
	alert("O CNPJ deve ser nesse formato 999.999.999-99.");
    elemento.focus();
    return(false);
  }
 
    if (!CGC_OK(AuxCPFCGC))
    {
      elemento.focus();
      alert("Número de CNPJ testado e entendido como inválido!");
      return(false);
    }
return(true);

}

function valida_cpf_novo(elemento) {

AuxCPFCGC = elemento.value;
var checkOK = "0123456789";


 AuxCPFCGC = AuxCPFCGC.replace( ".", "" );
 AuxCPFCGC = AuxCPFCGC.replace( ".", "" );
 AuxCPFCGC = AuxCPFCGC.replace( ".", "" );
 AuxCPFCGC = AuxCPFCGC.replace( "-", "" );

 if ( AuxCPFCGC == "" || AuxCPFCGC == null || AuxCPFCGC.length != 11 )
  {
    alert("CPF deve conter 11 dígitos!");
    elemento.focus();
    return(false);
  }

  for (i = 1; i <= AuxCPFCGC.length ; i++) 
  {
    if (AuxCPFCGC.substring(i-1,i) == " ")
    {
      elemento.focus();	  
      alert("O CPF deve ser nesse formato 999.999.999-99.");
      return(false);
    }
  }

var checkStr = AuxCPFCGC;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("O CPF deve ser nesse formato 999.999.999-99.");
    elemento.focus();
    return(false);
  }
 
    if (!CPF_OK(AuxCPFCGC))
    {
      elemento.focus();
      alert("Número de CPF testado e entendido como inválido!");
      return(false);
    }
return(true);

}
function FormataCampoCpf(campo,max,teclapres) {
	var tecla = teclapres.keyCode;
	vr = campo.value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	if (tam < max && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		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 <= 17) ){
	 		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 ) ;}
	}		
}

function FormataCampoCnpj(campo,max,teclapres) {
	var tecla = teclapres.keyCode;
	vr = campo.value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	if (tam < max && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		campo.value = vr ; }
	 	if ( (tam > 2) && (tam <= 6) ){
	 		campo.value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 7) && (tam <= 9) ){
	 		campo.value = vr.substr( 0, tam - 6 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 10) && (tam <= 12) ){
	 		campo.value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 13) && (tam <= 14) ){
	 		campo.value = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		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 ) ;}
	}		
}

//
//	if ( document.cadastro.apelido.value == "" ) {
//		alert("Por favor, digite o nome que aparecerá na busca de ofertas.");
//		document.cadastro.apelido.focus();
//		return false;
//	}
//

function valida_cadastro () {
	
	if ( document.cadastro.razao.value == "" ) {
		alert("Por favor, digite o nome/razão social.");
		document.cadastro.razao.focus();
		return false;
	}
	if ( document.cadastro.fantasia.value == "" && (!isblank(document.cadastro.cnpj.value) || (document.cadastro.nome_cadastro[1].checked == true))) {
		alert("Por favor, digite o nome de fantasia.");
		document.cadastro.fantasia.focus();
		return false;
	}
	if ( document.cadastro.nome_cadastro[0].checked == false && document.cadastro.nome_cadastro[1].checked == false) {
		alert("Por favor, informe se no cadastro devem constar o nome/razão social ou o nome fantasia.");
		document.cadastro.nome_cadastro[0].focus();
		return false;
	}

	
	if ( document.cadastro.contato.value == "" ) {
		alert("Por favor, digite o nome do contato.");
		document.cadastro.contato.focus();
		return false;
	}
	//blabla
	 if ((document.cadastro.cnpj.value == "" || document.cadastro.cnpj.value == null) && (document.cadastro.cpf.value == "" || document.cadastro.cpf.value == null)){
 		alert("Voce deve informar o CPF ou o CNPJ.");
		document.cadastro.cnpj.focus();
		return false;
	}

	if ( isblank(document.cadastro.cpf.value) && !valida_cnpj_novo(document.cadastro.cnpj) ){
		return false;
	}

	if ( isblank(document.cadastro.cnpj.value) && !valida_cpf_novo(document.cadastro.cpf) ){
		return false;
	}

	if (isblank(document.cadastro.cpf.value)){
	
		if ( document.cadastro.nome_diretor1.value == "" ) {
			alert("Por favor, digite o nome do 1º diretor.");
			document.cadastro.nome_diretor1.focus();
			return false;
		}
		if ( document.cadastro.data_diretor1.value == "" ) {
			alert("Por favor, digite a data de aniversário do 1º diretor.");
			document.cadastro.data_diretor1.focus();
			return false;
		}
		if ( valida_data_2(document.cadastro.data_diretor1.value) ) {
			alert("Por favor, digite uma data válida no formatao 'dd/mm', ex. ( 01/01 ), para o campo data de aniversário do 1º diretor.");
			document.cadastro.data_diretor1.focus();
			return false;
		}
		if ( document.cadastro.email_diretor1.value == "" ) {
			alert("Por favor, digite o e-mail do 1º diretor.");
			document.cadastro.email_diretor1.focus();
			return false;
		}
		if ( !valida_mail(document.cadastro.email_diretor1.value) ) {
			alert("Por favor, um e-mail válido para o e-mail do 1º diretor.");
			document.cadastro.email_diretor1.focus();
			return false;
		}
	}
		if ( document.cadastro.nome_diretor2.value != "" || document.cadastro.data_diretor2.value != "" || document.cadastro.email_diretor2.value != "" ){
			if ( document.cadastro.nome_diretor2.value == "" ) {
				alert("Por favor, digite o nome do 2º diretor.");
				document.cadastro.nome_diretor2.focus();
				return false;
			}
		if ( document.cadastro.data_diretor2.value == "" ) {
			alert("Por favor, digite a data de aniversário do 2º diretor.");
			document.cadastro.data_diretor2.focus();
			return false;
		}
		if ( valida_data_2(document.cadastro.data_diretor2.value) ) {
			alert("Por favor, digite uma data válida no formatao 'dd/mm', ex. ( 01/01 ), para o campo data de aniversário do 2º diretor.");
			 document.cadastro.data_diretor2.focus();
			return false;
		}
		if ( document.cadastro.email_diretor2.value == "" ) {
			alert("Por favor, digite o e-mail do 2º diretor.");
			document.cadastro.email_diretor2.focus();
			return false;
		}
		if ( !valida_mail(document.cadastro.email_diretor2.value) ) {
			alert("Por favor, um e-mail válido para o e-mail do 2º diretor.");
			document.cadastro.email_diretor2.focus();
			return false;
		}	
	}	
	if ( document.cadastro.nome_diretor3.value != "" || document.cadastro.data_diretor3.value != "" || document.cadastro.email_diretor3.value != "" ){
		if ( document.cadastro.nome_diretor3.value == "" ) {
			alert("Por favor, digite o nome do 3º diretor.");
			document.cadastro.nome_diretor3.focus();
			return false;
		}
		if ( document.cadastro.data_diretor3.value == "" ) {
			alert("Por favor, digite a data de aniversário do 3º diretor.");
			document.cadastro.data_diretor3.focus();
			return false;
		}
		if ( valida_data_2(document.cadastro.data_diretor3.value) ) {
			alert("Por favor, digite uma data válida no formatao 'dd/mm', ex. ( 01/01 ), para o campo data de aniversário do 3º diretor.");
			 document.cadastro.data_diretor3.focus();
			return false;
		}
		if ( document.cadastro.email_diretor3.value == "" ) {
			alert("Por favor, digite o e-mail do 3º diretor.");
			document.cadastro.email_diretor3.focus();
			return false;
		}
		if ( !valida_mail(document.cadastro.email_diretor3.value) ) {
			alert("Por favor, um e-mail válido para o e-mail do 3º diretor.");
			document.cadastro.email_diretor3.focus();
			return false;
		}	
	}
	if ( document.cadastro.email_diretor4.value != "" || document.cadastro.data_diretor4.value != "" || document.cadastro.email_diretor4.value != "" ){
		if ( document.cadastro.nome_diretor4.value == "" ) {
			alert("Por favor, digite o nome do 4º diretor.");
			document.cadastro.nome_diretor4.focus();
			return false;
		}
		if ( document.cadastro.data_diretor4.value == "" ) {
			alert("Por favor, digite a data de aniversário do 4º diretor.");
			document.cadastro.data_diretor4.focus();
			return false;
		}
		if ( valida_data_2(document.cadastro.data_diretor4.value) ) {
			alert("Por favor, digite uma data válida no formatao 'dd/mm', ex. ( 01/01 ), para o campo data de aniversário do 4º diretor.");
			 document.cadastro.data_diretor4.focus();
			return false;
		}
		if ( document.cadastro.email_diretor4.value == "" ) {
			alert("Por favor, digite o e-mail do 4º diretor.");
			document.cadastro.email_diretor4.focus();
			return false;
		}
		if ( !valida_mail(document.cadastro.email_diretor4.value) ) {
			alert("Por favor, um e-mail válido para o e-mail do 4º diretor.");
			document.cadastro.email_diretor4.focus();
			return false;
		}	
	}
	if ( document.cadastro.nome_diretor5.value != "" || document.cadastro.data_diretor5.value != "" || document.cadastro.email_diretor5.value != "" ){
		if ( document.cadastro.nome_diretor5.value == "" ) {
			alert("Por favor, digite o nome do 5º diretor.");
			document.cadastro.nome_diretor5.focus();
			return false;
		}
		if ( document.cadastro.data_diretor5.value == "" ) {
			alert("Por favor, digite a data de aniversário do 5º diretor.");
			document.cadastro.data_diretor5.focus();
			return false;
		}
		if ( valida_data_2(document.cadastro.data_diretor5.value) ) {
			alert("Por favor, digite uma data válida no formatao 'dd/mm', ex. ( 01/01 ), para o campo data de aniversário do 5º diretor.");
			 document.cadastro.data_diretor5.focus();
			return false;
		}
		if ( document.cadastro.email_diretor5.value == "" ) {
			alert("Por favor, digite o e-mail do 5º diretor.");
			document.cadastro.email_diretor5.focus();
			return false;
		}
		if ( !valida_mail(document.cadastro.email_diretor5.value) ) {
			alert("Por favor, um e-mail válido para o e-mail do 5º diretor.");
			document.cadastro.email_diretor5.focus();
			return false;
		}	
	}
	if ( document.cadastro.atividade1.value != "" && !ValidaInteiro(document.cadastro.atividade1.value)) {
		alert("Por favor, digite um número de 1 a 6 para a atividade Administradora.");
		document.cadastro.atividade1.focus();
		return false;
	}
	if ( document.cadastro.atividade1.value != "" && ( document.cadastro.atividade1.value < 0 || document.cadastro.atividade1.value > 6 )) {
		alert("Por favor, digite um número de 1 a 6 para a atividade Administradora.");
		document.cadastro.atividade1.focus();
		return false;
	}
	if ( document.cadastro.atividade2.value != "" && !ValidaInteiro(document.cadastro.atividade2.value)) {
		alert("Por favor, digite um número de 1 a 6 para a atividade Loteadora.");
		document.cadastro.atividade2.focus();
		return false;
	}
	if ( document.cadastro.atividade2.value != "" && ( document.cadastro.atividade2.value < 0 || document.cadastro.atividade2.value > 6 )) {
		alert("Por favor, digite um número de 1 a 6 para a atividade Loteadora.");
		document.cadastro.atividade2.focus();
		return false;
	}
	if ( document.cadastro.atividade3.value != "" && !ValidaInteiro(document.cadastro.atividade3.value)) {
		alert("Por favor, digite um número de 1 a 6 para a atividade Incorporadora.");
		document.cadastro.atividade3.focus();
		return false;
	}
	if ( document.cadastro.atividade3.value != "" && ( document.cadastro.atividade3.value < 0 || document.cadastro.atividade3.value > 6 )) {
		alert("Por favor, digite um número de 1 a 6 para a atividade Incorporadora.");
		document.cadastro.atividade3.focus();
		return false;
	}
	if ( document.cadastro.atividade4.value != "" && !ValidaInteiro(document.cadastro.atividade4.value)) {
		alert("Por favor, digite um número de 1 a 6 para a atividade Corretora.");
		document.cadastro.atividade4.focus();
		return false;
	}
	if ( document.cadastro.atividade4.value != "" && ( document.cadastro.atividade4.value < 0 || document.cadastro.atividade4.value > 6 )) {
		alert("Por favor, digite um número de 1 a 6 para a atividade Construtora.");
		document.cadastro.atividade4.focus();
		return false;
	}
	if ( document.cadastro.atividade5.value != "" && !ValidaInteiro(document.cadastro.atividade5.value)) {
		alert("Por favor, digite um número de 1 a 6 para a atividade Construtora.");
		document.cadastro.atividade5.focus();
		return false;
	}
	if ( document.cadastro.atividade3.value != "" && ( document.cadastro.atividade5.value < 0 || document.cadastro.atividade5.value > 6 )) {
		alert("Por favor, digite um número de 1 a 6 para a atividade Corretora.");
		document.cadastro.atividade5.focus();
		return false;
	}
	if ( document.cadastro.atividade6.value != "" && !ValidaInteiro(document.cadastro.atividade6.value)) {
		alert("Por favor, digite um número de 1 a 6 para a atividade Urbanizadora.");
		document.cadastro.atividade6.focus();
		return false;
	}
	if ( document.cadastro.atividade6.value != "" && ( document.cadastro.atividade6.value < 0 || document.cadastro.atividade6.value > 6 )) {
		alert("Por favor, digite um número de 1 a 6 para a atividade Urbanizadora.");
		document.cadastro.atividade6.focus();
		return false;
	}
	if ( document.cadastro.telefone.value == "" ) {
		alert("Por favor, digite o telefone 1.");
		document.cadastro.telefone.focus();
		return false;
	}
	if ( document.cadastro.endereco.value == "" ) {
		alert("Por favor, digite o endereço.");
		document.cadastro.endereco.focus();
		return false;
	}
	if ( document.cadastro.numero.value == "" ) {
		alert("Por favor, digite o número.");
		document.cadastro.numero.focus();
		return false;
	}	
	if ( document.cadastro.estado_cad.value == "" ) {
		alert("Por favor, escolha o estado.");
		document.cadastro.estado_cad.focus();
		return false;
	}
	if ( ( document.cadastro.cidade_cad.value == "" || document.cadastro.cidade_cad.value == "0" ) && document.cadastro.cidade_outra.value == "" ) {
		alert("Por favor, escolha a cidade. Se a cidade não estiver na lista, digite a cidade no campo outra cidade.");
		document.cadastro.cidade_cad.focus();
		return false;
	}
	if ( ( document.cadastro.bairro_cad.value == "" || document.cadastro.bairro_cad.value == "0" ) && document.cadastro.bairro_outro.value == "" ) {
		alert("Por favor, escolha o bairro. Se a bairro não estiver na lista, digite o bairro no campo outro bairro.");
		document.cadastro.bairro_cad.focus();
		return false;
	}	
	if ( document.cadastro.cep.value == "" ) {
		alert("Por favor, digite o cep.");
		document.cadastro.cep.focus();
		return false;
	}
	if ( valida_cep(document.cadastro.cep.value) ) {
		alert("Por favor, digite um cep válido no formato 99999-99.");
		document.cadastro.cep.focus();
		return false;
	}
	if ( document.cadastro.regional_cad.value == "" && document.cadastro.cidade_cad.value == "1" ) {
		alert("Por favor, escolha a região.");
		document.cadastro.regional_cad.focus();
		return false;
	}
	if ( document.cadastro.email.value == "" ) {
		alert("Por favor, digite o e-mail.");
		document.cadastro.email.focus();
		return false;
	}
	if ( !valida_mail(document.cadastro.email.value) ) {
		alert("Por favor, um e-mail válido para o e-mail.");
		document.cadastro.email.focus();
		return false;
	}
	if ( document.cadastro.senha.value == "" ) {
		alert("Por favor, digite a senha.");
		document.cadastro.senha.focus();
		return false;
	}
	if ( document.cadastro.senha.value != document.cadastro.confirme_senha.value ) {
		alert("Por favor, digite a confirmação da senha igual a senha.");
		document.cadastro.confirme_senha.focus();
		return false;
	}
	return true;
}

function valida_cadastro_email () {
	if ( document.cadastro.email.value == "" ) {
		alert("Por favor, digite o e-mail.");
		document.cadastro.email.focus();
		return false;
	}
	if ( !valida_mail(document.cadastro.email.value) ) {
		alert("Por favor, um e-mail válido para o e-mail.");
		document.cadastro.email.focus();
		return false;
	}
	return true;
}

function valida_cadastro_cnpj () {
	if ( !valida_cnpj_novo(document.cadastro.cnpj) ){
		return false;
	}
	return true;
}

function evento_valor(field) {
	if (field.checked = true){
		field.value = "Sim";
	}else{
		field.value = "Não"
	}
}


function valida_curriculo () {

	if ( document.curriculo.nome.value == "" ) {
		alert("Por favor, digite o seu nome.");
		document.curriculo.nome.focus();
		return false;
	}
	if ( document.curriculo.dia.value == "" || document.curriculo.mes.value == "" || document.curriculo.ano.value == "") {
		alert("Por favor, digite a sua data de nascimento.");
		document.curriculo.dia.focus();
		return false;
	}
	if ( valida_data(document.curriculo.dia.value+"/"+document.curriculo.mes.value+"/"+document.curriculo.ano.value) ) {
		alert("Por favor, digite uma data válida no formatao 'dd/mm/aaaa', ex. ( 01/01/2002 ), para o campo data de nascimento.");
		document.curriculo.dia.focus();
		return false;
	}
	if ( document.curriculo.est_civil.value == "" ) {
		alert("Por favor, digite o seu estado civil.");
		document.curriculo.est_civil.focus();
		return false;
	}

/*	if ( document.curriculo.filhos.value == "" ) {
		alert("Por favor, digite o número de filhos.");
		document.curriculo.filhos.focus();
		return false;
	}*/

	if ( document.curriculo.endereco.value == "" ) {
		alert("Por favor, digite o seu endereço.");
		document.curriculo.endereco.focus();
		return false;
	}
	if ( document.curriculo.numero.value == "" ) {
		alert("Por favor, digite o número do seu endereço.");
		document.curriculo.numero.focus();
		return false;
	}
	if ( document.curriculo.bairro.value == "" ) {
		alert("Por favor, digite o seu bairro.");
		document.curriculo.bairro.focus();
		return false;
	}
	if ( document.curriculo.cidade_end.value == "" ) {
		alert("Por favor, digite a sua cidade.");
		document.curriculo.cidade_end.focus();
		return false;
	}
	if ( document.curriculo.estado.value == "" ) {
		alert("Por favor, escolha o seu estado.");
		document.curriculo.estado.focus();
		return false;
	}
	if ( document.curriculo.cep.value == "" ) {
		alert("Por favor, digite o seu cep.");
		document.curriculo.cep.focus();
		return false;
	}
	if ( valida_cep(document.curriculo.cep.value) ) {
		alert("Por favor, digite um cep válido no formato 99999-99.");
		document.curriculo.cep.focus();
		return false;
	}
	if ( document.curriculo.telefone.value == "" ) {
		alert("Por favor, digite o seu telefone.");
		document.curriculo.telefone.focus();
		return false;
	}
	if ( document.curriculo.email.value == "" ) {
		alert("Por favor, digite o seu e-mail.");
		document.curriculo.email.focus();
		return false;
	}
	if ( !valida_mail(document.curriculo.email.value) ) {
		alert("Por favor, um e-mail válido.");
		document.curriculo.email.focus();
		return false;
	}
	if ( document.curriculo.cargo.value == "" ) {
		alert("Por favor, digite o seu cargo pretendido.");
		document.curriculo.cargo.focus();
		return false;
	}
	if ( document.curriculo.tempo_experiencia.value == "" ) {
		alert("Por favor, digite o seu tempo experiência no cargo pretendido.");
		document.curriculo.tempo_experiencia.focus();
		return false;
	}
	if ( document.curriculo.grau_escolaridade.value == "" ) {
		alert("Por favor, escolha o seu grau escolaridade.");
		document.curriculo.grau_escolaridade.focus();
		return false;
	}
	if ( document.curriculo.outros.checked == true && document.curriculo.descricao_outros.value == "" ) {
		alert("Por favor, digite outro conhecimento específico.");
		document.curriculo.descricao_outros.focus();
		return false;
	}
	return true;
}

function valida_fiador ( ){
	if ( document.fiador.nome.value == "" ) {
		alert("Por favor, digite o nome do fiador.");
		document.fiador.nome.focus();
		return false;
	}
	if ( document.fiador.cpf.value == "" && document.fiador.cnpj.value == "" ) {
		alert("Por favor, digite o CPF ou o CNPJ do fiador.");
		document.fiador.cpf.focus();
		return false;
	}
	if ( document.fiador.cpf.value != "" ) {
		if ( !valida_cpf_novo(document.fiador.cpf) ){
			return false;
		}
	}
	if ( document.fiador.cnpj.value != "" ) {
		if ( !valida_cnpj_novo(document.fiador.cnpj) ){
			return false;
		}
	}
	/*
	if ( document.fiador.cpf.value != "" && document.fiador.pai.value == "" ) {
		alert("Por favor, digite o nome do pai do fiador.");
		document.fiador.pai.focus();
		return false;
	}
	if ( document.fiador.cpf.value != "" && document.fiador.mae.value == "" ) {
		alert("Por favor, digite o nome da mãe do fiador.");
		document.fiador.mae.focus();
		return false;
	}
	*/
	if ( valida_data(document.fiador.dia_contra.value+"/"+document.fiador.mes_contra.value+"/"+document.fiador.ano_contra.value) ) {
		alert("Por favor, digite uma data válida no formatao 'dd/mm/aaaa', ex. ( 01/01/2002 ), para o campo data do contrato.");
		document.fiador.dia_contra.focus();
		return false;
	}
	if ( document.fiador.numero_contrato.value == "" ) {
		alert("Por favor, digite o número do contrato.");
		document.fiador.numero_contrato.focus();
		return false;
	}
	if ( document.fiador.valor_contrato.value == "" ) {
		alert("Por favor, digite o valor mensal do contrato.");
		document.fiador.valor_contrato.focus();
		return false;
	}
	if ( valida_data(document.fiador.dia_vencto_contra.value+"/"+document.fiador.mes_vencto_contra.value+"/"+document.fiador.ano_vencto_contra.value) ) {
		alert("Por favor, digite uma data válida no formatao 'dd/mm/aaaa', ex. ( 01/01/2002 ), para o campo data do vencimento do contrato.");
		document.fiador.dia_vencto_contra.focus();
		return false;
	}
	return true;
}

function valida_inquilino ( ){
	if ( document.fiador.nome.value == "" ) {
		alert("Por favor, digite o nome do inquilino.");
		document.fiador.nome.focus();
		return false;
	}
	if ( document.fiador.cpf.value == "" && document.fiador.cnpj.value == "" ) {
		alert("Por favor, digite o CPF ou o CNPJ do inquilino.");
		document.fiador.cpf.focus();
		return false;
	}
	if ( document.fiador.cpf.value != "" ) {
		if ( !valida_cpf_novo(document.fiador.cpf) ){
			return false;
		}
	}
	if ( document.fiador.cnpj.value != "" ) {
		if ( !valida_cnpj_novo(document.fiador.cnpj) ){
			return false;
		}
	}
	/*
	if ( document.fiador.cpf.value != "" && document.fiador.pai.value == "" ) {
		alert("Por favor, digite o nome do pai do fiador.");
		document.fiador.pai.focus();
		return false;
	}
	if ( document.fiador.cpf.value != "" && document.fiador.mae.value == "" ) {
		alert("Por favor, digite o nome da mãe do fiador.");
		document.fiador.mae.focus();
		return false;
	}
	*/
	if ( valida_data(document.fiador.dia_contra.value+"/"+document.fiador.mes_contra.value+"/"+document.fiador.ano_contra.value) ) {
		alert("Por favor, digite uma data válida no formatao 'dd/mm/aaaa', ex. ( 01/01/2002 ), para o campo data do contrato.");
		document.fiador.dia_contra.focus();
		return false;
	}
	if ( document.fiador.numero_contrato.value == "" ) {
		alert("Por favor, digite o número do contrato.");
		document.fiador.numero_contrato.focus();
		return false;
	}
	if ( document.fiador.valor_contrato.value == "" ) {
		alert("Por favor, digite o valor mensal do contrato.");
		document.fiador.valor_contrato.focus();
		return false;
	}
	if ( valida_data(document.fiador.dia_vencto_contra.value+"/"+document.fiador.mes_vencto_contra.value+"/"+document.fiador.ano_vencto_contra.value) ) {
		alert("Por favor, digite uma data válida no formatao 'dd/mm/aaaa', ex. ( 01/01/2002 ), para o campo data do vencimento do contrato.");
		document.fiador.dia_vencto_contra.focus();
		return false;
	}
	return true;
}

function valida_corretor ( ){
	if ( document.corretor.nome.value == "" ) {
		alert("Por favor, digite o nome do corretor.");
		document.corretor.nome.focus();
		return false;
	}
	if ( !valida_cpf_novo(document.corretor.cpf) ){
		return false;
	}
	return true;
}

function valida_fiador_nao_cadastrado ( ){
	if ( document.fiador_nao_cadastrado.nome.value == "" ) {
		alert("Por favor, digite o nome do corretor.");
		document.fiador_nao_cadastrado.nome.focus();
		return false;
	}
	if ( !valida_cpf_novo(document.fiador_nao_cadastrado.cpf) ){
		return false;
	}
	return true;
}

function valida_pesquisa (form1){
	if ( form1.nome.value == "" && form1.cpf.value == "" ) {
		alert("Por favor, digite o nome ou cpf para a pesquisa.");
		form1.nome.focus();
		return false;
	}
	return true;
}

function valida_inscricao () {
	
	if ( document.inscricao.nome.value == "" ) {
		alert("Por favor, digite o nome do participante.");
		document.inscricao.nome.focus();
		return false;
	}
	if ( !valida_cpf_novo(document.inscricao.cpf) ){
		return false;
	}	
	if ( document.inscricao.email.value == "" ) {
		alert("Por favor, digite o e-mail do participante.");
		document.inscricao.email.focus();
		return false;
	}
	if ( !valida_mail(document.inscricao.email.value) ) {
		alert("Por favor, um e-mail válido.");
		document.inscricao.email.focus();
		return false;
	}
	if ( document.inscricao.nome_razao.value == "" ) {
		alert("Por favor, digite o nome ou razão social para o faturamento.");
		document.inscricao.nome_razao.focus();
		return false;
	}
	if ( document.inscricao.email_fatura.value == "" ) {
		alert("Por favor, digite o e-mail para o faturamento.");
		document.inscricao.email_fatura.focus();
		return false;
	}
	if ( !valida_mail(document.inscricao.email_fatura.value) ) {
		alert("Por favor, um e-mail válido.");
		document.inscricao.email_fatura.focus();
		return false;
	}
	if ( document.inscricao.cnpj.value == "" && document.inscricao.cpf_fatura.value == "" ) {
		alert("Por favor, digite o cnpj ou o cpf para o faturamento.");
		document.inscricao.cnpj.focus();
		return false;
	}
	if ( document.inscricao.cnpj.value != "" && !valida_cnpj_novo(document.inscricao.cnpj) ){
		return false;
	}
	if ( document.inscricao.cpf_fatura.value != "" && !valida_cpf_novo(document.inscricao.cpf_fatura) ){
		return false;
	}
	if ( document.inscricao.endereco.value == "" ) {
		alert("Por favor, digite o endereço para o faturamento.");
		document.inscricao.endereco.focus();
		return false;
	}
	if ( document.inscricao.numero.value == "" ) {
		alert("Por favor, digite o numero do endereço para o faturamento.");
		document.inscricao.numero.focus();
		return false;
	}
	if ( document.inscricao.bairro.value == "" ) {
		alert("Por favor, digite o bairro para o faturamento.");
		document.inscricao.bairro.focus();
		return false;
	}
	if ( document.inscricao.cidade.value == "" ) {
		alert("Por favor, digite a cidade para o faturamento.");
		document.inscricao.cidade.focus();
		return false;
	}
	if ( document.inscricao.estado.value == "" ) {
		alert("Por favor, escolha o estado para o faturamento.");
		document.inscricao.estado.focus();
		return false;
	}
	if ( document.inscricao.cep.value == "" ) {
		alert("Por favor, digite o cep para o faturamento.");
		document.inscricao.cep.focus();
		return false;
	}
	if ( valida_cep(document.inscricao.cep.value) ) {
		alert("Por favor, digite um cep válido no formato 99999-99.");
		document.inscricao.cep.focus();
		return false;
	}
	if ( document.inscricao.telefone.value == "" ) {
		alert("Por favor, digite o telefone para o faturamento.");
		document.inscricao.telefone.focus();
		return false;
	}
	if ( document.inscricao.pagamento.checked == false ) {
		alert("Por favor, escolha a forma de pagamento.");
		document.inscricao.pagamento.focus();
		return false;
	}
	return true;
}

function confirma_inscricao () {
	if ( !(confirm("Confirma a inscricao do \""+document.inscricao.nome.value+"\" no curso \""+document.inscricao.curso.value+"\"?")))
		return false;
	return true;
} 

function altera_inscricao (codigo) {
	document.inscricao.action = "inscricao_altera.php?codigo="+codigo;
	document.inscricao.submit();
}

function deleta_fiador(codigo,nome,cpf,listagem,pagina) {
	if( confirm("Tem certeza que deseja deletar o fiador de nome \""+nome+"\" e de cpf \""+cpf+"\"?")){
		window.location.href = "protege_fiador_deleta.php?envia=Aceitar&codigo="+codigo+"&listagem="+listagem+"&pagina="+pagina;
	}
}

function deleta_inquilino(codigo,nome,cpf,listagem,pagina) {
	if( confirm("Tem certeza que deseja deletar o inquilino de nome \""+nome+"\" e de cpf \""+cpf+"\"?")){
		window.location.href = "protege_inquilino_deleta.php?envia=Aceitar&codigo="+codigo+"&listagem="+listagem+"&pagina="+pagina;
	}
}
function deleta_fiador_nao_cadastrado(codigo,nome,cpf,listagem,pagina) {
	if( confirm("Tem certeza que deseja deletar o fiador não cadastrado de nome \""+nome+"\" e de cpf \""+cpf+"\"?")){
		window.location.href = "protege_fiadornaocontrat_deleta.php?envia=Aceitar&codigo="+codigo+"&listagem="+listagem+"&pagina="+pagina;
	}
}

function deleta_corretor(codigo,nome,cpf,listagem,pagina) {
	if( confirm("Tem certeza que deseja deletar o corretor de nome \""+nome+"\" e de cpf \""+cpf+"\"?")){
		window.location.href = "protege_corretor_deleta.php?envia=Aceitar&codigo="+codigo+"&listagem="+listagem+"&pagina="+pagina;
	}
}

function desassociar_corretor(codigo,nome,cpf,listagem,pagina) {
	if( confirm("Tem certeza que deseja desassociar o corretor de nome \""+nome+"\" e de cpf \""+cpf+"\"?")){
		window.location.href = "protege_corretor_desassocia.php?envia=Aceitar&codigo="+codigo+"&listagem="+listagem+"&pagina="+pagina;
	}
}

function del_imovel(cod, vars){
	if (confirm("Tem certeza que deseja deletar o imovel de codigo \""+cod+"\"?")){
		window.location = "del_imo.php?codigo="+cod+"&"+vars;
	}
}

function troca_virgula( num ) {
	var aux = "";
    for ( var i = 0; i < num.length ; i++ ) {
    	if ( num.substring(i, i+1) == "," )
			aux += '.';
		else if ( num.substring(i, i+1) != "." )
			aux += num.substring(i, i+1);
    }
    return aux;
}

function valida_cadastro_imovel () {

	var frente = troca_virgula(document.imovel.frente.value);
	var area = troca_virgula(document.imovel.area.value);
	var fundo = troca_virgula(document.imovel.fundo.value);
	var preco = troca_virgula(document.imovel.preco.value);
	var iptu = troca_virgula(document.imovel.iptu.value);
	var condominio = troca_virgula(document.imovel.condominio.value);
	if ( document.imovel.transacao.value == "" ) {
		alert("Por favor, informe o tipo de transação.");
		document.imovel.transacao.focus();
		return false;
	}
	if ( document.imovel.imovel.value == "" ) {
		alert("Por favor, informe o tipo do imovel.");
		document.imovel.imovel.focus();
		return false;
	}
	if ( document.imovel.situacao.value == "" ) {
		alert("Por favor, informe a situação.");
		document.imovel.situacao.focus();
		return false;
	}
	if ( document.imovel.acabamento.value == "" && ( document.imovel.imovel.value == "Apartamento" || document.imovel.imovel.value == "Flat" || document.imovel.imovel.value == "Casa" ) ) {
		alert("Por favor, informe o padrão de acabanmento.");
		document.imovel.acabamento.focus();
		return false;
	}
	if ( document.imovel.chaves.value == "" ) {
		alert("Por favor, informe aonde será a entrega das chaves.");
		document.imovel.chaves.focus();
		return false;
	}
	if ( document.imovel.mobiliado.value == "" && ( document.imovel.imovel.value == "Apartamento" || document.imovel.imovel.value == "Flat" || document.imovel.imovel.value == "Casa" ) ) {
		alert("Por favor, informe se o imóvel é imobiliado ou não.");
		document.imovel.mobiliado.focus();
		return false;
	}
	if ( document.imovel.zoneamento.value == "" && document.imovel.imovel.value == "Terreno" ) {
		alert("Por favor, digite o zoneamento.");
		document.imovel.zoneamento.focus();
		return false;
	}
	if ( document.imovel.ano_construcao.value == "" && document.imovel.imovel.value != "Rural" && document.imovel.imovel.value != "Terreno" ) {
		alert("Por favor, informe o ano construção.");
		document.imovel.ano_construcao.focus();
		return false;
	}
	if ( document.imovel.frente.value == ""  && document.imovel.imovel.value == "Terreno" ) {
		alert("Por favor, digite a medida da frente.");
		document.imovel.frente.focus();
		return false;
	}
	if ( isNaN(frente)  && document.imovel.frente.value != "" ) {
		alert("Por favor, digite um número para a medida da frente.");
		document.imovel.frente.focus();
		return false;
	}
	if ( document.imovel.area.value == "" && document.imovel.imovel.value != "Rural" && document.imovel.imovel.value != "Terreno" ) {
		alert("Por favor, digite a área útil.");
		document.imovel.area.focus();
		return false;
	}
	if ( isNaN(area) && document.imovel.area.value != "" ) {
		alert("Por favor, digite um número para a área útil.");
		document.imovel.area.focus();
		return false;
	}
	if ( document.imovel.fundo.value == ""  && document.imovel.imovel.value == "Terreno" ) {
		alert("Por favor, digite a medida de fundo.");
		document.imovel.fundo.focus();
		return false;
	}
	if ( isNaN(fundo)  && document.imovel.fundo.value != "" ) {
		alert("Por favor, digite um número para a medida de fundo.");
		document.imovel.fundo.focus();
		return false;
	}
	if ( document.imovel.quartos.value == "" && ( document.imovel.imovel.value == "Apartamento" || document.imovel.imovel.value == "Flat" || document.imovel.imovel.value == "Casa" || document.imovel.imovel.value == "Rural" ) ) {
		alert("Por favor, informe a quantidade de quartos.");
		document.imovel.quartos.focus();
		return false;
	}
	if ( document.imovel.salas.value == "" && ( document.imovel.imovel.value == "Apartamento" || document.imovel.imovel.value == "Flat" || document.imovel.imovel.value == "Casa" || document.imovel.imovel.value == "Rural" ) ) {
		alert("Por favor, informe a quantidade de salas.");
		document.imovel.salas.focus();
		return false;
	}
	if ( document.imovel.suites.value == "" && ( document.imovel.imovel.value == "Apartamento" || document.imovel.imovel.value == "Flat" || document.imovel.imovel.value == "Casa" ) ) {
		alert("Por favor, informe a quantidade de suítes.");
		document.imovel.suites.focus();
		return false;
	}
	if ( document.imovel.banhos.value == ""  && document.imovel.imovel.value != "Terreno" ) {
		alert("Por favor, informe a quantidade de banhos.");
		document.imovel.banhos.focus();
		return false;
	}
	if ( document.imovel.garagem.value == "" && ( document.imovel.imovel.value == "Apartamento" || document.imovel.imovel.value == "Flat" || document.imovel.imovel.value == "Casa" ) ) {
		alert("Por favor, informe a quantidade de vagas na garagem.");
		document.imovel.garagem.focus();
		return false;
	}
	if ( document.imovel.elevadores.value == "" && ( document.imovel.imovel.value == "Apartamento" || document.imovel.imovel.value == "Flat" ) ) {
		alert("Por favor, informe a quantidade de elevadores.");
		document.imovel.elevadores.focus();
		return false;
	}
	if ( document.imovel.andares.value == "" && ( document.imovel.imovel.value == "Apartamento" || document.imovel.imovel.value == "Flat" || document.imovel.imovel.value == "Casa" ) ) {
		alert("Por favor, informe a quantidade de andares.");
		document.imovel.andares.focus();
		return false;
	}
	if ( document.imovel.unidade.value == "" && ( document.imovel.imovel.value == "Apartamento" || document.imovel.imovel.value == "Flat" ) ) {
		alert("Por favor, informe a quantidade de unidades por andar.");
		document.imovel.unidade.focus();
		return false;
	}
	if ( document.imovel.box.value == "" && ( document.imovel.imovel.value == "Apartamento" || document.imovel.imovel.value == "Flat" || document.imovel.imovel.value == "Casa" || document.imovel.imovel.value == "Rural" ) ) {
		alert("Por favor, informe a quantidade de box.");
		document.imovel.box.focus();
		return false;
	}
	if ( document.imovel.armario_quarto.value == "" && ( document.imovel.imovel.value == "Apartamento" || document.imovel.imovel.value == "Flat" || document.imovel.imovel.value == "Casa" || document.imovel.imovel.value == "Rural" ) ) {
		alert("Por favor, informe se o quartos tem armários ou não.");
		document.imovel.armario_quarto.focus();
		return false;
	}
	if ( document.imovel.armario_cozinha.value == "" && ( document.imovel.imovel.value == "Apartamento" || document.imovel.imovel.value == "Flat" || document.imovel.imovel.value == "Casa" || document.imovel.imovel.value == "Rural" ) ) {
		alert("Por favor, informe se a cozinha tem armários ou não.");
		document.imovel.armario_cozinha.focus();
		return false;
	}
	if ( document.imovel.dce.value == "" && ( document.imovel.imovel.value == "Apartamento" || document.imovel.imovel.value == "Casa" ) ) {
		alert("Por favor, informe se o imóvel tem dce ou não.");
		document.imovel.dce.focus();
		return false;
	}
	if ( document.imovel.estado_cad.value == "" ) {
		alert("Por favor, escolha o estado.");
		document.imovel.estado_cad.focus();
		return false;
	}
	if ( ( document.imovel.cidade_cad.value == "" || document.imovel.cidade_cad.value == "0" ) && document.imovel.cidade_outra.value == "" ) {
		alert("Por favor, escolha a cidade. Se a cidade não estiver na lista, digite a cidade no campo outra cidade.");
		document.imovel.cidade_cad.focus();
		return false;
	}
	if ( ( document.imovel.bairro_cad.value == "" || document.imovel.bairro_cad.value == "0" ) && document.imovel.bairro_outro.value == "" && document.imovel.imovel.value != "Rural" ) {
		alert("Por favor, escolha o bairro. Se a bairro não estiver na lista, digite o bairro no campo outro bairro.");
		document.imovel.bairro_cad.focus();
		return false;
	}
	if ( valida_cep(document.imovel.cep.value) && document.imovel.cep.value != "" ) {
		alert("Por favor, digite um cep válido no formato 99999-99.");
		document.imovel.cep.focus();
		return false;
	}
	if ( document.imovel.preco.value == "" ) {
		alert("Por favor, digite o preço.");
		document.imovel.preco.focus();
		return false;
	}
	if ( isNaN(preco) ) {
		alert("Por favor, digite um número para o preço.");
		document.imovel.preco.focus();
		return false;
	}
	if ( document.imovel.condominio.value == "" && ( document.imovel.imovel.value == "Apartamento" || document.imovel.imovel.value == "Flat" ) ) {
		alert("Por favor, digite o condomínio.");
		document.imovel.condominio.focus();
		return false;
	}
	if ( isNaN(condominio) && document.imovel.condominio.value != "" ) {
		alert("Por favor, digite um número para o condomínio.");
		document.imovel.condominio.focus();
		return false;
	}
	if ( document.imovel.iptu.value == "" && document.imovel.imovel.value != "Terreno" ) {
		alert("Por favor, digite o iptu.");
		document.imovel.iptu.focus();
		return false;
	}
	if ( isNaN(iptu) && document.imovel.iptu.value != "" ) {
		alert("Por favor, digite um número para o iptu.");
		document.imovel.iptu.focus();
		return false;
	}
	if ( document.imovel.situacao.value == "Em construção" && valida_data(document.imovel.dia.value+"/"+document.imovel.mes.value+"/"+document.imovel.ano.value) ) {
		alert("Por favor, digite uma data válida no formatao 'dd/mm/aaaa', ex. ( 01/01/2002 ), para o campo data de previsão de entrega.");
		document.imovel.dia.focus();
		return false;
	}
	/*
	if ( document.imovel.pequena1.value != "" || document.imovel.grande1.value != "" ) {
		if ( document.imovel.pequena1.value == "" ) {
			alert("Por favor, escolha a foto pequena 1.");
			document.imovel.pequena1.focus();
			return false;
		}
		if ( document.imovel.grande1.value == "" ) {
			alert("Por favor, escolha a foto grande 1.");
			document.imovel.grande1.focus();
			return false;
		}
	}
	if ( document.imovel.pequena2.value != "" || document.imovel.grande2.value != "" ) {
		if ( document.imovel.pequena2.value == "" ) {
			alert("Por favor, escolha a foto pequena 2.");
			document.imovel.pequena2.focus();
			return false;
		}
		if ( document.imovel.grande2.value == "" ) {
			alert("Por favor, escolha a foto grande 2.");
			document.imovel.grande2.focus();
			return false;
		}
	}
	if ( document.imovel.pequena3.value != "" || document.imovel.grande3.value != "" ) {
		if ( document.imovel.pequena3.value == "" ) {
			alert("Por favor, escolha a foto pequena 3.");
			document.imovel.pequena3.focus();
			return false;
		}
		if ( document.imovel.grande3.value == "" ) {
			alert("Por favor, escolha a foto grande 3.");
			document.imovel.grande3.focus();
			return false;
		}
	}
	if ( document.imovel.pequena4.value != "" || document.imovel.grande4.value != "" ) {
		if ( document.imovel.pequena4.value == "" ) {
			alert("Por favor, escolha a foto pequena 4.");
			document.imovel.pequena4.focus();
			return false;
		}
		if ( document.imovel.grande4.value == "" ) {
			alert("Por favor, escolha a foto grande 4.");
			document.imovel.grande4.focus();
			return false;
		}
	}
	if ( document.imovel.pequena5.value != "" || document.imovel.grande5.value != "" ) {
		if ( document.imovel.pequena5.value == "" ) {
			alert("Por favor, escolha a foto pequena 5.");
			document.imovel.pequena5.focus();
			return false;
		}
		if ( document.imovel.grande5.value == "" ) {
			alert("Por favor, escolha a foto grande 5.");
			document.imovel.grande5.focus();
			return false;
		}
	}
	if ( document.imovel.pequena6.value != "" || document.imovel.grande6.value != "" ) {
		if ( document.imovel.pequena6.value == "" ) {
			alert("Por favor, escolha a foto pequena 6.");
			document.imovel.pequena6.focus();
			return false;
		}
		if ( document.imovel.grande6.value == "" ) {
			alert("Por favor, escolha a foto grande 6.");
			document.imovel.grande6.focus();
			return false;
		}
	}
	if ( document.imovel.pequena7.value != "" || document.imovel.grande7.value != "" ) {
		if ( document.imovel.pequena7.value == "" ) {
			alert("Por favor, escolha a foto pequena 7.");
			document.imovel.pequena7.focus();
			return false;
		}
		if ( document.imovel.grande7.value == "" ) {
			alert("Por favor, escolha a foto grande 7.");
			document.imovel.grande7.focus();
			return false;
		}
	}
	if ( document.imovel.pequena8.value != "" || document.imovel.grande8.value != "" ) {
		if ( document.imovel.pequena8.value == "" ) {
			alert("Por favor, escolha a foto pequena 8.");
			document.imovel.pequena8.focus();
			return false;
		}
		if ( document.imovel.grande8.value == "" ) {
			alert("Por favor, escolha a foto grande 8.");
			document.imovel.grande8.focus();
			return false;
		}
	}
	*/
	return true;
}

function altera_meucadastro ( ){
	document.cadastro.action = "meucadastro_altera.php";
	document.cadastro.submit();
	return;
}

function altera_formcadastro ( ){
	document.cadastro.action = "formcadastro_altera.php";
	document.cadastro.submit();
	return;
}

function altera_imovel ( str ){
	document.imovel.action = "edita_imovel_altera.php?"+str;
	document.imovel.submit();
	return;
}

function altera_cadimovel ( ){
	document.imovel.action = "cadimoveis_altera.php";
	document.imovel.submit();
	return;
}

function edita_curriculo ( ){
	document.curriculo.action = "cad_curriculos_altera.php";
	document.curriculo.submit();
	return;
}

function alerta_exlcui ( elemento , codigo ) {
	if ( elemento.checked == true ) {
		if (!(confirm("Tem certeza que deseja excluir a foto "+codigo+""))) elemento.checked = false;
	}
	return;
}

function Muda_Preco (form1,campo1,campo2,campo3,inicial){
	var i;
	var Tipo = document.forms(form1).item(campo1).options[document.forms(form1).item(campo1).selectedIndex].value;
	
	for (var i = document.forms(form1).item(campo2).options.length ; i > 0 ; i-- ) {
		document.forms(form1).item(campo2).options[i-1] = null;
	}
	document.forms(form1).item(campo3).options[0]=new Option(inicial,'');
	
	for (var i = document.forms(form1).item(campo3).options.length ; i > 0 ; i-- ) {
		document.forms(form1).item(campo3).options[i-1] = null;
	}
	document.forms(form1).item(campo3).options[0]=new Option(inicial,'');
	
	if ((Tipo == "Aluguel") || (Tipo == "Temporada")){
		var precos = new Array('100','200','300','400','500','750','1.000','1.500','2.000','5.000','8.000','12.000');
		document.forms(form1).item(campo2).options[0]=new Option(inicial,'');
		document.forms(form1).item(campo3).options[0]=new Option(inicial,'');
		for(i=0;i<precos.length;i++){
			document.forms(form1).item(campo2).options[i+1]= new Option(precos[i],precos[i]);
			document.forms(form1).item(campo3).options[i+1]= new Option(precos[i],precos[i]);
		}
	}
	
	else{
		var precos = new Array('30.000','45.000','60.000','75.000','90.000','105.000','120.000','135.000','150.000','165.000','180.000','195.000','210.000','240.000','270.000','300.000','330.000','360.000','420.000','480.000','600.000','720.000','900.000','1.500.000','3.000.000','5.000.000','7.500.000','10.500.000');
		document.forms(form1).item(campo2).options[0]=new Option(inicial,'');
		document.forms(form1).item(campo3).options[0]=new Option(inicial,'');
		for(i=0;i<precos.length;i++){
			document.forms(form1).item(campo2).options[i+1]= new Option(precos[i],precos[i]);
			document.forms(form1).item(campo3).options[i+1]= new Option(precos[i],precos[i]);
		}
	}
}

function isblank(s){
	for(var i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	}
	return true;
}

function validaNumero(numero){
	if (parseInt){
		if (parseInt(numero)!="NaN"){
			return true;
		}else{
			return false;
		}
	}else{

		return true;
	}
}

function valida_indice(){
	
	var d = new Date();
	d.getDate();
	i = document.pesquisa_indice;

	if (i.mes_inicial.value==""){
		i.mes_inicial.value = (d.getMonth()+1);
	}
	if (i.ano_inicial.value==""){
		i.ano_inicial.value = d.getYear();
	}
	if (i.mes_final.value==""){
		i.mes_final.value = (d.getMonth()+1);
	}
	if (i.ano_final.value==""){
		i.ano_final.value = d.getYear();
	}
	if (i.ano_final.value < i.ano_inicial.value){
		alert("O ano final deve ser maior que o ano inicial!");
		i.ano_final.focus();
		return false;
	}
	if (parseInt(i.ano_final.value) == parseInt(i.ano_inicial.value)){
		if (parseInt(i.mes_final.value) < parseInt(i.mes_inicial.value)){
			alert("O mês final deve ser maior que o mês inicial!");
			i.mes_final.focus();
			return false;
		}		
	}
	submit();
	return true;
}

function pop(url){
janela=window.open(url,'Popup_Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=600,height=400,left=0,top=0')
}


function ValidaInteiro(valor) {
	var strNumeros = '0123456789';

	for (i = 0; i < valor.length; i++)
		if ((strNumeros.indexOf(valor.substr(i, 1)) == -1) && !((i == 0) && (valor.substr(i, 1) == '-')))
				return false;
	return true;
}

function FormataInteiro(campo, event) {
	var strNumeros = '0123456789';

	for (i = 0; i < campo.value.length; i++)
		if ((strNumeros.indexOf(campo.value.substr(i, 1)) == -1) && !((i == 0) && (campo.value.substr(i, 1) == '-'))) {
			campo.value = campo.value.substr(0, i);
			return false;
	}
}

function votaEnquete() {
 codEnq = enquete.codigo.value;	 
 size = enquete.voto.length;
 valor = -1;
 for ( i=0 ; i<size  ; i++  ) {
	if (enquete.voto[i].checked)	{
		valor = enquete.voto[i].value;
		break;
	}
 }
 if (valor != -1) {
	 url = "../home/enquete.php?codigo="+codEnq+"&voto="+valor+"&acao=votar";
	 window.open(url,'','width=250,height=320');
 } else 
	 alert("Selecione uma opção.");
 
}

function imprime_curriculo(cod) {
		url = "imprime_curriculo.php?codigo=" + cod;
		window.open(url, '', 'width=550, height=600, scrollbars=yes');
}