function VAR1()
   {
      document.FrmLogin.TxLogin.focus();
   }

function FECHARWIN(url)
	{
		parent.location=url;
   }

function NOVAWIN(url)
	{
		parent.location=url;
   }

function BIBLIOTECA(url)
	{
		window.open(url,'','toolbar=No,menubar=No,location=No,scrollbars=Yes,resizable=No,status=Yes,width=350,height=500,left=200,top=25');
   }

function INFOJANELA(url,w,h)
	{
   	var conf;
      conf = 'toolbar=No,menubar=No,location=No,scrollbars=Yes,resizable=No,status=No,width='+w+',height='+h+',left=200,top=125'
		window.open(url,'',conf);
   }

function JANELA(url,w,h)
	{
   	var conf;
//		conf = 'toolbar=No,menubar=No,location=No,scrollbars=No,resizable=No,status=No,width='+w+',height='+h+',left=200,top=125'
//		window.open(url,'',conf);
      conf = 'status:false;dialogWidth:'+w+'px;dialogHeight:'+h+'px'
		showModalDialog(url,window,conf);
   }

function JANELASOM(url,w,h)
	{
   	var conf;
		conf = 'toolbar=No,menubar=No,location=No,scrollbars=No,resizable=No,status=No,width='+w+',height='+h+',left=200,top=125'
		window.open(url,'',conf);
//      conf = 'status:false;dialogWidth:'+w+'px;dialogHeight:'+h+'px'
//		showModalDialog(url,window,conf);
   }

function MOSTRAHELP(url)
	{
		showModalDialog(url,window,'status:false;dialogWidth:550px;dialogHeight:200px');
//--		showHelp(url);

   }

function WINPEDIDO(url)
	{
		showModalDialog(url,window,'status:false;dialogWidth:700px;dialogHeight:500px');
   }

function WINMSGUSEROK(url)
	{
		showModalDialog(url,window,'status:false;dialogWidth:300px;dialogHeight:200px');
   }

function VERIFICA_CPF(valor)
	{
	   erro = 0;
	   aux1 = 0;
	   aux2 = 0;
	   aux3 = 1;
	   for (i=0;i<valor.length-2;i++)
	      {
	         if ((valor.substr(i,1) != "/") && (valor.substr(i,1) != "-") && (valor.substr(i,1) != "."))
	            {
	               aux1 = aux1+(11-aux3)*valor.substr(i,1);
	               aux2 = aux2+(12-aux3)*valor.substr(i,1);
	               aux3++;
	            }
	      }
	   resto = aux1-((Math.floor(aux1/11))*11);
	   (resto < 2) ? dig1=0 : dig1=11-resto;
	   aux2 = aux2+(2*dig1);
	   resto = aux2-((Math.floor(aux2/11))*11);
	   (resto < 2) ? dig2=0 : dig2=11-resto;
	   aux = dig1+" "+dig2;
	   aux = aux.substr(0,1)+aux.substr(2,1);
	   if (aux != valor.substr(valor.length-2))
      	{
         	alert('Erro no CPF, verifique!');
	      	return false;
         }
	   else
	      if ((valor == "00000000000") || (valor == "11111111111") || (valor == "22222222222") || (valor == "33333333333") || (valor == "44444444444") || (valor == "55555555555") || (valor == "66666666666") || (valor == "77777777777") || (valor == "88888888888") || (valor == "99999999999"))
	         {
	            alert('Erro no CPF, verifique!');
	            return false;
	         }
	      else
	         return true;
	}

function VERIFICA_CNPJ(valor)
	{
	   aux1 = 0;
	   aux2 = 0;
	   aux3 = 1;
	   aux4 = 0;
	   for (i=0;i<valor.length-2;i++)
	      {
	         if ((valor.substr(i,1) != "/") && (valor.substr(i,1) != "-") && (valor.substr(i,1) != "."))
	            {
	               (aux3 < 5) ? aux4 = 6-aux3 : aux4 = 14-aux3;
	               aux1 = aux1+(valor.substr(i,1)*aux4);
	               (aux3 < 6) ? aux4 = 7-aux3 : aux4 = 15-aux3;
	               aux2 = aux2+(valor.substr(i,1)*aux4);
	               aux3++;
	            }
	      }
	   resto = aux1-((Math.floor(aux1/11))*11);
	   (resto < 2) ? dig1=0 : dig1=11-resto;
	   aux2 = aux2+(2*dig1);
	   resto = aux2-((Math.floor(aux2/11))*11);
	   (resto < 2) ? dig2=0 : dig2=11-resto;
	   aux = dig1+" "+dig2;
	   aux = aux.substr(0,1)+aux.substr(2,1);
	   if (aux != valor.substr(valor.length-2))
      	{
         	alert('Erro no CNPJ, verifique!');
	      	return false;
         }
	   else
	      if ( (valor == "99999999999962") || (valor == "00000000000000") )
      	{
         	alert('Erro no CNPJ, verifique!');
	      	return false;
         }
	      else
	         return true;
	}

function POPUP(url)
	{
	   showModalDialog(url,window,"status:false;dialogWidth:650px;dialogHeight:500px");
   }

