/* ----------------- Jquery ------------------*/
$(document).ready(function(){	
	//-- Pour cacher/afficher les divs correspondant au titre h1 --
	$('h1').click(function(){
		if($('#' + $(this).attr('class')).css('display') != 'block')
			$('#' + $(this).attr('class')).show('slow');
		else
			$('#' + $(this).attr('class')).slideUp('slow');
	});
	
	//-- Pour cacher/afficher les divs correspondant au titre h2 --
	$('h2, h3').click(function(){
		if($('#' + $(this).attr('class')).css('display') != 'block')
			$('#' + $(this).attr('class')).css({'display' : 'block'});
		else
			$('#' + $(this).attr('class')).css({'display' : 'none'});
	});
	
	
	/* Pour les legendes sur les images */
	$('img.screen').load(function(){
		$('div.screen_jeu').css({'position' : 'relative'});
		$('div.screen_description').css({'position' : 'absolute', 'bottom' : '0px', 'left' : '0px', 'display' : 'none', 'background-color' : 'black', 
										'font-size' :'0.8em', 'color' : 'white', 'margin-top' : parseInt($('.screen').css('margin-top')),
										'margin-bottom' : parseInt($('.screen').css('margin-bottom'))+10, 'margin-left' : parseInt($('.screen').css('margin-left'))+1,
										'margin-right' : parseInt($('.screen').css('margin-right'))-1, 'border-top' : '1px solid #014373', 'border-bottom' : '1px solid #014373'});
		$('div.screen_legende').css({'padding' : '2px 2px 2px 4px'});
		
		$('div.screen_description').each(function(){  
			$(this).css('opacity', 0.7);  
			$(this).css('width', $(this).siblings('img').width());  
			$(this).parent().css('width', $(this).siblings('img').width());  
			$(this).css('display', 'block');  
		});  
	  
		$('div.screen_jeu').hover(function(){  
			$(this).children('.screen_description').stop().fadeTo(500, 1);  
		}, function(){  
			$(this).children('.screen_description').stop().fadeTo(500, 0.7);  
		});  
	});
	
	
	/* Pour les barre de progression */
	$(".h1_connexion").each(function(){
		$('#reponse').css({'display' : 'none'});
		$('div.barre').css({'position' : 'relative'});
		$('div.progressionBarre').css({'position' : 'absolute', 'bottom' : '0px', 'left' : '0px', 'display' : 'none', 'margin-top' : parseInt($('.barre').css('margin-top')),
									'margin-bottom' : parseInt($('.barre').css('margin-bottom')), 'margin-left' : parseInt($('.barre').css('margin-left')),
									'margin-right' : parseInt($('.barre').css('margin-right'))});
									
		$(".progressionBarre").animate({'width' : '700'}, 2500, 0, function(){
			$('#h1_connexion').animate({'opacity' : 0}, 500, 0, function(){
				$('#h1_connexion').css({'display' : 'none'});
				$('#reponse').css({'display' : 'block'});
				
				$('#formulaire').each(function(){
					$('#formulaire').submit();
				});
			});
		}); 
	});
	
	$('li.communaute').hover(function(){
		$(this).css({'position' : 'relative'});
	});
});

/* ----------------- Javascript only ------------------*/
/* Pour avoir plusieurs submit dans un formulaire */
function multiSubmit(id, lien){
	document.getElementById(id).action = lien;
	document.getElementById(id).submit();
}
