/* ********************************************************************************************** */
/* ***** 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,110,120,130,140,160,180,250);
var size_actual_i = 3; // Corresponde al cuarto elemento en el arreglo tamanos.

// Variable por defecto.
var fontSize_default = '';
var fontWeight_default = '';
var fontStyle_default = '';
var fontFamily_default = '';
var color_default = '';


if (document.all) { // ie.

  // Inicializa arreglos de estilos.
  var fontsize   = new Array();
  var fontweight = new Array();
  var fontstyle  = new Array();
  var fontfamily = 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
    fontsize[i] = document.styleSheets[0].rules[i].style.fontSize;
    fontweight[i] = document.styleSheets[0].rules[i].style.fontWeight;
    fontstyle[i] = document.styleSheets[0].rules[i].style.fontStyle;
    fontfamily[i] = document.styleSheets[0].rules[i].style.fontFamily;
    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;

    if ( (aux.substring(0,1) == '*') || (aux.substring(0,5) == '.base') ) {

      fontSize_default   = document.styleSheets[0].rules[i].style.fontSize;
      fontWeight_default = document.styleSheets[0].rules[i].style.fontWeight;
      fontStyle_default  = document.styleSheets[0].rules[i].style.fontStyle;
      fontFamily_default = document.styleSheets[0].rules[i].style.fontFamily;
      color_default      = document.styleSheets[0].rules[i].style.color;
    };
    
    if ( (aux.indexOf('topArticulo td H1') >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('topArticulo')       >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('contArticulo')      >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('contentArt')        >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('topArt')            >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('footlink')          >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('textAdjunto')       >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
    if ( (aux.indexOf('CUERPO')            >= 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 (fontstyle[j] == '') { if (fontStyle_default != '') { fontstyle[j] = fontStyle_default; }else{ fontstyle[j] = 'Normal' }; };
      if (fontfamily[j] == '') { if (fontFamily_default != '') { fontfamily[j] = fontFamily_default; }else{ fontfamily[j] = 'Verdana, Arial, Helvetica, sans-serif' }; };
      if (fontcolor[j]  == '') { if (color_default != '') { fontcolor[j]  = color_default; }else{ fontcolor[j] = '#000000' }; };

      if (size_actual != 100) {
        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;
        };
      }
      else { // Tamano original.
        tam_final = parseInt(fontsize[j]);
      };

      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.fontStyle  = fontstyle[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 = '/prontus_cross/stat/enviar/formulario.html?_URL=' + escape(url);
  var envia = window.open(loc,'enviar',
              'toolbar=0,status=0,menubar=0,scrollbars=0,resizable=0,location=0,directories=0,width=425,height=520');
  envia.focus();
};

// ******************************** IMPRIMIR PAGINA *******************************
// Imprime noticia actual.
function imprimir() {
  var url = document.URL;
  var loc = '/cgi-bin/imprimir.cgi?_URL=' + escape(url);
  var imprime = window.open(loc, 'imprimir');
  imprime.focus();
};                                                                                         

// ******************************** FECHA *******************************
function lafecha() {
var aux = 'enero,febrero,marzo,abril,mayo,junio,julio,agosto,septiembre,octubre,noviembre,diciembre'; 
var meses = aux.split(',');
var aux = 'Domingo,Lunes,Martes,Mi&eacute;rcoles,Jueves,Viernes,S&aacute;bado';
var semana = aux.split(',');
var fecha = new Date();
var diasem = fecha.getDay();
var dia = fecha.getDate();
var mes = fecha.getMonth();
var ano = fecha.getYear();
if (ano < 2000) { ano += 1900; };

document.write(semana[diasem]  + ' ' +  dia + ' de ' + meses[mes] + ' ' + ano);
};
