function jsf_popup(url, titulo, largura, altura, scrollbar) 
{
	var myWin = window.open(url ,titulo ,'width=' + largura + ', height=' + altura +', scrollbars=' + scrollbar + ', toolbar=no, location=no, status=yes, menubar=no, resizable=no, left=10, top=10');
	myWin.focus();
}
/////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Descrição: Script para aplicação de Máscaras
*/
 
function jMascara (objForm, strField, sMask, evtKeyPress) {
      var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

      if(window.event) { // Internet Explorer
        nTecla = evtKeyPress.keyCode; }
      else if(evtKeyPress.which) { // 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( " ", "" );
	  sValue = sValue.toString().replace( ":", "" );
      fldLen = sValue.length;
      mskLen = sMask.length;

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

      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...
		  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;

          return true;
        } }
      else {
        return true;
      }
    }

/////////////////////////////////////////////////////////////////////////////////////////////////	
/**
* Descrição: Script para ocultar/mostrar qualquer objeto
*/
 
function jMostraOculta_Objeto ( campo , acao )
{
	if ( acao == 'onBlur' ) 
	{
		document.getElementById(campo).style.display='none';
	}
	else if ( acao = 'onFocus' ) 
	{
		document.getElementById(campo).style.display='';
	}
}

/////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Descrição: Script para usuário digitar apenas números
*/

function jCampoNumerico ( x , y , evtKeyPress )
{
// Inicializa a variavel
var nTecla = 0;
// Verifica plataforma
if (document.all)
{
// Plataformas tipo IE
nTecla = evtKeyPress.keyCode ;
}
else
{
// Plataformas tipo NETSCAPE
nTecla = evtKeyPress.which ;
}
// Verifica tecla pressionada
if ((( nTecla > 47 ) && ( nTecla < 58 ))  // numerico (0123456789)
|| ( nTecla == 8   )   // backspace
|| ( nTecla == 127 )   // delete
|| ( nTecla == 0   )   // teclas nao definidas
//|| ( nTecla == 9   )   // tabulacao
|| ( nTecla == 13  )   // enter
//|| ( nTecla == 44  )   // , (vírgula)
//|| ( nTecla == 46  ))  // . (ponto)
)
{
// Digita a tecla pressionada
return true;
}
else
{
// Ignora a tecla pressionada
return false;
}
}





function confirma_exclusao ( pagina )
{
	if ( confirm ('Deseja excluir o registro?') )
	{
		location.href = pagina ;
	}
}

function redimensiona_iframe ( iframe ) 
{
	//h = document.body.clientHeight - 175 ;
	//document.getElementById(iframe).style.height = h + 'px';

	var tamanho = document.getElementById("conteudo").offsetHeight;
	tamanho = tamanho + 40;
    parent.document.getElementById(iframe).style.height = tamanho + 'px';
}

function expiracao ( opcao )
{
	if ( opcao == "S" )
	{
		document.getElementById('tr_expiracao').style.display = "" ;
	}
	else
	{
		document.getElementById('tr_expiracao').style.display = "none" ;
		document.getElementById('dataexpiracao').value = "" ;	
	}
}

function adciona_filtro ( id, campo, opcao )
{
	//alert(opcao.checked);
	if(opcao.checked == true)
	{
		id = ';('+id+')';
		valor = parent.document.getElementById(campo).value.replace(id, ''); 
		//alert(valor);
		parent.document.getElementById(campo).value = valor+id ;
	}
	else
	{
		id = ';('+id+')';
		valor = parent.document.getElementById(campo).value.replace(id, ''); 
		parent.document.getElementById(campo).value = valor;
	}
}

