$(document).ready(function() {

	/* bandeau opacity */
	$(".opacity").css({
		backgroundColor: '#fff',
		display: 'block',
		height: '44px',
		opacity: 0.5
	});
	
	/* annonceurs */
	$("#annonceurs").css('overflow', 'hidden');

	var top1 = $("#annonceurs .content").offset().top;
	var heightDiv = $("#annonceurs").height();
	var heightTxt = $("#annonceurs .content").height();
	var differenceTailleInitial = parseInt(heightTxt) - parseInt(heightDiv);

	$("#scroll_top").mouseover(
		function(){
				
			if(heightTxt > heightDiv)
			{
				var top2 = $("#annonceurs .content").offset().top;
				var differenceTaille = parseInt(top1) - parseInt(top2);
							
				if(differenceTaille != 0)
					$("#annonceurs .content").animate({"top": "+="+differenceTaille+"px"}, 4000);
			}
		}
	);
	$("#scroll_top").mouseout(
		function() {
			$("#annonceurs .content").stop();
		}
	);
	
	$("#scroll_bas").mouseover(
		function() {
			var top2 = $("#annonceurs .content").offset().top;
			var differenceTaille = parseInt(top1) - parseInt(top2);
			
			if(heightTxt > heightDiv)
			{
				var top2 = $("#annonceurs .content").offset().top;
				var differenceTaille = parseInt(top1) - parseInt(top2);
			
				if(parseInt(top1) == parseInt(top2))
					$("#annonceurs .content").animate({"top": "-="+differenceTailleInitial+"px"}, 4000);
				else if( differenceTaille < differenceTailleInitial)
				{
					differenceTaille = differenceTailleInitial - differenceTaille;
					$("#annonceurs .content").animate({"top": "-="+differenceTaille+"px"}, 4000);
				}
			}
		}
	);
	$("#scroll_bas").mouseout(
		function() {
			$("#annonceurs .content").stop();			
		}	
	);
	
});