

this.imagePreview = function(){ 
    cibleToolTip=".vignettes";
    var xOffset = -10;//plus negatif, plus decale vers le bas
    var    yOffset = 10;//plus positif, plus decale vers la droite

//    xOffset = -10;
//    yOffset = -50;



    $(cibleToolTip).each(function(e){
	var p=$(this).parent().prev();
	this.tooltipText=p.html();
	var inforealisation= p.children('ul').children('li.film_realisation').html();
	inforealisation = inforealisation!=null ? " - " + inforealisation : "";
	var infodop= p.children('ul').children('li.film_dop').html();
	infodop = infodop!=null ? " &nbsp;  &nbsp; " + infodop : "";
	var infoproduction= p.children('ul').children('li.film_production').html();
	infoproduction = infoproduction!=null ? " &nbsp;  &nbsp; " + infoproduction : "";

	this.titrefancybox=p.children('ul').children('li.film_titre').html()+inforealisation+infodop+infoproduction;
	this.alt="";
	this.title="";
    });                
    $(cibleToolTip).hover(function(e){
//        $("body").append("<div id='fenetreTooltip'>" +  this.tooltipText + "<br /><img src='"+ this.src +"' alt='Image fenetreTooltip' />" +"</div>");                                                                
	var lehtml="<img src='"+ this.src +"' alt='Image fenetreTooltip' /><br />"+this.tooltipText ;
        $("#fenetreTooltip")
	.html(lehtml)
                        .css("top",(e.pageY - xOffset) + "px")
                        .css("left",(e.pageX + yOffset) + "px")
                        .fadeIn("fast");                                                

    },
        function(){
            $("#fenetreTooltip").hide();
    }); 
        $(cibleToolTip).mousemove(function(e){
                $("#fenetreTooltip")
                        .css("top",(e.pageY - xOffset) + "px")
                        .css("left",(e.pageX + yOffset) + "px");
        });                     
};



$(document).ready(function() {
    imagePreview();//active les tooltip image preview
    $('.infos_films, .infos_films *').css("display","none");
    appelle_fancybox();
});

function appelle_fancybox(){
    $("a.boxdimages").fancybox({
	'padding' : 10,
	'imageScale' : true,
	'zoomOpacity':false,
	'overlayOpacity':.2,
	'zoomSpeedIn':		300, 
	'zoomSpeedOut':	400, 
	'zoomSpeedChange':	100, 
	'overlayShow': true,
	'centerOnScroll':false,
	'hideOnContentClick': false
    });
};
$(window).bind('load', function() {
    return;
   var preload = new Array();
    $("a.boxdimages").each(function() {
        s = $(this).attr("href");
        preload.push(s)
    });
    var img = document.createElement('img');
    $(img).bind('load', function() {
        if(preload[0]) {
            this.src = preload.shift();
        }
    }).trigger('load');
});
var couleuractif="";
var couleurinactif="";
var hauteuroriginale=0;

function changeliste (objet){
        $("#fenetreTooltip").hide();
	$('.liste_titre a').removeClass('blanc');
	$(objet).addClass('blanc')
	cible=$(objet).attr('href');
	$('.liste_liste').addClass('blanc');
	if($(cible).css('display')=='block'){
//	    $(cible).css('display','none');
	    $(cible).hide(200);
	    if(hauteuroriginale>0)  $('.unephotodunfilm a img').css("height",hauteuroriginale);
	    $('.unephotodunfilm').show(200);
	    $(objet).addClass('gris');
	}
	else{
//	    $('.liste_liste').css('display','none');
	    $('.liste_liste').hide(200);
//	    $(cible).css('display','block');
	    $(cible).addClass('blanc');
	    $(cible).show(200);
	}
}

function changeimages(objet){
    $("#fenetreTooltip").hide();
    if(hauteuroriginale>0)  $('.unephotodunfilm a img').css("height",hauteuroriginale);
    if($(objet).attr("enroute")=="oui"){
	//clique alors que filtre en route -> on l'enleve
	$(objet).attr('enroute','non');
	$(objet).css("text-decoration","none");
	$('.unephotodunfilm').show(200);
    }
    else{
	var classe=$(objet).attr('title');
	//	classes.split(" ");
	//	alert(classes);
	$('.unephotodunfilm').hide(200);
	if(hauteuroriginale==0)   hauteuroriginale=$('.'+classe+' a img').height();
	$('.'+classe+' a img').css("height",82);
	$('.'+classe).show(200);
	$('.lien_filtre').css("text-decoration","none");
	$(objet).css("text-decoration","underline");
	$(objet).attr('enroute','oui');
    }
}

$(document).ready(function(){

    var couleurinactif=$('#couleur_tabs').css("background-color");
    var couleuractif=$('#content_wrapper').css("background-color");

    $('.liste_liste').hide(0);
    $('#liste_titres').addClass('blanc');
    $('#liste_titres').show(500);
    $('#lien_liste_titres').addClass('blanc');
//    $('.liste_titre a').css('background-color',couleurinactif);
    $('.toggle_liste').click(function(){
	changeliste(this);
	return false;
    });
    $('.lien_filtre').click(function(){
	changeimages(this);
	return false;
    });


});





