
/**
 * Configura para que as combinações Alt + Seta para cima e Alt + Seta para baixo
 * funcionem como aumentar e diminuir fonte respectivamente.
 *
 */
function configFonte(e) {
	e = e ? e : window.event;
	
	if (e.altKey && e.keyCode == 38) {
		banese.noticia.aumentarFonte('corpo');
	} else if (e.altKey && e.keyCode == 40) {
		banese.noticia.diminuirFonte('corpo');
	}
}

document.onkeydown = configFonte;


/**
 * Aumentar ou diminuir a fonte do texto do conteúdo exibido.
 * 	Execução: banese.noticia.aumentarFonte(container) | banese.noticia.diminuirFonte(container)
 *  Para incluir mais tags para serem afetados pelo ação, incluí-la no Array
 * 		_elAfetados
 */
var banese = {
  noticia: new Object()
}

banese.noticia = {
  _elAfetados: new Array("DIV","P","A","LI","STRONG","H1","H2","H3","H4","H5","H6","LABEL","FONT", "SPAN"),
	
  _value: 1,
  _valueAdd: 0.085,
  _limitMais: 100000,
  _limitMenos: 1,
	
  aumentarFonte: function(container) {
	this._value = Math.min(this._limitMais, this._value + this._valueAdd);
	this.updateFonte(container);
  },

  diminuirFonte: function(container) {
	this._value = Math.max(this._limitMenos, this._value - this._valueAdd);
	this.updateFonte(container);
  },
	
  updateFonte: function(container) {		
    var objCont = document.getElementById(container);

    if (objCont == null) {
		objCont = document.getElementById("corpo_noticia");
	}

    if (objCont != null) {
	  for (i=0; i < this._elAfetados.length; i++) {
          var elObjs = objCont.getElementsByTagName(this._elAfetados[i]);

          for (j=0; j < elObjs.length; j++) {
            elObjs[j].style.fontSize = this._value + 'em';
	      }
      }
    }
  }
}




/** Tamanho da fonte. Palavras-chave: (fonte) */
var b = 12;

/** Representa aumentar fonte. Palavras-chave: (mais, aumentar) */
var sinalMais  = '+';

/** Representa diminuir fonte Palavras-chave: (menos, dimunuir)*/
var sinalMenos = '-';

/**
 * Aumenta a fonte de texto espe
 * Palavras-chave: (aumenta, fonte, size, diminui)
 *
 * @param sinal
 *        Flag que indica quando aumentar ou quando diminuir a fonte.
 */
function font_size(sinal) {
  var parag;
  var tamfonte;
  var quanttd;
  var alink;
	
  var objCorpo = document.getElementById('corpo');

  if (objCorpo != null) {  
    parag    = objCorpo.getElementsByTagName('p');
    tamfonte = objCorpo.getElementsByTagName('td');
    quanttd  = objCorpo.getElementsByTagName('li');
    alink     = objCorpo.getElementsByTagName('a');
  }

  try {
    if (b <= 16 && sinal == '+') {
      b = b < 17 ? (b+2) : 17;
      document.getElementById('corpo').className = "fonte" + b;

      for (i=0; i <= parag.length-1;i++) {
        parag[i].style.fontSize = b + 'px';
      }

      for (i=0; i <= tamfonte.length-1;i++) {
        tamfonte[i].style.fontSize = b + 'px';
      }

      for (i=0; i <= quanttd.length-1;i++) {
        quanttd[i].style.fontSize = b + 'px';
      }

	  for (i=0; i <= alink.length-1;i++) {
        alink[i].style.fontSize = b + 'px';
      }

    } else if(b >= 0 && sinal == '-') {
      b = b > 12 ? (b-2): 12;
      document.getElementById('corpo').className = "fonte" + b;

      for (i=0; i <= parag.length-1;i++) {
        parag[i].style.fontSize = b + 'px';
      }
		
      for (i=0; i <= tamfonte.length-1;i++) {
        tamfonte[i].style.fontSize = b + 'px';	 
      }
		
      for (i=0; i <= quanttd.length-1;i++) {
        quanttd[i].style.fontSize = b + 'px';
      }
      for (i=0; i <= alink.length-1;i++) {
        alink[i].style.fontSize = b + 'px';
      }
    }
  } catch(e) {
    //alert('ERRO: ' + e);
  }
}