//******************************************************
// $Source: /data/cvs/BCSite/script/genericas.js,v $
// $Author: felipe $
// $Date: 2009/05/06 18:17:09 $
// $Revision: 2.3 $
// $Name: PRODUCAO $
// $Header: /data/cvs/BCSite/script/genericas.js,v 2.3 2009/05/06 18:17:09 felipe Exp $
//******************************************************
    var AutoSkip                    = true;
    var GerenciadorGlobalBody       = null;
    var preGerenciadorGlobalBody    = null;
    var localidadeGlobal            = null;
    var GerenteControladorGrid      = null;
//******************************************************

function trocaEstilo(opcao, nomeEstilo){
    opcao.className = nomeEstilo;
}

    function menuCima(src,corCima) {
        if (!src.contains(event.fromElement)) {
            src.style.cursor = 'hand';
            src.bgColor = corCima;
        }
    }
    function menuFora(src,corFora) {
        if (!src.contains(event.toElement)) {
            src.style.cursor = 'default';
            src.bgColor = corFora;
        }
    }
    function menuClick(src) {
        if(event.srcElement.tagName=='TD'){
            src.children.tags('A')[0].click();
        }
    }	

    function trocaMarcador(nomeMarcador,status){  
        if(status){
            document.images[nomeMarcador].style.visibility ="visible";
        }else{
            document.images[nomeMarcador].style.visibility ="hidden";
        }
        return true;  
    }  

    function trocaFigura(origem,nova){
        origem.src = nova.src;
    }

function setLocalidade(parmLocalidade){
    localidadeGlobal = parmLocalidade;
}

function getLocalidade(){
    return localidadeGlobal;
}

function setGerenciadorBody( GerenciadorParam ) {
   GerenciadorGlobalBody = GerenciadorParam;
}
function setPreGerenciadorBody( GerenciadorParam ) {
   preGerenciadorGlobalBody = GerenciadorParam;
}

function bodyOnBlurGenerico() {
   if ( preGerenciadorGlobalBody != null ) {
      if ( preGerenciadorGlobalBody.onBlur != null ) {
         preGerenciadorGlobalBody.onBlur();
      }
   }
   if ( GerenciadorGlobalBody != null ) {
      if ( GerenciadorGlobalBody.onBlur != null ) {
         GerenciadorGlobalBody.onBlur();
      }
   }
}

function bodyOnFocusGenerico() {
   if ( preGerenciadorGlobalBody != null ) {
      if ( preGerenciadorGlobalBody.onFocus != null ) {
         preGerenciadorGlobalBody.onFocus();
      }
   }
   if ( GerenciadorGlobalBody != null ) {
      if ( GerenciadorGlobalBody.onFocus != null ) {
         GerenciadorGlobalBody.onFocus();
      }
   }
}

function bodyOnLoadGenerico() {
    if ( preGerenciadorGlobalBody != null ) {
        if ( preGerenciadorGlobalBody.onLoad != null ) {
            preGerenciadorGlobalBody.onLoad();
        }
    }
    if ( GerenciadorGlobalBody != null ) {
        if ( GerenciadorGlobalBody.onLoad != null ) {
            GerenciadorGlobalBody.onLoad();
        }
    }
    if(GerenteControladorGrid!=null){
        GerenteControladorGrid.inicializa();
        GerenteControladorGrid.resize();
    }

}

function bodyOnUnLoadGenerico() {

   if ( preGerenciadorGlobalBody != null ) {
      if ( preGerenciadorGlobalBody.onUnLoad != null ) {
         preGerenciadorGlobalBody.onUnLoad();
      }
   }
   if ( GerenciadorGlobalBody != null ) {
      if ( GerenciadorGlobalBody.onUnLoad != null ) {
         GerenciadorGlobalBody.onUnLoad();
      }
   }

}

function bodyOnResizeGenerico() {
    if(GerenteControladorGrid!=null){
        GerenteControladorGrid.resize();
    }

}


