// JavaScript Document
// Appel jquery

var fadeTime = 300;
var lastOpen = null;

function afficherMasque()
{
	var w = $('body').width();
	var mh = $('body').height();
	var ih = $(document).height();

	if ( mh < ih ) mh = ih;		

	$('#masque')
		.css({width: w + 'px', height: mh +'px', opacity: 0.5, filter:'Alpha(Opacity=50)'})
		.fadeIn(fadeTime);

}

// affichage popup

$.fn.showPop = function(el, f)

{
	
	$(this).each(
		function()
		{
			$(this).click(
				function()
				{
					if (f) f.call();
					
					var extraPos = 0;
					if( $(window).height() < $(el).height() ) extraPos = 150;
					var tPos = ( $(window).height() - $(el).height() )/2 + $(window).scrollTop() + extraPos;
					var lPos = ( $(window).width() - $(el).width() )/2;
					if (lastOpen != null) $(lastOpen).fadeOut(fadeTime);
					$(el)
						.fadeIn(fadeTime)
						.css({ top: tPos + 'px', left: lPos + 'px' });
					afficherMasque();
					
					lastOpen = el;
					return false;
				}
			);
		}
	);
	
}

$.fn.showElem = function()
{ 
	var tPos = ( $(window).height() - $(this).height() )/2 + $(window).scrollTop();
	var lPos = ( $(window).width() - $(this).width() )/2;

	$(this)
		.fadeIn(fadeTime)
		.css({ top: tPos + 'px', left: lPos + 'px' });
	
	afficherMasque();
	
	lastOpen = this;

	return false;
}



$.fn.hidePop = function()
{
	$(this).each(
		function()
		{
			$(this).click(
				function()
				{
					$('#masque').fadeOut(fadeTime);
					$(lastOpen).fadeOut(fadeTime);
					return false;
				}
			);
		}
	);
}


$(function() {
	
	// ouverture popup photo
	// $('.show-pop-classement').showPop('#classement');
	// $('.show_pop_conf_1').showPop('#conf_1');
	// $('.show_pop_conf_2').showPop('#conf_2');

	// fermeture popup
	$('.fermer').hidePop();
	
			
});




