﻿/*
* Trata imagens em png para ie 5 e 6.
*/
function ValidarPng()
{
    $(document).ready(function(){ 
        $(document).pngFix(); 
    }); 
}

/*
* Troca as imagens no menu
* estado futuro = on | off 
*/
function animaMenu(itemMenu , estado)
{
    var css = this.className;
    var id = '#' + itemMenu.id.substring(0,itemMenu.id.length-1);
    var ids = new Array(id + "e",id + "c",id + "d");
    var fundos = new Array("url(" + npPags.Config.ApplicationPath + "App_Themes/estiloPadrao/img/topo/menu_esquerda_"+ estado +".jpg)", 
                           "url(" + npPags.Config.ApplicationPath + "App_Themes/estiloPadrao/img/topo/menu_bg_"+ estado +".jpg)" ,
                           "url(" + npPags.Config.ApplicationPath + "App_Themes/estiloPadrao/img/topo/menu_direita_"+ estado +".jpg)");
    for(var i=0;i<ids.length;i++)
        $(ids[i]).css('background-image',fundos[i]);    
        
    numero = itemMenu.id.substring(itemMenu.id.length-2,itemMenu.id.length-1);
    if(estado == "on")
       $('#filho'+ numero).show(); 
    else
       $('#filho'+ numero).hide();     
}

/*
* Troca estado das imagens de on para off 
* class = rollover
*/
function rollover()
{
    $('.rollover').hover(
            function(){
                this.src = this.src.replace('_off','_on');
            },
            function(){
                this.src = this.src.replace('_on','_off');
            }
        );
}

/*
* Cria Conteudo dos labels do Topo
*/
var _data = new Date();
function topoLabels()
{
    criaSaudacao();
    criaData();            
    setInterval('criaHora()',1000);        
}
function criaSaudacao()
{
    var controle = $('#saudacao')[0];
    var hora = _data.getHours();
    var saudacao = "Ola!";
    
    if (hora > 5 && hora < 12)
        saudacao = "Bom dia";
    else if (hora > 11 && hora < 18)
        saudacao = "Boa tarde";
    else
        saudacao = "Boa noite";
        
    controle.innerHTML = saudacao;        
}
function criaHora()
{
    _data = new Date();
    var controle = $('#hora')[0];
    var hora = _data.getHours();
    var minuto = _data.getMinutes();
    var segundo = _data.getSeconds();            
        
    if (segundo == 60)
    {
        segundo = 0;
        if (minuto == 60)
        {
            minuto = 0;
            if (hora == 24)
            {
                hora = 0;
                criaData();
                criaSaudacao();
            }
            else
            {
                hora = hora +1;
                criaSaudacao();
            }
        }
        else
            minuto = minuto +1;
        }
        else
            segundo = segundo +1;
            
    hora = hora < 10 ? '0' + hora : hora;
    minuto = minuto < 10 ? '0' + minuto : minuto;
    segundo = segundo < 10 ? '0' + segundo : segundo;
    
    controle.innerHTML = hora + ':' + minuto + ':' + segundo;                        
}
function criaData()
{    
    var controle = $('#data')[0];
    var dia = _data.getDate();
    var mes = _data.getMonth();
    var ano = _data.getFullYear();
    
    var dia = (dia < 10) ? '0' + dia : dia;
    var mes = (mes < 10) ? '0' + mes : mes;
    
    controle.innerHTML = dia + '/' + mes + '/' + ano;
}


/*
* Limpa o texto predefinido quando o controle ganha o foco
* seletorControle = seletor do controle a receber a animaçao
* palavra = palavra definida inserida no controle
* corFundo = cor que a palavra vai aparecer ( normalmente uma cor mais clara que o preto)
*/
function limpaTexto(seletorControle , palavra , corFundo)
{
    if(corFundo == null || corFundo == "")
        corFundo = "black";
            
    var controles = $(seletorControle)
    controles.each(function(){
        this.style.color = corFundo;
        this.value = palavra
    });
    controles.focus(function(){
        if(this.value == palavra)
        {
            this.style.color = 'black';         
            this.value = "";
        }
    });
    controles.blur(function(){
        if(this.value == "")
        {
            this.style.color = corFundo;
            this.value = palavra;
        }
    });
}

