/**
 * @author Florent
 */
$(document).ready(function(){
init ();
animation_logos ();
clear ();
 });


function init () {
placement_logos ();
$('#retour_estac').css({'opacity': '0', "left":(((window.screen.width)/2)-600) });
$('#logo_estac_anim').css({
		'top':((window.screen.height) / 2)-400,
		'left':((window.screen.width) / 2)-300,
		})
	$('#infos_generales').css({'opacity' : '0'});
	$('#choisir_profil').css({'opacity' : '0'});
	$('#fond_affiche').css({'opacity' : '0', "top":(((window.screen.height)/2)-550)});
	$('#dates *').css({'opacity' : '0'});
	$('#tarifs *').css({'opacity' : '0'});
	$('#plan_du_stade *').css({'opacity' : '0'});
	$('#abonnes *').css({'opacity' : '0'});
	$('#futur_abo *').css({'opacity' : '0'});
	$('#etudiants *').css({'opacity' : '0'});
	$('#ce *').css({'opacity' : '0'});
	$('#contact *').css({'opacity' : '0'});
	$('#info_abo *').css({'opacity' : '0'});
	$('#familles *').css({'opacity' : '0'});
	$('#options *').css({'opacity' : '0'});
	$('#estacfrlink').css({'opacity':'0'});
	$('#datelink').css({'opacity':'0'});
	$('#souscription').css({'opacity':'0'});	
}
 
 function placement_logos (){
 	for (var i = 1; i <= 10; i++) {

		if((i%2)==(1)){
		$('#' + i + '').css({
			'top': (Math.random() * (window.screen.height))/3,
			'left': (Math.random() * (window.screen.width))/4,
			
		});
		}
		else {
		$('#' + i + '').css({
			'top': (Math.random() * (window.screen.height))/3,
			'right': (Math.random() * (window.screen.width))/4,
		});	
		}
	
 };
 };
 
 function animation_logos(){
 $.timer(6000, function (timer){
 transistion ();
timer.stop();
 })	
 $.timer(7000, function (timer) {
 arrive_logos();
 timer.stop();
 });
$.timer(14000, function (timer) {
arrive_estac ();
timer.stop();
});
$.timer(22500, function (timer) {
fin_anim_bg ();
timer.stop();
});
$.timer(24500, function (timer) {
fleches_guide ();
timer.stop();
});

 };
 
 function arrive_logos(){
 		$('#1').animate({
 			opacity: 1,
 		}, 500, function(){
 			$('#1').animate({
 				opacity: 0,
 			}, 500, function(){
				$('#2').animate({
					opacity: 1,
				}, 500, function(){
				$('#2').animate({
					opacity: 0,
				}, 500, function(){
				$('#3').animate({
					opacity: 1,
				}, 500, function(){
				$('#3').animate({
					opacity: 0,
				}, 500, function(){
				$('#4').animate({
					opacity: 1,
				}, 500, function(){
				$('#4').animate({
					opacity: 0,
				}, 500, function(){
				$('#5').animate({
					opacity: 1,
					top: (window.screen.height/2)-200,
					left:(window.screen.width/2)-600,
				}, 500, function(){
				$('#5').animate({
					opacity: 1,
					top: (window.screen.height/2)-200,
					left:(window.screen.width/2)-600,
				}, 2000, function(){
				$('#5').animate({
					opacity: 0,
				}, 1500, function(){
				$('#6').animate({
					opacity: 1,
				}, 500, function(){
				$('#6').animate({
					opacity: 0,
				}, 500, function(){
				$('#7').animate({
					opacity: 1,
				}, 500, function(){
				$('#7').animate({
					opacity: 0,
				}, 500, function(){
				$('#8').animate({
					opacity: 1,
				}, 500, function(){
				$('#8').animate({
					opacity: 0,
				}, 500, function(){
				$('#9').animate({
					opacity: 1,
				}, 500, function(){
				$('#9').animate({
					opacity: 0,
				}, 500, function(){
				$('#10').animate({
					opacity: 1,
				}, 500, function(){
				$('#10').animate({
					opacity: 0,
				}, 500)
			})
			})
			})
			})
			})
			})
			})
			})
			})
			})
			})
			})
			})
			})
			})
			})
			})
			})
			})
			})

 	};
	
	 
