//Inicio Funcao janela POPUP
	function MM_openBrWindow(theURL,winName,features) { //v2.0
		janela = window.open(theURL,winName,features);
		janela.focus();
	}
//#Fim da Funcao janela POPUP
	function testeIFrame(ativa) {
		//alert(location.href + " - "+ parent.location.href)
		if(!ativa){
			if(location.href == parent.location.href){
				url = location.href;
				url = url.replace("?","@$");
				url = url.replace("&","$");
				pos = url.indexOf("//");
				xxx = url.indexOf ('/',pos+2)
				url = url.substring(xxx+1,(url.length));
				parent.location = "/index2.asp?redirect=1&url="+url
			}
		}
	}
//Inicio Funcao muda cor tabela - MENU
	function mOvr(src,clrOver) {
	if (!src.contains(event.fromElement)) {
		  src.style.cursor = 'DEFAULT';
		  src.bgColor = clrOver;
		}
	}
	function mOut(src,clrIn) {
		if (!src.contains(event.toElement)) {
		  src.style.cursor = 'default';
		  src.bgColor = clrIn;
		}
	}
//#Fim da Funcao muda cor tabela - MENU

//Inicio Funcao que verifica CPF e retorna na variavel errocpfcnpj o resultado
	function verificaCPF(numero) { 
  	  if (numero == "00000000000" || numero == "11111111111" || numero == "22222222222" || numero == "33333333333" || numero == "44444444444" || numero == "55555555555"
		  ||numero == "66666666666" || numero == "77777777777" || numero == "88888888888" || numero == "99999999999" ||  numero.length < 11 || numero.length > 11 ) {
    	  errocpfcnpj = 1
		  return false; 
	  } 
	  
 	  var checkOK = "0123456789";
	  var checkStr = numero;
	  var validade = 1;
	  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){
		  validade = false;
		  break;
		}
		allNum += ch;
	  }
	  if (!validade) {
    	errocpfcnpj = 1
		return false;    
	  }

	 var primeiro = numero.charAt(0); 
	 var n = false;
	 for (i=0; i<=10; i++)  {  
	   c = numero.charAt(i); 
	   if(! (c >= "0")&&(c <= "9"))    { 
		errocpfcnpj = 1
		return false;
	   } 
	   if( c!=primeiro )n = 1;
	 }  
	 if( ! n ){
		errocpfcnpj = 1
		return false;
	 }
	 soma=0; 
	 for ( i=0; i<9; i++ ) { 
		soma += (10-i) * ( eval(numero.charAt(i)) ); 
	 }
	 vdigito = 11-(soma % 11); 
	 if ( (soma % 11) < 2 ) vdigito = 0; 
	 if ( eval(numero.charAt(9)) != vdigito ){
		errocpfcnpj = 1
		return false;
	 }
	 soma=0; 
	 for ( i=0; i<9; i++ ) { 
		soma += (11-i) * ( eval(numero.charAt(i)) ); 
	 } 
	 soma += 2 * ( eval(numero.charAt(9)) ); 
	 vdigito = 11-(soma % 11); 
	 if ( (soma % 11) < 2 ) vdigito = 0; 
	 if ( eval(numero.charAt(10)) != vdigito){
		errocpfcnpj = 1			
		return false;
	 }
	 errocpfcnpj = false
	 //se chegou aki o cpf esta ok
	} 
//# Fim da Funcao que verifica CPF e retorna na variavel errocpfcnpj o resultado	

//Inicio da Funcao que verifica CNPJ e retorna na variavel errocpfcnpj o resultado	
	function verificaCNPJ(numero)  
	{  
  	  if (numero == "00000000000000" || numero == "11111111111111" || numero == "22222222222222" || numero == "33333333333333" || numero == "44444444444444" || numero == "55555555555555"
		  ||numero == "66666666666666" || numero == "77777777777777" || numero == "88888888888888" || numero == "99999999999999" ||  numero.length < 14 || numero.length > 14 ) {
    	  errocpfcnpj = 1
		  return false; 
	  } 
	  var checkOK = "0123456789";
	  var checkStr = numero;
	  var validade = 1;
	  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){
		  validade = false;
		  break;
		}
		allNum += ch;
	  }
	  if (!validade) {
    	errocpfcnpj = 1
		return false;    
	  }
		  
	 var primerio = numero.charAt(0);  
	 var multiplo,verificador,a, b = ""; 
	 var i,j,d,resu = 0; 
	 for ( var i=0; i<=13; i++ )  
	 {   
	   var c = numero.charAt(i);  
	   if( ! (c>="0")&&(c<="9") ) {
    	  errocpfcnpj = 1
		  return false; 
	   } 
	   if( c!=primerio ) { vcpf = 1; } 
	 }   
	 if( ! vcpf ){
		errocpfcnpj = 1
		return false; 
	 }  
	 a = numero.substring(0,12);  
	 b = numero.substring(12,15); 
	 multiplo = "543298765432"; 
	 verificador = ""; 
	 for ( j=1; j<3; j++ ) {  
	  resu = 0; 
	  for ( i=0; i<12; i++ ) { 
		resu += eval( a.charAt(i) )* eval( multiplo.charAt(i) );} 
		if( j == 2 ){ resu += (2 * d); }  
		d = ((resu*10) % 11); 
		if( d == 10 ){ d = 0; } 
		verificador = verificador + d; 
		multiplo = "654329876543"; 
	 }   
	 if( verificador != b ) { 
		errocpfcnpj = 1
		return false 
	 } else {
		errocpfcnpj = false
		//se chegou aki o cnpj esta ok - return 1 
	 }  
	}  
