function changeOnglet(_this){
	var getOnglets 	= document.getElementById('mes_onglets').getElementsByTagName('li');
	for(var i = 0; i < getOnglets.length; i++){
		if(getOnglets[i].id){
			if(getOnglets[i].id == _this.id){
				getOnglets[i].className = 'mon_onglet_selected';
				document.getElementById('c' + _this.id).style.display= 'block';
			}
			else{
				getOnglets[i].className = 'mon_onglet';
				document.getElementById('c' + getOnglets[i].id).style.display= 'none';
			}
		}
	}			
};

$(document).ready(function() {
		/*
		 * Affichage des visuels dans les familles Les Affiches et Les Tirages Limités
		 */
		$('body.les_affiches #productPicture img,body.les_tirages_limites #productPicture img').each(function() {
			//var url = $(this).attr('src');
			//$(this).wrap('<a href="' + url + '" class="thickbms" />');
			$(this).wrap('<a class="thickbms2" />');
		});

		// on enregistre l'image de départ
		var image = $('#productPicture img').attr('src');
		if (image) {
		image = image.replace("thumbnails","");
		$('#productPicture img').attr('src', image);
		$('.thickbms img').mouseover(function(){
			url = $(this).attr("src");
			url = url.replace("thumbnails","");
			
			$('#productPicture img').attr("src",url);
		
			
		});
		$('.thickbms img').mouseout(function(){
			
			$('#productPicture img').attr("src",image);
			$('#productPicture img').css("height","311px");

		});
		
		$('.thickbms img').click(function(){
			url = $(this).attr("src");
			url = url.replace("thumbnails","");
			$('#zoom').attr("src",url);
			$('#zoom').css("z-index","2000");
			$('#zoom').css("position","fixed");
			$('#zoom').css("top","0px");
			$('#zoom').css("width","1134px");
			var left = ($('#page').width()/2 - (1134/2));
			$('#zoom').css("left",left);
			$('#zoom').show();
			
		});

		$('.thickbms2 img').click(function(){
			url = $(this).attr("src");
			url = url.replace("thumbnails","");
			$('#zoom').attr("src",url);
			$('#zoom').css("z-index","2000");
			$('#zoom').css("position","fixed");
			//$('#zoom').css("top","400px");
			//$('#zoom').css("width","800px");

			$('#zoom').css('top', $(window).height()/2-$('#zoom').height()/2); 
			$('#zoom').css('left', $(window).width()/2-$('#zoom').width()/2); 

			var left = ($('#page').width()/2 - ($('#zoom').width()/2));
			$('#zoom').css("left",left);
			$('#zoom').show();
			
		});

		$('#zoom').click(function(){
			$('#zoom').hide();
		});
	};
		
		
		// Partie Diaporama
		// on capture la liste des images disponibles
		var tab_img = [];
		var cursor = 0;
		$('.diapo_bms .center img').each(function(){
			var image = $(this).attr("src");
			if (image) {
			image = image.replace("thumbnails/","");
			tab_img.push(image);
		};
		});
		var size = tab_img.length;
		// on capture les textes également
		var tab_desc = []
		var tab_nom = []
		
		$('.diapo_bms .description').each(function(){
				tab_desc.push($(this).html());
		});
		
		
		$('.diapo_bms .nom').each(function(){
				tab_nom.push($(this).html());
		});

		// on affiche la première en grand
		$("#diapo_bms").attr('src', tab_img[0]);
		$("#diapo_bms").css("width","427px");
		$("#diapo_bms").css("height","285px");
		$("#diapo_bms").show();
		// on affiche la description
		$('#description').text(tab_desc[0]);
		$('#description').show();
		// on affiche le nom
		$('#nom').text(tab_nom[0]);
		$('#nom').show();
		
		$("#prev").attr('src','/scripts/images/prev.gif');
		$('#prev').css("z-index","2000");
		$("#prev").css("position","absolute");
		$("#prev").css("left","625px");
		$("#prev").css("top","453px");
		$("#prev").show();

		$("#next").attr('src','/scripts/images/next.gif');
		$('#next').css("z-index","2000");
		$("#next").css("position","absolute");
		$("#next").css("left","638px");
		$("#next").css("top","453px");
		$("#next").show();
		
		$("#plus").attr('src','/scripts/images/plus.gif');
		$('#plus').css("z-index","2000");
		$("#plus").css("position","absolute");
		$("#plus").css("left","600px");
		$("#plus").css("top","453px");
		$("#plus").show();
		
		// Si on clique sur l'une des flèches, on passe sur une autre image
		$("#next").click(function(){
			cursor = cursor + 1;
			if (cursor > size) {
				cursor = 0;
			}
		$("#diapo_bms").attr('src', tab_img[cursor]);
		$('#nom').text(tab_nom[cursor]);
		$('#description').text(tab_desc[cursor]);

		});
		
		$("#prev").click(function(){
			cursor = cursor - 1;
			if (cursor < 0) {
				cursor = size;
			}
		$("#diapo_bms").attr('src', tab_img[cursor]);
		$('#nom').text(tab_nom[cursor]);
		$('#description').text(tab_desc[cursor]);

		});
		
		
		
		// Si on clique sur l'image, on la voit en grand
		$("#plus").click(function(){
			$("#zoom").attr("src", $("#diapo_bms").attr("src"));
			$('#zoom').css("z-index","2000");
			$('#zoom').css("position","fixed");
			$('#zoom').css("top","0px");
			$('#zoom').css("width","855px");
			var left = ($('#page').width()/2 - (855/2));
			$('#zoom').css("left",left);
			$('#zoom').show();
			
		});
		
		$('#zoom').click(function(){
			$('#zoom').hide();

		});
	
	//	$('body').hide();

		// Partie Titre article dans le diaporama
		$('#titre_diapo').text($('#chapo h1').html());
		$('#titre_diapo').show();
		
		// Partie suppression widget à droite
		if ($('#no_wdg_right').length > 0) {
			$('#rightbar').hide();
		} else {
			$('#rightbar').show();
		};
		
		// Partie suppression cadre espace central
	
		if ($('#no_cadre').length > 0) {
			$('#contentsInner').css('background-image','None');
		};
	
		// Partie zoom sur image
		
		$(".zoom_bms").each(function(){
			$(this).click(function(){
				$("#zoom").attr("src", $(this).attr("src"));
				$('#zoom').css("z-index","2000");
				$('#zoom').css("position","fixed");
				$('#zoom').css("top","0px");
				var width = $('.zoom_bms').width("100%");
				$('#zoom').css("width",width);
				
				
				var left = ($('#page').width()/2 - (width/2));
				$('#zoom').css("left",left);
				$('#zoom').show();	
			});
		});
	
	});



