//
//  Funciones que permiten al usuario subir o bajar el tamaņo de las letras
// Proveniente de diversos sitios: rnv / apple / pc-news
//
var uagent    = navigator.userAgent.toLowerCase();
var is_safari = ( (uagent.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc.") );

var is_moz    = (navigator.product == 'Gecko');
var is_ns4    = ( (is_ns) && (parseInt(navigator.appVersion) == 4) );
var is_opera  = (uagent.indexOf('opera') != -1);
var is_kon    = (uagent.indexOf('konqueror') != -1);
var is_webtv  = (uagent.indexOf('webtv') != -1);

var is_ie     = ( (uagent.indexOf('msie') != -1) && (!is_opera) && (!is_safari) && (!is_webtv) );
var is_ie4    = ( (is_ie) && (uagent.indexOf("msie 4.") != -1) );
var is_ns     = ( (uagent.indexOf('compatible') == -1) && (uagent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_safari) );

var is_win    =  ( (uagent.indexOf("win") != -1) || (uagent.indexOf("16bit") !=- 1) );
var is_mac    = ( (uagent.indexOf("mac") != -1) || (navigator.vendor == "Apple Computer, Inc.") );
var ua_vers   = parseInt(navigator.appVersion);

SMALLEST_FONTSIZE = 10;
LARGEST_FONTSIZE = 24;

actual=consultarcookie("fontSize")

if (actual>=SMALLEST_FONTSIZE && actual<=LARGEST_FONTSIZE) { 
    actual_fontsize=actual;

    setStyleByClass('div', 'postbody', 'fontSize', actual_fontsize);
    setStyleByClass('span', 'QUOTE',   'fontSize', actual_fontsize);
}
else { 
    actual_fontsize=14
}

// consulta el valor de una cookie
function consultarcookie(nombre) 
{
    var buscamos = nombre + "=";
    
    if (document.cookie.length > 0) {
        i = document.cookie.indexOf(buscamos);
    
        if (i != -1) {
            i += buscamos.length;
            j = document.cookie.indexOf(";", i);
            if (j == -1)
                j = document.cookie.length;
            
            return unescape(document.cookie.substring(i,j));
        }
    }
}

function LoadActualFontSize() 
{
    tempArray = document.cookie.split(";");
    for (tA = 0; tA < tempArray.length; tA++)
    {
        if (tempArray[tA].indexOf('fontSize') > -1)
        {
            fontSizeValue = tempArray[tA].split("=")
            actual_fontsize = parseInt(fontSizeValue[1]);
        }
    }
}


function SaveActualFontSize() 
{
	var expire = new Date ();
	expire.setTime (expire.getTime() + (6000 * 24 * 3600000));
	expire = expire.toGMTString();
	document.cookie="fontSize="+actual_fontsize+"; path=/; expires="+expire;
}


function aumentar_fuente() {
  actual_fontsize = parseInt(actual_fontsize)+2;
  if (actual_fontsize > LARGEST_FONTSIZE) { 
  	actual_fontsize = LARGEST_FONTSIZE 
  }
  setStyleByClass('div','postbody','fontSize',actual_fontsize);
  setStyleByClass('span','QUOTE','fontSize',actual_fontsize);

  SaveActualFontSize();
}


function disminuir_fuente() {
  actual_fontsize = parseInt(actual_fontsize)-2;
  if (actual_fontsize < SMALLEST_FONTSIZE)
        { actual_fontsize = SMALLEST_FONTSIZE };
  setStyleByClass('div','postbody','fontSize',actual_fontsize);
  setStyleByClass('span','QUOTE','fontSize',actual_fontsize);
  SaveActualFontSize();
}

// ------------------------------
// script por developer.apple.com
// setStyleByClass: given an element type and a class selector,
// style property and value, apply the style.
// args:
//  t - type of tag to check for (e.g., SPAN)
//  c - class name
//  p - CSS property
//  v - value

function setStyleByClass(t,c,p,v){

	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (is_ie) ? document.all : document.getElementsByTagName('*');
	} else {
		if (is_opera) {
			elements = document.all;
		}		
		else {
			elements = document.getElementsByTagName(t);
		}
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class' || node.attributes.item(j).nodeName == 'CLASS') {
				if(node.attributes.item(j).nodeValue == c) {
					eval('node.style.' + p + " = '" +v + "'");
				}
			}
		}
	}
} 


