function novaJanela(pag,win,toolbar,location,directories,status,menubar,scrollbars,resizable,copyhistory,left,top,width,height)
{
	//novaJanela(pagina,nomeajanela,barradeferramentas,location,directories,status,menubar,scrollbars,resizable,copyhistory,left,top,width,height)
	//novaJanela(pagina,nomeajanela,'no','no','no','no','no','no','no','yes',200,200,300,300)
	var par = 'tollbar='+toolbar+',location='+location+',directores='+directories+',status='+status+',menubar='+menubar+',scrollbars='+scrollbars+',resizable='+resizable+',copyhistory='+copyhistory+',left='+left+',top='+top+',width='+width+',height='+height;
	window.open(pag, win, par);
}


function DigitarSoNumero()
{
	if(((event.keyCode>=0x30)&&(event.keyCode<=0x39))||(event.keyCode==8)||(event.keyCode==13)){
		return true;
	}
event.keyCode=0;
}

function selCidade(val)
{
	var x = val.selectedIndex;
	var url = val.options[x].value;
	if (url != "")
	{
		window.location.href=url;
	}
}



function validaCPF(CPF)
{
if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" || CPF == "22222222222" || CPF == "33333333333" || CPF == "44444444444" || CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" || CPF == "88888888888" || CPF == "99999999999")
return false;
soma = 0;
for (i=0; i < 9; i ++)
soma += parseInt(CPF.charAt(i)) * (10 - i);
resto = 11 - (soma % 11);
if (resto == 10 || resto == 11)
resto = 0;
if (resto != parseInt(CPF.charAt(9)))
return false;
soma = 0;
for (i = 0; i < 10; i ++)
soma += parseInt(CPF.charAt(i)) * (11 - i);
resto = 11 - (soma % 11);
if (resto == 10 || resto == 11)
resto = 0;
if (resto != parseInt(CPF.charAt(10)))
return false;
//alert('Correto');
return true;
}


function validaCNPJ(CNPJ)
{
//CNPJ = document.validacao.CNPJID.value;
erro = new String;
if (CNPJ.length < 18) erro += "E' necessarios preencher corretamente o numero do CNPJ! \n\n";
if ((CNPJ.charAt(2) != ".") || (CNPJ.charAt(6) != ".") || (CNPJ.charAt(10) != "/") || (CNPJ.charAt(15) != "-")){
if (erro.length == 0) erro += "E' necessarios preencher corretamente o numero do CNPJ! \n\n";
}
//substituir os caracteres que nao sao numeros
if(document.layers && parseInt(navigator.appVersion) == 4){
x = CNPJ.substring(0,2);
x += CNPJ.substring(3,6);
x += CNPJ.substring(7,10);
x += CNPJ.substring(11,15);
x += CNPJ.substring(16,18);
CNPJ = x; 
}
else
{
CNPJ = CNPJ.replace(".","");
CNPJ = CNPJ.replace(".","");
CNPJ = CNPJ.replace("-","");
CNPJ = CNPJ.replace("/","");
}
var nonNumbers = /\D/;
if (nonNumbers.test(CNPJ)) erro += "A verificacao de CNPJ suporta apenas numeros! \n\n"; 
var a = [];
var b = new Number;
var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
for (i=0; i<12; i++){
a[i] = CNPJ.charAt(i);
b += a[i] * c[i+1];
}
if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
b = 0;
for (y=0; y<13; y++) {
b += (a[y] * c[y]); 
}
if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }
if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){
erro +="Digito verificador com problema!";
}
if (erro.length > 0){
alert(erro);
return false;
} else {
//alert("CNPJ valido!");
}
return true;
}