function repart_logos (){		
	for (var i = 1; i <= 10; i++) {
		$('#' + i + '').animate({
			opacity:0,
			left:-(Math.random() * 3000),
			top:(Math.random() * 3000),
			},3000)		
	
		};
 	
 	 };	
 
function arrive_estac () {
	$('#logo_estac_anim').animate({
		opacity:1,
	},8000, function(){
		$(this).animate({
		opacity:0,
		},1000)
	})
};

function fin_anim_bg () {
	$('#fond_beton').animate({opacity:0},500,function () {
	$(this).css ({
		'background':'url(img/bg_anim_fin.jpg) 50% 50%',
		'min-height':'100%',
		'min-width':'100%',
		'top':'0',
		'left':'0',
	})
	}).animate({opacity:1},1000, function () {
		$('#retour_estac').animate({
			opacity:1,
		},3000)
		
	})
	};
	
function fleches_guide (){
	$('#infos_generales').animate({
		opacity:1,	
	},200)
	$('#choisir_profil').animate({
		opacity:1,	
	},200)
	
	$.timer(2000, function (timer) {
	fleches_anim ();
	})
}

function fleches_anim () {
	$('#infos_generales').animate({
		top: '-=10',
		opacity:1,
		},500,'easeInQuad').animate({
		top: '+=10',
		opacity:0.9,	
		},500,'easeInQuad');
	$('#choisir_profil').animate({
		bottom : '-=10',
		opacity:1,
	},500,'easeInQuad').animate({
		bottom : '+=10',
		opacity:0.9,
	},500,'easeInQuad');
	
}


function date () {
	
	
	$('#main_container *').animate({
		left:-2000,
		opacity:0,
	},100);
	$('#dates').animate({
		opacity : 1,
		left:(((window.screen.width)/2)-300) ,
		},500, function (){
	$('#dates *').animate({
		opacity : 1,
		left:(((window.screen.width)/2)-300) ,
		},500);
	});
	deplacement_affiche () ;
	$('#fond_beton').animate({opacity:0.8},500,function () {
	$(this).css ({
		'background':'url(img/body_bg.jpg) 50% 50%',
		'min-height':'100%',
		'min-width':'100%',
		'top':'0',
		'left':'0',
	})
	}).animate({opacity:1},500);
	$("#fond_beton").removeAttr("background")
	$('#fond_affiche').animate({opacity:1},100);
}


function tarifs () {

	$('#main_container *').animate({
		left:-2000,
		opacity:0,
	},100);
	$('#tarifs').animate({
		opacity : 1,
		left:(((window.screen.width)/2)-300) ,
		},500, function (){
	$('#tarifs *').animate({
		opacity : 1,
		left:0,
		},500);
	});
	deplacement_affiche () ;
	$('#fond_beton').animate({opacity:0.8},500,function () {
	$(this).css ({
		'background':'url(img/body_bg.jpg) 50% 50%',
		'min-height':'100%',
		'min-width':'100%',
		'top':'0',
		'left':'0',
	})
	}).animate({opacity:1},500);
	$("#fond_beton").removeAttr("background")
	$('#fond_affiche').animate({opacity:1},100);
}

function options () {

	$('#main_container *').animate({
		left:-2000,
		opacity:0,
	},100);
	$('#options').animate({
		opacity : 1,
		left:(((window.screen.width)/2)-300) ,
		},500, function (){
	$('#options *').animate({
		opacity : 1,
		left:0,
		},500);
	});
	deplacement_affiche () ;
	$('#fond_beton').animate({opacity:0.8},500,function () {
	$(this).css ({
		'background':'url(img/body_bg.jpg) 50% 50%',
		'min-height':'100%',
		'min-width':'100%',
		'top':'0',
		'left':'0',
	})
	}).animate({opacity:1},500);
	$("#fond_beton").removeAttr("background")
	$('#fond_affiche').animate({opacity:1},100);
}