function Localidade(SepMilhar,SepDecimal,posDia,posMes) {
  this.SepMilhar = SepMilhar;
  this.SepDecimal = SepDecimal;
  this.posDia = posDia;
  this.posMes = posMes;
}



function getFocus() {
   AutoSkip = false;
}

function skipEdit(edit1,edit2) {
  if(AutoSkip) {
    if (edit1.value.length >= edit1.maxLength) {
      edit2.focus();
    }
  }
  return;
}

function keyPress() {
  AutoSkip = true;
  return;
}

function trim(str) {
  str = str.toString().replace(/\$|\ /g,'');
  return str;
}

function isDigit (c) {
  return ((c >= "0") && (c <= "9"))
}

function isInteger (s){
  var i;
  for (i = 0; i < s.length; i++){
    var c = s.charAt(i);
    if (!isDigit(c)) return false;
  }
  return true;
}

function days_in_month (year, month) {
  return 32 - new Date(year, month, 32).getDate();
}

function y2k(number) {
  return (number < 1000) ? number + 1900 : number;
}

function validaNumero() {
  var ret = false;
  var valorTecla = 0;
  keyPress();
  
  if ((event.keyCode<48)||(event.keyCode>57)) {
    ret=false;
  }
  else {
    ret=true;
  }
  event.returnValue=ret;
  
}

function validaString() {
    var ret = false;
    keyPress();
    if (event.keyCode==39) {
        ret=false;
    } else {
        ret=true;
    }
    event.returnValue=ret;
}

function validaData(dia,mes,ano) {
    
  if (!isInteger(dia)) {
      return false;
  }

  if (!isInteger(mes)) {
      return false;
  }

  if (!isInteger(ano)) {
      return false;
  }
      
  if (mes<1 || mes>12) {
    return false;
  }
  if (dia<1 || dia>31) {
    return false;
  }
  if (ano<1900 || ano>3000) {
    return false;
  }
  if (mes==4 || mes==6 || mes==9 || mes==11) {
    if (dia==31) {
	  return false;
    }
  }

  // Bissexto
  if (mes==2) {
    var g=parseInt(ano/4)
    if (isNaN(g)) {
      return false;
    }
    if (dia > 29){
      return false;
    }
    if (dia==29 && ((ano/4)!=parseInt(ano/4))){
      return false;
    }
  }
  return true;
}

function validaMoeda() {
    var ret = false;
	keyPress();
	if (((event.keyCode<48)||(event.keyCode>57)) && ((event.keyCode != 44)&&(event.keyCode != 46))) {
		ret=false;
	} else {
		ret=true;
	}
	event.returnValue=ret;
}


function DesformataMoeda(campo,decimal,milhar,qtdDecimal){
var str = ""
var temp
var inteira  = ""
var decimais = ""
  for (var i=0;i<campo.length;i++){
      temp=campo.substring(i,i+1)
      if (milhar.indexOf(temp)==-1){
		  str = str + temp
      }
    }

	inteiro = str.substring(0,str.lastIndexOf(decimal));

	if (str.indexOf(decimal) != -1){
	    cont = str.length;
		for (var i=qtdDecimal;i>0;i--) {
		  if (str.substring(str.lastIndexOf(decimal)+i,cont) != 0) {
		  	decimais = str.substring(str.lastIndexOf(decimal)+i,cont) + decimais;
		  }
		  cont--;
		}
	}
	return str;
}

function SomenteDigitos() {
  if (((window.event.keyCode > 47) && (window.event.keyCode < 58)) || ((window.event.keyCode > 95) && (window.event.keyCode < 106))) {
    return true;
  }
  else {
    return false;
  }
}

function TeclasPermitidas() {
  if ((window.event.keyCode == 9) || (window.event.keyCode == 8) || (window.event.keyCode == 46)) {
    return true;
  }
  else {
    return false;
  }
}

