function ValidaCNPJ(form){
		//verifica a quantidade de caracteres digitados
		//e o transforma em um numero inteiro.
		cnpj = document.form.cnpjf.value;
		tamanho = document.form.cnpjf.value;
		tamanho = tamanho.length;
		tamanho = parseInt(tamanho,10);
		if(tamanho < 18 || tamanho >18){
			alert("O campo CNPJ precisa ter exatamente 18 digitos");
			document.form.cnpjf.focus();
			return (false);
		}
		else{
			if(document.form.cnpjf.value == "00.000.000/0000-00"){
				alert("O CNPJ nao pode ser composto apenas do nº 0");
				document.form.cnpjf.focus();
				return (false);
			}
			else{
				//logica da validade
				n1 = document.form.cnpjf.value.substring(0,1);
				n2 = document.form.cnpjf.value.substring(1,2);
				n3 = document.form.cnpjf.value.substring(2,3);
				n4 = document.form.cnpjf.value.substring(3,4);
				n5 = document.form.cnpjf.value.substring(4,5);
				n6 = document.form.cnpjf.value.substring(5,6);
				n7 = document.form.cnpjf.value.substring(6,7);
				n8 = document.form.cnpjf.value.substring(7,8);
				n9 = document.form.cnpjf.value.substring(8,9);
				n10 = document.form.cnpjf.value.substring(9,10);
				n11 = document.form.cnpjf.value.substring(10,11);
				n12 = document.form.cnpjf.value.substring(11,12);
				n13 = document.form.cnpjf.value.substring(12,13);
				n14 = document.form.cnpjf.value.substring(13,14);

				//conta para identificação do 13 digito

				soma = n1 * 5;
				soma += n2 * 4;
				soma += n3 * 3;
				soma += n4 * 2;
				soma += n5 * 9;
				soma += n6 * 8;
				soma += n7 * 7;
				soma += n8 * 6;
				soma += n9 * 5;
				soma += n10 * 4;
				soma += n11 * 3;
				soma += n12 * 2;

				divisao = soma / 11;
				divisao = parseInt(divisao,10);
				soma = soma - (11 * divisao);

				if(soma == 0 || soma == 1){
					resultado1 = 0;
				}
				else{
					resultado1 = 11 - soma;
				}
				//conta para identificacao do 14 digito
				if(resultado1 == n13){

					soma = n1 * 6;
					soma += n2 * 5;
					soma += n3 * 4;
					soma += n4 * 3;
					soma += n5 * 2;
					soma += n6 * 9;
					soma += n7 * 8;
					soma += n8 * 7;
					soma += n9 * 6;
					soma += n10 * 5;
					soma += n11 * 4;
					soma += n12 * 3;
					soma += n13 * 2;
					
					divisao = soma / 11;
					divisao = parseInt(divisao,10);
					soma = soma - (11 * divisao);

					if(soma == 0 || soma == 1){
						resultado2 = 0;
					}
					else{
						resultado2 = 11 - soma;
					}
					if(resultado2 == n14){
					return (true);
					}
					else{
						alert("CNPJ Inválido");
						document.form.cnpjf.focus();
						return (false);
					}
				}else{
					alert ("CNPJ Inválido");
					document.form.cnpjf.focus();
					return (false);
				}
			}
		}
	}	
// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}
function numeros ()
{
	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 MascaraCEP (formato, keypress, objeto)
	{
	campo = eval (objeto);
	if (formato=='cepc')
		{
		caracteres = '01234567890';
		separacoes = 1;
		separacao1 = '-';
		conjuntos = 2;
		conjunto1 = 5;
		conjunto2 = 3;
		if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < 
		(conjunto1 + conjunto2 + 1))
			{
			if (campo.value.length == conjunto1) 
			   campo.value = campo.value + separacao1;
			}
		else 
			event.returnValue = false;
		}
		if (formato=='cep')
		{
		caracteres = '01234567890';
		separacoes = 1;
		separacao1 = '-';
		conjuntos = 2;
		conjunto1 = 5;
		conjunto2 = 3;
		if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < 
		(conjunto1 + conjunto2 + 1))
			{
			if (campo.value.length == conjunto1) 
			   campo.value = campo.value + separacao1;
			}
		else 
			event.returnValue = false;
		}
			if (formato=='cepf')
		{
		caracteres = '01234567890';
		separacoes = 1;
		separacao1 = '-';
		conjuntos = 2;
		conjunto1 = 5;
		conjunto2 = 3;
		if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < 
		(conjunto1 + conjunto2 + 1))
			{
			if (campo.value.length == conjunto1) 
			   campo.value = campo.value + separacao1;
			}
		else 
			event.returnValue = false;
		}
	}
function MascaraCNPJ (formato, keypress, objeto)
	{
	campo = eval (objeto);
	if (formato=='cnpjf')
		{
		caracteres = '01234567890';
		separacoes = 4;
		separacao1 = '.';
		separacao2 = '/';
		separacao3 = '-';				
		conjuntos = 5;
		conjunto1 = 2;
		conjunto2 = 6;
		conjunto3 = 10;
		conjunto4 = 15;
		conjunto5 = 3;
		if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < (conjunto1 + 1 + conjunto2 + 1 + conjunto3 + 1 + conjunto4 + 1 + conjunto5 + 1))
			{
			if (campo.value.length == conjunto1)
			   campo.value = campo.value + separacao1;
			if (campo.value.length == conjunto2)
			   campo.value = campo.value + separacao1;
			if (campo.value.length == conjunto3)
			   campo.value = campo.value + separacao2;
			if (campo.value.length == conjunto4)
			   campo.value = campo.value + separacao3;			   
			}
		else 
			event.returnValue = false;
		}
	}

