
var posSourisAcc = 0;
var pos_xAcc = 0;
var fiche_afficheeAcc = false;
var last_ficheAcc = false;
var clic_lien = false;
	
function initFicheAcc() {
	
	$("#contentwrap")
	// Au déplacemenet de la souris, on stocke la position du curseur
	.mousemove(function(e){ posSourisAcc = e.pageX - this.offsetLeft; });
	//.bind("click", function() { cacheFicheAcc() } ); 
	
	
	$("#coeurnav_produits .produit_liste_photo a")
	// Au survol de la vignette produit : on affiche la fiche
	.bind("mouseenter",function(e) { 
		$(this).parent().parent().parent().addClass('infiche');
		if ( fiche_afficheeAcc == false ){
			last_ficheAcc = $(this).parent().parent().parent();
			
			fiche_contenue = $(this).parent().parent().next("div.win_fiche");
			
			// Position de la souris
			containerPosition = getPosition($(this).parent().get(0));
			
			// En fonction de la position du curseur de la souris, on cale la fiche à gauche ou à droite 
			if ( posSourisAcc < 580 )
				gauche = containerPosition.x+15;
			else
				gauche = containerPosition.x-210;
			
			$("#fiche_produit").empty().append(fiche_contenue.html());
			$("#fiche_produit").css({left: gauche+'px', margin: '-30px 0px 0px 0px'});
			$('.win_fiche_content a').click(function(){				clic_lien = true;			});			$('.win_fiche_content').click(function(){				if(clic_lien){					clic_lien = false;				} else {					url = $(this).find('.winfiche_lienfiche a').attr('href');					window.location = url;				}			});	
			
			self.setTimeout('montreFicheAcc()', 1000);
		}
		
    })
	.bind("mouseleave", function() {
		$(this).parent().parent().parent().removeClass('infiche');
	});
	
	
	$("#fiche_produit")
	// Quand on clique sur la fiche ou quand on "sort" de la fiche produit : on cache la fiche
	.bind("mouseleave", function() { cacheFicheAcc() });
}


function cacheFicheAcc() {
	if ( fiche_afficheeAcc != false )
	{
		$("#fiche_produit").animate({opacity: "hide"}, "fast");
			
		fiche_afficheeAcc = false;
	}
}


function montreFicheAcc() {
	if(last_ficheAcc.hasClass('infiche')){
		fiche_afficheeAcc = true;
		$("#fiche_produit").animate({opacity: "show"}, "slow");
	}
}