function QtdDigitos(Tam, QtdDecimais) {
  qtdmilhar = (Tam - QtdDecimais);
  qtdsepmilhar = Math.floor(qtdmilhar / 3);
  if ((qtdmilhar % 3) != 0) {
    qtdsepmilhar++;
  }
  return ((qtdmilhar - qtdsepmilhar) + QtdDecimais);
}

function NaoEstorouDigitos(ObjetoCampo, QtdDecimais) {
  if (QtdDigitos(ObjetoCampo.maxLength,QtdDecimais) >= StringToOnlyDigits(ObjetoCampo.value).length) {
    return true;
  }
  else {
    return false;
  }
}

function ValorOnKeyDown(ObjetoCampo, QtdDecimais) {
  if (NaoEstorouDigitos(ObjetoCampo, QtdDecimais)) {
    if (TeclasPermitidas() != SomenteDigitos()) {
      return true;
    }
    else {
      return false;
    }
  }
  else {
    return TeclasPermitidas();
  }
}

function ValorOnBlur(ObjetoCampo, QtdDecimais) {
  ObjetoCampo.value = MascaraMonetaria(StringToOnlyDigits(ObjetoCampo.value), QtdDecimais);
  return true;
}

function ValorOnKeyUp(ObjetoCampo, QtdDecimais) {
  if (((window.event.keyCode > 47) && (window.event.keyCode < 58)) || ((window.event.keyCode > 95) && (window.event.keyCode < 106))) {
    ObjetoCampo.value = MascaraMonetaria(StringToOnlyDigits(ObjetoCampo.value), QtdDecimais);
    return(true);
  }
  else {
    if (window.event.keyCode == 8) {
      var fvalue = StringToOnlyDigits(ObjetoCampo.value);
      ObjetoCampo.value = MascaraMonetaria(fvalue.substring(0,fvalue.length), QtdDecimais);
      return(true);
    }
    else {
      if (window.event.keyCode == 46) {
        var fvalue = StringToOnlyDigits(ObjetoCampo.value);
        ObjetoCampo.value = MascaraMonetaria(fvalue.substring(0,fvalue.length-1), QtdDecimais);
        return(true);

      }
      else {
        return(false);
      }
    }
  }
}

function StringToOnlyDigits(strtext) {
  for (var i=0, output='', valid="1234567890"; i<strtext.length; i++) {
    if (valid.indexOf(strtext.charAt(i)) != -1) {
      output += strtext.charAt(i);
    }
  }
  return output;
}

function MascaraMonetaria(Valor, QtdDecimais) {
   QtdDecimais++;
   NumDig = Valor;
   TamDig = NumDig.length;
   Contador = 0;
   if (TamDig > 0) {
     numer = "";
     for (i = TamDig; (i >= 0); i--) {
       if ((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9)) {
         Contador++;
         if ((Contador <= QtdDecimais) && ((TamDig - i) == (QtdDecimais))) {
           numer = getLocalidade().SepDecimal + numer;
           Contador = 0;
         }
         else {
           if ((Contador == 3) && ((TamDig - i) > (QtdDecimais))) {
             numer = getLocalidade().SepMilhar + numer;
             Contador = 0;
           }
         }
         numer = NumDig.substr(i, 1) + numer;
       }
     }
     return numer;
   }
   else {
     return Valor;
   }
}

function removeFormat(Valor, SepMilhar, SepDecimal)
{
   NumDig = Valor;
   TamDig = NumDig.length;
   Contador = 0;
   if (TamDig > 0) {
   	  numer = "";
      for (i = 0; (i <= TamDig); i++) {
          if ((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9)) {
             numer = numer + NumDig.substr(i, 1);
          }
          else if (NumDig.substr(i,1) == SepMilhar){
          }
          else if (NumDig.substr(i,1) == SepDecimal){
             numer = numer + '.';
          }
      }

      return numer;
   }
   else {
      return Valor;
   }
}