function MascaraINS (formato, keypress, objeto)
	{
	campo = eval (objeto);
	if (formato=='inscf')
		{
		caracteres = '01234567890';
		separacoes = 1;
		separacao1 = '.';
		conjuntos = 2;
		conjunto1 = 3;
		conjunto2 = 7;
		conjunto3 = 10;		
		if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < 
		(conjunto1 + conjunto2 + 1))
			{
			if (campo.value.length == conjunto1) 
			   campo.value = campo.value + separacao1;
			if (campo.value.length == conjunto2) 
			   campo.value = campo.value + separacao1;			   
			}
		else 
			event.returnValue = false;
		}
	}
function checkData (){
		if (document.form.nomec.value == "") {
                alert("Por favor preencha o campo Nome.")
                document.form.nomec.focus()
        return false;
		}
		if (document.form.atividadec.value == "") {
                alert("Por favor preencha o campo Atividade.")
                document.form.atividadec.focus()
        return false;
		}
		if (document.form.dddtelc.value == "") {
                alert("Por favor preencha o campo DDD para o telefone.")
                document.form.dddtelc.focus()
        return false;
		}
		if (document.form.dddtelc.value.length <= 1)
		{
			   	alert("O campo DDD deve conter no mínimo 2 dígitos.");
			   	document.form.dddtelc.focus();
	   	return false;
		}  
		if (document.form.telefonec.value == "") {
                alert("Por favor preencha o campo Telefone.")
                document.form.telefonec.focus()
        return false;
		}		
		if (document.form.cidadec.value == "") {
                alert("Por favor preencha o campo Cidade.")
                document.form.cidadec.focus()
        return false;
        }
		if (document.form.cepc.value == "")
  		{
			    alert("Por favor preencha o campo CEP. Ex: 80000-200");
			    document.form.cepc.focus();
	    return false;
		}
		if (document.form.cepc.value.length <= 8)
		{
			   	alert("Por favor preencha o CEP corretamente.");
			   	document.form.cepc.focus();
	   	return false;
		}  
		if (document.form.estadoc.value == "") {
                alert("Por faavor preencha o campo Estado. ")
                document.form.estadoc.focus()
        return false;
        }
		if (document.form.paisc.value == "") {
                alert("Por favor preencha o campo País.")
                document.form.paisc.focus()
        return false;
		}
}
function checkData2 (){
		if (document.send.email.value == 0) {
				window.alert ("Por favor preencha o campo E-mail.");
		return false;
		}
		if ((document.send.email.value.indexOf("@",0) < 1) || (document.send.email.value.indexOf("@",0) == document.send.email.value.length - 1)) {
				window.alert("Seu e-mail está incorreto");
		return false;
		}
		if (document.send.ddd2.value == "") {
                alert("Por favor preencha o campo DDD para o telefone.")
                document.send.ddd2.focus()
        return false;
		}
		if (document.send.telefone.value.length <= 5)
		{
			   	alert("Por favor preencha o campo Telefone com no mínimo 5 números.");
			   	document.send.telefone.focus();
	   	return false;
		}  
		if (document.send.telefone.value == "") {
                alert("Por favor preencha o campo Telefone.")
                document.send.telefone.focus()
        return false;
		}		
		if (document.send.rua.value == "") {
                alert("Por favor preencha o campo Rua.")
                document.send.rua.focus()
        return false;
        }
		if (document.send.bairrocont.value == "") {
                alert("Por favor preencha o campo Bairro.")
                document.send.bairrocont.focus()
        return false;
        }
		if (document.send.cep.value == "")
  		{
			    alert("Por favor preencha o campo CEP. Ex: 80000-200");
			    document.send.cep.focus();
	    return false;
		}
		if (document.send.cep.value.length <= 8)
		{
			   	alert("Por favor preencha o CEP corretamente.");
			   	document.send.cep.focus();
	   	return false;
		}  		
		if (document.send.cidade.value == "") {
                alert("Por favor preencha o campo Cidade.")
                document.send.cidade.focus()
        return false;
        }		
		if (document.send.estado.value == "") {
                alert("Por favor preencha o campo Estado. ")
                document.send.estado.focus()
        return false;
        }
		if (document.send.pais.value == "") {
                alert("Por favor preencha o campo País.")
                document.send.pais.focus()
        return false;
		}
		if (document.send.mensagem.value == "") {
                alert("Por favor preencha o campo Mensagem.")
                document.send.mensagem.focus()
        return false;
		}
}
function checkData3 (){
		if (document.arearestrita.login.value == "") {
                alert("Por favor preencha o Login.")
                document.arearestrita.login.focus()
        return false;
		}
		if (document.arearestrita.pass.value == "") {
                alert("Por favor preencha a Senha.")
                document.arearestrita.pass.focus()
        return false;
		}
}
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.01
  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 && d.getElementById) x=d.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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
