
function AtualizaAtras()
		
		{
  			window.opener.location.reload()
  			self.close()
		}
		
//SCRIPT PARA VALIDAR O CAMPO DE EMAIL
function checaEmail(Email) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Email)) {
    return true;
  }
  else {
	return false;
  }
}


function SomenteNumeros()
  {
   if ( (event.keyCode >= 48) && (event.keyCode <= 57))
    {
     return true
    }
   else
    {
     if (event.keyCode != 8)
       {
         event.keyCode = 0
         return false
       }
    }
  }
function checkdata(data)
 {
   strdata = data.value.split("/");
   dia = strdata[0];
   mes = strdata[1];
   ano = strdata[2];
   if ( (dia > 31) || (isNaN(dia)) || (mes > 12) || (isNaN(mes)) || (isNaN(ano)) || (ano.length < 4) )
    {
	  alert("Data Inválida! A Data deve estar no formato dd/mm/aaaa.\nExemplo: 25/12/2002");
	  //data.focus();
	}
   else
    {
	  return true;
	}
 }

function AbreJanela(janela,larg,altura)
  {
   window.open(janela,'popup','width='+larg+ ' height='+altura+ ' scrollbars=yes resizable=no menubar=no status=yes ');
  }

function formata_valor(campo)
 {
   campo.value = campo.value.replace(".","");
   campo.value = campo.value.replace(",","");
   campo.value = campo.value + ".00";
 }

function check_cpf(pcpf)
{
if (pcpf.length != 11)
{sim=false}
else {sim=true}
//verifica se os numeros digitados são iguais
if (sim)
{
i = 1;
while(pcpf.charAt(i) == pcpf.charAt(i -1) && i < 10)
{
i++;
}
if(i == 10) sim=false
else sim=true
}
if (sim)
{
for (i=0; i<=(pcpf.length-1) && sim; i++)
{
val = pcpf.charAt(i)

if((val!="9")&&(val!="0")&&(val!="1")&&(val!="2")&&(val!="3")&&(val!="4")&&(
val!="5")&&(val!="6")&&(val!="7")&&(val!="8")) {sim=false}
}
if (sim)
{
soma = 0
for (i=0;i<=8;i++)
{
val = eval(pcpf.charAt(i))
soma = soma + (val*(i+1))
}
resto = soma % 11
if (resto>9) dig = resto -10
else dig = resto
if (dig != eval(pcpf.charAt(9))) { sim=false }
else
{
soma = 0
for (i=0;i<=7;i++)
{
val = eval(pcpf.charAt(i+1))
soma = soma + (val*(i+1))
}
soma = soma + (dig * 9)
resto = soma % 11
if (resto>9) dig = resto -10
else dig = resto
if (dig != eval(pcpf.charAt(10))) { sim = false }
else sim = true
}
}
}
if (sim) return true;
else return false;
}

function check_cgc (StrCGC)
{
var varFirstChr = StrCGC.charAt(0);
var vlMult,vlControle,s1, s2 = "";
var i,j,vlDgito,vlSoma = 0;
for ( var i=0; i<=13; i++ ) {

var c = StrCGC.charAt(i);
if( ! (c>="0")&&(c<="9") )
 {
   return false;
 }
if( c!=varFirstChr ) { vaCharCGC = true; }
}
if( ! vaCharCGC )
 {
   return false ;
 }


s1 = StrCGC.substring(0,12);
s2 = StrCGC.substring(12,15);
vlMult = "543298765432";
vlControle = "";
for ( j=1; j<3; j++ ) {

vlSoma = 0;
for ( i=0; i<12; i++ )
{ vlSoma += eval( s1.charAt(i) )* eval( vlMult.charAt(i) );}
if( j == 2 ){ vlSoma += (2 * vlDgito); }
vlDgito = ((vlSoma*10) % 11);
if( vlDgito == 10 ){ vlDgito = 0; }
vlControle = vlControle + vlDgito;
vlMult = "654329876543";
}
if( vlControle != s2 )
 { 
   return false;
 }
else
 {
   return true;
 }


}




