function AjouterFavoris() { // On crée la fonction AjouterFavoris()
	if ( navigator.appName != 'Microsoft Internet Explorer' ) { // Si le navigateur est Internet Explorer
	window.sidebar.addPanel("fille-jeux.fr", "http://www.fille-jeux.fr", ""); // Alors on utilise la fonction window.sidebar.addPanel("Nom utilisé pour enregistrer le site", "Adresse du site web", "")
	}
	
	else { // Sinon, si le navigateur n'est pas Internet Explorer
	window.external.AddFavorite("http://www.fille-jeux.fr", "fille-jeux.fr"); // Alors on utilise la fonction window.external.AddFavorite("Nom utilisé pour enregistrer le site", "Adresse du site web")
	}
}

function redirection(sLien) {
	document.location.href = sLien;
}

function afficheJeu() {
	sel = document.getElementById('p_JeuxFavoris');
	sLien = sel.options[sel.selectedIndex].value;
	
	document.location.href = sLien; 
}

function checkPseudo(){
	var pseudo = $('p_Pseudo').value; 

	new Ajax.Updater(
		'reponsePseudo',
		'inc/ajax-verif-pseudo.php',
		{
			method: 'post',
			parameters: {pseudo: pseudo}
		}
	);
}

function changeAvatar(avatarID, membre, site) {
	switch (avatarID) {
		case 1 :
			$('avatar').innerHTML = '<img src="img/avatars/defaut1.png" />';
			break;
			
		case 2 :
			$('avatar').innerHTML = '<img src="img/avatars/defaut2.png" />';
			break;
		
		case 3 :
			window.open ('inc/formulaire-avatar.php?membre='+membre, 'nom_interne_de_la_fenetre', config='height=400, width=600, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no');
			break;
	}
}

function affichageMessage(message, div_class, nom_champs) {
	$(nom_champs).innerHTML = message;
	
	ma_couleur = (div_class == 'confirmation'? '#CCE3F4': '#f4CACA' )
	
	new Effect.Opacity(nom_champs, {duration:1, fps:25, from:0, to:1}); 
	new Effect.Highlight(nom_champs, { startcolor: ma_couleur, endcolor: '#ffffff', duration:5 });
	setTimeout(function() {
					new Effect.Opacity(nom_champs, {duration:1, fps:25, from:1, to:0})
				}, 2000);
}

/***** COMMENTAIRES NEWS *****/
function ajoutCommentaireNews(newsID){
	commentaire = $F('p_Commentaire');
	var statut = "ajout";
	
	if (commentaire != '') {
	 	$('commentaires').innerHTML = '<br/><br/><br/><br/><center><img src = "img/ajax-loader.gif"><br/>Chargement en cours...</center>';
		setTimeout(function() {
			new Ajax.Updater(
				'commentaires',
				'inc/ajax-commentaire-news.php',
				{
					method: 'post',
					onComplete: function() { 
						$('texteCommentaire').innerHTML = '<div class="confirmation">Ton commentaire vient d\'\352tre correctement ajout\351</div>';
						$('p_Commentaire').value = ''; 
					},
					parameters: {commentaire: commentaire, newsID: newsID, statut: statut}
				}
			);
		}, 1000);
	} else $('texteCommentaire').innerHTML = '<div class="erreur">Tu dois \351crire un commentaire</div>';
}


function supprimerCommentaireNews(commentaireID, newsID){
	if (confirm('Veux tu vraiment supprimer ton commentaire?')) {
		var statut = "supprimer";
		
		$('commentaires').innerHTML = '<br/><br/><br/><br/><center><img src = "img/ajax-loader.gif"><br/>Chargement en cours...</center>';
		setTimeout(function() {
			new Ajax.Updater(
				'commentaires',
				'inc/ajax-commentaire-news.php',
				{
					method: 'post',
					parameters: {commentaireID: commentaireID, newsID: newsID, statut: statut}
				}
			);
		}, 1000);
	}
}

function commentairesPageNews(i, commentairesParPage, newsID){	
	$('commentaires').innerHTML = '<br/><br/><br/><br/><center><img src = "img/ajax-loader.gif"><br/>Chargement en cours...</center>';
	setTimeout(function() {
		new Ajax.Updater(
			'commentaires',
			'inc/ajax-pages-commentaire-news.php',
			{
				method: 'post',
				parameters: {i: i, newsID: newsID, commentairesParPage: commentairesParPage}
			}
		);
	}, 1000);
}



/***** RECOMMANDER A UN AMI *****/
function deroulantRecommander(jeu_nom, jeu_url) {
	if ($('recommander').innerHTML != '') {
		Effect.toggle('recommander','blind');	
	} else {
		Element.hide('recommander');
		var statut = 'deroulant';
		new Ajax.Updater(
			'recommander',
			'inc/ajax-recommander.php',
			{
				method: 'post',
				onComplete: function() { Effect.toggle('recommander','blind') },
				parameters: {jeu_nom: jeu_nom, jeu_url: jeu_url, statut: statut}
			}
		);
	}
}

function nomRecommander(type) {
	var nom = $F('p_'+type);
	var statut = 'nom';
	new Ajax.Updater(
		type,
		'inc/ajax-recommander.php',
		{
			method: 'post',
			parameters: {nom: nom, statut: statut}
		}
	);

}

function envoyerRecommander(jeu_nom, jeu_url) {
	var nom_ami = $F('p_NomAmi');
	var mon_nom = $F('p_NomAmi');
	var adresse_ami = $F('p_AdresseAmi')
	var statut = 'envoyer';
	new Ajax.Updater(
		'recUtil',
		'inc/ajax-recommander.php',
		{
			method: 'post',
			evalScripts: true,
			parameters: {jeu_nom: jeu_nom, jeu_url: jeu_url, nom_ami: nom_ami, mon_nom: mon_nom, adresse_ami: adresse_ami, statut: statut}
		}
	);

}

function lanceJeu(nom_jeu){	
	var s = document.getElementById("delai");
	if(s.innerHTML == 0){
		clearInterval(timer);	
		document.getElementById("affichage_jeu").innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" id="myMovieName" height="534" width="713"><param name="movie" value="http://www.fille-jeu.fr/swf/'+nom_jeu+'.swf"><param name="quality" value="high"><param name="bgcolor" value="#FFFFFF"><embed src="http://www.fille-jeu.fr/swf/'+nom_jeu+'.swf" quality="high" bgcolor="#FFFFFF" name="myMovieName" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" align="" height="534" width="713"></object>';
		
		return false;
	}
	s.innerHTML = s.innerHTML-1;
	
}

// Signaler un abus
function signalerCommentaire(type, commentaire_id) {
	window.open ('signaler_abus.php?type='+type+'&com='+commentaire_id, 'signaler_un_abus', 'height=217px, width=600px, toolbar=no, menubar=no, scrollbars=no, resizable=no, status=no');
}
