var equipe = -1;


/* Scroller de news ****/


step=3;
timerDown="";
timerUp="";
timerLeft="";
timerRight='';
function scrollDivDown(vitesse){
	el=document.getElementById('scroll');
	clearTimeout(timerDown) ;
	el.scrollTop+=step;
	timerDown=setTimeout('scrollDivDown('+vitesse+')',vitesse);

	if(el.scrollTop>=el.scrollHeight-el.offsetHeight){
		el.innerHTML+=el.innerHTML;
	}

}

function scrollDivUp(vitesse){
	el=document.getElementById('scroll');
	clearTimeout(timerUp) ;
	el.scrollTop-=step;
	timerUp=setTimeout('scrollDivUp('+vitesse+')',vitesse);

	if(el.scrollTop>=el.scrollHeight+el.offsetHeight){
		//el.scrollTop=0;
	}

}

function scrollDivLeft(){
	el=document.getElementById('scroll');
	if (parseInt(el.style.marginLeft)>0-(parseInt(el.style.width)-400)){
		el.style.marginLeft=(parseInt(el.style.marginLeft)-150)+"px";
	}
}

function scrollDivRight(){
	el=document.getElementById('scroll');
	if (parseInt(el.style.marginLeft)<0){
		el.style.marginLeft=(parseInt(el.style.marginLeft)+150)+"px";
	}

}


/*** variables pour la page joueur ***/
var lastIdJoueur =''; /* dernier id du tr du joueur */
var lastClassJoueur =''; /* classe de ce tr */

// CREATION D4UN OBJET XMLHTTPREQUEST EN FONCTION DU NAVIGATEUR
function getXhr()
 {
  if(window.XMLHttpRequest) xhr = new XMLHttpRequest(); 
  else if(window.ActiveXObject)
   {  
    try
     {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
     }
    catch (e)
     {
      xhr = new ActiveXObject("Microsoft.XMLHTTP");
     }
   }
  else 
   { 
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest, veuillez le mettre à jour"); 
    xhr = false; 
   } 
 }


/******************************************************************************************************

					ON PLACE ICI LES FONCTIONS  JAVASCRIPT LIAISON AJAX OU AUTRES


*******************************************************************************************************/



function afficherInfosMatch(id) {
		getXhr();
		data="id="+id+"&action=afficherInfoMatch";
		xhr.onreadystatechange = function()
			{
				if(xhr.readyState == 4 && xhr.status == 200){
					document.getElementById("infosMatch").innerHTML=xhr.responseText;
				}
			}
			 xhr.open("POST", "ajax/ajax.php", true);
			 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
			 xhr.send(data);	
			
}

function tournerResultatt(id) {	
	nomEquipe ="";
	if(equipe==-1){
		equipe=1	
	} else if(equipe==7){
		equipe = -1;
		nomEquipe = '&Eacutequipe 1' ;	
	} else {
		equipe +=1;
	}
	
	var tabEquipe = Array('', 'U9','U11 Dk1','U11 DK2','U13','U15','U18','Loisirs');
	if(equipe>0){
		nomEquipe = tabEquipe[equipe];	
	}
	
		getXhr();
		data="id="+equipe+"&action=tournerMatch";
		xhr.onreadystatechange = function()
			{
				if(xhr.readyState == 4 && xhr.status == 200){
					if(xhr.responseText.replace(/^\s\s*/, '').replace(/\s\s*$/, '')==""){
						document.getElementById("resultatDerniersMatch").innerHTML = "Aucun Résultat";	
					} else {
						document.getElementById("resultatDerniersMatch").innerHTML=xhr.responseText;
					}
					document.getElementById('nomEquipeRes').innerHTML = nomEquipe;
				}
			}
			 xhr.open("POST", "ajax/ajax.php", true);
			 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
			 xhr.send(data);
			 monTimerRes = setTimeout("tournerResultatt()",5000);
			 
			
}

function afficherCalendrier(annee, mois){
	getXhr();
		data="annee="+annee+"&mois="+mois+"&action=afficherCalendrier";
		xhr.onreadystatechange = function()
			{
				if(xhr.readyState == 4 && xhr.status == 200){
					document.getElementById("calendrier").innerHTML=xhr.responseText;
					
				}
			}
			 xhr.open("POST", "ajax/ajax.php", true);
			 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
			 xhr.send(data);	
}


function afficherPopUpNews(id){
	/* Fonction qui affiche le texte complet de la news dans le popUp prevu a cet effet 'texteEntierNews' */
	getXhr();
	data="id="+id+"&action=afficherTexteNews";
	xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200){
				document.getElementById('texteEntierNews').innerHTML = "<div style='background-color:#000; text-align:right;' ><a href='#' onclick=\"document.getElementById('texteEntierNews').style.visibility='hidden';\" style='color:#fff !important'>Fermer</a></div>";
				document.getElementById('texteEntierNews').innerHTML+=xhr.responseText;
				document.getElementById('texteEntierNews').style.visibility = 'visible';
				
			}
		}
	 xhr.open("POST", "ajax/ajax.php", true);
	 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
	 xhr.send(data);	
}

