/*
	UPM - UNESCO
	
	SCRIPTS
	
	03 - 2007
*/

if(!window.EXTRAS) EXTRAS = {};

UNESCO = {
	
	addStyles : function() {
        if(document.getElementById('contenedor_cambio_estilos')) document.getElementById('contenedor_cambio_estilos').innerHTML = '<a id="mp_texto_mayor" href="javascript:void(null);" onclick="UNESCO.aumentarTexto();"><span class="ico"></span></a> <a id="mp_texto_menor" href="javascript:void(null);" onclick="UNESCO.reducirTexto();"><span class="ico"></span></a> <a id="mp_restaurar_texto" href="javascript:void(null);" onclick="UNESCO.restaurarTexto();">Restaurar texto</a>';
    },

	addPrinter : function() {
        if(document.getElementById('contenedor_imprimir')) document.getElementById('contenedor_imprimir').innerHTML = '<a id="mp_imprimir" href="#" onclick="window.print(); return false;"><span class="ico"></span>Imprimir</a>';
    },
	
	addFavorites : function() {
		if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4) && (parseInt(navigator.appVersion)<=6)) { 
			if(document.getElementById('contenedor_favoritos')) document.getElementById('contenedor_favoritos').innerHTML = '<a id="mp_favoritos" href="#" onclick="UNESCO.agregarFavoritos();"><span class="ico"></span>Agregar a favoritos</a>';
		} else {
			if(document.getElementById('contenedor_favoritos')) document.getElementById('contenedor_favoritos').innerHTML = '<strong id="mp_favoritos" onclick="UNESCO.agregarFavoritos();"><span class="ico"></span>CTRL+D Favoritos</strong>';
		}
    },
	
	agregarFavoritos : function() {
		window.external.AddFavorite(url,titulo);
		return false;
    },
	
	aumentarTexto : function() {
		incremento+=0.25;
		tamano = original + incremento;
		if ( tamano <= 3 ) {
			document.getElementById("contenido").style.fontSize = tamano + "em";
		}
	},
	
	reducirTexto : function() {
		incremento-=0.25;
		tamano = original + incremento;
		tamano = original + incremento;
		if ( tamano >= 1 ) {
			document.getElementById("contenido").style.fontSize = tamano + "em";
		}
	},
	
	restaurarTexto : function() {
		document.getElementById("contenido").style.fontSize = original + "em";
		tamano = 0;
		incremento = 0;
	},
	
	establecerTexto : function() {
		if (tamano!=0) {
			document.getElementById("contenido").style.fontSize = tamano + "em";
		}
	},
	
	setUserOptions : function() {
		if(!prefsLoaded){
			cookie = UNESCO.readCookie("fontSize");
			tamano = cookie ? cookie : 1.4;
			UNESCO.establecerTexto(tamano);
			prefsLoaded = true;
		}
	},
	
	saveSettings : function() {
		UNESCO.createCookie("fontSize", tamano, 365);
	},
	
	createCookie : function(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	},

	readCookie : function(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			return null;
	}
	
}