/* ********************************************************************************************** */
/* ***** 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('CUERPO')      >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	if ( (aux.indexOf('titular')      >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	if ( (aux.indexOf('bajada')      >= 0) && (aux.indexOf(':hover') < 0) ) { found = 1; };
	if ( (aux.indexOf('fecha')      >= 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] = 'Tahona, Verdana, 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 = '/cgi-bin/enviar_px.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=450,height=380');
  envia.focus();
}; // enviar.

// ******************************** IMPRIMIR PAGINA *******************************
// Imprime noticia actual.
function imprimir() {
  var url = document.URL;
  var loc = '/cgi-bin/imprimir_px.cgi?TDIR=plantillas/extra/imprimir/pags&URL=' + escape(url);
  var imprime = window.open(loc, 'imprimir');
  imprime.focus();
}; // imprimir.

// Script para efecto onMouseOver.
var BROWSER_VALIDO = false;
// alert(navigator.appName + ' ' + parseInt(navigator.appVersion) + ' ' + navigator.userAgent + ' ' + navigator.userAgent.indexOf('MSIE 5'));
if ( (navigator.appName == "Netscape") || (navigator.appName == "Microsoft Internet Explorer") ) {
	if ( (parseInt(navigator.appVersion) >= 5) || (navigator.userAgent.indexOf('MSIE 5') > 0) || (navigator.userAgent.indexOf('MSIE 6') > 0) ) {
	  BROWSER_VALIDO = true;
	};
};


  var verok = 1; //version adecuada del navigator.
  browserName = navigator.appName;
  browserVer = parseInt(navigator.appVersion);
  if ((browserName == "Netscape" && browserVer >= 3)
     || (browserName == "Microsoft Internet Explorer" && browserVer >= 4) ) {
    verok = 1;
  } else {
    verok = 0;
  };

  var path    = '../imag/';
  var imagidx = 'none'; // Imagen inicialmente seleccionada.
  var img_portada = 'none'; // Imagen de la portada.

  function findIMG(nom) {
    var i;
    if (document[nom]) {
      return document[nom];
    };
    if (document.layers) {
      for(i=0; i < document.layers.length; i++) {
        if (document.layers[i].document[nom]) {
          return document.layers[i].document[nom];
        };
      };
    }else{
      if (document.all[nom]) { return document.all[nom]; };
      if (document.getElementById(nom)) { return document.getElementById(nom); };
    };
  }; // findIMG

  function ima_ck(nom, dir) {
    var aux = imagidx;
    imagidx = nom;
    ima_of(aux, dir);
    ima_on(imagidx, dir);
    return true;
  };

  function ima_on(nom, dir) {
    var x;
    if ((verok == 1) && (nom != 'none') && (nom != imagidx)) {
      x = findIMG(nom);
      if (x) {
        x.src = path + dir + '/'+ nom + '_on.gif';
        return true;
      };
    };
  };

  function ima_ac(nom, dir) {
    var x;

    if ((verok == 1) && (nom != 'none')) {
      x = findIMG(nom);
      if (x) {
        nom = nom.substring(0, 2) + 1;
        x.src = path + dir + '/'+ nom + '_on.gif'; // '_ac.gif';

        return true;
      };
    };
  };

  function ima_of(nom, dir) {
    var x;
    if ((verok == 1) && (imagidx != nom) && (nom != 'none')) {
      x = findIMG(nom);
      if (x) {
        // Para que quede la portada actual con el boton activo. Se configura al final de la portada antes de la funcion
        // initialize().
        // Ejemplo (portada.html):
        // var img_portada = 'po1';
        // ima_ac('por', 'head');
        if (img_portada.substring(0, 2) == nom.substring(0, 2)) {
          x.src = path + dir + '/'+ img_portada + '_on.gif';
        }
        else {
          x.src = path + dir + '/'+ nom + '_of.gif';
        };
        return true;
      };
    };
  };

// funcion para ventana pop-up con scroll.

  function subWin(loc, nom, ancho, alto, posx, posy) {
    var options="toolbar=0,status=0,menubar=0,scrollbars=1,resizable=0,location=0,directories=0,width=" + ancho + ",height=" + alto + ",left=" + posx + ",top=" + posy + ",screenX=" + posx + ",screenY=" + posy;

    window.name = 'top';
    var win = window.open(loc,nom,options);
    win.focus();
    // win.moveTo(posx, posy);
  };

// -----------------------------------------------------------
// Script para ventana popup sin scroll.
function subWin2(loc, nom, ancho, alto, posx, posy) {
  var options="toolbar=0,status=0,menubar=0,scrollbars=0,resizable=0,location=0,directories=0,width=" + ancho + ",height=" + alto;

  var win = window.open(loc, nom, options);
  win.focus();
  if ( (posx > 0) && (posy > 0) ) {
    // win.moveTo(posx, posy);
  };
};

