if (document.layers){
    document.captureEvents(Event.KEYDOWN | Event.KEYUP);
    document.onkeydown = PTATMascaraNumeroTecla;
    document.onkeyup   = PTATMascaraNumeroExibe;
}
/********************************************************************************/
/* Funo: PTATMascaraNumero                                                    */
/*------------------------------------------------------------------------------*/
/* Descrio: Classe responsvel por criar o objeto MascaraNumero. Conta a quan-*/
/*            tidade de numeros que faro parte da mscara atravs da prpria   */
/*            mscara passada como parmetro.                                   */
/*------------------------------------------------------------------------------*/
/* Parmetros: Nome: o nome da varivel que receber o objeto do tipo           */
/*                   PTATMascaraNumero dever obrigatiramente ser passado como    */
/*                   uma string neste parmetro.                                */
/*             Mascara: mscara de entrada que delimita a quantidade de nmeros */
/*                   a serem entrados. Delimita tambm o tamanho do TextBox.    */
/*                   A mscara  do tipo ___*__*__, ou seja, reconhece o carac- */
/*                   tere sublinhado (_) como sendo posio de nmero e qualquer*/
/*                   outro caractere com osendo pertencenta  mscara.          */
/*------------------------------------------------------------------------------*/
/* Retorno: Objeto PTATMascaraNumero.                                           */
/*------------------------------------------------------------------------------*/
/* Dependncias: Nenhum.                                                        */
/*------------------------------------------------------------------------------*/
/*                                                                              */
function PTATMascaraNumero(Nome, Mascara, SaidaComMascara, ValorEntrada, autoTab){

    //propriedades
    this.ComMascara  = SaidaComMascara;
    this.Mascara     = Mascara;
    this.autoTab     = autoTab;
    this.Valor       = '';
    this.Nome        = Nome;
    this.Qtde        = 0;
    this.Objeto      = null;
    this.Form        = '';
    this.lastKey     = 0;

    var Auxiliar     = '';

    //contar quantos numeros ter a mascara
    for (i=0; i<Mascara.length; i++){
        if (Mascara.charAt(i)=='_') this.Qtde++;
    }

    for (i = 0; i < ValorEntrada.length; i++){
        if ((ValorEntrada.charCodeAt(i)>=48) && (ValorEntrada.charCodeAt(i)<=57)) Auxiliar += ValorEntrada.charAt(i);
    }
    this.Valor = Auxiliar;

    //mtodos
    this.Exibe     = PTATMascaraNumeroExibe;
    this.Tecla     = PTATMascaraNumeroTecla;
    this.Blur      = PTATMascaraNumeroBlur;
    this.NextField = PTATMascaraNumeroNext;
    
    return this;
}
/*                                                                              */
/*------------------------------------------------------------------------------*/
/********************************************************************************/


function PTATMascaraNumeroBlur(){
    this.Objeto = (this.Objeto == null) ? document.getElementById(this.Nome) : this.Objeto;
    if (this.Valor=='')
        this.Objeto.value = '';
}

/********************************************************************************/
/* Funo: PTATMascaraNumeroExibe                                               */
/*------------------------------------------------------------------------------*/
/* Descrio: Mtodo destinado a exibir os valores digitados juntamente com sua */
/*            mscara.                                                          */
/*------------------------------------------------------------------------------*/
/* Parmetros: Nenhum.                                                          */
/*------------------------------------------------------------------------------*/
/* Retorno: Nenhum.                                                             */
/*------------------------------------------------------------------------------*/
/* Dependncias: Nenhum.                                                        */
/*------------------------------------------------------------------------------*/
/*                                                                              */
function PTATMascaraNumeroExibe(){
    var conteudo, qtdvalor;
    conteudo = '';
    qtdvalor = 0;
    var ValorEntrada;
    this.Objeto = (this.Objeto == null) ? document.getElementById(this.Nome) : this.Objeto;

    for (i = 0; i < this.Mascara.length; i++){
        if (qtdvalor<this.Valor.length){
            if (this.Mascara.charAt(i)!='_'){
                conteudo += this.Mascara.charAt(i);
            }
            else{
                conteudo += this.Valor.charAt(qtdvalor);
                qtdvalor++;
            }
        }
        else{
            conteudo += this.Mascara.charAt(i);
        }
    }

    this.Objeto.value = conteudo;

    if (PTATMascaraNumeroExibe.arguments.length > 0){
    if (((this.lastKey >= 48) && (this.lastKey <= 57)) || ((this.lastKey >= 96) && (this.lastKey <= 105))){
      if (this.autoTab && this.Valor.length == this.Qtde) this.NextField();
    }
    }
    this.lastKey = 0;
}

