var PORTADAS = {};


PORTADAS.wrapImage = function() {
	$('.texto img').wrapAll('<div class="media"></div>');

	if(jQuery.trim($('.caja-lateral').html()) == '') {
		$('.caja-lateral').remove();
	}
};

PORTADAS.enlacesIdiomas = function() {
	var url = document.location.href;
	var idioma = url.indexOf("-eus.html") >= 0 ? 'euskera' : '';
	$("#idiomas").find("a").each(function(indice) {
		if(indice == 0) {
			if(url.indexOf("construccion-eus.html") >= 0) {
				$(this).attr("href", "/index.html");
			} else {
				$(this).attr("href", idioma == '' ? url : url.replace("-eus.html", ".html"));
			}
		} else {
			$(this).attr("href", "/construccion-eus.html");
		}
	});
};

PORTADAS.moduloFB = function() {
	/*
	if(document.getElementById("ifrfacebook") != null) {
		iframeObj = $("#ifrfacebook");
		$(iframeObj).load(
			function() {
				document.domain = 'www.facebook.com';
				alert($(this).get(0).contentWindow.document.body.innerHTML);
				document.domain = 'www.fekoor.com';
			}
		);
	}
	*/
};

PORTADAS.FekoorTB = function() {
	if(document.location.href.indexOf('/fekoor-tb/videos') > -1) {
		$('.pestannas .activo').removeClass('activo');
		$('.galerias li').each(function(index) {			
			if(index%3 == 0) {
				$(this).css('clear', 'left');
			}
		});
	}
};

$(document).ready(function() {
	PORTADAS.wrapImage();
	PORTADAS.enlacesIdiomas();
	PORTADAS.moduloFB();
	PORTADAS.FekoorTB();
});

