
if(!selectedonglet || selectedonglet == undefined) var selectedonglet = 1;

// font mas y font menos
$(document).ready(function(){

$(".fontmas>a").click(
	function(){
		var css = $("#csstypo").attr('href');
		var ncss = "";
		switch(css){
			case "estilos/rhmstyle-comunes.css":
				ncss = "estilos/rhmstyle-comunes_2.css";
				break;
			case "estilos/rhmstyle-comunes_2.css":
				ncss = "estilos/rhmstyle-comunes_3.css";
				break;
			case "estilos/rhmstyle-comunes_3.css":
				ncss = "estilos/rhmstyle-comunes_4.css";
				break;
		}
		if(ncss != ""){
			$("#csstypo").attr('href', ncss);
		}
		return false;
	}
);

$(".fontmenos>a").click(
	function(){
		var css = $("#csstypo").attr('href');
		var ncss = "";
		switch(css){
			case "estilos/rhmstyle-comunes_4.css":
				ncss = "estilos/rhmstyle-comunes_3.css";
				break;
			case "estilos/rhmstyle-comunes_3.css":
				ncss = "estilos/rhmstyle-comunes_2.css";
				break;
			case "estilos/rhmstyle-comunes_2.css":
				ncss = "estilos/rhmstyle-comunes.css";
				break;
		}
		if(ncss != ""){
			$("#csstypo").attr('href', ncss);
		}
		return false;
	}
);

});

// incio pestanias

$(document).ready(
	function(){
		if($(".onglets>li").length) initOnglets(".onglet", "#item_", $(".onglets>li").length, selectedonglet); // final pestanias
		if($(".onglets-sub>li").length) initOnglets(".onglet-sub", "#item-sub_", $(".onglets-sub>li").length); // final SUBpestanias
		if($(".onglets-der-bus>li").length) initOnglets(".onglet-der-bus", "#item-der-bus_", $(".onglets-der-bus>li").length); // final buscador
		if($(".onglets-der-53>li").length) initOnglets(".onglet-der-53", "#item-der-53_", $(".onglets-der-53>li").length); // final cinco mas 3
		if($(".onglets-der-52>li").length) initOnglets(".onglet-der-52", "#item-der-52_", $(".onglets-der-52>li").length) 
		if($(".nav-items").length) initOnglets(".nav-item", ".autor-item-", $(".nav-items>li").length);
		// final cinco mas 2
		initSinopsis();
		initGeneros();
		initFaqs();
		initRSS();
		initDescripciones();
	}
);




//Cargamos Popup Solo en "magradallegir.com"
/*

$(document).ready(
		function(){
			createDiv();
		}
	);
function getInternetExplorerVersion()
//Returns the version of Internet Explorer or a -1
//(indicating the use of another browser).
{
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
 var ua = navigator.userAgent;
 var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
 if (re.exec(ua) != null)
   rv = parseFloat( RegExp.$1 );
}
return rv;
}
function checkVersion()
{
var imagetype = "png"; //Imagen por defecto
var ver = getInternetExplorerVersion();

if ( ver > -1 )
{
 if ( ver > 6.0 ) 
   //Carga PNG
	  imagetype = "png";
 else
	  //Carga GIF
	  imagetype = "gif";
}
return imagetype;
}

checkVersion();



function createDiv(){
	if (
		(location.href == 'http://www.magradallegir.com') ||
		(location.href == 'http://www.magradallegir.com/') ||
		(location.href == 'www.magradallegir.com') ||
		(location.href == 'www.magradallegir.com/') ||
		(location.href == 'http://magradallegir.com') ||
		(location.href == 'http://magradallegir.com/')
		){
		var tapadiv = document.createElement('div');
		tapadiv.setAttribute('id','tapa');
		tapadiv.style.width = "100%";
		tapadiv.style.height = "100%";
		tapadiv.style.left = "0px";
		tapadiv.style.top = "0px";
		tapadiv.style.position = "absolute";
		tapadiv.style.background = "#696969";
		tapadiv.style.filter = "alpha(opacity=57)";
		tapadiv.style.opacity = "0.57";
		tapadiv.style.zIndex = "500";
		document.body.style.height = "100%"; //ie6 height bug
		document.body.style.margin = "0"; //ie6 height bug

	
		
		var bannerdiv = document.createElement('div');
		bannerdiv.setAttribute('id','banner');
		bannerdiv.style.width = "578px";
		bannerdiv.style.height = "288px";
		bannerdiv.style.left = "154px";
		bannerdiv.style.top = "193px";
		bannerdiv.style.position = "absolute";
		bannerdiv.style.zIndex = "501";	
		
		var codigoHTML = '<img src="extension/me_gusta_leer/design/me_gusta_leer/images/magradallegir-banner/banner.' + checkVersion() +'" width="580" height="301" border="0" usemap="#link" />';
		codigoHTML = codigoHTML + '<map name="link" id="link">';
		codigoHTML = codigoHTML + '<area shape="rect" coords="514,17,564,56" href="javascript:cerrarBanner();" />';
		codigoHTML = codigoHTML + '<area shape="rect" coords="349,167,404,198" href="http://www.megustaleer.com/Concursos/Llevate-365-libros" target="_blank" /></map>';
	
		bannerdiv.innerHTML = codigoHTML;	
		
		document.body.appendChild(tapadiv);
		document.body.appendChild(bannerdiv);
	}
}

function cerrarBanner(){
	document.getElementById('banner').style.visibility = 'hidden';
	document.getElementById('tapa').style.visibility = 'hidden';
}



var startY=0;
var currY=startY;
var destY=currY;
var temp;
function floatMenu() {
	if (document.documentElement.scrollTop) {
		temp=document.documentElement.scrollTop;
	}else {
		temp=document.body.scrollTop;
	}
	destY=temp+startY;
	var newY=destY+"px";
	document.getElementById("tapa").style.top=newY;
}

if(document.getElementById("tapa") != null){
	window.onscroll=floatMenu;
	window.onresize=floatMenu;
}

*/




























