$(document).ready(function() {

	function formatTitle(title, currentArray, currentIndex, currentOpts) {
		var result = '<span id="fancybox-title-over">' + title;
		if(currentArray.length > 1)
			result += '<span style="float:right;">'+(currentIndex + 1) + ' sur ' + currentArray.length + '</span>';
		result += '</span>';
		
		return result;
	}


	$('.img').hover(function(){
		$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'89px'},{queue:false,duration:300});
	});
	
	$("a.group[href$=.jpg],a[href$=.png],a[href$=.gif]").fancybox({
		'titlePosition'  : 'over',
		'padding'           : 0,
		'autoScale'     	: true,
		'titleFormat'		: formatTitle,
		'cyclic' : true,
		'onComplete'	:	function() {
			$("#fancybox-wrap").hover(function() {
				$("#fancybox-title").show();
			}, function() {
				$("#fancybox-title").hide("slow");
			});
		}
	});
	
	$("a.group[href$=.swf]").fancybox({
		'titlePosition'  : 'over',
		'padding'           : 0,
		'autoScale'     	: true,
		'width'		: 880,
		'height' : 180,
		'onComplete'	:	function() {
			$("#fancybox-wrap").hover(function() {
				$("#fancybox-title").show();
			}, function() {
				$("#fancybox-title").hide("slow");
			});
		}
	});
	
	// on mouse over
	$("ul#primary-nav li a").hover(function () {
		$(this).animate({
			color: '#00a99d'
		}, 200);
	},
	// on mouse out
	function () {
		$(this).stop().animate({
			color: '#464646'
		}, 300);
	});
	
	// on mouse over
	$("ul.clearfix li a").hover(function () {
		$(this).animate({
			color: '#00a99d'
		}, 200);
	},
	// on mouse out
	function () {
		if($(this).hasClass('currentpage')) { newCol = '#464646'; }
		else { newCol = '#737373'; }
		$(this).stop().animate({
			color: newCol
		}, 300);
	});
	
	// animate logo background color
	changeLogoColor1();
	
	function changeLogoColor1()
	{
		$('#logo img').animate({ backgroundColor: '#00a99d' }, 2000);
		changeLogoColor2();
	}
	function changeLogoColor2()
	{
		$('#logo img').animate({ backgroundColor: '#ffffff' }, 2000);
		changeLogoColor1();
	}	
});

