var delai = 15000;
var nb_unes = 0;
var une_actuelle = 1;

var item_actuel = null;

$(document).ready(function() {
	$(".loader").css({display: "none"});
//	ajust_corps();
	active_hover_item();
	$('.facebox').facebox();
	
	var aleatoire = Math.random();
	var so = new SWFObject('Carousel.swf?a='+Math.random(), 'myheader', '800', '400', '9', '#FFFFFF');
	so.addParam('menu', 'false');
	so.addParam('allowFullScreen', 'true');
	so.addParam('wmode', 'transparent');
	so.write('carousel');
});

$(window).resize(function() {
//	ajust_corps();
});


function ajust_corps() {
	$(".corps").css({
		width: $(window).width(),
		height: $(window).height()-20
	});	
}

function active_hover_item() {
	$(".item").mouseover(function() {
		if($("#"+this.id).width() < 600) {
			$("#"+this.id+" .illustr1 .illustr2 .rollhover").css({
				"display":"block"
//				"opacity":0.7
			});
		}
	});
	$(".item").mouseout(function() {
		$("#"+this.id+" .illustr1 .illustr2 .rollhover").css({
			"display":"none"
//			"opacity":1
		});
	});
	
	$(".item").click(function() {
		$("body").scrollTo($("A[name='focus_item']").offset().top,800);
		if(item_actuel != null) {
			$("#"+item_actuel+" .plus_info_contact").css("display","none");
			$("#"+item_actuel+" .description").css("display","none");
			$("#"+item_actuel).animate({
				width: 359,
				height: 154					   
			}); 
			$("#"+item_actuel+" .illustr1").animate({
				width: 141,
				height: 139
			}); 
			$("#"+item_actuel+" .illustr1 .illustr2").animate({
				width: 141,
				height: 139
			});
		}
		item_actuel = this.id;
		
		if($("#"+this.id).width() < 600) {
			$("#"+this.id).prependTo("#lesitems");
			$("#"+this.id+" .illustr1 .illustr2 .rollhover").css("display","none");
			$("#"+this.id).animate({
				width: 800,
				height: $("#"+this.id+" .illustr1 .illustr2 IMG").height() + 10					   
			}); 
			$("#"+this.id+" .plus_info_contact").css("display","block");
			$("#"+this.id+" .description").css("display","block");
			$("#"+this.id+" .illustr1").animate({
				width: $("#"+this.id+" .illustr1 .illustr2 IMG").width(),
				height: $("#"+this.id+" .illustr1 .illustr2 IMG").height()
			});
			$("#"+this.id+" .illustr1 .illustr2").animate({
				width: $("#"+this.id+" .illustr1 .illustr2 IMG").width(),
				height: $("#"+this.id+" .illustr1 .illustr2 IMG").height()
			});
		}
		else { 
			$("#"+this.id+" .plus_info_contact").css("display","none");
			$("#"+this.id+" .description").css("display","none");
			$("#"+this.id).animate({
				width: 359,
				height: 154					   
			}); 
			$("#"+this.id+" .illustr1").animate({
				width: 141,
				height: 139
			}); 
			$("#"+this.id+" .illustr1 .illustr2").animate({
				width: 141,
				height: 139
			});
		}
	});
}

function ouvr_type(quoi) {
	$("#lesitems .item").css("display","none");
	$("DIV[rel='"+quoi+"']").each(function() {
		$(this).css("display","block"); 
		$("#"+this.id+" .illustr1 .illustr2 .rollhover").css("display","none");
		$("#"+this.id).animate({
			width: 800,
			height: $("#"+this.id+" .illustr1 .illustr2 IMG").height() + 10					   
		}); 
		$("#"+this.id+" .plus_info_contact").css("display","block");
		$("#"+this.id+" .description").css("display","block");
		$("#"+this.id+" .illustr1").animate({
			width: $("#"+this.id+" .illustr1 .illustr2 IMG").width(),
			height: $("#"+this.id+" .illustr1 .illustr2 IMG").height()
		});
		$("#"+this.id+" .illustr1 .illustr2").animate({
			width: $("#"+this.id+" .illustr1 .illustr2 IMG").width(),
			height: $("#"+this.id+" .illustr1 .illustr2 IMG").height()
		});
	});
}