var tamanodefault = 'tamano2';
var colordefault = 'turquesa';
var isLoaded = 0;
var estilo = jQuery("link[href=/_ui/desktop/css/nota/tamano2.css]").attr("id", "tamano");
var position;
var arrValues;
var total;

jQuery(document).ready(function(){

	if ( isLoaded != 1) {
		jQuery.getScript( '/_ui/desktop/js/jquery/jquery.cookie.js', function() {
			isLoaded = 1;
			var tamano = jQuery.cookie('lectura');
			arrValues = [ "tamano1", "tamano2", "tamano3", "tamano4" ];
			position = 1;
			// Si no tiene un tamano en la cookie lo cargo
			total = arrValues.length - 1;
			if(!is_null(tamano)){
				//alert(tamano+" no es null!")
				jQuery.each(arrValues,function( intIndex, objValue ){
					if(objValue==tamano){
						position = intIndex;
						if(intIndex==total){
							jQuery(".ampliar").css("background", "url(/_ui/desktop/imgs/layout/iconos/herramientas/aMasoff.gif) no-repeat");
						}
						if(intIndex==0){
							jQuery(".reducir").css("background", "url(/_ui/desktop/imgs/layout/iconos/herramientas/a-off.gif) no-repeat");
						}
					}
				});
				setSize(arrValues[position]);
			}
			// Si no tiene la cookie no hago nada
			//Delete cookie
			//jQuery.cookie('lectura', null); // delete cookie
		});
	}
});



function agrandarLetra(){
	if(position!=1){
		jQuery(".reducir").css("background", "url(/_ui/desktop/imgs/layout/iconos/herramientas/a-.gif) no-repeat");
	}
	if(position==total){return false;}
	else {
		if(position==total-1){jQuery(".ampliar").css("background", "url(/_ui/desktop/imgs/layout/iconos/herramientas/a+off.gif) no-repeat");}
		position=position+1;
	}
	setSize(arrValues[position]);
}

function reducirLetra(){
	if(position!=total-1){jQuery(".ampliar").css("background", "url(/_ui/desktop/imgs/layout/iconos/herramientas/a+.gif) no-repeat");}
	if(position==0){ return false}
	else {
		if(position==1){jQuery(".reducir").css("background", "url(/_ui/desktop/imgs/layout/iconos/herramientas/a-off.gif) no-repeat");}
		position=position-1;
	}
	setSize(arrValues[position]);
}


function setSize (size){
	jQuery("#tamano").attr({href: "/_ui/desktop/css/nota/"+size+".css"});
	jQuery.cookie('lectura', size, { expires: 7 });
}

function is_null( mixed_var ){
	return ( mixed_var === null );
}


