$(document).ready(function() {
	
	function subsubmenu(){
		$id = $(this).attr('subMenu');
		$('#' + $id).show();
		
		var level = parseInt( $(this).attr('level') );
		var position = $(this).position();
		
		$('#' + $id).css({
			top: position.top + 'px' ,
			marginLeft:'199px',
			width: '199px',
			position:'absolute',
			zIndex:99
		});
	}
	
	$('.blocMenu .menuItem').hover(function() {
			$('.ssmenuItem').hide();
			$('.submenuItem').hide();
			$id = $(this).attr('subMenu');
			
			$('#' + $id).css({
				top: '33px',
				marginLeft:'8px',
				width: '199px',
				position:'absolute',
				zIndex:99
			});
			
			$('#' + $id).show();
	});
	
	$('.ssmenuItem').mouseleave(function() {
		$('.ssmenuItem').fadeOut();
	});
	
	$( '.sousMenu' ).hover( subsubmenu );

	
	$('#right .previous').bind('click', function() {
		var left = parseInt($('#right .list .wrapper').offset().left) + 900;
		if (left <= 900)
		{
			$('#right .list .wrapper').animate({
				'marginLeft': '+=910px'
			});
		}
	});
	
	$('#right .next').bind('click', function() {
		var maxLeft = (($('#right .list .wrapper div.bloc').length/6)*900)*-1;
		var left = parseInt($('#right .list .wrapper').offset().left) - 900;
		if (left <= 0 && left >= maxLeft)
		{
			$('#right .list .wrapper').animate({
				'marginLeft': '-=910px'
			});
		}
	});
});
