
/*-----------------------------------------------------------*/
/*-----------------------accueil------------------------------------*/
/*-----------------------------------------------------------*/
window.onresize = function(){
	fixBackground();
}
function fixBackground() {
	if(0 == img_width || 0 == img_height) {
		return;	
	}
	var window_width = getClientWidth();
	var window_height = getClientHeight();
	var new_width = img_width*window_height/img_height;
	var new_height = img_height*window_width/img_width;
	if(new_width > window_width) {
		document.getElementById('background_img').style.width=new_width+"px";
		document.getElementById('background_img').style.height=window_height+"px";
		document.getElementById('background_img').style.left=(0-(new_width-window_width)/2)+"px";
		document.getElementById('background_img').style.top=0+"px";
	}
	else {
		document.getElementById('background_img').style.width=window_width+"px";
		document.getElementById('background_img').style.height=new_height+"px";
		document.getElementById('background_img').style.left=0+"px";
		document.getElementById('background_img').style.top=(0-(new_height-window_height)/2)+"px";
	}
	document.getElementById('background_img').style.display='block';
};

function getClientWidth()
{
  var x = window.innerWidth ||
          document.documentElement.clientWidth ||
          document.body.clientWidth;

  return x ? x : 0;
};

function getClientHeight()
{
  var x = window.innerHeight ||
          document.documentElement.clientHeight ||
          document.body.clientHeight;


  return x ? x : 0;
};

/*-----------------------------------------------------------*/
/*--------------------fin accueil------------------------------------*/
/*-----------------------------------------------------------*/





			function spectrum(){
				$('#body').animate( { backgroundColor: '#ECEEDF' }, 9181002);
				$('#body').animate( { backgroundColor: '#ECEEdd' }, 9181002);
				$('#body').animate( { backgroundColor: '#ECEEff' }, 9181002);
				spectrum(); 
		   	}
		   	
		   	
		   	
/* effet accordeon - permet de ne pas utiliser le plug-in accordeon */
/* onclick="montrer_article('#ID_ARTICLE'); return false;" */		   	
	function montrer_article (numero_article) {
		if ($('#block-article'+numero_article+ " .texte_article_slide").is(":visible")) {
			$('#block-article'+numero_article+ " .texte_article_slide").slideUp();

		} else {
			$(".texte_article_slide").slideUp();
			$('#block-article'+numero_article+ " .texte_article_slide").slideDown();
		}
	};
	

	function fin_roll (){
		this.title = this.t;
		this.name = this.i;	
		this.rel = this.test;
		$("#preview").remove();
		$("#gauche").animate({opacity: "1"});
    };	
    	
	
	function init () {
	/* ouverture colonne projet */
 	    $('#sous_menu').slideDown('slow');
	    $('#vignette').slideDown('slow');
	    $('#article').slideDown('slow');
	};



/* roolover image */

/* tooltip / http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery*/

