function redirect(where)
{
	window.location = '?mod='+where;	
}


var joueurs_selected = new Array();

function add_joueur(where)
{
	var joueur_id = where.val();		
	if(joueur_id == '---')
		return;

	joueurs_selected.push(joueur_id);
	var joueur_nom = where.find('option[value='+joueur_id+']').html();
	where.find('option[value='+joueur_id+']').remove();
	$('#serialize').val(joueurs_selected);

	$('<li>').html(joueur_nom).appendTo('#joueur_selected');	
}

function undo_joueur()
{
	var options = '<option value="---">Selectionnez un joueur</option>';

		
	for(var i = 0; i < joueurs.length; i++)
	{
			options += '<option value="'+joueurs[i][0]+'">'+joueurs[i][1]+'</option>'
	}
		
		
		var template = "<label></label>"+
		"<select name='add_joueur[0]' class='add_joueur' onchange='add_joueur($(this))'>"+
		options+
		"</select> ";
		
		$('#add_joueur_cont').html(template);
		joueurs_selected = new Array();
		$('#serialize').val('');
		$('#joueur_selected').empty();
}


function envoiLogin(where)
{
	var serialize =  where.find('input').serialize();
 $.ajax({
   type: "POST",
   url: "mod/login.php",
   data: serialize,
   success: function(msg){
   	$('#resultBottom').html(msg);
   }
	});
	
	return false;
}

		
function loadLogForm()
{
			if(oldClick == 'pages/connexion.html')
			$('#menuBottom').animate({
				height: 0
				}, 500, function(){$(this).hide(); oldClick = false;});
		else
			$('#menuBottom').show().animate({
				height: 0
				}, 500, function(){
					//$(this).hide();
			}).load('pages/connexion.html').show().animate({
				height: 250
				}, 500, function(){
			}).prepend('<div id="resultBottom"></div>');
			
			oldClick = 'pages/connexion.html';
}

function loadReglements()
{
		if(oldClick == 'pages/reglement.html')
			$('#menuBottom').animate({
				height: 0
				}, 500, function(){$(this).hide(); oldClick = false;});
		else
			$('#menuBottom').show().animate({
				height: 0
				}, 500, function(){
					//$(this).hide();
			}).load('pages/reglement.html').show().animate({
				height: 525
				}, 500, function(){
			}).prepend('<div id="resultBottom"></div>');
			
			oldClick = 'pages/reglement.html';

}


function loadInscription()
{
		if(oldClick == 'pages/inscription.html')
			$('#menuBottom').animate({
				height: 0
				}, 500, function(){$(this).hide(); oldClick = false;});
		else
			$('#menuBottom').show().animate({
				height: 0
				}, 500, function(){
					//$(this).hide();
			}).load('pages/inscription.html').show().animate({
				height: 525
				}, 500, function(){
			}).prepend('<div id="resultBottom"></div>');
			
			oldClick = 'pages/inscription.html';
}

function formForgetPass()
{
	
		if(oldClick == 'pages/mot-de-passe.php')
			$('#menuBottom').animate({
				height: 0
				}, 500, function(){$(this).hide(); oldClick = false;});
		else
			$('#menuBottom').show().animate({
				height: 0
				}, 500, function(){
					//$(this).hide();
			}).load('pages/mot-de-passe.php').show().animate({
				height: 250
				}, 500, function(){
			}).prepend('<div id="resultBottom"></div>');
			
			oldClick = 'pages/mot-de-passe.php';
}

function sendChangePass(where)
{
	var serialize =  where.find('input').serialize();
	var VAL = where.find('input#email').val();
	var new_string = new String(VAL);
  if (new_string.match('^[-_\.0-9a-zA-Z]{1,}@[-_\.0-9a-zA-Z]{1,}[\.][0-9a-zA-Z]{2,}$')) 
	$.ajax({
   type: "POST",
   url: "pages/mot-de-passe.php",
   data: serialize,
   success: function(msg){
   		alert("Un mail va vous \352tre envoy\351 \340 l\'adresse donn\351e afin de changer votre mot de passe.");
			$('#menuBottom').animate({
				height: 0,
				marginTop: 0
				}, 500, function(){
					$(this).hide();
					oldClick = false;
			});
   }
 });
 else 
 alert('Veuillez entrer un email valide.');
	return false;
}

function aff_resultats()
{
	$('#cont').animate({left: '-375'});
}

function aff_promo()
{	
	$('#cont').animate({left: '0'});
}

function show_promo(id)
{
	aff_promo();
	$('#promo_article').fadeOut().load('mod/aff_article.php?id='+id).fadeIn();
}

var carousel = {
	width: 285,
	next: function(){
		if(this.stepper <(this.length-1))
			$('.awardsCont .scroller').animate({marginLeft: -(++this.stepper * this.width )}, {queue: false})
	},
	before: function(){
		if(this.stepper > 0)
		$('.awardsCont .scroller').animate({marginLeft: -(--this.stepper * this.width) }, {queue: false})},
	stepper: 0,
	length: 0
}

function charge_video(file)
{
	var flashvars = {file: file, autostart:"true"};
	var params = {wmode: "transparent"};
	var attributes = {};

		swfobject.embedSWF("videos/player.swf", "big_photo_to_click", "300", "200", "9.0.0","expressInstall.swf", flashvars, params, attributes);
}

var vote = false;
function playerReady() {
  var player = document.getElementById('video');
	if (player.getAttribute('height') == null) {
		setTimeout("playerReady('"+video+"')",100);
	} else {
	try {
		player.addModelListener("STATE", "sendVote");
 }
 catch(err){
 		//setTimeout("playerReady()",100);
 }
	}
}
function sendVote()
{
 if(!vote)
 {
  vote = true;
  pageTracker._trackPageview(video);
 }
}