/*
*Fade inicial da imagem
*idImg = id da imagem
*porcentagem = tom do fade
*/
function FadeImg(idImg,porcentagem)
{
    var imgs = $('#' + idImg);
    imgs.each(function(){
         $(this).fadeTo("fast", porcentagem);
    });
    imgs.hover(
        function(){
            $(this).fadeTo("fast", 1);
        },
        function(){
            $(this).fadeTo("fast", porcentagem);
        }
    );
}

/*
* Controla o box de imagem da pagina inicial
*/
var _obj_link ;
var _obj_boxImg ;
var _vetorImgs;
var _lefttime;
var _vim = 6 * 1000;
var _vi = 5;

function boxImg(boxImg,link,setaDir,setaEsq,altura,largura,vetorImgs)
{
    var obj_boxImg = $(boxImg);
    var obj_link = $(link);
    var obj_setaDir = $(setaDir);
    var obj_setaEsq = $(setaEsq);    
    
    _obj_link = obj_link;
    _obj_boxImg = obj_boxImg;
    _vetorImgs = vetorImgs;
    
    obj_boxImg.css({
        'width' : largura + 'px',
        'height' : altura + 'px'
      });
    
    /*posicionamento*/
    obj_setaDir.css({
        'top' : (altura - 20 ) + 'px',
        'left' : (largura - 20) + 'px',
        'position' : 'absolute',
        'cursor' : 'default'
      });
    obj_setaEsq.css({
        'top' : (altura - 20 ) + 'px',
        'left' : (largura - 40) + 'px',
        'position' : 'absolute',
        'cursor' : 'default'
      });
    
    /*inicial*/
    
    var cont = parseInt(Math.random () * vetorImgs.length);
    obj_boxImg.get(0).src = vetorImgs[cont].img;    
    obj_link.get(0).href = vetorImgs[cont].link;  
    
    
    _lefttime = _vi;    
    /*1 em 1 segundo*/
    setInterval("Decrementa()",1000);
    setTimeout("MudaImg(" + cont + ", 'cima')",_vim);  
    /*evento*/  
    obj_setaDir.click(function(){
        if(cont >= vetorImgs.length-1)
            cont = 0; 
        else
            cont++;
            
        obj_boxImg.fadeTo(500,0.1,function(){
            obj_boxImg.get(0).src = vetorImgs[cont].img;     
            obj_link.get(0).href = vetorImgs[cont].link;      
            obj_boxImg.fadeTo(500,1);
        });     
        _lefttime = _vi;
        setTimeout("MudaImg(" + cont + ", 'cima')",_vim);
    });
    obj_setaEsq.click(function(){
        if(cont == 0)
            cont = vetorImgs.length-1;
        else
            cont--;
        
        obj_boxImg.fadeTo(500,0.1,function(){
            obj_boxImg.get(0).src = vetorImgs[cont].img;     
            obj_link.get(0).href = vetorImgs[cont].link;      
            obj_boxImg.fadeTo(500,1);
        }); 
        _lefttime = _vi;    
        setTimeout("MudaImg(" + cont + ", 'baixo')",_vim);     
    });
}

function Decrementa()
{
    if(_lefttime != 0)
        _lefttime = _lefttime-1;
}

function MudaImg(cont,direcao)
{
    if(_lefttime == 0)
    {
        if(direcao == 'cima')
        {
            if(cont >= _vetorImgs.length-1)
            cont = 0; 
            else
                cont++;
                
            _obj_boxImg.fadeTo(500,0.1,function(){
                _obj_boxImg.get(0).src = _vetorImgs[cont].img;     
                _obj_link.get(0).href = _vetorImgs[cont].link;      
                _obj_boxImg.fadeTo(500,1);
            });  
            _lefttime = _vi;   
            setTimeout("MudaImg(" + cont + ", 'cima')",_vim);  
        }
        else
        {
            if(cont == 0)
                cont = _vetorImgs.length-1;
            else
                cont--;
            
            _obj_boxImg.fadeTo(500,0.1,function(){
                _obj_boxImg.get(0).src = _vetorImgs[cont].img;     
                _obj_link.get(0).href = _vetorImgs[cont].link;      
                _obj_boxImg.fadeTo(500,1);
            });    
            _lefttime = _vi;   
            setTimeout("MudaImg(" + cont + ", 'baixo')",_vim);
        }
    }
}