function formataNumero(Valor, SepMilhar, SepDecimal, QtdDecimais)
{
   NumDig = Valor;
   TamDig = NumDig.length;
   Contador = 0;
   achou = false;
   if (TamDig > 0) {
   	  numer = "";
      for (i = 0; (i <= TamDig); i++) {
          if ((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9)) {
             numer = numer + NumDig.substr(i, 1);
          }
          else if (NumDig.substr(i,1) == '.'){
		  	 achou = true;
          }
		  if (achou)
		  	 Contador++;
		  if (Contador >= (QtdDecimais+1))
		  	 break;
      }

	  Contador = 0;
	  inteiro = false;
	  NumDig = numer;
	  TamDig = numer.length;
	  numer = "";

	  for (i = TamDig; (i >= 0); i--) {
          if ((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9)) {
             Contador++;
             if ((Contador == (QtdDecimais+1)) && (inteiro == false) ){
               numer = SepDecimal + numer;
               Contador = 0;
			   inteiro = true;
             }
             else {
               if ((Contador == 3) && (inteiro == true)) {
                 numer = SepMilhar + numer;
                 Contador = 0;
               }
             }
		  	 numer = NumDig.substr(i, 1) + numer;
		  }
 	  }
      return numer;
   }
   else {
      return Valor;
   }
}

function preparaMascaraMonetaria(Valor,QtdDecimais)
{
   NumDig = Valor;
   TamDig = NumDig.length;
   Contador = 0;
   achou = false;

   if (TamDig > 0)
   {
   	  numer = "";
      for (i = 0; (i <= TamDig); i++)
	  {
          if ((parseInt(NumDig.substr(i,1))>=0) && (parseInt(NumDig.substr(i, 1))<=9))
		  {
             numer = numer + NumDig.substr(i, 1);
          }
          else if (NumDig.substr(i,1) == '.')
		  {
		  	 achou = true;
          }

		  if (achou) Contador++;
		  if (Contador >= (QtdDecimais+1)) break;
      }

	  for(i=0;i<(QtdDecimais-Contador);i++)
   		numer = numer + '0';

   	  return numer;
  }
  else
  	  return Valor;
}

function addDays(myDate,days) {
    return new Date(now.getTime() + days*24*60*60*1000);
}

function removeChar(pstring,pcarac) {
  return replace(pstring,pcarac,'');
}

function replace(string,text,by) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;
    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;
    var newstr = string.substring(0,i) + by;
    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);
    return newstr;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
    if ((obj=MM_findObj(args[i]))!=null) {
      v=args[i+2];
      if (obj.style) {
        obj=obj.style;
        v=(v=='show')?'visible':(v='hide')?'hidden':v;
      }
      obj.visibility=v;
    }
}

function upper(campo) {
    campo.value = campo.value.toUpperCase();
}

function verificaCPF(cpf) {
    var i;
    var c;
    x = 0;
    soma = 0;
    dig1 = 0;
    dig2 = 0;
    texto = "";
    numcpf1="";
    numcpf = "";
    
    if ( !isInteger(cpf) ) {
        return false;
    }

    for (i = 0; i < cpf.length; i++) {
        c = cpf.substring(i,i+1);
        if (isDigit(c)) {
            numcpf = numcpf + c;
        }
    }

    for( i = numcpf.length; numcpf.length < 11; i++ ) {
        numcpf = "0"  + numcpf;
    }

    len = numcpf.length; x = len -1;
    for (var i=0; i <= len - 3; i++) {
        y = numcpf.substring(i,i+1);
        soma = soma + ( y * x);
        x = x - 1;
        texto = texto + y;
    }
    dig1 = 11 - (soma % 11);
    if (dig1 == 10) dig1=0 ;
    if (dig1 == 11) dig1=0 ;
    numcpf1 = numcpf.substring(0,len - 2) + dig1 ;
    x = 11; soma=0;
    for (var i=0; i <= len - 2; i++) {
        soma = soma + (numcpf1.substring(i,i+1) * x);
        x = x - 1;
    }
    dig2= 11 - (soma % 11);
    if (dig2 == 10) dig2=0;
    if (dig2 == 11) dig2=0;
    if ((dig1 + "" + dig2) == numcpf.substring(len,len-2)) {
        return true;
    }
    return false;
}

