$(document).ready(function(){
// COLORBOX (LIGHTBOX)
	$("a[rel='photo']").colorbox();
	$("a[rel='print']").colorbox({iframe:true, innerWidth:990, innerHeight:600});


// Initialisation Album
	window.$alb =
	{
		nbeScroll : parseInt($("#albums ul li").length),
		scroll : 1

	};
// Initialisation Breves
	window.$bre = {nbeScroll : 0, scroll : 1};

// Initialisation Boutik
	window.$bou = {nbeScroll : 0, scroll : 1};


// BOUTIK

	//CREA SLIDE
	$("#boutik .produits").wrap("<div class=\"slide\"></div>");
	
	//NOMBRE DE PRODUITS
	$bou.nbeScroll = $('#boutik .produits > *').length;
	
	//RETAILL DU UL
	$("#boutik .produits").css({'width':''+ ($bou.nbeScroll*258) +'px'});
	
	//CREA DES FLECHES
	$("#boutik .slide").after("<div class=\"BtkFlechLeft noactiv\"></div><div class=\"BtkFlechRight\"></div>");
	
	//SCROLL RIGHT
	$("#boutik .BtkFlechRight").click(function () {
	
		if ($bou.scroll < $bou.nbeScroll){
			$bou.scroll = $bou.scroll+1;
			$("#boutik .produits").animate({ "marginLeft" : "-=258px" },  600);
		}
		
		$("#boutik .BtkFlechLeft").removeClass('noactiv');
		
		if ($bou.scroll == $bou.nbeScroll){
			$("#boutik .BtkFlechRight").addClass('noactiv');
		}
	
	});
	
	//SCROLL LEFT
	$("#boutik .BtkFlechLeft").click(function () {

		if ($bou.scroll > 1){
			$bou.scroll = $bou.scroll-1;
			$("#boutik .produits").animate({ "marginLeft" : "+=258px" },  600);
		}
		
		$("#boutik .BtkFlechRight").removeClass('noactiv');
		
		if ($bou.scroll == 1) {
			$("#boutik .BtkFlechLeft").addClass('noactiv');
		}
	});

// PHOTOS
	//CREA SLIDE
	$("#albums ul").wrap("<div class=\"slide\"></div>");

	//CREA DES FLECHES
	$("#albums").append("<div class=\"flech_haut noactiv\"></div><div class=\"flech_bas noactiv\"></div>");
	
	//ACTIVER FLECHES BAS SI + DE 4 PHOTOS
	if ($alb.nbeScroll > 4){
		$("#albums .flech_bas").removeClass('noactiv');
	}
	
	//SCROLL DOWN
	$("#albums .flech_bas").click(function () {
		if ($alb.scroll < $alb.nbeScroll && $alb.nbeScroll > 4){
			$alb.scroll = $alb.scroll+1;
			$("#albums ul").animate({ "marginTop" : "-=85px" },  500);
			
			$("#albums .flech_haut").removeClass('noactiv');
		
			if ($alb.scroll == $alb.nbeScroll){
				$("#albums .flech_bas").addClass('noactiv');
			}
		}
	});
	
	//SCROLL UP
	$("#albums .flech_haut").click(function () {

		if ($alb.scroll > 1){
			$alb.scroll = $alb.scroll-1;
			$("#albums ul").animate({ "marginTop" : "+=85" },  500);
		}
		
		$("#albums .flech_bas").removeClass('noactiv');
		
		if ($alb.scroll == 1) {
			$("#albums .flech_haut").addClass('noactiv');
		}
	});
	
// BREVES
	//CREA SLIDE
	$("#breves ul").wrap("<div class=\"slide\"></div>");

	//CREA DES FLECHES
	$("#breves").append("<div class=\"flech_haut noactiv\"></div><div class=\"flech_bas\"></div>");

	//CALCUL NBE SCROLL
	var hauteuMax = $("#breves ul").height();
	$bre.nbeScroll =  Math.ceil(hauteuMax / 290);

	//SCROLL UP
	$("#breves .flech_haut").click(function () {

		if ($bre.scroll > 1){
			$bre.scroll = $bre.scroll-1;
			$("#breves ul").animate({ "marginTop" : "+=290px" },  800);
		}
		
		$("#breves .flech_bas").removeClass('noactiv');
		
		if ($bre.scroll == 1) {
			$("#breves .flech_haut").addClass('noactiv');
		}
	});
	
	//SCROLL DOWN
	$("#breves .flech_bas").click(function () {
		if ($bre.scroll < $bre.nbeScroll){
			$bre.scroll = $bre.scroll+1;
			$("#breves ul").animate({ "marginTop" : "-=290px" },  800);
		}
		
		$("#breves .flech_haut").removeClass('noactiv');
		
		if ($bre.scroll == $bre.nbeScroll){
			$("#breves .flech_bas").addClass('noactiv');
		}
	});

});
