
$(function() 
{
	$('#Recortables').hide();
	$('#Pegatinas').hide();
	$('#Postales').hide();
	$('#Instrucciones').hide();
	$('#LnkGoodies a, #EligeGoodies a').click(function() {
		$('#LnkGoodies a').removeClass('selected');
		$(this).addClass('selected');
		if ($(this).attr('id')=='LnkRec')
		{
			$('#Recortables').show();
			$('#Pegatinas').hide();
			$('#Postales').hide();
			$('#EligeGoodies').hide();
			$('#Instrucciones').show();
		}
		else if ($(this).attr('id')=='LnkCle')
		{
			$('#Recortables').hide();
			$('#Pegatinas').show();
			$('#Postales').hide();
			$('#Instrucciones').show();
			$('#EligeGoodies').hide();
		}
		else
		{
			$('#Recortables').hide();
			$('#Pegatinas').hide();
			$('#Postales').show();
			$('#Instrucciones').show();
			$('#EligeGoodies').hide();
		}
		return false;
	});
	
	$('.DescGoodie a').click(function() {
		if (!$(this).hasClass('descarga')) 
		{
			$(this).parent().find('a').removeClass('selected');
			$(this).addClass('selected');
			return false;
		}
	});
	
	$('.DescGoodie a.descarga').click(function (){
		fichero=$(this).attr('id');
		idioma=$(this).parent().find('.selected').attr('id');
		if (idioma==undefined) idioma='';
		DescargarGoodie(fichero+' '+idioma+'.jpg');
		return false;
	});
	
	$('.LnkMiKireei').click(function (){
		var origen='#'+$(this).parent().parent().parent().attr('id');						  	
		var dest='#'+$(this).attr('id');
		var options = {to: dest, className: 'cuadrotransfer'};
		//alert (origen+' '+dest);
		$(origen).effect('transfer',options,1000,function(){
			GuardarEnMiKireei(dest);
		});							 
		return false;				 
	});
	$('#LMiKAcordeon').accordion({autoHeight: false});
	$('a.x').click(function(){
		if (confirm('ĀSeguro de que quieres borrar esta entrada de miKireei?'))
		{
			var id=$(this).attr('id').substr(4);	
			$.ajax({
				type: "POST",
				url: "php/delfavorito.php?id="+id,
				success: function(respuesta, estado){
					$('.DivX'+respuesta).remove();
				},
				error: function (request, texto, error) {
					alert(texto+'-'+error);
				}
			});	
		}
		return false;
	});
	
	swfobject.embedSWF("publicidad/Banner_OBNI.swf", "LPubliGrandeFlash", "145", "277", "8", "#336699", false);
	swfobject.embedSWF("publicidad/kireei infantiles.swf", "LPubliGrandeFlash2", "145", "277", "8", false, {clickTag: 'http://www.kireei.com/verpubli.php?id=66'});
		
	//Adviento
	/*
	$('<img>').attr('src', './advcaja.png?rnd='+(new Date()).getTime()).load(function(){
		$('<img>').attr('src', './fondoadv.jpg?rnd='+(new Date()).getTime()).load(function() {  
			$('#LAdviento').show();
			$('#LBaB').css('top','88px');
			$('#LAdviento a').click(function(){
				num=$(this).attr('id');
				num=num.substring(2);
				$('#AdvCaja').html('<a href="#">'+num+'</a>');
				$('#LAdvientoCont2').fadeOut(500);
				left=30+(23*num)-55;
				$('#AdvCaja').css('left',left);
				if ($('#AdvCaja').css('display')=='none')
				{
					$('#AdvCaja').show();
					$('#LAdviento').animate({height: "734px"},3000);
				}
				$.ajax({
					type: "POST",
					url: "php/getadviento.php?id="+num,
					success: function(respuesta, estado){
					$('#LAdvientoCont2').html(respuesta);
					$('#LAdvientoCont2 img').load(function(){
						$('#LAdvientoCont2').fadeIn(500);
					})
					},
					error: function (request, texto, error) {
						alert(texto+'-'+error);
					}
				});
				$('#AdvCaja a').click(function(){
					$('#AdvCaja').hide();
					$('#LAdviento').animate({height: "81px"},1000);
					return false;
				});
				return false;
			});   
		});  
	});*/
})


function GuardarEnMiKireei (comp)
{
	var id=comp.substr(7);					  
	$('#LabMiK'+id).html('GUARDANDO.......');
	$(comp).toggle();	
	$('#LabMiK'+id).toggle();							  
	$.ajax({
		type: "POST",
		url: "php/addfavorito.php?id="+id,
		success: function(respuesta, estado){
			$('#LabMiK'+respuesta).html('GUARDADO EN MIKIREEI');
			//$('#LabMiK'+respuesta).effect("bounce",{times:3}, 300); Eliminado porque cambia la posicion del enlace
		},
		error: function (request, texto, error) {
			alert(texto+'-'+error);
		}
	});
}

function DescargarGoodie(fichero) {
	window.open('descargar.php?id='+fichero);
}