function afficherPopUpNewsArchives(id){
	/* Fonction qui affiche le texte complet de la news dans le popUp prevu a cet effet 'texteEntierNews' */
	getXhr();
	data="id="+id+"&action=afficherTexteNews";
	xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200){
				var colA= $("#colA").height();
				$("#texteEntierNews").height(colA);
				document.getElementById('texteEntierNews').innerHTML = "<div style='background-color:#000; text-align:right;' ><a href='#' onclick=\"document.getElementById('texteEntierNews').style.visibility='hidden';\" style='color:#fff !important'>Fermer</a></div>";
				document.getElementById('texteEntierNews').innerHTML+=xhr.responseText;
				document.getElementById('texteEntierNews').style.visibility = 'visible';
				
			}
		}
	 xhr.open("POST", "ajax/ajax.php", true);
	 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
	 xhr.send(data);	
}



function afficherAvisCoachEntier(id){
	/* Fonction qui affiche le texte complet de la news dans le popUp prevu a cet effet 'texteEntierNews' */
	getXhr();
	data="id="+id+"&action=afficherAvisCoachEntier";
	xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200){
				document.getElementById('texteEntierNews').innerHTML = "<div style='background-color:#000; text-align:right;' ><a href='#' onclick=\"document.getElementById('texteEntierNews').style.visibility='hidden';\" style='color:#fff !important'>Fermer</a></div>";
				document.getElementById('texteEntierNews').innerHTML+=xhr.responseText;
				document.getElementById('texteEntierNews').style.visibility = 'visible';
				
			}
		}
	 xhr.open("POST", "ajax/ajax.php", true);
	 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
	 xhr.send(data);	
}



function clickJoueur(id){
	if(lastIdJoueur!=''){
		document.getElementById(lastIdJoueur).className=lastClassJoueur;	
	}
	lastIdJoueur = id;
	lastClassJoueur = document.getElementById(id).className;	
	document.getElementById(id).className='trSelectionne';
	getXhr();
	data="id="+(id.substr(6,5))+"&action=afficherFicheJoueur";
	xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200){
				document.getElementById("colB").innerHTML=xhr.responseText;	
				$('.gallery a').lightBox();
				
			}
		}
	 xhr.open("POST", "ajax/ajax.php", true);
	 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
	 xhr.send(data);	
	
		
}

function afficherInfo(info){
	getXhr();
	data="id="+info+"&action=afficherInfosJoueur";
	xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200){
				document.getElementById("colB").innerHTML=xhr.responseText;
			}
		}
	 xhr.open("POST", "ajax/ajax.php", true);
	 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
	 xhr.send(data);	
	
		
}

function afficheStatistiqueSaison(saison){
	getXhr();
	data="saison="+saison+"&action=afficheStatistiqueSaison";
	xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200){
				document.getElementById("colA").innerHTML=xhr.responseText;
			}
		}
	 xhr.open("POST", "ajax/ajax.php", true);
	 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
	 xhr.send(data);	
	
		
}


function afficherCompositionCat(categorie){
	getXhr();
	data="cat="+categorie+"&action=afficheCompositonCat";
	xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200){
				document.getElementById("colA").innerHTML=xhr.responseText;
			}
		}
	 xhr.open("POST", "ajax/ajax.php", true);
	 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
	 xhr.send(data);	
	
		
}

function afficherResultatCat(categorie){
	getXhr();
	data="cat="+categorie+"&action=afficheResultatCat";
	xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200){
				document.getElementById("colA").innerHTML=xhr.responseText;
			}
		}
	 xhr.open("POST", "ajax/ajax.php", true);
	 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
	 xhr.send(data);	
	
		
}
function afficherInformations(categorie){
	getXhr();
	data="cat="+categorie+"&action=afficheInfosCat";
	xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200){
				document.getElementById("colA").innerHTML=xhr.responseText;
			}
		}
	 xhr.open("POST", "ajax/ajax.php", true);
	 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
	 xhr.send(data);	
	
		
}


function creerSelectMatch(cat){
	getXhr();
	data="cat="+cat+"&action=creerSelectMatch";
	xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200){
				document.getElementById("selectMatch").innerHTML=xhr.responseText;
			}
		}
	 xhr.open("POST", "ajax/ajax.php", true);
	 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
	 xhr.send(data);	
}


function afficherDiapoMatch(equipe, idmatch){
	getXhr();
	data="equipe="+equipe+"&match="+idmatch+"&action=afficherDiapo";
	xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4 && xhr.status == 200){
				document.getElementById("diapoMatch").innerHTML=xhr.responseText;
			}
		}
	 xhr.open("POST", "ajax/ajax.php", true);
	 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
	 xhr.send(data);	
}


function afficherGrandePhoto(photo){
	document.getElementById('imgBoutiqueGrande').src = photo;
	document.getElementById('grandePhotoBoutique').style.visibility = 'visible';
}