/********************************************************************************/
/* Funo: PTATMascaraNumeroTecla                                               */
/*------------------------------------------------------------------------------*/
/* Descrio: Funo que trata a entrada de dados, filtra as teclas pressiona-  */
/*            das para aceitar apenas nmeros. Verifica se a tecla backspace    */
/*            foi pressionada para excluir o ltimo nmero digitado na proprie- */
/*            dade Valor. Verifica se a tecla delete foi pressionada para esva- */
/*            ziar a propriedade Valor.                                         */
/*------------------------------------------------------------------------------*/
/* Parmetros: e: o evento realizado no input text da mscara.                  */
/*------------------------------------------------------------------------------*/
/* Retorno: Nenhum.                                                             */
/*------------------------------------------------------------------------------*/
/* Dependncias: Nenhum.                                                        */
/*------------------------------------------------------------------------------*/
/*                                                                              */
function PTATMascaraNumeroTecla (e){
    var whichCode;
    this.Objeto = (this.Objeto == null) ? document.getElementById(this.Nome) : this.Objeto;

    if (document.layers){
        whichCode = e.which;
    }
    else{
        whichCode = (window.Event) ? e.which : e.keyCode;
    }
  this.lastKey = whichCode;
    var key;

    if (((whichCode >= 48) && (whichCode <= 57)) || ((whichCode >= 96) && (whichCode <= 105))){
        //a tecla pressionada  um nmero
        if (this.Valor.length < this.Qtde){
            if (whichCode > 95){
                key = String.fromCharCode(whichCode-48);
            }
            else{
                key = String.fromCharCode(whichCode);
            }
            this.Valor += key;
        }
    }
    else{
        //se a tecla pressionada no for um numero
        switch (whichCode){
            case 8://Tecla backspace
                //apagar o ltimo caracter;
                this.Valor = this.Valor.substring(0,this.Valor.length-1);
            break;
            case 46://tecla delete
                //apaga todo o contedo da mscara;
                this.Valor = '';
            break;
        }
    }
    return 0;
}
/********************************************************************************/
/* Funo: PTATMascaraNumeroNext                                                */
/*------------------------------------------------------------------------------*/
/* Descrio: Funo que trata de mudar o foco da mascara para o proximo campo  */
/*            do Form.                                                          */
/*------------------------------------------------------------------------------*/
/* Parmetros: Nenhum.                                                          */
/*------------------------------------------------------------------------------*/
/* Retorno: Nenhum.                                                             */
/*------------------------------------------------------------------------------*/
/* Dependncias: Nenhum.                                                        */
/*------------------------------------------------------------------------------*/
/*                                                                              */
function PTATMascaraNumeroNext(){
  this.Objeto = (this.Objeto == null) ? document.getElementById(this.Nome) : this.Objeto;
  var theIndex = this.Objeto.tabIndex;
  var theForm = this.Objeto.form;
  for (var i = 0; i<theForm.elements.length; i++){
    if (theForm.elements[i].tabIndex == (theIndex+1)){
      theForm.elements[i].focus();
      break;
    }
  }
}

function AplicarEstilo(obj, Estilo){
	obj.className = Estilo;
}


var newwindow;
function AbrirJanela(url,nome,estilo)
{
	newwindow=window.open(url, 'name' ,estilo);
	if (window.focus) {newwindow.focus()}
}





var PieNG;
(PieNG = function(base) {
	if (/MSIE (5\.5|6).*Windows/.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
		// fucked-up browser (Internet Explorer for Windows)
		var blank = new Image;
		blank.src = _dynarch_menu_url + 'img/blank.gif';
		base || (base = document);
		var imgs = base.getElementsByTagName("img");
		for (var i = imgs.length; --i >= 0;) {
			var img = imgs[i];
			var src = img.src;
			if (!/\.png$/.test(src))
				continue;
			var s = img.style;
			if (!img.width && img.offsetWidth)
				s.width = img.offsetWidth + "px";
			if (!img.height && img.offsetHeight)
				s.height = img.offsetHeight + "px";
			s.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
			img.src = blank.src;
		}
	}
})();




function hidestatus(){
window.status='';
return true;
}

if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)

document.onmouseover=hidestatus;
document.onmouseout=hidestatus;

function fecharMenuPortal(evento){
	//top['clicaMouse'](evento);
	try {
		top.clicaMouse(evento);
	}
	catch(e){
 	}
 	
	return true;
}
