/* ********************************************************************************************** */
/* ***** Funciones para cambiar de tamano la letra del(los) estilo(s) referenciado(s),      ***** */
/* ***** imprimir pagina y enviar pagina.                                                   ***** */
/* ***** Archivo de estilos usado:                                                          ***** */
/* *****     /<carpeta prontus>/css/site/port/estilos.css                                   ***** */
/* ***** V1.0 09/04/2003 - MCO - Primera version.                                           ***** */
/* ***** V2.0 09/05/2003 - MCO - Se agrega el uso del estilo gral * y si en uno de los      ***** */
/* *****                         estilos usados no viene el valor, se usa uno por defecto.  ***** */
/* *****                         Se agrega restriccion para no tomar los estilos con hover. ***** */
/* ********************************************************************************************** */

// ****************************** CAMBIA TAMANO FONTS ******************************
// *************************** SOLO FUNCIONA EN EXPLORER *** corregido para MOZZILA ***************************

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,120,140,160,180,200);
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 browserName=navigator.appName;
if (browserName!="Microsoft Internet Explorer")
{

if (!window.document.all || window.document.all) { // ie.
  // Inicializa arreglos de estilos.
  var fontweight = new Array();
  var fontfamily = new Array();
  var fontsize   = new Array();
  var fontcolor  = new Array();
  for(var i in window.document.styleSheets[0].cssRules){
	//alert(i+" -- "+window.document.styleSheets[0].cssRules[i]);
};
	//alert(window.document.styleSheets[0].csscssRules);

  // 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[0].cssRules.length; i++) { // 1.2
    fontweight[i] = document.styleSheets[0].cssRules[i].style.fontWeight;
    fontfamily[i] = document.styleSheets[0].cssRules[i].style.fontFamily;
    fontsize[i] = document.styleSheets[0].cssRules[i].style.fontSize;
    fontcolor[i] = document.styleSheets[0].cssRules[i].style.color;
  };

  // Inicializa elementos a modificar.
  var var_elements = new Array();
  
  // Busca los elementos a modificar (css). Estos son fijos y hay que agregarlos directamente en este archivo.
  for (var i=0; i < window.document.styleSheets[0].cssRules.length; i++) {
    var aux = document.styleSheets[0].cssRules[i].selectorText;
    found = 0;
    // alert(aux + ' ' + aux.indexOf(':hover'));
    if (aux == '*') {
      fontWeight_default = document.styleSheets[0].cssRules[i].style.fontSize;
      fontFamily_default = document.styleSheets[0].cssRules[i].style.fontWeight;
      fontSize_default   = document.styleSheets[0].cssRules[i].style.fontFamily;
      color_default      = document.styleSheets[0].cssRules[i].style.color;
    };
    if ( (aux.indexOf('txt_size')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
     if ( (aux.indexOf('subtit_size')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
     if ( (aux.indexOf('tit_size')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_publicaciones_detalle_size')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_publicaciones_detalle_2_size')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_publicaciones_size')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('preview_publicaciones_chico')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('preview_publicaciones')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_datos_estadisticas')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_licenciamiento')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_mundo_escolar')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_acerca_de')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_educ_superior')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_graduados')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_estadisticas')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_estudios')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
     if ( (aux.indexOf('subtitulo')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if (found == 1) { var_elements[var_elements.length] = i; };
  };
};

function fontSize(signo) {
  // Hasta el momento el cambio de fonts sirve solo para ie.
if (!window.document.all || window.document.all)  { 

    if (signo == '+') {
      // Si el numero de size_actual_i es mayor a la cantidad de elementos del arreglo tamanos, 
      // NO realiza el proceso.
      if (size_actual_i >= (tamanos.length - 1)) { return; };
      size_actual_i++;
    }else{
      // Si el numero de size_actual_i es menor o igual a cero, NO realiza el proceso.
      if (size_actual_i <= 0) { return; };
      size_actual_i--;
    };
    
    size_actual = tamanos[size_actual_i]; // Asigna tamano actual en porcentaje con respecto al tamano inicial (100).
      
    // 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 }; };
      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;
      };
      
     // alert( window.document.styleSheets[0].cssRules[j].style.fontSize);
      if(document.styleSheets[0].cssRules[j].style.fontSize!=undefined){
      document.styleSheets[0].cssRules[j].style.fontSize = tam_final+'px';
      document.styleSheets[0].cssRules[j].style.fontWeight = fontweight[j];
      document.styleSheets[0].cssRules[j].style.fontFamily = fontfamily[j];
      document.styleSheets[0].cssRules[j].style.color      = fontcolor[j];
      }
    };
  };
};
}else{
if (document.all) { // ie.
  
  // Inicializa arreglos de estilos.
  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[0].rules.length; i++) { // 1.2
    fontweight[i] = document.styleSheets[0].rules[i].style.fontWeight;
    fontfamily[i] = document.styleSheets[0].rules[i].style.fontFamily;
    fontsize[i] = document.styleSheets[0].rules[i].style.fontSize;
    fontcolor[i] = document.styleSheets[0].rules[i].style.color;
  };

  // Inicializa elementos a modificar.
  var var_elements = new Array();
  
  // Busca los elementos a modificar (css). Estos son fijos y hay que agregarlos directamente en este archivo.
  for (var i=0; i < document.styleSheets[0].rules.length; i++) {
    var aux = document.styleSheets[0].rules[i].selectorText;
    found = 0;
    // alert(aux + ' ' + aux.indexOf(':hover'));
    if (aux == '*') {
      fontWeight_default = document.styleSheets[0].rules[i].style.fontSize;
      fontFamily_default = document.styleSheets[0].rules[i].style.fontWeight;
      fontSize_default   = document.styleSheets[0].rules[i].style.fontFamily;
      color_default      = document.styleSheets[0].rules[i].style.color;
    };
    if ( (aux.indexOf('txt_size')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
     if ( (aux.indexOf('subtit_size')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
     if ( (aux.indexOf('tit_size')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_publicaciones_detalle_size')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_publicaciones_detalle_2_size')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_publicaciones_size')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('preview_publicaciones_chico')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('preview_publicaciones')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_datos_estadisticas')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_licenciamiento')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_mundo_escolar')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_acerca_de')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_educ_superior')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_graduados')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_estadisticas')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	 if ( (aux.indexOf('tit_estudios')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
     if ( (aux.indexOf('subtitulo')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if (found == 1) { var_elements[var_elements.length] = i; };
  };
};

function fontSize(signo) {
  // Hasta el momento el cambio de fonts sirve solo para ie.

  if (document.all) {
    if (signo == '+') {
      // Si el numero de size_actual_i es mayor a la cantidad de elementos del arreglo tamanos, 
      // NO realiza el proceso.
      if (size_actual_i >= (tamanos.length - 1)) { return; };
      size_actual_i++;
    }else{
      // Si el numero de size_actual_i es menor o igual a cero, NO realiza el proceso.
      if (size_actual_i <= 0) { return; };
      size_actual_i--;
    };
    
    size_actual = tamanos[size_actual_i]; // Asigna tamano actual en porcentaje con respecto al tamano inicial (100).
      
    // 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 }; };
      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;
      };
      if(document.styleSheets[0].rules[j].style.fontSize!=undefined){
      document.styleSheets[0].rules[j].style.fontSize = tam_final+'px';
      document.styleSheets[0].rules[j].style.fontWeight = fontweight[j];
      document.styleSheets[0].rules[j].style.fontFamily = fontfamily[j];
      document.styleSheets[0].rules[j].style.color      = fontcolor[j];
      }
    };
  };
};

}