$(document).ready(function(){

	var estrella_on = base_url + "img/web/botones/estrella2.png";
	var estrella_off = base_url + "img/web/botones/estrella_en_off2.png";
	
	$('#estrella1').mouseover(function(){
		$('#estrella1').attr('src', estrella_on);
		$('#estrella2').attr('src', estrella_off);
		$('#estrella3').attr('src', estrella_off);
		$('#estrella4').attr('src', estrella_off);
		$('#estrella5').attr('src', estrella_off);
	});
	
	$('#estrella2').mouseover(function(){
		$('#estrella1').attr('src', estrella_on);
		$('#estrella2').attr('src', estrella_on);
		$('#estrella3').attr('src', estrella_off);
		$('#estrella4').attr('src', estrella_off);
		$('#estrella5').attr('src', estrella_off);
	});
	
	$('#estrella3').mouseover(function(){
		$('#estrella1').attr('src', estrella_on);
		$('#estrella2').attr('src', estrella_on);
		$('#estrella3').attr('src', estrella_on);
		$('#estrella4').attr('src', estrella_off);
		$('#estrella5').attr('src', estrella_off);
	});
	
	$('#estrella4').mouseover(function(){
		$('#estrella1').attr('src', estrella_on);
		$('#estrella2').attr('src', estrella_on);
		$('#estrella3').attr('src', estrella_on);
		$('#estrella4').attr('src', estrella_on);
		$('#estrella5').attr('src', estrella_off);
	});
	
	$('#estrella5').mouseover(function(){
		
		$('#estrella1').attr('src', estrella_on);
		$('#estrella2').attr('src', estrella_on);
		$('#estrella3').attr('src', estrella_on);
		$('#estrella4').attr('src', estrella_on);
		$('#estrella5').attr('src', estrella_on);
	});
	
	$('#t1>ul>li').click(function(){
		current_tab_id = $(this).attr('value');
		
		$('#t1>ul>li').each(
			function loop()
			{
				current_tab = $(this).attr('value');
				$('#t1_' + current_tab).hide();
				$(this).removeClass('sel');
			}
		);
		
		$('#t1_' + current_tab_id).fadeIn();
		$(this).addClass('sel');
	});
	
	$('#t2>ul>li').click(function(){
		current_tab_id = $(this).attr('value');
		
		$('#t2>ul>li').each(
			function loop()
			{
				current_tab = $(this).attr('value');
				$('#t2_' + current_tab).hide();
				$(this).removeClass('sel');
			}
		);
		
		$('#t2_' + current_tab_id).fadeIn();
		$(this).addClass('sel');
	});
	
	$('#t3>ul>li').click(function(){
		current_tab_id = $(this).attr('value');
		
		$('#t3>ul>li').each(
			function loop()
			{
				current_tab = $(this).attr('value');
				$('#t3_' + current_tab).hide();
				$(this).removeClass('sel');
			}
		);
		
		$('#t3_' + current_tab_id).fadeIn();
		$(this).addClass('sel');
	});	
	

	$('#t4>ul>li').click(function(){
		current_tab_id = $(this).attr('value');
		
		$('#t4>ul>li').each(
			function loop()
			{
				current_tab = $(this).attr('value');
				$('#t4_' + current_tab).hide();
				$(this).removeClass('sel');
			}
		);
		
		$('#t4_' + current_tab_id).fadeIn();
		$(this).addClass('sel');
	});		
	
	$('#easy_reader_si').click(function(){
		activar_easy_reader();
	});
	$('#easy_reader_no').click(function(){
		desactivar_easy_reader();
	});
	

	
});

function mostrar()
{
	$('.campo_oculto').fadeIn();
}

function activar_easy_reader () 
{
	$('.texto_descripcion, .texto_descripcion_p, .easy_reader').css('background-color', '#fff');
	$('.texto_descripcion, .texto_descripcion_p, .easy_reader').css('color', '#000');
	$('.texto_descripcion, .texto_descripcion_p, .easy_reader').css('font-weight', 'bold');
	$('.texto_descripcion, .texto_descripcion_p, .easy_reader').css('font-size', '15px');
	$('.texto_descripcion, .texto_descripcion_p').css('color', '#000');
	$('.easy_reader a, .texto_descripcion a, .texto_descripcion_p a').css('color', '#1d0ecf');
	$('.texto_descripcion, .texto_descripcion_p, .easy_reader a').css('line-height', '25px');
	
	$.ajax({
		type: "POST",
		url: base_url + "easy_reader/activar",
		data: "",
		success: function(msg){
		}
	});
	
	if (tie != 1 && tie > 0)
		tie = tie - 0.5;
}

function desactivar_easy_reader () 
{
	$('.texto_descripcion, .texto_descripcion_p, .easy_reader').css('background-color', '');
	$('.texto_descripcion, .texto_descripcion_p, .easy_reader').css('color', '');
	$('.texto_descripcion, .texto_descripcion_p, .easy_reader').css('font-weight', '');
	$('.texto_descripcion, .texto_descripcion_p, .easy_reader').css('font-size', '');
	$('.texto_descripcion, .texto_descripcion_p').css('color', '');
	$('.easy_reader a, .texto_descripcion a, .texto_descripcion_p a').css('color', '#fff');
	$('.texto_descripcion, .texto_descripcion_p, .easy_reader a').css('line-height', '');
	
	$.ajax({
		type: "POST",
		url: base_url + "easy_reader/desactivar",
		data: "",
		success: function(msg){
		}
	});
	
	if (tie < 1)
		tie = tie + 0.5;
}

function goto_and_open(tab_id)
{
	current_tab_id = tab_id;

	$('#t2>ul>li').each(
		function loop()
		{
			current_tab = $(this).attr('value');
			$('#t2_' + current_tab).hide();
			
			if (current_tab_id == current_tab)
				$(this).addClass('sel');
			else
				$(this).removeClass('sel');
		}
	);
	
	$('#t2_' + current_tab_id).fadeIn();
}
