// JavaScript Document

$(window).load(function() {
    $('.logo_slideshow').cycle({
		fx:     'fade',
		timeout: 4000,
		delay: -2000,  // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		before: onBefore
	});
	
	
	$('.liste-annee a').click(function() {
		$('.liste-annee a').removeClass("on");
		$(this).addClass("on");
	 }); 	
	displayYear();
	
});
// hide all but the first image when page loads
$(document).ready(function() {
				
	/*Init logos reference*/
	$('.logo_slideshow').show(); 
    $('.logo_slideshow img:gt(0)').hide();
	
	// scroll to top
	$('a.retour-top').click(function(){
	$.scrollTo( 0, 500);
	return false;
	});
	
	/*Affichage des actu*/
    $('.annee').hide();
    $('.annee.active').show();
	
	$('a.actu').click(function(){
	var myActu = $(this).attr("href");
	$('.annee').hide();
	$(myActu).fadeIn('slow');
	displayHideYear();
	$.scrollTo( 0, 500);
	return false;
	});
	
	
});

/*function displayHideYear() {
	 var anneeActu = window.location.href;
	 var anneeActuShow = anneActu.substr(-4,anneeActu.length);
	 alert(anneeActuShow);
}*/
function displayHideYear() {
	 var showHideYearPanel = window.location.href.substr(-5,window.location.href.length); 
	 $(document.getElementById('tab_'+showHideYearPanel)).addClass("on");
	 if (showHideYearPanel=='a2010') {$('.annee').removeClass("active");$('.liste-annee a').removeClass("on");$(document.getElementById('tab_'+showHideYearPanel)).addClass("on");$('#a2010').addClass("active");}
	 if (showHideYearPanel=='a2009') {$('.annee').removeClass("active");$('.liste-annee a').removeClass("on");$(document.getElementById('tab_'+showHideYearPanel)).addClass("on");$('#a2009').addClass("active");}
	 if (showHideYearPanel=='a2008') {$('.annee').removeClass("active");$('.liste-annee a').removeClass("on");$(document.getElementById('tab_'+showHideYearPanel)).addClass("on");$('#a2008').addClass("active");}
	 if (showHideYearPanel=='a2007') {$('.annee').removeClass("active");$('.liste-annee a').removeClass("on");$(document.getElementById('tab_'+showHideYearPanel)).addClass("on");$('#a2007').addClass("active");}
}


// callback fired when each slide transition begins
function onBefore(curr,next,opts) {
    var $slide = $(next);
    var w = $slide.outerWidth();
    var h = $slide.outerHeight();
    $slide.css({
        marginTop: (110 - h) / 2,
        marginLeft: (170 - w) / 2
    });
};

function displayYear() {
	var theDate=new Date()
	$('#year').html(theDate.getFullYear());
}
