// Cambia la fuente para resoluciones mayores

var estilo=document.styleSheets[0];
var reglas;
if (estilo.cssRules)
{
	reglas = estilo.cssRules;
}
else
{
	reglas = estilo.rules;
}
var general = reglas[0].style;
var camino = reglas[1].style;
var tamFuente = reglas[4].style;
var h4 = reglas[18].style;
var h3 = reglas[19].style;
var tamTitularH2 = reglas[23].style;
var tamTitularH4 = reglas[24].style;

var domain="ihcantabria.com";

var actual; 
var c = readCookie("fontSize");
if (c != null)
{
	actual=parseInt(c);
	ponTexto(c);
}
else
{
	actual=12;
}

function $(elem)
{
	return document.getElementById(elem);	
}

function getVar(nombre)
{
	var vars = [], hash;
	var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	for(var i = 0; i < hashes.length; i++)
	{
		hash = hashes[i].split('=');
		vars.push(hash[0]);
		vars[hash[0]] = hash[1];
	}
	return vars[nombre];
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function ponTexto(tam)
{
	var t = parseInt(tam);
	eraseCookie("fontSize");
	general.fontSize=t+"px";
	general.lineHeight=(t+5)+"px";
	camino.fontSize=((t-t%2)-1)+"px";
	camino.height=((t-t%2)-3)+"px";
	camino.marginTop=(-(t-t%2)/2-71)+"px";
	tamFuente.fontSize=t+"px";
	tamTitularH2.fontSize=(t+2)+"px";
	tamTitularH4.fontSize=(t+2)+"px";
	h4.fontSize=t+"px";
	h3.fontSize=(t+2)+"px";
	createCookie("fontSize",t,10);
}

function creceTexto()
{
	if (actual<16)
	{
		actual=actual+1;
		ponTexto(actual)
	}
}

function disminuyeTexto()
{
	if (actual>10)
	{
		actual=actual-1;
		ponTexto(actual)
	}
}

function limitaImagenes(nomLista,maxSize)
{
		imgEv = document.getElementById(nomLista).getElementsByTagName("img");
		for (i=0;i<imgEv.length;i++)
		{
			imgEv.item(i).style.display="inline";
			var h = imgEv.item(i).height;
			var w = imgEv.item(i).width;
			imgEv.item(i).style.display="none";
			if (h > w)
			{
				if (h > maxSize)
				{
					imgEv.item(i).height = maxSize;
				}
			}
			else
			{
				if (w > maxSize)
				{
					imgEv.item(i).width = maxSize;
				}
			}
			imgEv.item(i).style.display="inline";
		}
}

function enviaBusqueda()
{
	document.location.href = "/"+document.form_buscar.lang.value+"/buscador.asp?busqueda="+encodeURIComponent(escape(document.form_buscar.busqueda.value));
}