/*
*Seta uma altura para div relacionado a otra div
*divRecebe = div que recebera a altura
*divBase = div que sera feito a copia da altura
*marginTop = margin-top para o divRecebe (0 = anula)
*marginBotom = margin-bottom para o divRecebe (0 = anula)
*/
function setarTamanho(divRecebe , divBase , marginTop , marginBotom){
    var obj_divBase = $(divBase);
    var altura = obj_divBase.get(0).offsetHeight;
    $(divRecebe).css({
        'height': (altura * 0.9) + 'px',
        'margin-top':(altura * marginTop) + 'px',
        'margin-bottom':(altura * marginBotom) + 'px'
    });
}



/*
*Troca a div pelo respectivo DropDownList do destaque de curso no flash
*indice = indice da vez a ser trocado (1 a 6)
*Não usado
*/
function trocaDdlDiv(indice)
{
    var obj_div = $('#curso_div_' + indice + ' div');
    var obj_ddl = $('#curso_div_' + indice + ' select');
        
    obj_div.hover(function(){
        obj_div.hide();                
        obj_ddl.show(); 
        
        obj_ddl.hover(function(){},function(){   
                escondeDdl();                  
                obj_ddl.hide(); 
                obj_div.show();               
        });
                
    });
}

/*
*Esconde os DropDownList do destaque de curso no flash
*/
function escondeDdl()
{
    for(var i=1; i<=6;i++){
        $('#curso_div_' + i + ' div').show();
        $('#curso_div_' + i + ' select').hide();
    }
}

/*
*Inser flash na pagina
*/
function carregaFlash(idControle , idFlash , caminhoFlash , largura , altura , wmode)
{
    var swf = new SWFObject(caminhoFlash,idFlash,largura,altura,"9","#FFFFFF");
    if (wmode != null)
        swf.addParam("wmode", wmode);
    swf.write(jQuery('#' + idControle)[0]);
	
    idFlash = document.getElementById('idFlash');
}

/*
*Controla a abertura do subMenu de Conteudos
*qtd dos menus pais para o vetor que auxilia os que estao abertos e fechados
*/
function subMenuConteudo(qtd) /* Não esta sendo usado */
{
    var vet=new Array(); //vetor auxiliar para ver os que estao aberto
    var pos_cont = 0;
        
    $('.pai_').each(function(){
        vet[pos_cont] = 0;
        pos_cont ++;

        var indice = this.id.split('_')[1];
        $('#pai_'+indice).hover(function(){
            
            /*fecha os que estao aberto*/
            for(var y=0;y<vet.length;y++)
            {
                if(vet[y]==1 && y != (indice-1))
                {
                    vet[y] = 0;
                    $('.filho_'+(y+1)).slideToggle("fast");
                    break;
                }
             }       
             
            /*atualiza o estado do clicado*/ 
            if (vet[indice-1] == 0)
                vet[indice-1] = 1;
            else
                vet[indice-1] = 0;
            $('.filho_'+indice).slideToggle("fast");
            
        });  
    });
}

