/* ******************************************************************************************** */
/* ***** Funcion que cambia de tamano la letra del(los) estilo(s) referenciado(s).        ***** */
/* ***** Archivo de estilos usado:                                                        ***** */
/* *****     /web/p4_lanacion/css/site/port/estilos.css                                   ***** */
/* ***** V1.0 10/01/2003 - MCO                                                            ***** */
/* ***** V1.1 13/01/2003 - ALD - Uso de selectorText                                      ***** */
/* ***** V1.2 13/01/2003 - MCO - Recuperacion y reasignacion de atributos al mismo estilo ***** */
/* ***** V1.3 15/01/2003 - MCO - Se elimina cant en porcentaje de la llamada a la funcion ***** */
/* *****                         para dejarlo en forma local al js y modificar solo este  ***** */
/* *****                         en afinamientos o cambios posteriores.                   ***** */
/* ***** V1.4 15/01/2003 - ALD - Agrega estilos, aumenta "salto" y disminuye margenes.    ***** */
/* ***** V1.5 17/01/2003 - ALD - Optimiza un poco para agilizar la ejecucion.             ***** */
/* ***** V1.6 30/01/2003 - ALD - Mejora manejo de intervalos de tama?.                   ***** */
/* ***** V1.7 03/06/2003 - MCO - Nueva optimizacion. Se agrega tratamiento para el * que  ***** */
/* *****                         indica valor generico de las cascadas                    ***** */
/* ******************************************************************************************** */

var size_actual = 100;
var intervalo   = 10;  // 10% o -10% Segun el signo que venga como parametro de la funcion.

var tamanos = new Array(70,80,90,100,130,180,250);
var size_actual_i = 3; // Corresponde al cuarto elemento en el arreglo tamanos.

// Variable por defecto.
var fontWeight_default = '';
var fontFamily_default = '';
var fontSize_default = '';
var color_default = '';
var indice_hoja_estilos = 0;

if (document.all) { // ie.

  // Inicializa arreglos de estilos. V1.7.
  var fontweight = new Array();
  var fontfamily = new Array();
  var fontsize   = new Array();
  var fontcolor  = new Array();

  // Rescata los atributos de los css del primer archivo de estilos de la pagina html (por eso se usa el subindice 0).
  for (var i=0; i < document.styleSheets[indice_hoja_estilos].rules.length; i++) { // 1.2
    fontweight[i] = document.styleSheets[indice_hoja_estilos].rules[i].style.fontWeight;
    fontfamily[i] = document.styleSheets[indice_hoja_estilos].rules[i].style.fontFamily;
    fontsize[i] = document.styleSheets[indice_hoja_estilos].rules[i].style.fontSize;
    fontcolor[i] = document.styleSheets[indice_hoja_estilos].rules[i].style.color;
  };

  // Inicializa elementos a modificar.
  var var_elements = new Array();
  var debug="";

  // Busca los elementos a modificar (css). Estos son fijos y hay que agregarlos directamente en este archivo.
  for (var i=0; i < document.styleSheets[indice_hoja_estilos].rules.length; i++) {
    var aux = document.styleSheets[indice_hoja_estilos].rules[i].selectorText;
    found = 0;
    
    
    //if ( aux.indexOf('recuadro') >= 0 ) { //debug
     //debug+=aux+"\n"; //debug
    //};  //debug
     
    if (aux == '*') {
      fontWeight_default = document.styleSheets[indice_hoja_estilos].rules[i].style.fontSize;
      fontFamily_default = document.styleSheets[indice_hoja_estilos].rules[i].style.fontWeight;
      fontSize_default   = document.styleSheets[indice_hoja_estilos].rules[i].style.fontFamily;
      color_default      = document.styleSheets[indice_hoja_estilos].rules[i].style.color;
    };

    if ( (aux.indexOf('artTitular')   >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('artBajada')    >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('contArticulo') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
   
        
    if (found == 1) { var_elements[ var_elements.length] = i; };
  };
   //alert(debug); // debug
};

function cambia_size(signo) {
  // Hasta el momento el cambio de fonts sirve solo para ie.

  if (document.all) {
    if ( (signo == '20') || (signo == 'mas') ) {// 1.3
      if (size_actual_i >= (tamanos.length - 1)) { return; };
      size_actual_i++;
    }else{
      if (size_actual_i <= 0) { return; };
      size_actual_i--;
    };
    size_actual = tamanos[size_actual_i];

    // 1.5 Solo aplica cambios a elementos preseleccionados.
    for (var i=0; i < var_elements.length; i++) {
      var j = var_elements[i];

    
      if (fontsize[j]   == '') { if (fontSize_default != '') { fontsize[j] = fontSize_default; }else{ fontsize[j] = 12 }; }; // V1.7.
      //if (fontweight[j] == '') { if (fontWeight_default != '') { fontweight[j] = fontWeight_default; }else{ fontweight[j] = 'Normal' }; };
      //if (fontfamily[j] == '') { if (fontFamily_default != '') { fontfamily[j] = fontFamily_default; }else{ fontfamily[j] = 'Arial, Helvetica, sans-serif' }; };
      //if (fontcolor[j]  == '') { if (color_default != '') { fontcolor[j]  = color_default; }else{ fontcolor[j] = '#000000' }; };

      var tam_final = parseInt((parseInt(fontsize[j]) * size_actual)/100);

      if (tam_final - parseInt(tam_final) > 0) { // Si resultado da con decimal, se agrega uno al entero.
        tam_final = parseInt(tam_final) + 1;
      };
        
      document.styleSheets[indice_hoja_estilos].rules[j].style.fontSize   = tam_final+'px';
      //document.styleSheets[indice_hoja_estilos].rules[j].style.fontWeight = fontweight[j];
      //document.styleSheets[indice_hoja_estilos].rules[j].style.fontFamily = fontfamily[j];
      //document.styleSheets[indice_hoja_estilos].rules[j].style.color      = fontcolor[j];
	  //alert(document.styleSheets[indice_hoja_estilos].rules[j].selectorText +"\n"+tam_final+"\n"+document.styleSheets[indice_hoja_estilos].rules[j].style.fontSize);
    
	    //alert(fontsize[j] +"\n"+document.styleSheets[indice_hoja_estilos].rules[j].style.fontSize);

	};
  }
  else{ 
    alert("Este Navegador no soporta aumento/disminucion del texto.")
  };
};

