

function afficherStatDragons(arg_article)
{
	
	if (window.XMLHttpRequest) // pour firefox, opera...
    {xhr_object= new XMLHttpRequest();}
	else if (window.ActiveXObject)  // pour internet explorer
	    {xhr_object= new ActiveXObject("Microsoft.XMLHTTP");}
	else {return false;}
	
	xhr_object.open("GET","index.php?function=rechercheStatDragons&article="+arg_article,false);
	xhr_object.send(null);
	
	if (xhr_object.readyState ==4)
	    {document.getElementById('divContenuStatDragons').innerHTML=xhr_object.responseText;}
}



function afficherImageNews(arg_image,arg_largeur,arg_hauteur)
{

	var largeur=arg_largeur;//'389';
	var hauteur=arg_hauteur;//'260';
	if(hauteur>260)
		hauteur=260;
	if(largeur>389)
		largeur=389;
	/*
	 *  On va appliquer un margin-top aux images dont la hauteur ne 
	 *  vaut pas 260 (la taille du conteneur de l'image)  afin de 
	 *  pouvoir centrer verticalement l'image.
	 */ 
	var margeHaut=(260-parseInt(hauteur))/2;

	document.getElementById('zoneNewsPhoto').innerHTML='<img src="'+arg_image+'" width="'+largeur+'" height="'+hauteur+'" style="margin-top:'+margeHaut+'px;">';
}

var videoSelec='';


function afficherVideoNews(arg_Video,arg_article)
{
    if (videoSelec!=arg_article)
    {
    	document.getElementById('zoneNewsVideo').innerHTML=arg_Video;
    	videoSelec=arg_article;
    }
    
}


function changerImageMouseOver(arg_zone,arg_classOver)
{
	arg_zone.className =arg_classOver;	
	
}

function changerImageMouseOut(arg_zone,arg_classOut)
{
	arg_zone.className =arg_classOut;	
}

function pr_retournerJourAvantProchainMatch(arg_dateProchainMatch,arg_heureProchainMatch)
{
	//Fonction permetant d'afficher le compte à rebours du prochain match
	/*
	 * On converti les agurments en entier 
	 */
	dateProchainMatch=arg_dateProchainMatch.split('/');
	arg_jour=parseInt(dateProchainMatch[0],10);
	arg_mois=parseInt(dateProchainMatch[1],10);
	arg_annee=parseInt(dateProchainMatch[2],10);
	
	heureProchainMatch=arg_heureProchainMatch.split(':');
	arg_heure=parseInt(heureProchainMatch[0],10);
	arg_minute=parseInt(heureProchainMatch[1],10);
 	document.getElementById('jourAvantProchainMatch').innerHTML=compte_a_rebours_prochain_match(arg_annee,arg_mois,arg_jour,arg_heure,arg_minute);
	setTimeout(function(){pr_retournerJourAvantProchainMatch(arg_dateProchainMatch,arg_heureProchainMatch);},1000);
}

function compte_a_rebours_prochain_match(annee,mois,jour,heure,min)
{
	var date_prochain_match=new Date(annee,mois-1,jour,heure,min);
	var date_jour=new Date();
	var temps_restant=(date_prochain_match.getTime()-date_jour.getTime())/1000;
	var nbre_jour=Math.floor(temps_restant/3600/24);  // récupere le nb de jour
	temps_restant=temps_restant % (3600*24);
	var nbre_heure=Math.floor(temps_restant / 3600);	// recupère le nb d'heure
	temps_restant=temps_restant % 3600;
	var nbre_minute=Math.floor(temps_restant/60);		// récupère le nb minute
	temps_restant=temps_restant % 60;
	var nbre_seconde=Math.floor(temps_restant);
	
	var retour=nbre_jour+"j "+nbre_heure+"h "+nbre_minute+"min "+nbre_seconde+"s";
	return retour;
}

function enregistrerSondage(formulaireSondage)
{
	var sondageSelectionne=false;
	var boutonRadio=document.getElementsByName("choixSondage");
	for (i=0; i< boutonRadio.length;i++)
	{
		if (boutonRadio[i].checked==true)
		{
			sondageSelectionne=true;
			var fonction="index.php?function=enregistrerVoteSondage&reponse="+boutonRadio[i].value;
			appelFonctionPhpPourSondage(fonction);

			
		}
	}
	if (sondageSelectionne==false)
	{
		alert('Veuillez selectionner une reponse');
	}
}

function afficherFormSondage()
{
	var fonction="index.php?function=pr_creerFormulaireSondage&appel=javascript";
	appelFonctionPhpPourSondage(fonction);
}


function afficherResultatSondage()
{
	var fonction="index.php?function=afficherResultatVoteSondage";
	appelFonctionPhpPourSondage(fonction);

}

function favoris()
 {
	if ( navigator.appName != 'Microsoft Internet Explorer' )
	{ 
	   window.sidebar.addPanel("Dragons Catalans","http://www.catalansdragons.fr/","Dragons Catalans"); 
	}
	else 
	{ 
	window.external.AddFavorite("http://www.catalansdragons.fr/","Dragons Catalans"); 
    } 
 }



function appelFonctionPhpPourSondage(arg_fonction)
{
	if (window.XMLHttpRequest) // pour firefox, opera...
    {xhr_object= new XMLHttpRequest();}
	else if (window.ActiveXObject)  // pour internet explorer
	    {xhr_object= new ActiveXObject("Microsoft.XMLHTTP");}
	else {return false;}
	
	xhr_object.open("GET",arg_fonction,false);
	xhr_object.send(null);
	
	if (xhr_object.readyState ==4)
	    {document.getElementById('divContenuSondage').innerHTML=xhr_object.responseText;}
	else
	    {return false;}
}