/***
* Descrição.: formata um campo do formulário de
* acordo com a máscara informada...
* Parâmetros: - objForm (o Objeto Form)
* - strField (string contendo o nome
* do textbox)
* - sMask (mascara que define o
* formato que o dado será apresentado,
* usando o algarismo "9" para
* definir números e o símbolo "!" para
* qualquer caracter...
* - evtKeyPress (evento)
*
* Uso.......: <input type="textbox"
* name="xxx".....
* onkeypress="return txtBoxFormat(document.rcfDownload, 'str_cep', '99999-999', event);">
* Observação: As máscaras podem ser representadas
* como os exemplos abaixo:
* CEP -> 99999-999
* CPF -> 999.999.999-99
* CNPJ -> 99.999.999/9999-99
* C/C -> 999999-!
* Tel -> (99) 9999-9999
***/
function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

if(document.all) { // Internet Explorer
nTecla = evtKeyPress.keyCode; }
else if(document.layers) { // Nestcape
nTecla = evtKeyPress.which;
}

sValue = objForm[strField].value;

// Limpa todos os caracteres de formatação que
// já estiverem no campo.
sValue = sValue.toString().replace( "-", "" );
sValue = sValue.toString().replace( "-", "" );
sValue = sValue.toString().replace( ".", "" );
sValue = sValue.toString().replace( ".", "" );
sValue = sValue.toString().replace( "/", "" );
sValue = sValue.toString().replace( "/", "" );
sValue = sValue.toString().replace( "(", "" );
sValue = sValue.toString().replace( "(", "" );
sValue = sValue.toString().replace( ")", "" );
sValue = sValue.toString().replace( ")", "" );
sValue = sValue.toString().replace( " ", "" );
sValue = sValue.toString().replace( " ", "" );
fldLen = sValue.length;
mskLen = sMask.length;

i = 0;
nCount = 0;
sCod = "";
mskLen = fldLen;

while (i <= mskLen) {
bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

if (bolMask) {
sCod += sMask.charAt(i);
mskLen++; }
else {
sCod += sValue.charAt(nCount);
nCount++;
}

i++;
}

objForm[strField].value = sCod;

if (nTecla != 8) { // backspace
if (sMask.charAt(i-1) == "9") { // apenas números...
return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9
else { // qualquer caracter...
return true;
} }
else {
return true;
}
}


//ABRE FOTOS - SOCIAL 2004
function openfoto(foto,largura,altura,texto){
helpwindow=window.open('','helpwindow','resizable=no,width='+largura+',height='+altura+',scrollbars=no,toolbar=no,status=no, top=40, left=360');
helpwindow.document.write('<html><head><title>CASA COR &reg;</title><style>a {text-decoration: none}</style></head>');
helpwindow.document.write('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
helpwindow.document.write('<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="5"><tr><td><p align="center"><img src="images/social2004/')
helpwindow.document.write(foto);
helpwindow.document.write('"');
helpwindow.document.write('<br> <font face="verdana, arial" size="1" align="center">') 
helpwindow.document.write(texto);
helpwindow.document.write('</font>');
helpwindow.document.write('</p>');
helpwindow.document.write('<center>');
helpwindow.document.write('<a href="javascript:window.close()"><font face="arial" color="#000000"><small>Carregando...</small></font></a>');
helpwindow.document.write('</center></td></tr></table>');
helpwindow.document.write('</body>');
helpwindow.document.write('</html>');

helpwindow.document.close();
}


//ABRE FOTOS - PROJETO ARQUITETONICO 2004
function openfoto2(foto,largura,altura,texto){
helpwindow=window.open('','helpwindow','resizable=no,width='+largura+',height='+altura+',scrollbars=no,toolbar=no,status=no, top=40, left=360');
helpwindow.document.write('<html><head><title>CASA COR &reg;</title><style>a {text-decoration: none}</style></head>');
helpwindow.document.write('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
helpwindow.document.write('<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="5"><tr><td><p align="center"><img src="images/proj_arquitetonico/')
helpwindow.document.write(foto);
helpwindow.document.write('"');
helpwindow.document.write('<br> <font face="verdana, arial" size="1" align="center">') 
helpwindow.document.write(texto);
helpwindow.document.write('</font>');
helpwindow.document.write('</p>');
helpwindow.document.write('<center>');
helpwindow.document.write('<a href="javascript:window.close()"><font face="arial" color="#000000"><small>Carregando...</small></font></a>');
helpwindow.document.write('</center></td></tr></table>');
helpwindow.document.write('</body>');
helpwindow.document.write('</html>');

helpwindow.document.close();
}



