$(window).load(function(){
						  
	$().piroBox({
			my_speed: 400,
			bg_alpha: 0.8, 
			close_all : '.piro_close,.piro_overlay'

	});


	$(".point").hide();
	
	$(".plan li").mouseover(function(){
									 
		$(".point").hide();
		goto = $(this).html();	
		
		for (i=0; i<$(".point").length; i++){
		
			if ($(".point:eq("+i+")").html()==goto){
				$(".point:eq("+i+")").fadeIn("fast");	
				break;
			}
		
		}
	})
	
	z = 1;
	last = 0;
	
	$(".selecteur span").mouseover(function(){
											
		clearInterval(id);
		var index = $(".selecteur span").index(this);
		
		if (last!=index){
			
		last=index;
											
											
		$(".selecteur span").css("background-position", "top");
		$(this).css("background-position", "bottom");
									
											
		$(".highlight img").eq(index).hide();
		
		z++;
		$(".highlight img").eq(index).css("z-index",z);
		
		$(".highlight img.active").removeClass("active");
		$(".highlight img").eq(index).addClass("active");
		$(".highlight img").eq(index).fadeIn("slow");
			
		z++;
		$(".selecteur").css("z-index",z);
		z++;
		$(".highlight a").css("z-index",z);
		}
	})
	
	
	function anim() {
		
		last++;
		
		if(last > 7) last = 0;
		
		$(".selecteur span").css("background-position", "top");
		$(".selecteur span").eq(last).css("background-position", "bottom");
		
		
									
		$(".highlight img").eq(last).hide();
		
		z++;
		$(".highlight img").eq(last).css("z-index",z);
		$(".highlight a").css("z-index",z);
		
		$(".highlight img.active").removeClass("active");
		$(".highlight img").eq(last).addClass("active");
		$(".highlight img").eq(last).fadeIn("fast");
			
		z++;
		$(".selecteur").css("z-index",z);
		
	}
	
	$("#go_listing_photos").click(function(event){
		$.scrollTo(".box_photos", 800, {queue:true} );
	});
	
	
	
	if ($(".black").length!=0){
		
		$(".pop").css("margin-left", ($(window).width()-600)/2);
		$(".pop").css("margin-top", ($(window).height()-440)/2);
		$(".pop").css("display", "block");
		
		$(".black").css("height", $("body").height());
		$(".black").css("display", "block");
		
		survol = 0;
		
		$(".pop").mouseover(function(){
			survol = 1;
		});		
		
		$(".pop").mouseout(function(){
			survol = 0;
		});		
		
		
		$(".black").click(function(){
			if( survol == 0){
				$(".black").hide();
				$(".pop").html("");
				
			};
			survol = 0;
		});		
	
	}

	
	var id = setInterval(function(){ anim() }, 3000);
	
});
