var mover = 1;
var last;
var modulo=30;

function mainmenu(){
$("#nav ul").css({display: "none"}); // Opera Fix
$("#nav li").hover(function(){
		$(this).find('ul:first:hidden').css({visibility: "visible",display: "none"}).show();
		},function(){
		$(this).find('ul:first').css({display: "none"});
		});
};


$('document').ready(function(){
	mainmenu();
	$("a.light").lightbox();
	
	if ($('#menu').attr('rel')){
		var bg = $('#menu').attr('rel');
		//alert(bg);
		$('body').css({backgroundImage:'url('+bg+')'});	
	}
	
	$('.fameElement').each(function(){
		if($(this).prev().length>0){
			var haut = $(this).prev().position().top+$(this).prev().height();
			
			$(this).css({'top':haut+"px"});
			//alert(haut);
		}
	});
	$('#fame').css({'visibility':'visible'});
		setInterval('fameAnimation()',40);
		last= $('.fameElement').last();
		first=$('.fameElement').first();
		modulo=first.height();
		$('.fameElement a').hover(function(){
			mover=0;
		},function(){
			mover=1;
		});
		
});

function fameAnimation (){
	$('#innerFame').css({'top':$('#innerFame').position().top-mover+"px"});
	if ($('#innerFame').position().top==-modulo){
		first.css({'top':last.position().top+last.last().height()+"px"});
		last=first;
		if (first.next().length>0){
			first=first.next();
		}else {
			first=$('.fameElement').first();
		}
		modulo+=first.height();
	}/*if ($('#innerFame').position().top==-400){
		//alert("redo");
		$('#innerFame').css({'top':"0px"});
		$('.fameElement').each(function(){
			$(this).css({'top':($(this).position().top-400)+"px"});
			//
		});
		modulo=first.height();
	}*/


}