﻿$( function() { 

	function moveDiv() {
	
		direction = 1;
	
		function move() {
			if ( direction == 1 ) {
				$('#animation_index_2').spriteAnimation( {
					numberOfLoops: 1,
					direction: 'ltr',
					startFrame: 0,
					endFrame: 5,
					interval: 70
				} );
				direction = -1;
			}
			else {
				$('#animation_index_2').spriteAnimation( {
					numberOfLoops: 1,
					direction: 'gtr',
					startFrame: 5,
					endFrame: 0,
					interval: 70
				} );
				direction = 1;
			}
		}
	
		function go() {
			move();
			setTimeout( go, 500 );
		}
		go();
		
	}
	moveDiv();
	
	function special_etape_final3() {
		$( '#animation_special_8' ).animate( { marginTop : '+=450px' },350 ).animate( { marginLeft : '+=210px', marginTop : '-=250px' },400 ).animate( { marginLeft : '+=160px', marginTop : '+=250px' },500 ).animate( { marginLeft : '+=160px', marginTop : '-=150px' }, 600 ).animate( { marginLeft : '+=150px' , marginTop :'+=130px ' } );
	}

	function special_etape_final2() {
		$( '#animation_index' ).fadeIn( 'slow' );
		setTimeout( special_etape_final3, 0 );
	}

	function special_etape_final1() {
		$( '#bulles' ).fadeIn( 'slow' );
		$( '#animation_special_1, #animation_special_2, #animation_special_3, #animation_special_4, #animation_special_5, #animation_special_6' ).fadeOut( 'slow' );
		setTimeout( special_etape_final2, 1000 );
	}

	function special_etape5_bis(){
		$( '#animation_special_1' ).animate( { marginTop : '+=10px' }, 500 ).animate( {  marginTop : '-=10px' }, 500 );
		$( '#animation_special_2' ).animate( { marginTop : '+=10px' }, 500 ).animate( {  marginTop : '-=10px' }, 500 );
		$( '#animation_special_3' ).animate( { marginTop : '+=10px' }, 500 ).animate( {  marginTop : '-=10px' }, 500 );
		$( '#animation_special_5' ).animate( { marginTop : '+=10px' }, 500 ).animate( {  marginTop : '-=10px' }, 500 );
		$( '#animation_special_6' ).animate( { marginTop : '+=10px' }, 500 ).animate( {  marginTop : '-=10px' }, 500 );
		$( '#animation_special_4' ).animate( { marginLeft : '+=40px'}, 100 );
		$( '#animation_special_4' ).animate( { marginTop : '+=10px' }, 500 ).animate( {  marginTop : '-=10px' }, 500 );
		setTimeout( special_etape_final1, 500 );
	}

	function special_etape6() {
		$( '#animation_special_5' ).animate( { marginTop : '+=10px' }, 500 ).animate( {  marginTop : '-=10px' }, 500 );
		$( '#animation_special_1' ).animate( { marginTop : '+=10px' }, 500 ).animate( {  marginTop : '-=10px' }, 500 );
		$( '#animation_special_2' ).animate( { marginTop : '+=10px' }, 500 ).animate( {  marginTop : '-=10px' }, 500 );
		$( '#animation_special_3' ).animate( { marginTop : '+=10px' }, 500 ).animate( {  marginTop : '-=10px' }, 500 );
		$( '#animation_special_6' ).animate( { opacity : 0.5, width : '+=50px', height : '+=50px' }, 500 ).animate( { opacity : 1, width : '-=50px', height : '-=50px' }, 500 ).animate( { marginLeft : '-=280px', marginTop : '-=580px'  },250 ).animate( { marginLeft : '-=520px', marginTop: '+=360px' } );
		setTimeout( special_etape5_bis, 1600 );
	}

	function special_etape4_bis(){
		$( '#animation_special_5' ).animate( { marginTop : '+=10px' }, 500 ).animate( { marginTop : '-=10px' }, 500 );
		$( '#animation_special_2' ).animate( { marginTop : '+=10px' }, 500 ).animate( { marginTop : '-=10px' }, 500 );
		$( '#animation_special_1' ).animate( { marginTop : '+=10px' }, 500 ).animate( { marginTop : '-=10px' }, 500 );
		$( '#animation_special_3' ).animate( { marginTop : '+=10px' }, 500 ).animate( { marginTop : '-=10px' }, 500 );
		$( '#animation_special_4' ).animate( { marginLeft : '-=100px', marginTop : '-=400px' },350 ).animate( { marginLeft : '-=380px', marginTop : '+=480px' }, 500 );
		setTimeout( special_etape6, 500 );
	}

	function special_etape5() {
		$( '#animation_special_1' ).animate( { marginTop : '+=10px' }, 500 ).animate( { marginTop : '-=10px' }, 500 );
		$( '#animation_special_2' ).animate( { marginTop : '+=10px' }, 500 ).animate( { marginTop : '-=10px' }, 500 );
		$( '#animation_special_3' ).animate( { marginTop : '+=10px' }, 500 ).animate( { marginTop : '-=10px' }, 500 );
		$( '#animation_special_5' ).animate( { opacity : 0.5, width : '+=50px', height : '+=50px' }, 500 ).animate( { opacity : 1, width : '-=50px', height : '-=50px' }, 500 ).animate( { marginLeft : '-=320px' , marginTop : '-=100px' }, 200 );
		setTimeout( special_etape4_bis, 1050 );
	}

	function special_etape2_bis(){
		$( '#animation_special_2' ).animate( { marginLeft : '-=130px' },350 );
		setTimeout( special_etape5, 500 );
	}

	function special_etape4() {
		$( '#animation_special_1' ).animate( { marginTop : '+=10px' }, 500 ).animate( { marginTop : '-=10px' }, 500 );
		$( '#animation_special_3' ).animate( { marginTop : '+=10px' }, 500 ).animate( { marginTop : '-=10px' }, 500 );
		$( '#animation_special_4' ).animate( { opacity : 0.5, width : '+=100px', height : '+=100px' }, 350 ).animate( { opacity : 1, width : '-=260px', height : '-=260px', marginLeft : '+=60px' , marginTop : '+=60px'}, 500 );
		$( '#animation_special_4' ).animate( { opacity : 1, width : '+=160px' , height : '+=160px', marginTop : '-=60px ', marginLeft : '-=60px'  }, 500 ).animate( { marginTop : '-=180px' , marginLeft : '-=240px'}, 200 ); 
		setTimeout( special_etape2_bis, 1450 );
	}
	
	function special_etape3() {
		$( '#animation_special_1' ).animate( { marginTop : '+=10px' }, 500 ).animate( { marginTop : '-=10px' }, 500 );
		$( '#animation_special_3' ).animate( { opacity : 0.5}, 300 ).animate( { opacity : '1' , width : '+=300px' , height : '+=300px' , marginLeft : '-=500px' , marginTop : '-=130px'}, 550).animate ( {  width : '-=300px' , height : '-=300px' , marginLeft : '-=120px' , marginTop : '-=80px' } , 550);
		setTimeout( special_etape4, 500 );
	}
	
	function special_etape2() {
		$( '#animation_special_1' ).animate( { marginTop : '+=10px'}, 500 ).animate( { marginTop: '-=10px' }, 500 );
		$( '#animation_special_2' ).animate( { opacity : 0.5, marginLeft : '-300px' , marginTop : '-210px' }, 480 ).animate( { opacity : 1 }, 180 );
		setTimeout( special_etape3, 500 );
	}	
	
	function special_etape1() {
		$( '#animation_special_1' ).animate( { opacity : 0.5, marginLeft : '-350px' , marginTop : '-230px' }, 800 ).animate( { opacity : 1, marginLeft : '-=150px' , marginTop : '+=125px' }, 200);
		setTimeout( special_etape2, 600 );
	}
		
	$( '#bulles, #animation_index' ).hide();
	$( '#animation_special_1, #animation_special_2, #animation_special_3, #animation_special_4, #animation_special_5, #animation_special_6' ).animate( { opacity : 0 }, 0 );
	setTimeout( special_etape_final2, 18300 );
	
	$( '#menu1' ).bind( 'mouseover', function(){ $( '#menu1' ).animate( { top:'-5px', left:'+5px'} ); } );
	$( '#menu1' ).bind( 'mouseout', function(){ $( '#menu1' ).animate( { top:'0px', left:'0px'} ); } );
	
	$( '#menu2' ).bind( 'mouseover', function(){ $( '#menu2' ).animate( { top:'-5px', left:'+56px'} ); } );
	$( '#menu2' ).bind( 'mouseout', function(){ $( '#menu2' ).animate( { top:'0px', left:'51px'} ); } );

	$( '#menu3' ).bind( 'mouseover', function(){ $( '#menu3' ).animate( { top:'-5px', left:'+104px'} ); } );
	$( '#menu3' ).bind( 'mouseout', function(){ $( '#menu3' ).animate( { top:'0px', left:'99px'} ); } );

	$( '#menu4' ).bind( 'mouseover', function(){ $( '#menu4' ).animate( { top:'-5px', left:'+154px'} ); } );
	$( '#menu4' ).bind( 'mouseout', function(){ $( '#menu4' ).animate( { top:'0px', left:'149px'} ); } );

	$( '#menu5' ).bind( 'mouseover', function(){ $( '#menu5' ).animate( { top:'-5px', left:'+201px'} ); } );
	$( '#menu5' ).bind( 'mouseout', function(){ $( '#menu5' ).animate( { top:'0px', left:'196px'} ); } );

	$( '#menu6' ).bind( 'mouseover', function(){ $( '#menu6' ).animate( { top:'-5px', left:'+252px'} ); } );
	$( '#menu6' ).bind( 'mouseout', function(){ $( '#menu6' ).animate( { top:'0px', left:'247px'} ); } );
	
	
	
	
	
	
	$( '#menu1EN' ).bind( 'mouseover', function(){ $( '#menu1EN' ).animate( { top:'-25px', left:'+5px'} ); } );
	$( '#menu1EN' ).bind( 'mouseout', function(){ $( '#menu1EN' ).animate( { top:'-20px', left:'0px'} ); } );
	
	$( '#menu2EN' ).bind( 'mouseover', function(){ $( '#menu2EN' ).animate( { top:'-25px', left:'+52px'} ); } );
	$( '#menu2EN' ).bind( 'mouseout', function(){ $( '#menu2EN' ).animate( { top:'-20px', left:'47px'} ); } );

	$( '#menu3EN' ).bind( 'mouseover', function(){ $( '#menu3EN' ).animate( { top:'-25px', left:'+100px'} ); } );
	$( '#menu3EN' ).bind( 'mouseout', function(){ $( '#menu3EN' ).animate( { top:'-20px', left:'95px'} ); } );

	$( '#menu4EN' ).bind( 'mouseover', function(){ $( '#menu4EN' ).animate( { top:'-25px', left:'+149px'} ); } );
	$( '#menu4EN' ).bind( 'mouseout', function(){ $( '#menu4EN' ).animate( { top:'-20px', left:'144px'} ); } );

	$( '#menu5EN' ).bind( 'mouseover', function(){ $( '#menu5EN' ).animate( { top:'-25px', left:'+197px'} ); } );
	$( '#menu5EN' ).bind( 'mouseout', function(){ $( '#menu5EN' ).animate( { top:'-20px', left:'192px'} ); } );

	$( '#menu6EN' ).bind( 'mouseover', function(){ $( '#menu6EN' ).animate( { top:'-25px', left:'+248px'} ); } );
	$( '#menu6EN' ).bind( 'mouseout', function(){ $( '#menu6EN' ).animate( { top:'-20px', left:'243px'} ); } );

	var flashvars = {};
	var params = { wmode  : "transparent" };
	var attributes = {};
	
	var flash2 = function() {
		swfobject.embedSWF( 'images/flash/animText.swf', 'textFlash', '188', '26', '9.0.0', 'images/flash/animText.swf', flashvars, params, attributes );
	};
	var flash3 = function() {
		swfobject.embedSWF( 'images/flash/animSundis.swf', 'logoFlash', '270', '113', '9.0.0', 'images/flash/animSundis.swf', flashvars, params, attributes );
	};
	
	swfobject.embedSWF( 'images/flash/animPrincipal.swf', 'animPrincipal', '750', '307', '9.0.0', 'images/flash/animPrincipal.swf', flashvars, params, attributes );
	setTimeout( flash2, 18300);
	setTimeout(flash3,18300);

	$( '#popup' ).colorbox({width:"50%", inline:true, href:"#popupContact"});
	
} );

