$(document).ready(function() {
	
	/* Fonction de cache/apparition du programme page competences */
	if ($("dd.programme_complet")) {
		var i = 0;
		$("dd.programme_complet:gt(0);")
			.hide();
		$("dt")
			.append("<a href='#"+i+"' name='#"+i+"' class='lien_bouton_developp'>Détails</a>");
		$(".lien_bouton_developp")
			.click(function(){
				$(this)
					.parent()
					.parent()
					.find("dd.programme_complet")
					.slideToggle();
			});
	} 
	
	if ($('#body_accueil')) {
		
		var slides = $('#ajaxsrc a');

		var nbSlides = slides.length + 1;
		
		var i = 1;
		
		slides.each(function(ind, el) {
			
			var img = new Image();
			
			$(img)
				.load(function() {
					$(el).html(this);
					$('#tagline_preview').append($(el));
					i++;
					makeHomeSlider();
				})
				.attr({
					src: $(el).text(),
					title: $(el).attr('rel'),
					alt: $(el).attr('rel'),
					width: '379',
					height: '239'
					});
			
		});
		
		$('#ajaxsrc').remove();
		
		function makeHomeSlider() {
		
			if (i == nbSlides) {
				$('#tagline_preview').nivoSlider({
					directionNav:true,
					effect:'fade',
					controlNav:false,
					pauseOnHover:true,
					directionNavHide:false,
					pauseTime:6000,
					animSpeed:500,
					captionOpacity:0.7
				});
			}
			
		}
	} 
	
	if ($(".realisations")) {
		
		$(".realisations .image a").hover(
			function() {
				$(this).find("span.hover").stop().fadeTo('normal', 1).show();
			},
			
			function() {
				$(this).find("span").stop().fadeTo('normal', 0);
			}
			
		);
		
	} 
	
	if ($('#imageReal')) {
		
		$('#imageReal').nivoSlider({
			directionNav:false,
			effect:'fade',
			controlNav: false,
		});
		
	} 

});