/*Não usado*/
function subMenuInternoCurso(itemMenu,estado,aberto)
{
   var id = itemMenu.id.substring(itemMenu.id.length-1);
   if(aberto != id)
   {
       var obj_e = $('#curso_int_menu_esq_' + id)
       var obj_c = $('#curso_int_menu_cen_' + id)
       var obj_d = $('#curso_int_menu_dir_' + id)
       var caminho = npPags.Config.ApplicationPath + 'App_Themes/estiloPadrao/img/controles/conteudo/';
       
       obj_e.css('background-image','url(' + caminho + 'interna_menu_esquerda_' + estado + '.gif)');
       obj_c.css('background-image','url(' + caminho + 'interna_menu_bg_' + estado + '.gif)');
       obj_d.css('background-image','url(' + caminho + 'interna_menu_direita_' + estado + '.gif)'); 
       
       if (estado == "on")
          obj_c.css('color','white');
       else
          obj_c.css('color','#9FB2B9');
   }
}
/*Não usado*/
function subMenuInternoCurso_fechar(id)
{
    var obj_e = $('#curso_int_menu_esq_' + id)
    var obj_c = $('#curso_int_menu_cen_' + id)
    var obj_d = $('#curso_int_menu_dir_' + id)
    var caminho = npPags.Config.ApplicationPath + 'App_Themes/estiloPadrao/img/controles/conteudo/';
    
    obj_e.css('background-image','url(' + caminho + 'interna_menu_esquerda_off.gif)');
    obj_c.css('background-image','url(' + caminho + 'interna_menu_bg_off.gif)');
    obj_d.css('background-image','url(' + caminho + 'interna_menu_direita_off.gif)');  
   
    obj_c.css('color','#9FB2B9');
}

/*
*Adiciona evento no Objeto
*/
function addEventSimple(obj,evt,fn) {
    if (typeof(obj) == 'string')
        obj = document.getElementById(obj);
	if (obj.addEventListener)
		obj.addEventListener(evt,fn,false);
	else if (obj.attachEvent)
		obj.attachEvent('on'+evt,fn);
}

/*
*Remove evento no Objeto
*/
function removeEventSimple(obj,evt,fn) {
    if (typeof(obj) == 'string')
        obj = document.getElementById(obj);
	if (obj.removeEventListener)
		obj.removeEventListener(evt,fn,false);
	else if (obj.detachEvent)
		obj.detachEvent('on'+evt,fn);
}

// ------------------------------------------------- mask ------------------------------------------------ //
// --------------------------------------------------------------------------------------------------------//

/*
JavaScript mask library
Levidad Studio (www.levidad.com)

usage: in an input field, set its maxlength according to the type of
mask you are applying (see comments in each function to know what the
size must be). Then, set its onKeyPress event to
mask(this,function_name). E.g.: If you want a phone mask, create:
<input type="text" maxlength="13" onKeyPress="mask(this,phoneMask);" />
and you are done.
**********************************************************************/

function onlyNumbers(value){
	value = value.replace(/\D/g, '');
	return value;
}

function onlyLetters(value){
	value = value.replace(/[^A-Za-z]/g, '');
	return value;
}

function onlyAlpha(value){
	value = value.replace(/\W/gi, '');
	return value;
}

function shortYearDateMask(value){
	// maxlength="8"
	// xx/xx/xx
    value = value.replace(/\D/g, '');
    value = value.replace(/(\d{2})(\d{2})/g, '$1/$2');
    value = value.replace(/(\d{2})(\d{2})/g, '$1/$2');
    return value;
}

function longYearDateMask(value){
	// maxlength="10"
	// xx/xx/xxxx
    value = value.replace(/\D/g, '');
    value = value.replace(/^(\d{2})(\d{2})/g, '$1/$2');
	value = value.replace(/(\d{4})$/g, '/$1');
    return value;
}

function phoneMask(value){
	// maxlength="13"
	// (xx)xxxx-xxxx
    value = value.replace(/\D/g, '');
    value = value.replace(/^(\d{2})(\d)/g, '($1)$2');
    value = value.replace(/(\d{4})(\d)/g, '$1-$2');
    return value;
}

function cepMask(value){
	// maxlength="9"
	// xxxxx-xxx
    value = value.replace(/\D/g, '');
    value = value.replace(/(\d{5})(\d)/, '$1-$2');
    return value;
}

function cpfMask(value){
	// maxlength="14"
	// xxx.xxx.xxx-xx
	value = value.replace(/\D/g, '');
	value = value.replace(/(\d{3})(\d)/,'$1.$2');
	value = value.replace(/(\d{3})(\d)/,'$1.$2');
	value = value.replace(/([\d|\.]{11})(\d{2})/,'$1-$2');
	return value;
}