//# Fim da Funcao que verifica CNPJ e retorna na variavel errocpfcnpj o resultado.

//Inicio Funcao testa e-mail e retorna na variavel erroemail o resultado
	function VerificaEmail(email) {
		erroemail = false;
		email = email.toLowerCase();
		var CaracteresErro = "*|,\":<>[]{}`\';()&$#%çáéíóúãõâêîôûàèìòù^~!? ";
		var CaracteresObrig = "@."; 
		var CaracteresErroFinal = "@_-."; 
		var CaracteresErroInicio = "@."; 
		var ContaArroba = 0;
		//---------------------------------------------------------------------//
		if(email.length < 4){
			erroemail = 1;
			return false; };
		for (var i = 0; i < email.length; i++) {
			if (CaracteresErro.indexOf(email.charAt(i)) != -1){
				erroemail = 1;
				return false; };
			if (email.charAt(i)=="@"){
				ContaArroba++
				if (ContaArroba>1){
					erroemail = 1;
					return false; };
			}
		}
		for (var i = 0; i < CaracteresObrig.length; i++) {
			if (email.indexOf(CaracteresObrig.charAt(i)) == -1){
				erroemail = 1; 
				return false;	};
		}
		if (email.indexOf ('@.',0) != -1||email.indexOf ('..',0) != -1){
			//---testa sequencia de carateres inválidas
			erroemail = 1;
			return false;	};

		for (var i = 0; i < CaracteresErroInicio.length; i++) {
			if (email.charAt(0)==CaracteresErroInicio.charAt(i)){
				erroemail = 1; 
				return false;	};
		}
		temp = email.length -1
		for (var i = 0; i < CaracteresErroFinal.length; i++) {
			if (email.charAt(temp)==CaracteresErroFinal.charAt(i)){
				erroemail = 1; 
				return false;	};
		}
/*USANDO A FUNÇÃO - SINTAXE
		VerificaEmail(form.campo.value);
		if(erroemail==1)	{
			alert("Esse e-mail não é válido!");
			form.campo.focus();
			return false;	};
*/
	} 
//#Fim da Funcao testa e-mail e retorna na variavel erroemail o resultado	

//Funcao testa data	
	function VerificaData(d1,gravaData)	{
		errodata = false;
		var2 = d1;
		pos = var2.indexOf("/");
		dia = var2.substring(0,pos);
		pos_anterior = pos;
		pos = var2.indexOf("/",pos+1);
		mes = var2.substring(pos_anterior+1,pos);
		pos_anterior = pos;
		ano = var2.substring(pos+1,var2.length);
		if (dia.indexOf(0)==0) {
			dia = dia.substring(1,2);	};
		if (mes.indexOf(0)==0){
			mes = mes.substring(1,2);	};

		var checkOK = "0123456789";
		var validade = true;
		var checkStr = ano;
		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){
				  validade = false;
				  break;
				}
			allNum += ch;
		}
		if (!validade) {errodata=true;	return false;	};

		if (ano.indexOf(0)==0 && ano.length==2){
			ano = parseInt(ano) + 2000;
		}else if (ano.length==2){
			ano = parseInt(ano) + 1900;	
		}

		
		data = new Date(mes + "/" + dia + "/" + ano);
		if (gravaData=="1"){ datateste = data }else{ datateste="";	};
		if (data.getDate()!=dia){errodata=true;	return false;	};
		if (data.getMonth()+1!=mes){errodata=true;	return false;	};
		if (data.getFullYear()!=ano){errodata=true;	return false;	};

/*USANDO A FUNÇÃO - SINTAXE
		VerificaData(form.campo.value);
		if(errodata==true)	{
			alert("Data informada inválida. Utiliza o formato DD/MM/AAAA!");
			form.campo.focus();
			return false;	};
*/

	}
//#Fim da Funcao testa data	


function adjustFrame(frame) 	{	
	if(frame !==null) {
		if (document.all) {
			var w = frame.document.body.scrollWidth;
			var h = frame.document.body.scrollHeight;
			if(frame.document.body.scrollWidth > frame.document.body.offsetWidth) {
				document.all[frame.name].height = h + 30;
			}
			else {
				document.all[frame.name].height = h;
			}
	  	}
	  	else if (document.getElementById) {
			var w = frame.document.width;
			var h = frame.document.height;
			/*
			if(frame.document.body.scrollWidth > frame.document.body.offsetWidth)  {
				//document.getElementById(frame.name).height = h + 30;
				document.all[frame.name].height = h + 30;
		  	}
			else  {
				//document.getElementById(frame.name).height = h;
				document.all[frame.name].height = h;
		  	}
			*/
	  	}
	}
	return false;
}