$(document).ready(function(){
	$('body > *').fadeOut(0);
});

$(window).load(function(){
	$('body > *').fadeIn(800);
	$('.thejloupe').hide();
	$('#loader').hide();
	$('#lightbox-background').hide();
	$('#loupe').click(function(e){
		if ($('.thejloupe').hasClass('active')){
			$('#loupe').attr('src', tpl_url + 'images/loupe.png');
			$('#image-principale').unbind('mousemove');
			$('#image-principale').unbind('mouseleave');
			$('#image-principale').unbind('mouseenter');
			$('.thejloupe').removeClass('active');
			$('.thejloupe').remove();
		}else{
			$('#loupe').attr('src',tpl_url + 'images/loupe2.png');
			$('#image-principale').jloupe(
				{
				radiusLT: 0,
				radiusRT: 0,
				radiusRB: 0,
				radiusLB: 0,
				width: 200,
				height: 150,
				backgroundColor: '#000',
				fade: false
			});
			$('.thejloupe').addClass('active');
		}
	});
	$('#agrandir').click(function(){
		var img = new Image();
		img.src = $('#image-principale').attr('src');
		
		$(img).load(function(){
			$('#lightbox').show();
			$('#lightbox-background').show();
			$('#lightbox-background').fadeTo(0,0.7);
			$('#fermer-lightbox').show();
			$('#lightbox').css('width', img.width);
			$('#lightbox').css('height', img.height + 100);
			$('#lightbox').css('backgroundImage', 'url(' + $('#image-principale').attr('src') + ')');
		});
	});
	
	$('#lightbox').click(function(){
		$(this).hide();
		$('#fermer-lightbox').hide();
		$('#lightbox-background').hide();
		$('#lightbox').css('marginBottom', 0);
	});
	
	$('#fermer-lightbox').click(function(){
		$(this).hide();
		$('#lightbox').hide();
		$('#lightbox-background').hide();
		$('#lightbox').css('marginBottom', 0);
	});
	
	$('#site-lent').click(function(){
		if($(this).hasClass('unactive')){
			jQuery.fx.off = false;
			$(this).removeClass('unactive');
			$(this).html('Le site est trop lent cliquez içi pour d&eacute;sactiver les animations');
		}else{
			jQuery.fx.off = true;
			$(this).addClass('unactive');
			$(this).html('R&eacute;activer les animations');
		}
	});
	
	
	
	$('#news').click(function(){
		loadPage({
		'page':'news.php',
		'subtitle' : 'News'
		});
	});
	
	
	
	loadPage();
	
});