function cnpjMask(value){
	// maxlength="18"
	// xx.xxx.xxx/xxxx-xx
	value = value.replace(/\D/g, '');
	value = value.replace(/^(\d{2})(\d)/,'$1.$2');
	value = value.replace(/(\d{3})(\d)/,'$1.$2');
	value = value.replace(/(\d{3})(\d)/,'$1/$2');
	value = value.replace(/(\d{4})(\d)/,'$1-$2');
	return value;												
}

function currencyMask(value)
{
    // maxlength: any
    // xxxx,xx
    value = onlyNumbers(value);
    
    // Remove todos os zeros à esquerda.
    while ((value[0] && value[0] == '0') && value[1])
        value = value.substr(1,value.length);
        
    // Acrescenta zeros à esquerda até que o tamanho da string seja pelo menos 3.
    while (value.length < 3)
        value = '0' + value;
        
    // Acrescenta a vírgula.
    value = (value.substr(0,value.length - 2)) + ',' + (value.substr(value.length - 2, value.length));
    
    return value;
}

function mask(control, maskName){
    _control = control;
    _maskName = maskName;
    setTimeout('applyMask()', 1);
}

function applyMask(){
    _control.value = _maskName(_control.value);
}

/* mask */
(function(B) { var A = (window.orientation != undefined); B.extend({ mask: { rules: { "z": /[a-z]/, "Z": /[A-Z]/, "a": /[a-zA-Z]/, "*": /[0-9a-zA-Z]/, "@": /[0-9a-zA-ZÃ§Ã‡Ã¡Ã Ã£Ã©Ã¨Ã­Ã¬Ã³Ã²ÃµÃºÃ¹Ã¼]/ }, fixedChars: "[(),.:/ -]", keyRepresentation: { 8: "backspace", 9: "tab", 13: "enter", 16: "shift", 17: "control", 18: "alt", 27: "esc", 33: "page up", 34: "page down", 35: "end", 36: "home", 37: "left", 38: "up", 39: "right", 40: "down", 45: "insert", 46: "delete", 116: "f5", 224: "command" }, iphoneKeyRepresentation: { 10: "go", 127: "delete" }, signals: { "+": "", "-": "-" }, options: { attr: "alt", mask: null, type: "fixed", defaultValue: "", signal: false, onInvalid: function() { }, onValid: function() { }, onOverflow: function() { } }, masks: { "phone": { mask: "(99) 9999-9999" }, "phone-us": { mask: "(999) 9999-9999" }, "cpf": { mask: "999.999.999-99" }, "cnpj": { mask: "99.999.999/9999-99" }, "date": { mask: "39/19/9999" }, "date-us": { mask: "19/39/9999" }, "cep": { mask: "99999-999" }, "time": { mask: "29:59" }, "cc": { mask: "9999 9999 9999 9999" }, "integer": { mask: "999.999.999.999", type: "reverse" }, "decimal": { mask: "99,999.999.999.999", type: "reverse", defaultValue: "000" }, "decimal-us": { mask: "99.999,999,999,999", type: "reverse", defaultValue: "000" }, "signed-decimal": { mask: "99,999.999.999.999", type: "reverse", defaultValue: "+000" }, "signed-decimal-us": { mask: "99,999.999.999.999", type: "reverse", defaultValue: "+000"} }, init: function() { if (!this.hasInit) { var C = this, D, E = (A) ? this.iphoneKeyRepresentation : this.keyRepresentation; this.ignore = false; this.fixedCharsReg = new RegExp(this.fixedChars); this.fixedCharsRegG = new RegExp(this.fixedChars, "g"); for (D = 0; D <= 9; D++) { this.rules[D] = new RegExp("[0-" + D + "]") } this.keyRep = E; this.ignoreKeys = []; B.each(E, function(F) { C.ignoreKeys.push(parseInt(F)) }); this.hasInit = true } }, set: function(G, D) { var C = this, E = B(G), F = "maxLength"; this.init(); return E.each(function() { var N = B(this), O = B.extend({}, C.options), M = N.attr(O.attr), H = "", J = C.__getPasteEvent(); H = (typeof D == "string") ? D : (M != "") ? M : null; if (H) { O.mask = H } if (C.masks[H]) { O = B.extend(O, C.masks[H]) } if (typeof D == "object") { O = B.extend(O, D) } if (B.metadata) { O = B.extend(O, N.metadata()) } if (O.mask != null) { if (N.data("mask")) { C.unset(N) } var I = O.defaultValue, L = N.attr(F), K = (O.type == "reverse"); O = B.extend({}, O, { maxlength: L, maskArray: O.mask.split(""), maskNonFixedCharsArray: O.mask.replace(C.fixedCharsRegG, "").split("") }); if (K) { N.css("text-align", "right") } if (N.val() != "") { N.val(C.string(N.val(), O)) } else { if (I != "") { N.val(C.string(I, O)) } } N.data("mask", O); N.removeAttr(F); N.bind("keydown", { func: C._keyDown, thisObj: C }, C._onMask).bind("keyup", { func: C._keyUp, thisObj: C }, C._onMask).bind("keypress", { func: C._keyPress, thisObj: C }, C._onMask).bind(J, { func: C._paste, thisObj: C }, C._delayedOnMask) } }) }, unset: function(D) { var C = B(D), E = this; return C.each(function() { var H = B(this); if (H.data("mask")) { var F = H.data("mask").maxlength, G = E.__getPasteEvent(); if (F != -1) { H.attr("maxLength", F) } H.unbind("keydown", E._onMask).unbind("keypress", E._onMask).unbind("keyup", E._onMask).unbind(G, E._delayedOnMask).removeData("mask") } }) }, string: function(F, C) { this.init(); var E = {}; if (typeof F != "string") { F = String(F) } switch (typeof C) { case "string": if (this.masks[C]) { E = B.extend(E, this.masks[C]) } else { E.mask = C } break; case "object": E = C } if ((E.type == "reverse") && E.defaultValue) { if (typeof this.signals[E.defaultValue.charAt(0)] != "undefined") { var D = F.charAt(0); E.signal = (typeof this.signals[D] != "undefined") ? this.signals[D] : this.signals[E.defaultValue.charAt(0)]; E.defaultValue = E.defaultValue.substring(1) } } return this.__maskArray(F.split(""), E.mask.replace(this.fixedCharsRegG, "").split(""), E.mask.split(""), E.type, E.defaultValue, E.signal) }, unmaskedVal: function(C) { return B(C).val().replace(B.mask.fixedCharsRegG, "") }, _onMask: function(C) { var E = C.data.thisObj, D = {}; D._this = C.target; D.$this = B(D._this); if (D.$this.attr("readonly")) { return true } D.value = D.$this.val(); D.nKey = E.__getKeyNumber(C); D.range = E.__getRange(D._this); D.valueArray = D.value.split(""); D.data = D.$this.data("mask"); D[D.data.type] = true; return C.data.func.call(E, C, D) }, _delayedOnMask: function(C) { C.type = "paste"; setTimeout(function() { C.data.thisObj._onMask(C) }, 1) }, _keyDown: function(D, E) { this.ignore = (B.inArray(E.nKey, this.ignoreKeys) > -1); if (this.ignore) { var C = this.keyRep[E.nKey]; E.data.onValid.call(E._this, C ? C : "", E.nKey) } return A ? this._keyPress(D, E) : true }, _keyUp: function(C, D) { if (D.nKey == 9 && (B.browser.safari || B.browser.msie)) { return true } return (!D.infinite) ? this._paste(C, D) : true }, _paste: function(D, E) { if (E.reverse) { this.__changeSignal(D.type, E) } var C = this.__maskArray(E.valueArray, E.data.maskNonFixedCharsArray, E.data.maskArray, E.data.type, E.data.defaultValue, E.data.signal); E.$this.val(C); if (!E.reverse && E.data.defaultValue.length && (E.range.start == E.range.end)) { this.__setRange(E._this, E.range.start, E.range.end) } if ((B.browser.msie || B.browser.safari) && !E.reverse) { this.__setRange(E._this, E.range.start, E.range.end) } return true }, _keyPress: function(J, C) { if (this.ignore || J.ctrlKey || J.metaKey || J.altKey) { return true } if (C.reverse) { this.__changeSignal(J.type, C) } var K = String.fromCharCode(C.nKey), M = C.range.start, G = C.value, E = C.data.maskArray; if (C.reverse) { var F = G.substr(0, M), I = G.substr(C.range.end, G.length); G = (F + K + I); if (C.data.signal && (M - C.data.signal.length > 0)) { M -= C.data.signal.length } } var L = G.replace(this.fixedCharsRegG, "").split(""), D = this.__extraPositionsTill(M, E); C.rsEp = M + D; if (C.infinite) { C.rsEp = 0 } if (!this.rules[E[C.rsEp]]) { C.data.onOverflow.call(C._this, K, C.nKey); return false } else { if (!this.rules[E[C.rsEp]].test(K)) { C.data.onInvalid.call(C._this, K, C.nKey); return false } else { C.data.onValid.call(C._this, K, C.nKey) } } var H = this.__maskArray(L, C.data.maskNonFixedCharsArray, E, C.data.type, C.data.defaultValue, C.data.signal, D); C.$this.val(H); return (C.reverse) ? this._keyPressReverse(J, C) : (C.fixed) ? this._keyPressFixed(J, C) : true }, _keyPressFixed: function(C, D) { if (D.range.start == D.range.end) { if ((D.rsEp == 0 && D.value.length == 0) || D.rsEp < D.value.length) { this.__setRange(D._this, D.rsEp, D.rsEp + 1) } } else { this.__setRange(D._this, D.range.start, D.range.end) } return true }, _keyPressReverse: function(C, D) { if (B.browser.msie && ((D.rangeStart == 0 && D.range.end == 0) || D.rangeStart != D.range.end)) { this.__setRange(D._this, D.value.length) } return false }, __changeSignal: function(D, E) { if (E.data.signal !== false) { var C = (D == "paste") ? E.value.charAt(0) : String.fromCharCode(E.nKey); if (this.signals && (typeof this.signals[C] != "undefined")) { E.data.signal = this.signals[C] } } }, __getPasteEvent: function() { return (B.browser.opera || (B.browser.mozilla && parseFloat(B.browser.version.substr(0, 3)) < 1.9)) ? "input" : "paste" }, __getKeyNumber: function(C) { return (C.charCode || C.keyCode || C.which) }, __maskArray: function(H, G, D, F, C, I, E) { if (F == "reverse") { H.reverse() } H = this.__removeInvalidChars(H, G); if (C) { H = this.__applyDefaultValue.call(H, C) } H = this.__applyMask(H, D, E); switch (F) { case "reverse": H.reverse(); return (I || "") + H.join("").substring(H.length - D.length); case "infinite": return H.join(""); default: return H.join("").substring(0, D.length) } return "" }, __applyDefaultValue: function(E) { var C = E.length, D = this.length, F; for (F = D - 1; F >= 0; F--) { if (this[F] == E.charAt(0)) { this.pop() } else { break } } for (F = 0; F < C; F++) { if (!this[F]) { this[F] = E.charAt(F) } } return this }, __removeInvalidChars: function(E, D) { for (var C = 0; C < E.length; C++) { if (D[C] && this.rules[D[C]] && !this.rules[D[C]].test(E[C])) { E.splice(C, 1); C-- } } return E }, __applyMask: function(E, C, F) { if (typeof F == "undefined") { F = 0 } for (var D = 0; D < E.length + F; D++) { if (C[D] && this.fixedCharsReg.test(C[D])) { E.splice(D, 0, C[D]) } } return E }, __extraPositionsTill: function(E, C) { var D = 0; while (this.fixedCharsReg.test(C[E])) { E++; D++ } return D }, __setRange: function(E, F, C) { if (typeof C == "undefined") { C = F } if (E.setSelectionRange) { E.setSelectionRange(F, C) } else { var D = E.createTextRange(); D.collapse(); D.moveStart("character", F); D.moveEnd("character", C - F); D.select() } }, __getRange: function(D) { if (!B.browser.msie) { return { start: D.selectionStart, end: D.selectionEnd} } var E = { start: 0, end: 0 }, C = document.selection.createRange(); E.start = 0 - C.duplicate().moveStart("character", -100000); E.end = E.start + C.text.length; return E } } }); B.fn.extend({ setMask: function(C) { return B.mask.set(this, C) }, unsetMask: function() { return B.mask.unset(this) }, unmaskedVal: function() { return B.mask.unmaskedVal(this[0]) } }) })(jQuery)