function plan_du_stade(){
	$('#main_container *').animate({
		left: -2000,
		opacity: 0,
	}, 100);
	$('#plan_du_stade').animate({
		opacity: 1,
		left: (((window.screen.width)/2)-300),
	}, 500, function(){
		$('#plan_du_stade *').animate({
			opacity: 1,
			left: 0,
		}, 500);
	});
	deplacement_affiche();
	$('#fond_beton').animate({
		opacity: 0.8
	}, 500, function(){
		$(this).css({
			'background': 'url(img/body_bg.jpg) 50% 50%',
			'min-height': '100%',
			'min-width': '100%',
			'top': '0',
			'left': '0',
		})
	}).animate({
		opacity: 1
	}, 500);
	$("#fond_beton").removeAttr("background")
	$('#fond_affiche').animate({
		opacity: 1
	}, 100);
}



function info_abo(){
	$('#main_container *').animate({
		left: -2000,
		opacity: 0,
	}, 100);
	$('#info_abo').animate({
		opacity: 1,
		left: (((window.screen.width)/2)-300),
	}, 500, function(){
		$('#info_abo *').animate({
			opacity: 1,
			left: 0,
		}, 500, function (){
			$('#estacfrlink').css({'opacity':'0'});
	        $('#datelink').css({'opacity':'0'});
			$('#souscription').animate({left :120},1);			
			$('#estacfrlink').animate({left :420,opacity:0},1);
			$('#datelink').css({left: 420 , opacity : 0},1);	
		});
	});
	deplacement_affiche();
	$('#fond_beton').animate({
		opacity: 0.8
	}, 500, function(){
		$(this).css({
			'background': 'url(img/body_bg.jpg) 50% 50%',
			'min-height': '100%',
			'min-width': '100%',
			'top': '0',
			'left': '0',
		})
	}).animate({
		opacity: 1
	}, 500);
	$("#fond_beton").removeAttr("background")
	$('#fond_affiche').animate({
		opacity: 1
	}, 100);

}

function abonnes(){
	$('#main_container *').animate({
		left: -2000,
		opacity: 0,
	}, 100);
	$('#abonnes').animate({
		opacity: 1,
		left: (((window.screen.width)/2)-300),
	}, 500, function(){
		$('#abonnes *').animate({
			opacity: 1,
			left: 0,
		}, 500);
	});
	deplacement_affiche();
	$('#fond_beton').animate({
		opacity: 0.8
	}, 500, function(){
		$(this).css({
			'background': 'url(img/body_bg.jpg) 50% 50%',
			'min-height': '100%',
			'min-width': '100%',
			'top': '0',
			'left': '0',
		})
	}).animate({
		opacity: 1
	}, 500);
	$("#fond_beton").removeAttr("background")
	$('#fond_affiche').animate({
		opacity: 1
	}, 100);
	link_alive ();
}

function futur_abo(){
	$('#main_container *').animate({
		left: -2000,
		opacity: 0,
	}, 100);
	$('#futur_abo').animate({
		opacity: 1,
		left: (((window.screen.width)/2)-300),
	}, 500, function(){
		$('#futur_abo *').animate({
			opacity: 1,
			left: 0,
		}, 500);
	});
	deplacement_affiche();
	$('#fond_beton').animate({
		opacity: 0.8
	}, 500, function(){
		$(this).css({
			'background': 'url(img/body_bg.jpg) 50% 50%',
			'min-height': '100%',
			'min-width': '100%',
			'top': '0',
			'left': '0',
		})
	}).animate({
		opacity: 1
	}, 500);
	$("#fond_beton").removeAttr("background")
	$('#fond_affiche').animate({
		opacity: 1
	}, 100);
	link_alive ();
}


function familles(){
	$('#main_container *').animate({
		left: -2000,
		opacity: 0,
	}, 100);
	$('#familles').animate({
		opacity: 1,
		left: (((window.screen.width)/2)-300),
	}, 500, function(){
		$('#familles *').animate({
			opacity: 1,
			left: 0,
		}, 500);
	});
	deplacement_affiche();
	$('#fond_beton').animate({
		opacity: 0.8
	}, 500, function(){
		$(this).css({
			'background': 'url(img/body_bg.jpg) 50% 50%',
			'min-height': '100%',
			'min-width': '100%',
			'top': '0',
			'left': '0',
		})
	}).animate({
		opacity: 1
	}, 500);
	$("#fond_beton").removeAttr("background")
	$('#fond_affiche').animate({
		opacity: 1
	}, 100);
	link_alive ();
}


