/*----------------------------------------------------------------------------- 
GLOBALS Javascript 
version:   	1.0 
date:      	15/07/2010 
author: 	SequenceDigitale / Spin Production
version history: /js/
-----------------------------------------------------------------------------*/
	

/* JQUERY */
	
	/* TARGET=_BLANK */
		$("a[rel='external'], a[rel='upload']").attr('target', '_blank');
		
	/* INDEX MENU */		
		$("#index #menu a").removeClass('noscript');
		$("#index #menu span").css({"opacity": 0, "visibility": "visible"});
		$("#index #menu span").hover(
			function(){
				$(this).stop().animate({opacity: 1}, 300);				
				var i = $("#index #menu span").index(this);
				$("#navigation ul li").eq(i).find("a").addClass("active");
				
			}
		);		

		$("#index #menu span").mouseout(
			function(){
				$(this).stop().animate({opacity: 0}, 300);
				$("#navigation a").removeClass("active");
			}
		);
		
		$("#navigation ul li").hover(
			function(){
				var i = $("#navigation ul li").index(this);
				$("#index #menu span").eq(i).hover();
			}
		);
		
		$("#navigation ul li").mouseout(
			function(){
				var i = $("#navigation ul li").index(this);
				$("#index #menu span").eq(i).mouseout();
			}
		);
		
	/* CHARGER LES IMAGES */
		$("#content div.slide img").css({"opacity": 0});
		$(document).ready(function() {
			$("#content div.slide img").animate({"opacity": 1}, 1000);
		});
		
	/* MENU SECTION */
		var menuHeight = $("#menu ul").height();
		var boxHeight = $("#menu #carrousel").height();
		var p = 0;
		
		if( boxHeight < menuHeight ){
			$("#menu").removeClass('noscript');			
			menuHeight = $("#menu ul").height();
			boxHeight = $("#menu #carrousel").height();
			
			var pages = Math.ceil(menuHeight / boxHeight)
			
			$("#menu .top").click( 
				function(){
					if( --p < 0 ) p = 0;
					$("#menu ul").stop().animate({"marginTop" : (0 - (p*boxHeight)) + "px"}, 1000);
				}
			);
			
			$("#menu .down").click( 
				function(){
					if( ++p >= pages ) p = pages-1;				
					$("#menu ul").stop().animate({"marginTop" : (0 - (p*boxHeight)) + "px"}, 1000);
				}
			);
			
			
		}
		
		

		
		
		
			