// -------------------------------------------- tableRollover -------------------------------------------- //
// --------------------------------------------------------------------------------------------------------//

// Adds rollover effect to the table rows.

// param: tableId: the id of the table to which this script will apply the effect.
// param: cssClass_mouseOver: the css class name to apply to rows being mouse-overed.
// param: cssClass_mouseOut: the name of the css class to aplly to apply to r
// param: ignoreFirstRow: 
function addTableRollover(tableId, cssClass_mouseOver, cssClass_mouseOut, ignoreFirstRow)
{
    mouseOverCssClass = cssClass_mouseOver;
    mouseOutCssClass = cssClass_mouseOut;

    var table = document.getElementById(tableId);
    
    if (table)
    {        
        for (var i = 0; i < table.rows.length; i++)
        {

            if (i == 0 && ignoreFirstRow)
                continue;

            var currentRow = table.rows[i];
            
            currentRow.onmouseover = function () {this.className = cssClass_mouseOver;};
            currentRow.onmouseout = function() {this.className = cssClass_mouseOut;};
        }
    }
}
// ---------------------------------------------- rollovers ---------------------------------------------- //
// --------------------------------------------------------------------------------------------------------//

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_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_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];}
}

// ---

function rolloverSimple(elementId, mouseOverImage)
{
    var element = document.getElementById(elementId);
    
    if (element)
    {
        // Registers mouseover event to change the element's image.
        addEventSimple(element, "mouseover", function() {MM_swapImage(elementId, '', mouseOverImage, 1);});
    
        // Registers mouseout event to restore the element's image.
        addEventSimple(element, "mouseout", MM_swapImgRestore);
    }
}