function isNum( caractere ) 
{ 
         var strValidos = "0123456789" 
         if ( strValidos.indexOf( caractere ) == -1 ) 
                 return false; 
         return true; 
} 
function validaTecla(campo, event) 
{ 
         var BACKSPACE=  8; 
         var key; 
         var tecla; 


         CheckTAB=true; 
         if(navigator.appName.indexOf("Netscape")!= -1) 
                 tecla= event.which; 
         else 
                 tecla= event.keyCode; 


         key = String.fromCharCode( tecla); 
         //alert( \'key: \' + tecla + \'  -> campo: \' + campo.value); 


         if ( tecla == 13 ) 
                 return false; 
         if ( tecla == BACKSPACE ) 
                 return true; 
         return ( isNum(key)); 
} 
function FormataCNPJ( el ) 
{ 
         vr = el.value; 
         tam = vr.length; 


      if ( vr.indexOf(".") == -1 ) 
      { 
      if ( tam <= 2 ) 
              el.value = vr; 
      if ( (tam > 2) && (tam <= 6) ) 
              el.value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, tam ); 
      if ( (tam >= 7) && (tam <= 10) ) 
              el.value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '.' + vr.substr( 5, 3 ) + '/'; 
      if ( (tam >= 11) && (tam <= 18) ) 
             el.value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '.' + vr.substr( 5, 3 ) + '/' + vr.substr( 8, 4 ) + '-' + vr.substr( 12, 2 ) ; 
      } 
      return true; 
} 



function soNumero(e)
{
if (document.all) // Internet Explorer
var tecla = event.keyCode;
else if(document.layers) // Nestcape
var tecla = e.which;
if (tecla > 47 && tecla < 58) // numeros de 0 a 9
return true;

else
{
if (tecla != 8) // backspace
event.keyCode = 0;
//return false;
else
return true;
}
}


function valFrm()
{
	var f = window.document.frm;
	if (f.cli_nome.value=="")
	{
		alert("O campo NOME não pode ser vazio.");
		f.cli_nome.focus();
		return false;
	}
	if (f.cli_endereco.value=="")
	{
		alert("O campo ENDEREÇO não pode ser vazio.");
		f.cli_endereco.focus();
		return false;
	}
	if (f.cli_numero.value=="")
	{
		alert("O campo NÚMERO não pode ser vazio.");
		f.cli_numero.focus();
		return false;
	}

	if (f.cli_cep.value=="")
	{
		alert("O campo CEP não pode ser vazio.");
		f.cli_cep.focus();
		return false;
	}
	if (f.cli_tele.value=="")
	{
		alert("O campo TELEFONE não pode ser vazio.");
		f.cli_tele.focus();
		return false;
	}
	if (f.cli_email.value=="")
	{
		alert("O campo E-MAIL não pode ser vazio.");
		f.cli_email.focus();
		return false;
	}
	if (f.cli_email.value.indexOf('@', 0) == -1){
		alert('O campo E-MAIL está incorreto.');
		f.cli_email.focus();
		return false;
	}
	if (f.cli_email.value.indexOf('.', 0) == -1){
		alert("O campo E-MAIL está incorreto.");
		f.cli_email.focus();
		return false;
	}

	if (f.cli_senha.value=="")
	{
		alert("O campo SENHA não pode ser vazio.");
		f.cli_senha.focus();
		return false;
	}
	/*if (f.cli_lembretesenha.value=="")
	{
		alert("O campo LEMBRETE DE SENHA não pode ser vazio.");
		f.cli_lembretesenha.focus();
		return false;
	}
*/
	if ( (f.cli_informativo[0].checked == false) && (f.cli_informativo[1].checked == false))
	{
		alert("A opção INFORMATIVO não pode ser vazio.");
		return false;
	}
	

	if (f.cli_dns_dia.value=="")
	{
		alert("O campo DIA da data de nascimento não pode ser vazio.");
		f.cli_dns_dia.focus();
		return false;
	}
	if (f.cli_dns_mes.value=="")
	{
		alert("O campo MÊS da data de nascimento não pode ser vazio.");
		f.cli_dns_mes.focus();
		return false;
	}
	if (f.cli_dns_ano.value=="")
	{
		alert("O campo ANO da data de nascimento não pode ser vazio.");
		f.cli_dns_ano.focus();
		return false;
	}
	if ( (f.cli_sexo[0].checked==false) && (f.cli_sexo[1].checked==false) )
	{
		alert("A opção SEXO não pode estar vazia.");
		return false;
	}


	if (f.cli_cidade.value=="")
	{
		alert("O campo CIDADE não pode ser vazio.");
		f.cli_cidade.focus();
		return false;
	}
	if (f.cli_estado.value=="")
	{
		alert("O campo ESTADO não pode ser vazio.");
		f.cli_estado.focus();
		return false;
	}
	if (f.cli_vertudo.value=="")
	{
		alert("Marque se deseja que seus dados sejam exibidos.");
		//f.tb_estado_est_id.focus();
		return false;
	}

return true;
}
