$(document).ready(function(){
	$('.showbook').live('click',function(){
		var href = $(this).attr('href');
		if ($('#ajax').is(':visible')) {
			$('#ajax').css('display','block').animate({height:'1px'}).empty();
			$('.labelproj').fadeIn();
		}
		
		$('.labelproj').fadeOut();
		$('#ajax').css('display','block').animate({height:'489px'},function(){
			
			$('#ajax').html('<img class="loader" src="pschhh_imports/loader.gif" alt="loading">');
			LoadSlider(1, 1);
		});
		
		function LoadSlider(id_tag, id_cat){ // ----------- début de ma fonction -----------
				$('#ajax').load('portfolio.php?tag='+id_tag+'&cat='+id_cat,function(){
						$('#ajax #portfolio').hide().fadeIn();
						$('.poptext').hide(); // a remplacer par un display:none en CSS
						$(".proj-title").click(function() {
						 $(this).next(".poptext").next().hide();
					     $(this).next(".poptext").fadeIn('normal');
					    });
					    $(".closetext").click(function(){
					       $(this).parent().fadeOut('normal');
					       $(this).parent().next(".ghost-btn").fadeIn('normal');
					    });
						$("#tag a").click(function(){
							//recup l'id du tag courant
								var id_tag = $(this).attr('id');		
								//recup l'id de la cat courante
								var id_cat = $('#cat .filtered a').attr('id');
								//requete ajax avec les parametres précédents
								LoadSlider(id_tag, id_cat);
						});
						$("#cat a").click(function(){
								//recup l'id du tag courant
								var id_cat = $(this).attr('id');
								//recup l'id de la cat courante
								var id_tag = $('#tag .filtered a').attr('id');
								//requete ajax avec les parametres précédents
								LoadSlider(id_tag, id_cat);
						});
						/*----- fancybox -------- */	
						$(function() {
							$("a.liens").live('click', function() {
       						$(this).fancybox();
   							});
						});

						$('.slide-img').each(function(index) {
							//alert(index + ': ' + $(this).text());
							if($(this).children(".slide")){
								var id_slideshow = $(this).children(".slide").attr("id"); 
								var id_table = id_slideshow.split("_", 2);
								var id = id_table[1];
								//alert(id);
								var name = 'slideshow_';
								window[name + id]  =new TINY.fader.fade("slideshow_"+id,{
									id:"slides"+id,
									navid:"pagination"+id,
									activeclass:"current",
									/*auto: 5*/
								});					
							};
						});
				}); // fin du callback de l'ajax
			
			}//fin fonction test
		return true;
	});
});

	
$(document).ready(function(){
	$('.closebook').live('click',function(){
		var href = $(this).attr('href');
		if ($('#ajax').is(':visible')) {
			$('#ajax').css('display','block').animate({height:'1px'}).empty();
			$('.labelproj').fadeIn();
		}
	});
	
	$(function() {
	
	$('a.equipe').fancybox(); // Select all links with lightbox class
	
	});
	

}); // fin du document ready