function addEventSimple(obj,evt,fn) {
	if (obj.addEventListener)
		obj.addEventListener(evt,fn,false);
	else if (obj.attachEvent)
		obj.attachEvent('on'+evt,fn);
}

// Aplica afeito de opacidade (alpha) em um elemento. Sem efeito de transição.
// Param "elementId": O id do elemento no qual o efeito deve ser aplicado.
// Param "mouseOutOpacity": Um valor entre 0 e 1 que especifica a opacidade do
// elemento quando o não mouse estiver sobre ele.
function rolloverOpacity(elementId, mouseOutOpacity)
{
	if (!mouseOutOpacity) var mouseOutOpacity = .5;
	
	var isIE = BrowserDetect.browser == 'Explorer';
	var el = document.getElementById(elementId);
	
	if (isIE)
	{
		ieOpacityValue = parseInt(mouseOutOpacity * 100);
		el.style['filter'] = 'alpha(opacity=' + ieOpacityValue + ')';
		addEventSimple(el, 'mouseover', function(){el.style['filter'] = 'alpha(opacity=100)';});
		addEventSimple(el, 'mouseout', function(){el.style['filter'] = 'alpha(opacity=' + ieOpacityValue + ')';});
	}
	else
	{
		el.style['MozOpacity'] = mouseOutOpacity;
		addEventSimple(el, 'mouseover', function(){el.style['MozOpacity'] = 1;});
		addEventSimple(el, 'mouseout', function(){el.style['MozOpacity'] = mouseOutOpacity;});
	}
}

// ----------------------------------------- findElementPosition ----------------------------------------- //
// --------------------------------------------------------------------------------------------------------//

function findElementPosition(obj) {
    var curleft = curtop = 0;

    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        }
        while (obj = obj.offsetParent);
    }

    return [curtop, curleft];
}