$(document).ready(function() {
						 
	$(".message .nav a:first").css("background-position","bottom");
	var k = 1;
	$(".live .active").fadeIn("slow");
	
	function anim_news() {
		
		var active = $(".live .active");
		var next = active.next("a");
		
		if (!next.length) {	
			var next = $(".live a:first");
		}
		
		active.fadeOut("slow");
		next.fadeIn("slow");
		
		next.addClass("active");
		active.removeClass("active");
		
	}
	
	function anim_message() {
		
		var slider_puce = $(".nav a");

		var position = ($(".message").width()+10)*k;
		$(".nav a").css("background-position","top");
		$(".message div.panneau").animate({"right" : position+"px"}, "slow", "easeOutBack");
		$(slider_puce[k]).css("background-position","bottom");
		
		k++;
		
		if (k== slider_puce.size()){
			k=0;
		}
		
	}
	
	var id1 = setInterval(function(){ anim_news() }, 4000);
	var id2 = setInterval(function(){ anim_message() }, 5000);
	

	$(".menus a.link").mouseover( function() {
		
		$(".under").hide();
		
		$(this).next(".under").fadeIn("slow");
		
		var posx = $(this).width()/2+2;
		var position = $(this).position();
		
		if ($(this).next(".under").length != 0){
			$(".marqueur").animate({"left": position.left+posx+"px"}, "fast", "easeOutBack");
			$(".marqueur").show();
		}else{
			$(".marqueur").hide();
		}
		
		$(".link").css("color", "#999999");
		$(this).css("color", "#FFFFFF");
	});
	
	
	$(".message .nav a").mouseover( function() {
		clearInterval(id2);	
		
		var id = $(".message .nav a").index(this);
		var position = ($(".message").width()+10)*id;
		
		$(".nav a").css("background-position","top");
		$(".message div.panneau").animate({"right" : position+"px"}, "slow", "easeOutBack");
		$(this).css("background-position","bottom");
	
	});
	
	
	
		img = new Image();
		img.onload = function() {
			
			$(".people").css("background-image", "url(" + source + ")");
			$(".people").css("display", "block");
			
			var page = window.location.pathname;
			page = page.split("/");
			page = page[page.length - 1];
			page = page.substr(0, page.lastIndexOf("."));
			page = page.replace(new RegExp("(%20|_|-)", "g"), "");
			
			if(page!="infinitispresentation" && page!="index" ){
				$("#l1").css("margin-left", 80);
				$("#l2").css("margin-left", -20);
				$(".people").css("margin-left",0);
				$(".people").show();
				$("#l3").show();
			}else{
				$(".people").animate({opacity: 1,left: '+=90px'}, "slow");
				$("#l1").animate({left: '+=80px'}, "slow");
				$("#l2").animate({left: '-=20px'}, "slow");
				$("#l3").fadeIn(3000);
			}
			
	
	
		}
		
		var page = window.location.pathname;
		page = page.split("/");
		page = page[page.length - 1];
		
		if(page.substr(0,14)=="infinitis_CGPI" || page.substr(0,5)=="index"){
			source = "web_ressources/illustrations/head_infinitis.gif";
		}else{
			source = "web_ressources/illustrations/head_"+Math.floor(Math.random()*4+1)+".gif";
		}
		
		img.src = source;
	
	
		$("area, .liens div").mouseover(function(){
		
		id = $(this).attr("id");
		
		bg = "ressources/fr_"+id+".gif";
		$("#map").attr("src", bg);
							 
	 });
	
	
		$("area, .liens div").click(function(){
			
			id = $(this).attr("id");
			alt =$(this).attr("alt");
			
			$(".nodispo").hide();
			$("h1.region").html(alt);
			$(".mini_immo").hide();
			$("."+id).show();
			
			if ($("."+id).length==0){
				$(".nodispo").show();
			}
								 
		 });
		
		$(".mini_immo").mouseover( function() {
			
			$(".mini_immo em").hide();
			$(this).find("em").fadeIn("fast");
										 
		});
		
		$(".mini_immo").mouseout( function() {
			
			$(".mini_immo em").hide();
										 
		});
		
		
		$("ol li.dehide").click( function() {
								 
			$(".hide").hide();
			$(this).parent("ol").children("li").css("color","#666");
			
			$(this).css("color","#000");
			$(this).next(".hide").slideDown("fast");
			$(this).next(".hide").slideDown("fast");
			
								 
		});


});
