/* ********************************************************************************************** */
/* ***** 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 ***************************

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 = '';

  
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('TEXTblackSN')  >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTarticulo') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTepigrafe') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TITULAR')      >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTrojobold') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTrecuadro') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('FOTO')         >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTbajada')   >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('autor')        >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('fuente')       >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTgrisbold') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTepigrafe') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };  
    if ( (aux.indexOf('TITULAR') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };       
    if ( (aux.indexOf('TEXTbajada') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };    
    if ( (aux.indexOf('TEXTarticulo') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };  
    if ( (aux.indexOf('TEXTfecha') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };     
    if ( (aux.indexOf('TEXTlugar') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };     
    if ( (aux.indexOf('TEXTfuente') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };    
    if ( (aux.indexOf('TEXTautor') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };     
    if ( (aux.indexOf('FECHAPSHRT') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };    
    if ( (aux.indexOf('SECCION') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };       
    if ( (aux.indexOf('TEXTtitulo01') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };  
    if ( (aux.indexOf('TEXTtitulo02') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };  
    if ( (aux.indexOf('TEXTtitulo03') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };  
    if ( (aux.indexOf('TEXTtitulo04') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };  
    if ( (aux.indexOf('TEXTtitulo05') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };  
    if ( (aux.indexOf('TEXTtitulo06') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };  
    if ( (aux.indexOf('TEXTtitulo07') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };  
    if ( (aux.indexOf('TEXTtitulo08') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };  
    if ( (aux.indexOf('TEXTtitulo09') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };  
    if ( (aux.indexOf('TEXTtitulo10') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };  
    if ( (aux.indexOf('TEXTarticulo01') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTarticulo02') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTarticulo03') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTarticulo04') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTarticulo05') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTarticulo06') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTarticulo07') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTarticulo08') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTarticulo09') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTarticulo10') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('TEXTtiturl') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };    
    if ( (aux.indexOf('TEXTurl') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if (found == 1) { var_elements[var_elements.length] = i; };
  };
};

function cambia_size(signo) {
  // Hasta el momento el cambio de fonts sirve solo para ie.

  if (document.all) {
    if (signo == 'mas') {
      // 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;
      };
      
      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];
    };
  };
};


// ******************************** ENVIAR A *******************************
// Envío de noticia por e-mail.
function enviar() {
  var url = document.URL;
  var loc = '/cgi-bin/enviar.cgi?ACCI=Showform&TDIR=plantillas/extra/enviar/pags&URL=' + escape(url);
  var envia = window.open(loc,'enviar',
              'toolbar=0,status=0,menubar=0,scrollbars=0,resizable=0,location=0,directories=0,width=470,height=320');
  envia.focus();
}; // enviar_a.


// ******************************** IMPRIMIR PAGINA *******************************
// Imprime.
function imprimir() {
  var url = document.URL;
  var loc = '/cgi-bin/imprimir.cgi?TDIR=plantillas/extra/imprimir/pags&URL=' + escape(url);
  var imprime = window.open(loc, 'imprimir');
  imprime.focus();
}; // imprime.