function initOnglets(objO, objI, counti, selected){
	
	if(!selected) selected = 1;
		
	var items = new Array();
	for(var i=1; i<=counti; i++){
		items[i] = i;
	}
		
	// action des onglets
	$.each(items, function(i){
		$(objO+i).click(function(){
			showDiv(i);});			  
		})
	
	//
	function showDiv(id){
		for(var i=1; i<=counti; i++){
			if(i != id){
				$(objO+i+">a").removeClass('act');
				$(objI+i).hide();
			}
		}
		$(objO+id+">a").addClass('act');
		$(objI+id).show();
	}
		
	showDiv(selected);
}


function initSinopsis(){		
	// ferme tous les sinopsis
	$(".sinopsis").each(
		function(){
			$(this).children('.sinopsis_content').hide();
			$(this).children('p:first').removeClass("sinopsis-menos");
			$(this).children('p:first').addClass("sinopsis-mas");
		}
	
	);
		
	// action au click sur un sinopsis
	$(".sinopsis").click(
		function(){
			if($(this).children('.sinopsis_content').css("display") == "block"){
				$(this).children('.sinopsis_content').hide();
				$(this).children('p:first').removeClass("sinopsis-menos");
				$(this).children('p:first').addClass("sinopsis-mas");
			} else {
				$(this).children('.sinopsis_content').show();
				$(this).children('p:first').removeClass("sinopsis-mas");
				$(this).children('p:first').addClass("sinopsis-menos");
			}
		}
	);
	
}


function initGeneros(){	
// ferme tous les generos
$(".generos").each(
function(){
$(this).children('.generos_content').hide();
$(this).children('p:first').removeClass("generos-menos");
$(this).children('p:first').addClass("generos-mas");


$(this).children('p:first').click(
function(){
if($(this).parent().children('.generos_content').css("display") == "block"){
$(this).parent().children('.generos_content').hide();
$(this).removeClass("generos-menos");
$(this).addClass("generos-mas");
} else {
$(this).parent().children('.generos_content').show();
$(this).removeClass("generos-mas");
$(this).addClass("generos-menos");
}
}
);

}

);
}


function initFaqs(){	
// ferme tous les faqs
$(".respuestasfaqs").each(
function(){
$(this).children('.respuestasfaqs_content').hide();
$(this).children('p:first').removeClass("respuestasfaqs-menos");
$(this).children('p:first').addClass("respuestasfaqs-mas");

$(this).children('p:first').click(
function(){
if($(this).parent().children('.respuestasfaqs_content').css("display") == "block"){
$(this).parent().children('.respuestasfaqs_content').hide();
$(this).removeClass("respuestasfaqs-menos");
$(this).addClass("respuestasfaqs-mas");
} else {
$(this).parent().children('.respuestasfaqs_content').show();
$(this).removeClass("respuestasfaqs-mas");
$(this).addClass("respuestasfaqs-menos");
}
}
);

}

);
}


function initRSS(){	
// ferme tous les RSS
$(".querss").each(
function(){
$(this).children('.querss_content').hide();
$(this).children('p:first').removeClass("querss-menos");
$(this).children('p:first').addClass("querss-mas");

$(this).children('p:first').click(
function(){
if($(this).parent().children('.querss_content').css("display") == "block"){
$(this).parent().children('.querss_content').hide();
$(this).removeClass("querss-menos");
$(this).addClass("querss-mas");
} else {
$(this).parent().children('.querss_content').show();
$(this).removeClass("querss-mas");
$(this).addClass("querss-menos");
}
}
);

}

);
}

function initDescripciones(){		
	// ferme tous les sinopsis
	$(".descripciones").each(
		function(){
			$(this).children('.descripciones_content').hide();
			$(this).children('p:first').removeClass("descripciones-menos");
			$(this).children('p:first').addClass("descripciones-mas");
		}
	
	);
		
	// action au click sur un descripciones
	$(".descripciones").click(
		function(){
			if($(this).children('.descripciones_content').css("display") == "block"){
				$(this).children('.descripciones_content').hide();
				$(this).children('p:first').removeClass("descripciones-menos");
				$(this).children('p:first').addClass("descripciones-mas");
			} else {
				$(this).children('.descripciones_content').show();
				$(this).children('p:first').removeClass("descripciones-mas");
				$(this).children('p:first').addClass("descripciones-menos");
			}
		}
	);
	
}