/**
 * Adiciona método lpad() à classe String.
 * Preenche a String à esquerda com o caractere fornecido,
 * até que ela atinja o tamanho especificado.
 */
String.prototype.lpad = function(pSize, pCharPad)
{
	var str = this;
	var dif = pSize - str.length;
	var ch = String(pCharPad).charAt(0);
	for (; dif>0; dif--) str = ch + str;
	return (str);
} //String.lpad


/**
 * Formata a string fornecida como CNPJ ou CPF, adicionando zeros
 * à esquerda se necessário e caracteres separadores, conforme solicitado.
 * @param String pCpfCnpj
 * 	String fornecida para ser formatada.
 * @param boolean pUseSepar
 * 	Indica se devem ser usados caracteres separadores (. - /).
 * @param boolean pIsCnpj
 * 	Indica se a string fornecida é um CNPJ.
 * 	Caso contrário, é CPF. Default = false (CPF).
 * @return String de CPF ou CNPJ devidamente formatada.
 */
function formatCpfCnpj(pCpfCnpj, pUseSepar, pIsCnpj)
{
        var NUM_DIGITOS_CPF   = 11;
        var NUM_DIGITOS_CNPJ  = 14;
        var NUM_DGT_CNPJ_BASE = 8;

	if (pIsCnpj==null) pIsCnpj = false;
	if (pUseSepar==null) pUseSepar = true;
	var maxDigitos = pIsCnpj? NUM_DIGITOS_CNPJ: NUM_DIGITOS_CPF;
	var numero = pCpfCnpj;

	numero = numero.lpad(maxDigitos, '0');
	if (!pUseSepar) return numero;

	if (pIsCnpj)
	{
		reCnpj = /(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/;
		numero = numero.replace(reCnpj, "$1.$2.$3/$4-$5");
	}
	else
	{
		reCpf  = /(\d{3})(\d{3})(\d{3})(\d{2})$/;
		numero = numero.replace(reCpf, "$1.$2.$3-$4");
	}

	return numero;
} //formatCpfCnpj


// Abre uma janela popup centralizada
function openWin( windowURL, windowName, aheight, awidth) {
    openWin( windowURL, windowName, aheight, awidth, "" );
}

function openWin( windowURL, windowName, aheight, awidth, opcoes ) {

    // paramentros de altura e largura
    var str = "height=" + aheight + ",innerHeight=" + aheight;
    str += ",width=" + awidth + ",innerWidth=" + awidth;


    if ( window.screen ) {
        var ah = screen.availHeight - 30;
        var aw = screen.availWidth - 10;

        // Centralizacao da janela na tela
        var xc = (aw - awidth) / 2;
        var yc = (ah - aheight) / 2;

        // Posicionamento da janela popup
        str += ",left=" + xc + ",screenX=" + xc;
        str += ",top=" + yc + ",screenY=" + yc;
    }
    if(opcoes != ""){
        str += ","+opcoes;
    }
    // Abre a janela popup
    wcliente = window.open( windowURL, windowName, str);

    // Retorno o handle da janela para colocar o foco na Popup
    return wcliente;
}

function obtemIndiceCampo( formulario, nomeCampo ) {
   for (var i=0; i < formulario.length; i++) {
        if ( trim(nomeCampo) == trim(formulario.elements[i].name) ) {
            return i;
        } 
    }
    return -1;
}

function validaCGC(s) {
    var c;
    var	Soma1, Soma2, Digito1, Digito2, i;
    var	CGC;
    var V;

    function CriaArray (n) {
        this.length = n 
    }
    V = new CriaArray(14)

    CGC = "";
    Soma1 = 0;
    Soma2 = 0;
    Digito1 = 0;
    Digito2 = 0;

    for (i = 0; i < s.length; i++) {
        c = s.substring(i, i+1);
        if (isDigit(c))
            CGC = CGC + c;
    }

    if ((trim(CGC) != "") && (CGC.length == 14)) {
        for (i = 0; i < CGC.length; i++) {
            V[i] = parseFloat(CGC.substring(i, i + 1));
        }
	Soma1 = (V[11] * 2) + (V[10] * 3) + (V[9] * 4) + (V[8] * 5) + 
                (V[7] * 6) + (V[6] * 7) + (V[5] * 8) + (V[4] * 9) + 
                (V[3] * 2) + (V[2] * 3) + (V[1] * 4) + (V[0] * 5);
        Soma2 = (V[12] * 2) + (V[11] * 3) + (V[10] * 4) + (V[9] * 5) + 
                (V[8] * 6) + (V[7] * 7) + (V[6] * 8) + (V[5] * 9) + 
                (V[4] * 2) + (V[3] * 3) + (V[2] * 4) + (V[1] * 5) + 
                (V[0] * 6);

	Digito1 = Soma1 - parseInt(Soma1 / 11) * 11;
	if ((Digito1 == 0) || (Digito1 == 1)) 
            Digito1 = 0;
	else
            Digito1 = 11 - Digito1;
	     
	Digito2 = Soma2 - parseInt(Soma2 / 11) * 11;
	if ((Digito2 == 0) || (Digito2 == 1))
            Digito2 = 0;
	else
            Digito2 = 11 - Digito2;
	  
	if ((Digito1 == V[12]) && (Digito2 == V[13]) && (Soma1 != 0) && (Soma2 != 0)) {
            return true;
	}
    }
    return false;
}

// Retorna se a string é um e-mail válido
function validaEmail(email) {

    var retorno = false;
    var reEmail = /^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;

    if (reEmail.test(email)) {
        retorno = true;
    } else if (email != null && email != "") {
        retorno = false;
    }
    return retorno;
}

// Retorna se a string é uma senha válida pelo padrão de cadastro do site
function validarSenha(senha) {

    var retorno = false;
    var reSenha = /^[A-Za-z0-9]{6,10}$/;

    if (reSenha.test(senha)) {
        retorno = true;
    } else if (senha != null && senha != "") {
        retorno = false;
    }
    return retorno;
}

// Retorna se as string formam um CEP válido
function validarCEP(prefixoCEP , sufixoCEP ) {
    
    var retorno = false;
    var reCEPPrefixo = /^[A0-9]{5}$/;
    var reCEPSufixo  = /^[A0-9]{3}$/;

    if (reCEPPrefixo.test(prefixoCEP) && reCEPSufixo.test(sufixoCEP) ) {
        retorno = true;
    } else if (prefixoCEP != null && prefixoCEP != "" && sufixoCEP != null && sufixoCEP != "") {
        retorno = false;
    }
    return retorno;
}

// Retorna se a string tem acentos ou caracteres invï¿½lidos para nomes de arquivos
function caracteresInvalidos( param ){
    var objExpReg = /[ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½\'\"!@#$%ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½&*()?,|]/gi;
    return objExpReg.test(param)
}

function getObjeto(name){
    this.nome = name;
    if (document.getElementById){
        this.obj = document.getElementById(name);
        if(document.getElementById(name) != null){
            this.style = document.getElementById(name).style;
        }
    }else if (document.all){
        this.obj = document.all[name];
        if(this.obj != null){
            this.style = document.all[name].style;
        }
    }else if (document.layers){
        this.obj = document.layers[name];
        if(this.obj != null){
            this.style = document.layers[name];
            this.obj.captureEvents(Event.onmouseout);
        }
    }
    this.isVisivel  = function __iv(){
        ret = true;
        if(this.style.visibility == "none"){
            ret = false;
        }
        return ret;                  
    }

    this.getNome       = function __n()   {return this.nome;         }
    this.visivel       = function __v()   {this.style.display="";    }
    this.invisivel     = function __inv() {this.style.display="none";}
    this.getObjeto     = function __w1()  {return this.obj;          }
    this.getEstilo     = function __w2()  {return this.style;        }
    this.setEstilo     = function __w3(p1){this.obj.className = p1;  }
    this.getNomeEstilo = function __w4()  {return this.obj.className;}

}

function BotaoLink(nome, formClick, figuraDisplay, nomeFigura,nomeFiguraFoco){
    this.nome               = nome;
    this.img                = new Image();
    this.imgFoco            = new Image();
    this.img.src            = nomeFigura;
    this.imgFoco.src        = nomeFiguraFoco;
    this.figuraDisplay      = new getObjeto(figuraDisplay);
    this.formBotao          = new getObjeto(formClick);
    this.botao_bullet       = null;
    this.getImagem          = function __bt1(){return this.img;}
    this.getImagemFoco      = function __bt2(){return this.imgFoco;}
    this.getFiguraDisplay   = function __bt3(){return this.figuraDisplay;}
    this.setaFoco           = function __bt4(controle){
                                                       if(controle != null){ 
                                                          controle.style.cursor = 'hand';
                                                       }
                                                       this.getFiguraDisplay().getObjeto().src = this.getImagemFoco().src;
                                                       if(this.botao_bullet != null){
                                                          this.botao_bullet.setaFoco();
                                                       } 
                                              };
    this.tiraFoco           = function __bt5(controle){
                                                       if(controle != null){ 
                                                          controle.style.cursor = 'default'; 
                                                       }
                                                       this.getFiguraDisplay().getObjeto().src = this.getImagem().src;
                                                       if(this.botao_bullet != null){
                                                          this.botao_bullet.tiraFoco();
                                                       } 
                                              };
    this.click              = function __bt6(controle){
                                                        if(this.formBotao != null){
                                                            this.formBotao.getObjeto().submit();
                                                        }
                                                      };
    this.setaBullet         = function __bt7(parmBullet){this.botao_bullet = parmBullet;};
}

function setaFocoControle(objeto,controle){
    if(objeto!=null){
        objeto.setaFoco(controle);
    }
}

function setaFocoControle2(objeto,controle,controle2){
    if(objeto!=null){
        objeto.setaFoco(controle, controle2);
    }
}

function isExisteObjeto(condicao){
    var ret = false;
    if(condicao != "undefined"){
        ret = true;
    }
    return ret;
}

//******************************************************
// Verificar se é um número.
//******************************************************
function verificarNumero (pStr)
{
    var retorno = false;
    var reDigits = /^\d+$/;
    
    if (reDigits.test(pStr)) {
            retorno = true;
    } else if (pStr != null && pStr != "") {
            retorno = false;
    }
    
    return retorno;
}

function contarCharDigitado(texto, totalDigitado, tamanhoLimite) 
{ 
    if (texto.value.length == 0){
        totalDigitado.value = 4000;        
    }

    if (texto.value.length >= tamanhoLimite) { 
        texto.value         = texto.value.substring(0, tamanhoLimite); 
        totalDigitado.value = 0;
    } 
    else {
        totalDigitado.value = tamanhoLimite - texto.value.length;
    }    

} 

//******************************************************
// Manipulacao de imagens
//******************************************************
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];}
}
//******************************************************

//=====================================
//Chama flash no site (correção do IE)
//=====================================
function addFlashIE7(swfFile, width, height, name, extParam){
    document.write('<object type="application/x-shockwave-flash" id="'+name+'" name="'+name+'" width="' + width + '" height="' + height + '" data="' + swfFile + '.swf">');
    document.write('<param name="allowScriptAccess" value="sameDomain" />');
    document.write('<param name="movie" value="' + swfFile + '.swf" />');
    document.write('<param name="menu" value="false" />');
    if (extParam != null){
        document.write(extParam);
    }
    document.write('<param name="quality" value="high" />');
    document.write('<param name="bgcolor" value="#FFFFFF" />');
    document.write('<param name="wmode" value="transparent" />');
    document.write('</object>');
}