var max=160;
var min=80;
var increase=20;// el valor del incremento o decremento en el tamaņo   
  
//Cambia el tamaņo del texto en la web
function textSize(action,elem){
    
    var div = elem.split(",");

    for(var i=0;i < div.length;i++) {
      var obj=document.getElementById(div[i]);
      if (obj.style.fontSize==""){
        obj.style.fontSize="100%";
      }
      present=parseInt(obj.style.fontSize); //valor actual del tamaņo del texto
      //accion sobre el texto
      if( action=="restore" ){
        value="100";
      }
      if( action=="increase" && ((present+increase) <= max )){
        value=present+increase;  
      }
      if( action=="decrease" && ((present-increase) >= min )){
        value=present-increase;     
      }    
      obj.style.fontSize=value+"%"
    }

      check_size(value);
      send_Cookie("investigacion",value,0,location.hostname);

  }

//Establece un tamaņo de texto dado en los elementos pasados como argumento separados por coma
function set_Size(value,elem){

  var div = elem.split(",");
  for(var i=0;i < div.length;i++) {
    var obj=document.getElementById(div[i]);
    if (value!='') obj.style.fontSize=value+"%";
  }
  check_size(value);
}

//Crea una cookie con las preferencias de tamaņo del usuario
function send_Cookie (name_cookie,value_cookie,life_cookie_days,domain_cookie)
{
  var date = new Date();
  document.cookie = name_cookie +
  "=" + encodeURIComponent(value_cookie) + "; path=/; domain=" + domain_cookie ;
}

// Lee una cookie y devuelve el valor establecido como tamaņo de letra
function get_Cookie(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 ('');

}
     
//Borra la cookie -> no lo uso
function delete_cookie ( name_cookie, domain_cookie )
{
  //document.cookie = name_cookie + "=; max-age=0; path=/; domain=" + dominio_cookie ;
  send_Cookie (name_cookie,"",-1,domain_cookie);
}
//document.getElementById('foo').style.backgroundImage='url(your_image.jpg)';
//document.body.style.backgroundImage='url(your_image.jpg)';

//Comprueba el tamaņo de la letra y oculta los enlaces
function check_size(value){
     a = document.getElementById('increase').style;
     if (value==max){ 
          a.display = "none";
     }
     else { 
          a.display="";
     }
     a = document.getElementById('decrease').style;
     if (value==min){ 
          a.display = "none";
     }
     else {
          a.display="";
     }
}