function TEXTOS(url)
	{
		window.open(url,'','toolbar=No,menubar=No,location=No,scrollbars=No,resizable=No,status=No,width=650,height=450,left=200,top=155');

   }

function MSG_ENVIAR_EMAIL(url)
	{
		showModalDialog(url,window,'status:false;dialogWidth:400px;dialogHeight:300px');
   }

function DELETA()
	{
   	if ( confirm('Deseja excluir este registro?'))
      	return true;
      else
      	return false;
   }

function ReturnSizePage(type)
	{
      var width = document.body.clientWidth;
      var height = document.body.clientHeight;

		if (type.toLowerCase()=="w")
			{
				return width;
			}
				else (type.toLowerCase()=="h")
			{
				return height;
			}
	}

function MascaraVALOR (campo, tammax, teclapres)
{
	var tecla = teclapres.keyCode;
	vr = event.srcElement.value;
	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 < tammax && 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 ){
	 		// document.form[campo].value = vr ;
	 		event.srcElement.value = vr ;
		}
	 	if ( (tam > 2) && (tam <= 5) ){
	 		//document.form[campo].value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ;
	 		event.srcElement.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ;
		}
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		//document.form[campo].value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;
	 		event.srcElement.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;
		}
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		//document.form[campo].value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;
	 		event.srcElement.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) ){
	 		//document.form[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 ) ;
	 		event.srcElement.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) ){
	 		//document.form[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 ) ;
	 		event.srcElement.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 MascaraCPF (formato, objeto)
{
	campo = eval (objeto);
	if (formato=='CPF')
		{
			caracteres = '01234567890';
	      separacao1 = '.';
	      separacao2 = '-';
	      conjuntos = 4;
	      conjunto1 = 3;
	      conjunto2 = 7;
	      conjunto3 = 11;
	      conjunto4 = 14;
	      if ( (caracteres.search(String.fromCharCode (window.event.keyCode))!=-1) && campo.value.length < (conjunto4) )
	         {
	            if (campo.value.length == conjunto1)
	               campo.value = campo.value + separacao1;
	            else if (campo.value.length == conjunto2)
	               campo.value = campo.value + separacao1;
	            else if (campo.value.length == conjunto3)
	               campo.value = campo.value + separacao2;
	         }
	      else
		      event.returnValue = false;
		}
}

function MascaraCNPJ (formato, objeto)
{
	campo = eval (objeto);
	if (formato=='CNPJ')
		{
			caracteres = '01234567890';
	      separacao1 = '.';
	      separacao2 = '.';
	      separacao3 = '/';
	      separacao4 = '-';
	      conjunto1 = 2;
	      conjunto2 = 6;
	      conjunto3 = 10;
	      conjunto4 = 15;
	      conjunto5 = 18;
	      if ( (caracteres.search(String.fromCharCode (window.event.keyCode))!=-1) && campo.value.length < (conjunto5) )
	         {
	            if (campo.value.length == conjunto1)
	               campo.value = campo.value + separacao1;
	            else if (campo.value.length == conjunto2)
	               campo.value = campo.value + separacao1;
	            else if (campo.value.length == conjunto3)
	               campo.value = campo.value + separacao3;
	            else if (campo.value.length == conjunto4)
	               campo.value = campo.value + separacao4;
	         }
	      else
		      event.returnValue = false;
		}
}

function MascaraDATA (formato, objeto)
{
	campo = eval (objeto);
	if (formato=='DATA')
		{
			caracteres = '01234567890';
	      separacao1 = '/';
	      separacao2 = '-';
	      conjunto1 = 2;
	      conjunto2 = 5;
	      conjunto3 = 8;
	      conjunto4 = 10;
	      if ( (caracteres.search(String.fromCharCode (window.event.keyCode))!=-1) && campo.value.length < (conjunto4) )
	         {
	            if (campo.value.length == conjunto1)
	               campo.value = campo.value + separacao1;
	            else if (campo.value.length == conjunto2)
	               campo.value = campo.value + separacao1;
	         }
	      else
		      event.returnValue = false;
		}
}

function MascaraFONE (formato, objeto)
{
	campo = eval (objeto);
	if (formato=='FONE')
		{
			caracteres = '01234567890';
	      separacao1 = '(';
	      separacao2 = ') ';
	      separacao3 = '';
	      separacao4 = '-';
	      conjunto1 = 0;
	      conjunto2 = 3;
	      conjunto3 = 4;
	      conjunto4 = 9;
	      conjunto5 = 14;
	      if ( (caracteres.search(String.fromCharCode (window.event.keyCode))!=-1) && campo.value.length < (conjunto5) )
	         {
	            if (campo.value.length == conjunto1)
	               campo.value = separacao1 + campo.value;
	            else if (campo.value.length == conjunto2)
	               campo.value = campo.value + separacao2;
	            else if (campo.value.length == conjunto3)
	               campo.value = campo.value + separacao3;
	            else if (campo.value.length == conjunto4)
	               campo.value = campo.value + separacao4;
	         }
	      else
		      event.returnValue = false;
		}
}