function etudiants(){
	$('#main_container *').animate({
		left: -2000,
		opacity: 0,
	}, 100);
	$('#etudiants').animate({
		opacity: 1,
		left:(((window.screen.width)/2)-300),
	}, 500, function(){
		$('#etudiants *').animate({
			opacity: 1,
			left: 0,
		}, 500);
	});
	deplacement_affiche();
	$('#fond_beton').animate({
		opacity: 0.8
	}, 500, function(){
		$(this).css({
			'background': 'url(img/body_bg.jpg) 50% 50%',
			'min-height': '100%',
			'min-width': '100%',
			'top': '0',
			'left': '0',
		})
	}).animate({
		opacity: 1
	}, 500);
	$("#fond_beton").removeAttr("background")
	$('#fond_affiche').animate({
		opacity: 1
	}, 100);
	link_alive ();
}

function ce () {
		$('#main_container *').animate({
		left: -2000,
		opacity: 0,
	}, 100);
	$('#ce').animate({
		opacity: 1,
		left:(((window.screen.width)/2)-300),
	}, 500, function(){
		$('#ce *').animate({
			opacity: 1,
			left: 0,
		}, 500);
	});
	deplacement_affiche();
	$('#fond_beton').animate({
		opacity: 0.8
	}, 500, function(){
		$(this).css({
			'background': 'url(img/body_bg.jpg) 50% 50%',
			'min-height': '100%',
			'min-width': '100%',
			'top': '0',
			'left': '0',
		})
	}).animate({
		opacity: 1
	}, 500);
	$("#fond_beton").removeAttr("background")
	$('#fond_affiche').animate({
		opacity: 1
	}, 100);
	link_alive ();
}

function contact (){
		$('#main_container *').animate({
		left: -2000,
		opacity: 0,
	}, 100);
	$('#contact').animate({
		opacity: 1,
		left:(((window.screen.width)/2)-300),
	}, 500, function(){
		$('#contact *').animate({
			opacity: 1,
			left: 0,
		}, 500);
	});
	deplacement_affiche();
	$('#fond_beton').animate({
		opacity: 0.8
	}, 500, function(){
		$(this).css({
			'background': 'url(img/body_bg.jpg) 50% 50%',
			'min-height': '100%',
			'min-width': '100%',
			'top': '0',
			'left': '0',
		})
	}).animate({
		opacity: 1
	}, 500);
	$("#fond_beton").removeAttr("background")
	$('#fond_affiche').animate({
		opacity: 1
	}, 100);
	
}

function transistion () {
	
	$('#fond_beton').animate({opacity:0.8},500,function () {
	$("#intro_anim").html('');
	$(this).css ({
		'background':'url(img/body_bg.jpg) 50% 50%',
		'min-height':'100%',
		'min-width':'100%',
		'top':'0',
		'left':'0',
	})
	}).animate({opacity:1},500);
	 
}

function deplacement_affiche () {
	$('#fond_affiche').animate({
		left:-2000,
		top:20,
		opacity:0
		},500,function (){
			$('#fond_affiche').animate({
				opacity : 1,
				top:10,
				left:(((window.screen.width)/2)-490),
			},50);
			});
			
	
}

function clear () {
	$(':text').click( function () {
		this.value="";
		$(this).css ({"color":"#000000","text-align":"left"})
	});

}

function send_mail(){
	$.post("mail.php", { 
		sujet: document.forms['contact'].subject.value, 
		nom_complet : document.forms['contact'].realname.value,
		email : document.forms['contact'].email.value,
		phone : document.forms['contact'].phone.value,
		ancien_num_place : document.forms['contact'].ancien_num_place.value, 
		type : document.forms['contact'].type.value,
		message : document.forms['contact'].message.value,     
		success: function(){
     alert("Votre e-mail a bien \351t\351 envoy\351 !"); 
		},
  
   });
	
	
function link_alive () {
	$('#main_container a').css({
		"left":"30%",
	})
}
}
	