this.imagePreview = function(){	

yOffset = 0;
		 
	$("a.imagePreview").hoverIntent(	
	function(e){
		this.t = this.title;
		this.title = "";	
		this.i=this.name;
		this.name = "";
		this.test = this.rel;
		this.rel = "";	
		
		
			
		$("#image_roll").append("<p id='preview'><img class='marge_image' src='"+ this.i +"' alt='Image preview' /><br/>"+ this.t +"</p>");	
	
		/* console.log($('span.legende_roll').height()); */
	
		 y = $(this).offset().top - yOffset;
		 hauteurimg = parseInt(this.test) ;
		 bottom = y + hauteurimg +  50 ;
		 decalage = (bottom - $(window).height() );
		
/*
		console.log(y ); 
		console.log(hauteurimg); 
		 console.log(y + parseInt(hauteurimg)); 
*/
		
		
		if( $(window).height()+ $(window).scrollTop() < bottom ) {
					$("#preview").css("top",(y - decalage + $(window).scrollTop() ) + "px").fadeIn("fast");
		} 
		else {
					$("#preview").css("top",(y) + "px").fadeIn("fast");
		}
		$("#gauche").animate({opacity: "0.1"});						
    },
	function(){
		this.title = this.t;
		this.name = this.i;	
		this.rel = this.test;
		$("#preview").remove();
		$("#gauche").animate({opacity: "1"});
    });	
		
};








	
$(document).ready(function(){
init();
imagePreview();



/*-----------------------------------------------------------*/
/*-----------------------affichage------------------------------------*/
/*-----------------------------------------------------------*/

$("li.chronologique, li.chronologique ul").hoverIntent(
 function() {
	$("ul.tri_date").fadeIn("fast").css('display','block');
 },

 function() {
	$("ul.tri_date").fadeOut("fast");
 }
); 





$("li.alphabetique, li.alphabetique ul").hoverIntent(
 function() {
	$("ul.tri_lettre").fadeIn("fast").css('display','block');
 },

 function() {
	$("ul.tri_lettre").fadeOut("fast");
 }
);



$("a.par_liste").click(function() {
	$(".menu_dates").css('display','none');
	$(".menu_mots").css('display','block');

});

$("a.par_vignette").click(function() {
	$(".menu_dates").css('display','block');
	$(".menu_mots").css('display','none');

});

/*-----------------------------------------------------------*/
/*-----------------------OPEN LAYER PROJETS------------------------------------*/
/*-----------------------------------------------------------*/


  $('a.load_ajax_projet').bind('click',function(){
  
  	var url = $(this).attr('href');

	$("#layer_article").fadeIn("slow");
	$("#layer_load").fadeIn("slow");
	
	$('#layer_load').html('<p class="container centre"><img src="loading.gif" alt="chargement"></p>').show('fast', function(){
		$("#layer_load").load(url);
	});
			        
	
	$('html, body').animate({scrollTop:0}, 'slow');
	return false;
  });

/* fin open layer article  */

/*-----------------------------------------------------------*/
/*-----------------------PAGINATION------------------------------------*/
/*-----------------------------------------------------------*/

$(".pagination_date a").click(function() {
  	$(".pagination_date a").removeClass("on").animate({ color: "#181002 " }, 400 );
  	$(this).animate({ color: "#FDF2DE " }, 400 ).addClass("on");
  	$('span.jakob.selected:last').next().addClass('clear');
	
});

/* effet couleur lien date*/
$("p.pagination_date a").hover(
 function() {
 $(this).animate({ color: "#FDF2DE" }, 400 );
 },
 function() {
  	if($(this).hasClass('on')) {
		} 
		else {
  	$(this).animate({ color: "#181002 " }, 400 );
		}
 }
);


/*-----------------------------------------------------------*/
/*-----------------------MOTS------------------------------------*/
/*-----------------------------------------------------------*/
$("#mots ul li a").click(function() {
	$("#mots ul li a").removeClass("on"); 
	$("#mots ul li a").animate({ color: "#181002 " }, 400 ); 
	$(this).animate({ color: "#FDF2DE" }, 400 );
	$(this).addClass("on");
});

$("#mots ul li a").hover(
 function() {
		if($(this).hasClass('on')) {
			
		} 
		else {
  			$(this).css('cursor','pointer');
			$(this).animate({ color: "#FDF2DE" }, 400 );
		}
 },

 function() {
 		if($(this).hasClass('on')) {
			
		} 
		else {
  			$(this).css('cursor','pointer');
			$(this).animate({ color: "#181002" }, 400 );
		}
 }
);


/*-----------------------------------------------------------*/
/*-----------------------CHRONOLOGIQUE------------------------------------*/
/*-----------------------------------------------------------*/

$("li.chronologique a").click(function() {
	$("li.chronologique a, li.alphabetique a").removeClass("on"); 
	$("li.chronologique a, li.alphabetique a").animate({ color: "#181002 " }, 400 ); 
	$(this).animate({ color: "#FDF2DE" }, 400 );
	$(this).addClass('on');
});

$("li.chronologique a").hover(
 function() {
		if($(this).hasClass('on')) {
			
		} 
		else {
  			$(this).css('cursor','pointer');
			$(this).animate({ color: "#FDF2DE" }, 400 );
		}
 },

 function() {
 		if($(this).hasClass('on')) {
			
		} 
		else {
  			$(this).css('cursor','pointer');
			$(this).animate({ color: "#181002" }, 400 );
		}
 }
);

/*-----------------------------------------------------------*/
/*-----------------------ALPHABETIQUE------------------------------------*/
/*-----------------------------------------------------------*/
$("li.alphabetique a").click(function() {
	$("li.chronologique a, li.alphabetique a").removeClass("on"); 
	$("li.chronologique a, li.alphabetique a").animate({ color: "#181002 " }, 400 ); 
	$(this).animate({ color: "#FDF2DE" }, 400 );
	$(this).addClass('on');
});

$("li.alphabetique a").hover(
 function() {
		if($(this).hasClass('on')) {
			
		} 
		else {
  			$(this).css('cursor','pointer');
			$(this).animate({ color: "#FDF2DE" }, 400 );
		}
 },

 function() {
 		if($(this).hasClass('on')) {
			
		} 
		else {
  			$(this).css('cursor','pointer');
			$(this).animate({ color: "#181002" }, 400 );
		}
 }
);

/*-----------------------------------------------------------*/
/*-------------------MENU SOMMAIRE--------------------------*/
/*-----------------------------------------------------------*/

$("#menu ul li a").click(function() {
	$("#menu ul li a").animate({ color: "#181002" }, 400 ); 
	$(this).animate({ color: "#FDF2DE" }, 400 );
	$(this).addClass('on');
});

$("#menu ul li a").hover(
 function() {
		if($(this).hasClass("on")) {
			
		} 
		else {
  			$(this).css("cursor","pointer");
 			$(this).animate({ color: "#FDF2DE" }, 400 );
		}
 },

 function() {
 		if($(this).hasClass("on")) {
			
		} 
		else {
  			$(this).css("cursor","pointer");
			$(this).animate({ color: "#181002" }, 400 );
		}
 }
); 

/*-----------------------------------------------------------*/

/*-----------------------------------------------------------*/
/*-------------------SOUS MENU--------------------------*/
/*-----------------------------------------------------------*/

$("#ss_menu ul li a").click(function() {
	$("#ss_menu ul li a").animate({ color: "#181002" }, 400 ); 
	$(this).animate({ color: "#FDF2DE" }, 400 );
	$(this).addClass('on');
});

$("#ss_menu ul li a").hover(
 function() {
		if($(this).hasClass("on")) {
			
		} 
		else {
  			$(this).css("cursor","pointer");
 			$(this).animate({ color: "#FDF2DE" }, 400 );
		}
 },

 function() {
 		if($(this).hasClass("on")) {
			
		} 
		else {
  			$(this).css("cursor","pointer");
			$(this).animate({ color: "#181002" }, 400 );
		}
 }
); 

/*-----------------------------------------------------------*/





/* controle roll vignettes */
$("span.jakob").hoverIntent(
 function() {
 
 	if($(this).hasClass('selected')) {
		} 
		else {
  	$(this).animate({opacity: "1"});
		}
  },
 function() {
	if($(this).hasClass('selected')) {
		}
		else {
  	$(this).animate({opacity: "0.5"});
		}
 }
);

/*-----------------------------------------------------------*/


/* controle diaporama */
$("#pauseButton").hover(
 function() {
 $(this).animate({ backgroundColor: "#FDF2DE" }, 400 );
 },
 function() {
 $(this).animate({ backgroundColor: "#181002181002 " }, 400 );
 }
); 

/*-----------------------------------------------------------*/

/* changement de niveau claque pour les textes */
/* $("#article_texte").animate({ opacity: "0.6" }, "fast" ); */

$(".tri_date").animate({ opacity: "0.95" }, "fast" );
$(".tri_lettre").animate({ opacity: "0.95" }, "fast" );

$("#gauche_texte").animate({ opacity: "0.9" }, "fast" );


	
   $("#article_texte").hoverIntent({
		sensitivity: 3,
		interval: 200,
		over: article_texte_over,
		timeout: 0,
		out: article_texte_out
	});

	
function article_texte_over(){
/* 	$(this).animate({ opacity: "1" }, "fast" ); */
	$(this).css("z-index", "55");
}


function article_texte_out(){
/* 	$(this).animate({ opacity: "0.6" }, "fast" ); */
	$(this).css("z-index", "35");
}


/* --------------------- */





     
});


    
    
    
    
		









	
	
