var animandoAcceso = false;
$(function() {
	$('.doNot').hide();
	$('div.acceso>h2').css('fontSize', '1.4em').each(function() { FLIR.replace(this); });
	$('div#accesorios h2:not(.notFlir)').css('fontSize', '1.8em').each(function() { FLIR.replace(this); });
	$('div#principio h2').css('fontSize', '2.4em').each(function() { FLIR.replace(this); })
	$('div#principio>h3').css('fontSize', '1.2em').each(function() { FLIR.replace(this); })
	$('div#espacios h2').css('fontSize', '1.6em').each(function() { FLIR.replace(this); })
	var backActivo = $('div.acceso.activo').css('background');
	$('div.acceso:not(.sinEnlace)').css('cursor', 'pointer').bind('click', function() { window.location.href = $('h2>a', this)[0].href; });
	$('div.acceso.activo:not(.sombreado):not(#espacios):not(.sinEnlace)').hover(function() { $(this).css('background', '#425E64'); }, function() { $(this).css('background', '#383C39'); });
	$('div.acceso:not(.activo):not(.sombreado):not(#espacios):not(.sinEnlace)').hover(function() { $(this).css('background', '#344748'); }, function() { $(this).css('background', 'transparent'); });
	
	$('div.principio').css('cursor','pointer').bind('click', function() { window.location.href = $('a', this)[0].href; } );
	$('div.accesorio:not(.actualidad)>div').css('cursor','pointer').bind('click', function() { window.location.href = $(this).parent().find('a')[0].href; });
	
	//$('div.acceso:not(.activo)>div').hide();
	$('div#espacios>a.espacio').hover(function() { $('>img', this)[0].src=$('>img', this)[0].src.split('.jpg')[0]+'-hover.jpg'; }, function() { $('>img', this)[0].src=$('>img', this)[0].src.split('-hover.jpg')[0]+'.jpg'; })
	$('div.saborea').css('cursor', 'pointer').bind('click', function() { window.location.href='/restauracion/'; });
	$('div#principal>div>h2').css('fontSize', '2.5em').each(function() { FLIR.replace(this); });
	$('div#principal>div.columnas h2').css('fontSize', '2em').each(function() { FLIR.replace(this); });
	//$('div#principal>h2').css('fontSize', '2.5em').each(function() { FLIR.replace(this); });
	//$('div#principal h2 a').css('fontSize', '2em').each(function() { FLIR.replace(this); });
	$('div#principal>h3').each(function() { FLIR.replace(this); });
		
	$('div#principal h2 a').each(function() {
		var $estethis = $(this);
		var salida = '';
		var texto = $estethis.text();
		var longTexto = texto.length;
		if (longTexto > 27) {
			var cont = 0;
			var n = 0;
			for (n = 0; n < longTexto; n++) {
				if (cont > 19 && texto.substr(n, 1) == ' ') {
					salida += '<br/>';
					cont = 0;
				} else {
					salida += texto.substr(n,1);
					cont++;
				}
			}
		$estethis.html(salida);
		}
	});
	$('div#principal h2 a').css('fontSize', '2em', 'lineHeight', '0.5em').each(function() { FLIR.replace(this); });
	$('div#principal h2').css('lineHeight', '0.5em');
	$('div#principal h2 a').each(function() { if($('img', this).length > 1) $('img', this).not(':last').css({marginBottom:'-8px'}); });
	
	// reducir imágenes en noticias
	$('div#principal li.textonew img').each(function() {
	
		var $imgdenew = $(this);
		var ancho = $imgdenew.attr("width");
		var alto = $imgdenew.attr("height");
		if(ancho>240){
			$imgdenew.attr("width","240");
			$imgdenew.attr("height",(240*alto)/ancho);
		}
	});
	
	// cambiar el enlace y texto de "more link text"
	$('div#principal li.textonew a.more-link').each(function() {
		var $readmore = $(this);
		var linkancla = $readmore.attr("href");
		var linkanclarr = linkancla.split('#');
		var newlinkancla = linkanclarr[0];
		$readmore.attr("href",newlinkancla);
		if (linkancla.indexOf("/noticias/")>0){
		$readmore.html('Ampliar&nbsp;noticia&nbsp;>');
		} else {
		$readmore.html('Read&nbsp;more&nbsp;>');
		};
	});
	
});