var info_alerte	 = "TRUE STORIES ALERTE INFO !";
var info_confirm = "TRUE STORIES CONFIRMATION INFO !";
var msg_stories  = "<br /><br /><center><b><font color='red' size='1'>Désolé, mais il n'y a aucun résultat correspondant à votre recherche</font></b></center>";

function change_css(nomcss) 
{
	$('link[rel=stylesheet]:eq(2)').attr('disabled',true).attr('href','/img/theme/'+nomcss+'/theme.css').attr('disabled',false);
};

function racineSite(){
	var locarray = location.href.split("/");
	delete locarray[(locarray.length-1)];
	var racine = locarray.join("/");
	return racine;
}

var CHECK_IE = document.all?true:false; 
if (!CHECK_IE) document.captureEvents(Event.MOUSEMOVE); document.onmousemove = getMousePosition;
var xPos = 0;
var yPos = 0;
function getMousePosition(e) 
{
  xPos = (xPos < 0) ? 0 : ((CHECK_IE) ? (((document.documentElement.scrollLeft) ? event.clientX + document.documentElement.scrollLeft : event.clientX +  document.body.scrollLeft)) : e.pageX);
  yPos = (yPos < 0) ? 0 : ((CHECK_IE) ? (((document.documentElement.scrollTop)  ? event.clientY + document.documentElement.scrollTop  : event.clientY +  document.body.scrollTop))  : e.pageY);
}

function tm_tooltip_moves()
{
	tip	= $("#tm_tooltip");	if(tip.css('display') == "block") tip.css({'top' : yPos, 'left' : xPos + 15});
}


function tm_tooltip(t, s)
{	
		tip	= $("#tm_tooltip");
		if(s == 's')
		{		
			t = t.replace(/#c#/g, "'");
			$("#tm_tooltip_text").html(t);			
			tip.show(); 			
		}	
		else 
			tip.hide();
}

function lookup(inputString) {
    if(inputString.length == 0) {
        $("#suggestions").hide();
    } else {
        $.get("traitement_ajax.php", {membres: ""+inputString+""}, function(data){
            if(data.length >0) {
                $("#suggestions").show();
                $("#autoSuggestionsList").html(data);
            }
        });
    }
} 

function display_check(display)
{
	if($("#"+display).css("display") == 'block') $("#"+display).hide("slow"); else $("#"+display).show("slow");
}
	
function display_info(display)
{
	if(display == 'display_email') 		display_check(display); else $("#display_email").hide("slow");
	if(display == 'display_facebook') 	display_check(display); else $("#display_facebook").hide("slow");
	if(display == 'display_deezer') 	display_check(display); else $("#display_deezer").hide("slow");
	if(display == 'display_live') 		display_check(display); else $("#display_live").hide("slow"); 
	if(display == 'display_myspace') 	display_check(display); else $("#display_myspace").hide("slow");
	if(display == 'display_twitter') 	display_check(display); else $("#display_twitter").hide("slow");
	if(display == 'display_dm')			display_check(display); else $("#display_dm").hide("slow");
	if(display == 'display_yt') 		display_check(display); else $("#display_yt").hide("slow");
	if(display == 'display_labrute') 	display_check(display); else $("#display_labrute").hide("slow");
}
 
function story_vote(numero_s, nick, etat)
{
	 if(etat != "non_membre")
	 {
		$.get('traitement_ajax.php',{ story_vote: numero_s, nick: nick, etat: etat },function success(data)
			{		 
			  if(data == 1)
				$("#span_story_info").html('<span class="span_i_green bradius">Ton vote positif a bien été pris en compte. Merci d\'avoir voté.</span>');		 
			 
			  if(data == 2)
				$("#span_story_info").html('<span class="span_i_red bradius">Ton vote négatif a bien été pris en compte. Merci d\'avoir voté.</span>');
					
			  if(data == 3)
				$("#span_story_info").html('<span class="span_i_red bradius">Desolé, mais tu ne peux voter qu\'une fois par heure.</span>');
			}
		);
	  }
	  else
	  $("#span_story_info").html('<span class="span_i_red bradius">Seul les membres peuvent voter</span>');
}	 	 
	
function addToPostIt(numero_s, titre, etat)
{
	 if(etat != "non_membre")
	 { 
		$.get('traitement_ajax.php',{ post_it: numero_s, titre: titre },function success(data)
			{		 
			  if(data == 1)
				$("#span_story_info").html('<span class="span_i_green bradius">La story '+titre+' a bien été ajoutée à vos post-it.</span>');		 
			 }
		);		 
	 }
	 else
	 $("#span_story_info").html('<span class="span_i_red bradius">Seul les membres peuvent ajouter un post-it.</span>');	
}		 
	
function broken_link(numero_s, nick, etat)
{
	 if(etat != "non_membre")
	 { 
		$.get('traitement_ajax.php',{ broken_link: numero_s, nick: nick },function success(data)
			{		 
			  if(data == 1)
				$("#span_story_info").html('<span class="span_i_green bradius">Merci d\'avoir signaler un lien mort.</span>');		 
			 }
		);		 
	 }
	 else
	 $("#span_story_info").html('<span class="span_i_red bradius">Merci, mais seul les membres peuvent signaler un lien mort.</span>');	
}		 
	 
function artiste_favoris(numero_a, nick, etat)
{   
	 if(etat != "non_membre")
	 {
		$.get('traitement_ajax.php',{ artiste_favoris: numero_a, nick: nick, etat: etat},function success(data)
		{		 
			if(data == 2)
				$("#span_artiste_favoris").html('<a onclick="artiste_favoris(\''+numero_a+'\',\''+nick+'\',\'add\');" onmouseover="artiste_fav.src=\'img/fav_on.gif\';" onmouseout="artiste_fav.src=\'img/fav_on_1.gif\';" style="cursor: pointer;"><img src="img/fav_on_1.gif" name=\artiste_fav\' id=\'artiste_fav\' style="border:0px;"/></a> <br> <span class="span_i_red">Cet artiste a bien été retiré de votre profil</span>');
		   
			if(data == 1)
				$("#span_artiste_favoris").html('<a onclick="artiste_favoris(\''+numero_a+'\',\''+nick+'\',\'remove\');" onmouseover="artiste_fav.src=\'img/fav_off_1.gif\';" onmouseout="artiste_fav.src=\'img/fav_off.gif\';" style="cursor: pointer;"><img src="img/fav_off.gif" name=\artiste_fav\' id=\'artiste_fav\' style="border:0px;"/></a> <br> <span class="span_i_green">Cet artiste a bien été ajouté à votre profil</span>');
		 }
		);			
	  }
	  else
	  $("#span_artiste_favoris").html('<img src="img/fav_on_1.gif" name=\'artiste_fav\' id=\'artiste_fav\' style="border:0px;"/><br> <span class="span_i_red">Seul les membres peuvent ajouter des artistes à leur profil</span>');	
}	 
	 
function story_favoris(numero_story, nick, etat)
{
	 if(etat != "non_membre")
	 {
		 $.get('traitement_ajax.php',{ story_favoris: numero_story, nick: nick, etat: etat },function success(data)
		{	
			  if(data == 2)
			  {
			   $("#span_story_info").html('<span class="span_i_red bradius">Cette Story a bien été retirée de votre profil</span>');
			   $("#span_story_favoris").html('<img onclick="story_favoris(\''+numero_story+'\',\''+nick+'\',\'add\');" onmouseover="this.src=\'img/fav_on.gif\';" onmouseout="this.src=\'img/fav_on_1.gif\';" style="cursor: pointer;" src="img/fav_on_1.gif" name=\story_fav\' id=\'story_fav\' style="border:0px;"/>');
			  }	   
			  if(data == 1)
			  {
			   $("#span_story_info").html('<span class="span_i_green bradius">Cette Story a bien été ajoutée à votre profil</span>');	
			   $("#span_story_favoris").html('<img onclick="story_favoris(\''+numero_story+'\',\''+nick+'\',\'remove\');" onmouseover="this.src=\'img/fav_off_1.gif\';" onmouseout="this.src=\'img/fav_off.gif\';" style="cursor: pointer;" src="img/fav_off.gif" name=\story_fav\' id=\'story_fav\' style="border:0px;"/>');
			  }
		 }
		);
	  }
	  else
	  $("#span_story_info").html('<span class="span_i_red bradius">Seul les membres peuvent ajouter des Stories à leur profil</span>');
}	 
	  
function flux_rss(le_flux)
{
	
	$("#div_flux").html("<center><img src='img/ajax-loader.gif'> chargement...</center>");
	$.get(
		'traitement_ajax.php', 
		{ flux_rss: le_flux},
		function success(data)
		{
			$("#div_flux").fadeOut('slow', function() {

				$("#div_flux").html(data).fadeIn('slow');

				});
		}
	);
}
 
var verif_g;
function verif_Pseudo(pseudo)
{
	if(pseudo != '')
    {
		verif_g = 2;
		if(pseudo.length<2)
           $("#div_pseudo").html('<span class="span_i_red bradius"><b>'+pseudo+' :</b> ce pseudo est trop court</span>');
		else if (pseudo.length>20)
			$("#div_pseudo").html('<span class="span_i_red bradius"><b>'+pseudo+' :</b> ce pseudo est trop long</span>');
		else if (isNaN(pseudo) == false)
			$("#div_pseudo").html('<span class="span_i_red bradius"><b>'+pseudo+' :</b> que des chiffres ?</span>');
		else
		{
				$.get('traitement_ajax.php',{ pseudo: escape(pseudo)},function success(data)
					{
					  verif_g = data;	 
					  
					  if(data == 1)
						$("#div_pseudo").html('<span class="span_i_red bradius"><b>'+pseudo+' :</b> ce pseudo est déjà pris</span>')
						   
					  if(data == 2)
						$("#div_pseudo").html('<span class="span_i_red bradius"><b>'+pseudo+' :</b> ce pseudo est invalide</span>');
						   
					  if(data == 3)
						$("#div_pseudo").html('<span class="span_i_green bradius"><b>'+pseudo+' :</b> ce pseudo est libre</span>');
					}
				);
		}
	}
	else
	$("#div_pseudo").html('');
}

var verif_email;
function verif_mdp(email, place)
{
    if(email != '')
    {				  
		verif_email = 1;
		$.get('traitement_ajax.php',{ email: escape(email)},function success(data)
		{	  
				if(data == 1)
				{
					if(place == "mdp")
					{
						$("#div_email").html('<span class="span_i_green bradius">Cette adresse E-mail est bien dans notre base de donnée.</span>');
						$("#valider").attr('disabled', false);
					}
				}
				if(data == 2)
				{
					if(place == "mdp")
					{
						$("#div_email").html('<span class="span_i_red bradius">L\'adresse e-mail que vous avez entrée n\'a pas été enregistrée.</span>');
						$("#valider").attr('disabled', true);
					}						
				}
				verif_email = data;
		}
		);				   
    }
   else
   $("#div_email").html('');
 } 

//////////////////////////////////////////
function afficher_story(id, titre) {
	location.href = id+"-"+titre;	
}

function afficher_artiste(id) {
	location.href = "artiste?id="+id;	
}

function afficher_checked(Controleur, Controle) {
if(document.getElementById(Controleur).checked == true) $("#"+Controle).show("slow"); else $("#"+Controle).hide("slow");
}

function jAlertSwitch(info)
{
	switch(info)
		{
		case "droits" :
			jAlert('Vous n\'avez pas les droits nécessaire pour accéder à cette page.', info_alerte);
			break;
		default :
			jAlert('Une erreur est survenue.', info_alerte);
		} 
}

function suppressions(quoi, var1, var2)
{
	if(quoi == "wall")
	{
		jConfirm('Voulez vous vraiment effacer ce message de votre profil ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_sup.php',{ wall: var1},function success(data){
					if(data == 1)
					initPagination("truelife", "null");	
					else
					jAlertSwitch("droits");
				});	
		});	

	}

	if(quoi == "broken_link")
	{
		jConfirm('Avez vous vraiment corrigé ce lien mort ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_sup.php',{ broken_link: var1},function success(data){
					if(data == 1)
					location.reload();
					else
					jAlertSwitch("droits");
				});	
		});	
		
	}
	
	if(quoi == "post_it")
	{
		jConfirm('Voulez vous vraiment décoller ce post-it ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_sup.php',{ post_it: var1},function success(data){
					if(data == 1)
					initPaginationGlobal("postit", "null", 8);
					else
					jAlertSwitch("droits");
				});	
		});		
	}
	
	if(quoi == "suggestions")
	{
		jConfirm('Voulez vous vraiment supprimer cette suggestion ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_sup.php',{ suggestions: var1},function success(data){
					if(data == 1)
					initPaginationGlobal("suggestions", "null", 8);
					else
					jAlertSwitch("droits");
				});	
		});		
	}	
	
	if(quoi == "artiste")
	{
		jConfirm('Voulez vous vraiment supprimer cet artiste ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_sup.php',{ artiste: var1},function success(data){
					if(data == 1)
					location.href = "artistes";
					else
					jAlertSwitch("droits");
				});	
		});			
	}
		
	if(quoi == "avis")
	{
		jConfirm('Voulez vous vraiment supprimer cet avis ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_sup.php',{ avis: var1},function success(data){
					if(data == 1)
					location.reload();
					else
					jAlertSwitch("droits");
				});	
		});				
	}	
		
	if(quoi == "quotes")
	{
		jConfirm('Voulez vous vraiment supprimer cette citation ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_sup.php',{ citation: var1},function success(data){
					if(data == 1)
					initPaginationGlobal("quotes", "null", 20);	
					else
					jAlertSwitch("droits");
				});	
		});		
	}
		
	if(quoi == "membre")
	{
		jConfirm('Voulez vous vraiment supprimer ce membre ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_sup.php',{ membre: var1},function success(data){
					if(data == 1)
					{
						if(var2 == "membres")
						initPaginationGlobal(var2, "null", 10);
						if(var2 == "profil")
						location.href = racineSite();
					}
					else
					jAlertSwitch("droits");
				});	
		});			
	}
	
	if(quoi == "img")
	{
		jConfirm('Voulez vous vraiment supprimer cette image ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_sup.php',{ img: var1, img_mini: var2},function success(data){
					if(data == 1)
					initPaginationGlobal("img", "null", 25);	
					else
					jAlertSwitch("droits");
				});	
		});			
	}

	if(quoi == "tribune")
	{
		jConfirm('Voulez vous vraiment supprimer ce message ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_sup.php',{ msgt: var1},function success(data){
					if(data == 1)
					initPaginationGlobal("truelives", "null", 30);
					else
					jAlertSwitch("droits");
				});	
		});					
	}
	
	if(quoi == "story")
	{
		jConfirm('Voulez vous vraiment supprimer cette story ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_sup.php',{ story: var1},function success(data){
					if(data == 1)
					location.href = racineSite();
					else
					jAlertSwitch("droits");
				});	
		});				
	}
	
	if(quoi == "commentaire")
	{
		jConfirm('Voulez vous vraiment supprimer ce commentaire ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_sup.php',{ commentaire: var1},function success(data){
					if(data == 1)
					initPaginationGlobal("commentaires", var2, 100);	
					else
					jAlertSwitch("droits");
				});	
		});			
	}
	
	if(quoi == "proposition_sup")
	{
		jConfirm('Voulez vous vraiment supprimer cette proposition ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_sup.php',{ story: var1},function success(data){
					if(data == 1)
					initPaginationGlobal("propositions", "null", 20);	
					else
					jAlertSwitch("droits");
				});	
		});		
	}
	
	if(quoi == "proposition_val")
	{		
		jConfirm('Voulez vous vraiment valider cette proposition ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_ajax.php',{ proposition: var1},function success(data){
					if(data == 1)
					initPaginationGlobal("propositions", "null", 20);	
					else
					jAlertSwitch("droits");
				});	
		});			
	}
}
function verifications(quoi, n)
{
	if(quoi == "son_moment")
	{
		if (document.son_moment.nom.value =='')
		{jAlert('Merci de saisir le nom l\'auteur !', info_alerte);return false ;}
		if (document.son_moment.titre.value =='')
		{jAlert('Merci de saisir le titre du son !', info_alerte);return false ;}
		if (document.son_moment.music.value =='')
		{jAlert('Merci de choisir le fichier !', info_alerte);return false ;}
		return true;
	}
	
	if(quoi == "evenement")
	{
		if (document.evenement.url.value =='')
		{jAlert('Merci de saisir l\'url de la story !', info_alerte);return false ;}
		if (document.evenement.image.value =='')
		{jAlert('Merci de choisir l\'image !', info_alerte);return false ;}	
		return true;
	}	
	
	if(quoi == "tribune")
	{
		if ($('#message').val() =='')
		{jAlert('Merci de saisir votre message !', info_alerte);return false ;}
		return true;
	}
	
	if(quoi == "post_it")
	{
		if ($("#msg").val() =='')
		{jAlert('Merci de saisir votre message !', info_alerte);return false ;}
		return true;
	}
	
	if(quoi == "recherche")
	{
		if ($('#recherche').val() =='' || $('#recherche').val() =='Rechercher...')
		{jAlert('Merci de saisir votre recherche !', info_alerte);return false ;}
		return true;
	}	
	
	if(quoi == "suggestion")
	{
		if (document.suggestion.suggestion.value =='')
		{jAlert('Merci de saisir une suggestion !', info_alerte);return false ;}
		return true;
	}
	
	if(quoi == "quotes")
	{
		if (document.ajout.citation.value =="")
		{jAlert("Merci de saisir la citation !", info_alerte);return false ;}
		if (document.ajout.auteur.value =="")
		{if(confirm('Etes vous sur de ne pas connaitre l\'auteur ?')){return true;}
		else{return false;}}
		return true;
	}
	
	if(quoi == "avatar")
	{
		if (document.avatar.new_avatar.value =='')
		{jAlert('Merci de choisir une image (de format gif ou jpg) !', info_alerte);return false ;}
		return true;
	}
	
	if(quoi == "artiste")
	{
		if (document.ajout.nom_artiste.value =='')
		{jAlert('Merci de saisir l\'alias de l\'artiste !', info_alerte);return false ;}
		if (document.ajout.nom.value =='')
		{jAlert('Merci de saisir le nom de l\'artiste !', info_alerte);return false ;}
		if (document.ajout.pays.value =='')
		{jAlert('Merci de saisir la nationalité de l\'artiste !', info_alerte);return false ;}
		if (document.ajout.genre.value =='')
		{jAlert('Merci de saisir le genre ou les genres de l\'artiste !', info_alerte);return false ;}	
		if (document.ajout.story.value =='')
		{jAlert('Merci de saisir une petite bio pour cet artiste !', info_alerte);return false ;}			
		return true;
	}
	
	if(quoi == "img")
	{
		if (document.form_img.image.value =='')
		{jAlert('Merci de choisir une image (de format gif ou jpg) !', info_alerte);return false ;}
		return true;
	}
	
	if(quoi == "profileMdp")
	{
			if ($("#oldmdp").val() != n)
			{jAlert("Merci de saisir votre <b>bon</b> ancien mot de passe !", info_alerte);return false ;}
			if ($("#lemdp").val() == "")
			{jAlert("Merci de saisir votre mot de passe !", info_alerte);return false ;}
			if ($("#mdp2").val() == "")
			{jAlert("Merci de confirmer votre mot de passe !", info_alerte);return false ;}
			if ($("#lemdp").val() != $("#mdp2").val())
			{jAlert("Attention, les deux mots de passe saisis sont différents ! Merci de les saisir à nouveau.", info_alerte);return false ;}
			
		return true;
	}
	
	if(quoi == "profileEmail")
	{
		var verif 	= new RegExp("^([a-zA-Z0-9_-])+([.]?[a-zA-Z0-9_-]{1,})*@([a-zA-Z0-9-_]{2,}[.])+[a-zA-Z]{2,4}$");
		if (verif.exec($("#email").val()) == null)
		{jAlert("Votre adresse E-mail n'est pas correcte !", info_alerte);return false ;}
		return true;		
	}
	
	if(quoi == "wall")
	{
		if ($("#wall").val() =='')
		{jAlert('Merci de saisir votre message !', info_alerte);return false ;}
		return true;
	}
	
	if(quoi == "repondreWall")
	{
		if ($('#wall'+n).val() == '')
		{jAlert('Merci de saisir votre message !', info_alerte);return false ;}
		return true;
	}	
	
	if(quoi == "commentaire")
	{
		if ($('#the_comment_'+n).val().replace(/^\s+/g,'').replace(/\s+$/g,'') =='' || $('#the_comment_'+n).val() =='Votre réaction...')
		{jAlert('Merci de saisir un commentaire !', info_alerte);return false ;}
		return true;
	}		
	
	if(quoi == "avis")
	{
		if (document.envoyercom.avis.value =='')
		{jAlert('Merci de saisir un avis !', info_alerte);return false ;}
		return true;
	}	
	
	if(quoi == "proposer_story")
	{
		if (document.proposer.titre.value =="")
		{jAlert("Merci de saisir le titre de la Story !", info_alerte);return false ;}

		if (document.proposer.story.value =="")
		{jAlert("Merci de saisir la Story !", info_alerte);return false ;}
		
		return true;
	}	
	
	if(quoi == "story")
	{
		if (document.ajout.titre.value =="")
		{jAlert("Merci de saisir le titre de la Story !", info_alerte);return false ;}

		if (document.ajout.story.value =="")
		{jAlert("Merci de saisir la Story !", info_alerte);return false ;}

		if(document.ajout.moment.checked == true)
		{
				if (document.ajout.description_story.value =="")
				{jAlert("Merci de saisir la description !", info_alerte);return false ;}
			
				if(n == "add") // Si c'est une modif on est pas obligé d'upload une image :D
				{
				if (document.ajout.img_moment.value =="")
				{jAlert("Merci d'uploader une image !", info_alerte);return false ;}
				}
		}
		
		return true;
	}
	
	if(quoi == "login")
	{
		if (document.log.login.value =="")
		{jAlert('Merci de saisir votre login', info_alerte);return false ;}

		if (document.log.mdp.value =="")
		{jAlert('Merci de saisir votre mot de passe !', info_alerte);return false ;}

		return true;
	}
	
	if(quoi == "email")
	{
		if (document.mdp.email.value =="" || verif_email == 2)
		{jAlert("Merci de saisir un e-mail valide !", info_alerte);return false ;}
		return true;
	}
	
	if(quoi == "sign")
	{
		varpseudo = document.inscription.pseudo.value;
	
		if (varpseudo =="" || verif_g == 1 || verif_g == 2) // Verification Ajax
		{jAlert("Merci de saisir un <b>pseudo</b> digne de ce nom ! ..enfin de ce pseudo !!", info_alerte);return false ;}

		if (document.inscription.mdp.value =="")
		{jAlert("Merci de saisir votre <b>mot de passe</b> !", info_alerte);return false ;}
		
		if (document.inscription.mdp2.value =="")
		{jAlert("Merci de confirmer votre <b>mot de passe</b> !", info_alerte);return false ;}
		
		var email 	= document.inscription.email.value;
   		var verif 	= new RegExp("^([a-zA-Z0-9_-])+([.]?[a-zA-Z0-9_-]{1,})*@([a-zA-Z0-9-_]{2,}[.])+[a-zA-Z]{2,4}$");
   		if (verif.exec(email) == null)
		{jAlert("Cette adresse <b>E-mail</b> n'est pas correcte !", info_alerte);return false ;}

		if (verif_email == 1)
		{jAlert("Cette adresse <b>E-mail</b> est déjà utilisée par un de nos membres !", info_alerte);return false ;}
		
		if (document.inscription.mdp.value != document.inscription.mdp2.value)
		{jAlert("Attention, les deux <b>mots de passe</b> saisis sont différents! Merci de les saisir à nouveau.", info_alerte);return false ;}
		
		if (document.inscription.calcul.value != n)
		{jAlert("<center>Merci de faire le calcul ! <br /> (Utilisez une calculatrice si c'est trop dur <b>;P</b>)</center>", info_alerte);return false ;}

		return true;
	}
}

// Shows the help messages in the helpline window
function helpline(help) {

vide_help = "&nbsp;";	
b_help = "AIDE : GRAS";
i_help = "AIDE : ITALIQUE";
u_help = "AIDE : SOULIGNEMENT";
line_help = "AIDE : BARRAGE";
center_help = "AIDE : CENTRER";
couleur_help = "AIDE : CHANGER LA COULEUR DU TEXTE (ROUGE PAR DEFAUT)";
img_help = "AIDE : INSERER UNE IMAGE";
url_help = "AIDE : INSERER UNE URL AVEC UN TITRE";
dm_help = "AIDE : INSERER UNE VIDEO DE DAILY MOTION";
yt_help = "AIDE : INSERER UNE VIDEO DE YOUTUBE";
mc_help = "AIDE : INSERER UNE VIDEO DE METACAFE";
ke_help = "AIDE : INSERER UNE VIDEO DE KEWEGO";
pari_help = "AIDE : INSERER UNE VIDEO DU PARISIEN";
wid_help = "AIDE : INSERER UNE VIDEO DE WIDEO";
sp_help = "AIDE : INSERER UNE VIDEO DE SOUTH PARK STUDIO";
ll_help = "AIDE : INSERER UNE VIDEO DE LIVE LEAK";
sn_help = "AIDE : INSERER UNE VIDEO DE SNOTR";
ju_help = "AIDE : INSERER UNE VIDEO DE JUBII TV";
ms_help = "AIDE : INSERER UNE VIDEO DE MYSPACE TV";
flv_help = "AIDE : INSERER UN FICHIER FLV";
zp_help = "AIDE : INSERER UNE VIDEO DE CANAL+";
sav_help = "AIDE : INSERER UNE VIDEO DE CANAL+";
source_help = "AIDE : SPECIFIER UNE SOURCE";
tj_help = "AIDE : INSERER UNE VIDEO DE TOM ET JERRY";
las_help = "AIDE : INSERER UNE VIDEO DES LASCARS";
allocine_help = "AIDE : INSERER UNE VIDEO D'ALLOCINE";
alloclips_help = "AIDE : INSERER UNE VIDEO D'ALLOCLIPS";
happytreefriends_help = "AIDE : INSERER UNE VIDEO HAPPY TREE FRIENDS";
les10choses_help = "AIDE : INSERER UNE VIDEO DES 10 CHOSES...";

profile_facebook_help = "Inserer soit l'ID qui se trouve dans l'url (exemple: 61735123), soit le nom de votre compte.";
profile_playlist_help = "Inserer l'<b>ID</b> de votre playlist Deezer.";
profile_deezer_help = "Inserer le nom de votre compte.";
profile_live_help = "Inserer l'adresse email de votre compte live. Exemple: moncompte@live.fr";
profile_myspace_help = "Inserer le nom de votre compte. Exemple: justintimberlake";
profile_twitter_help = "Inserer le nom de votre compte.";
profile_dailymotion_help = "Inserer le nom de votre compte.";
profile_youtube_help = "Inserer le nom de votre compte.";
profile_labrute_help = "Inserer le nom de votre compte.";
	
	help = eval(help + "_help");
	if (document.getElementById) document.getElementById("help").innerHTML=help
}

function helpline_bis(help) {

vide_help = "&nbsp;";	
profile_avatar_help = "Votre image sera automatiquement redimensionnée. <br>Les extensions acceptées sont : jpg et gif<br>Sa taille ne doit pas dépasser 800 ko."; 

	help = eval(help + "_help");
	if (document.getElementById) document.getElementById("help_2").innerHTML=help
}

function helpline_3(help) 
{
vide_help = "&nbsp;";	
profile_playlist_deezer_help = "Veuillez copier le code du lecteur exportable de votre playlist,  <img src='img/deezer.png' border='0'> Deezer vous le propose comme ci-dessous<br><img src='img/playlist_deezer_exemple.gif' border='0'>"; 

	help = eval(help + "_help");
	if (document.getElementById) document.getElementById("help_3").innerHTML=help
}

function limite(zone,max) 
{ 
	if(zone.value.length>=max){zone.value=zone.value.substring(0,max);} 
}

function pCGlobal(page_index, jq)
{
	$("#Pagination").css("display", "none");
	$("#"+laTab).html("<center><img src='img/ajax-loader.gif'> chargement...</center>");
	$.get('chargement_'+laTab+'.php',{ p : page_index, nbItem : LenbItem, filtre: leFiltre, tab: laTab },function success(data)
	{
			$("#"+laTab).fadeOut('slow', function() {
					if(data != 0) $("#"+laTab).html(data).fadeIn('slow'); else $("#"+laTab).html(msg_stories).fadeIn('slow');
					if(num_entries > LenbItem ) $("#Pagination").css("display", "block");
			});	
	});	
	return false;
}
           
function initPaginationGlobal(tab, filtre, nbItem) 
{
	leFiltre = filtre;
	laTab = tab;
	LenbItem = nbItem;
	$.get('chargement_'+laTab+'.php',{ nbRows: "nbRows", filtre: leFiltre, tab: laTab},function success(data)
	{
		num_entries = data;
		if(num_entries <= LenbItem) $("#Pagination").css("display", "none");
		$("#Pagination").pagination(num_entries, LenbItem, leFiltre, laTab, { num_edge_entries: 2, num_display_entries: 8, callback: pCGlobal, items_per_page:LenbItem });		
	});
 }
  
function trueUpdate()
{
	$.get('traitement_ajax.php', { whosOnline: "1854" }, function success(data) { $("#whosOnline").html(data); });
	window.setTimeout('trueUpdate()',30000);
}

function pageselectCallbackIndex(page_index, jq)
{
	$("#Pagination").css("display", "none");
	$("#stories").html("<center><img src='img/ajax-loader.gif'> chargement...</center>");	
	$.get('chargement_stories.php',{ p : page_index, nbItem : nbItem, filtre: leFiltre, info: lInfo },function success(data)
	{
			$("#stories").fadeOut('slow', function() 
			{
							if(data != 0) $("#stories").html(data).fadeIn('slow'); else $("#stories").html(msg_stories).fadeIn('slow');
							if(num_entries > nbItem ) $("#Pagination").css("display", "block");
			});	
			

	});	
	return false;
}
           
function initPaginationIndex(filtre, info) {
	nbItem = 50;
	leFiltre = filtre;
	lInfo = info;
	$.get('chargement_stories.php',{ nbRows: "nbRows", filtre: leFiltre, info: lInfo},function success(data)
	{
			num_entries = data;
			if(num_entries <= nbItem) $("#Pagination").css("display", "none");
			$("#Pagination").pagination(num_entries, nbItem, leFiltre, lInfo, { num_edge_entries: 2, num_display_entries: 8, callback: pageselectCallbackIndex, items_per_page:nbItem });	
	});
}

function rechercheStories()
{
	if(verifications('recherche')) initPaginationIndex('recherche', $('#recherche').val());
} 

function changeSearchIMG()
{
	if($('#recherche').val() != '') $('#rechercheIMG').attr('src', 'img/recherche_on.png'); else $('#rechercheIMG').attr('src', 'img/recherche.png');
}

function goToTop()
{
	$('html,body').animate({ scrollTop: 0 }, "slow");
}

function openSlide(elem) { 
	if($('#'+elem).css("display") == "block")
		$('#'+elem).slideUp("slow");
	else 
	$('#'+elem).slideDown("slow");
}

function openSlideState(elem)
{
	openSlide(elem);
	if($("#"+elem+"_state").html() == "-") $("#"+elem+"_state").html("+"); else $("#"+elem+"_state").html("-");
}

function only_members()
{
	jAlert("Oups, ce service est réservé aux membres. <br />Si vous n'êtes pas encore membre du site, <a href='sign'>inscrivez-vous</a>, c'est gratuit !  ", info_alerte);
}

function bientot_disponible()
{
	jAlert("Service bientôt disponible.", info_alerte);
}

function true_friends(action, to, from, profil)
{
	if(action == "block")
	{
		jConfirm('Voulez vous vraiment <b>bloquer</b> cette personne ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_ajax.php',{ friend: action, to: to},function success(data){
					if(data == 1)
					{
						if(from == "membres")
						{
							if(profil != 0)
							initPaginationGlobal(from, "friends:"+profil+":1", 10);
							else
							initPaginationGlobal(from, "null", 10);
						}
						if(from == "profil")
						location.reload();
					}
					else
					jAlertSwitch("droits");
				});	
		});			
	}
	if(action == "remove")
	{
		jConfirm('Voulez vous vraiment vous <b>débarasser</b> de cette "<b>ami(e)</b>" ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_ajax.php',{ friend: action, to: to},function success(data){
					if(data == 1)
					{
						if(from == "membres")
						{
							if(profil != 0)
							initPaginationGlobal(from, "friends:"+profil+":1", 10);
							else
							initPaginationGlobal(from, "null", 10);
						}
						if(from == "profil")
						location.reload();
					}
					else
					jAlertSwitch("droits");
				});	
		});			
	}
	if(action == "accept")
	{
		jConfirm('Voulez vous vraiment <b>accepter</b> cette <b>demande d\'amitié</b> ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_ajax.php',{ friend: action, to: to},function success(data){
					if(data == 1)
					{
						if(from == "membres")
						{
							if(profil != 0)
							initPaginationGlobal(from, "friends:"+profil+":1", 10);
							else
							initPaginationGlobal(from, "null", 10);
						}
						if(from == "profil")
						location.reload();
					}
					else
					jAlertSwitch("droits");
				});	
		});			
	}
	if(action == "deblock")
	{
		jConfirm('Voulez vous vraiment <b>débloquer</b> cette personne ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_ajax.php',{ friend: action, to: to},function success(data){
					if(data == 1)
					{
						if(from == "membres")
						{
							if(profil != 0)
							initPaginationGlobal(from, "friends:"+profil+":1", 10);
							else
							initPaginationGlobal(from, "null", 10);
						}
						if(from == "profil")
						location.reload();
					}
					else
					jAlertSwitch("droits");
				});	
		});			
	}	
	if(action == "add")
	{
		jConfirm('Voulez vous vraiment ajouter cette personne à vos "<b>amis</b>" ?', info_confirm, function(r) {
				if(r)
				$.get('traitement_ajax.php',{ friend: action, to: to},function success(data){
					if(data == 1)
					{
						if(from == "membres")
						{
							if(profil != 0)
							initPaginationGlobal(from, "friends:"+profil+":1", 10);
							else
							initPaginationGlobal(from, "null", 10);
						}
						if(from == "profil")
						location.reload();
					}
					else
					jAlertSwitch("droits");
				});	
		});			
	}

	if(action == "request")
	{
		jAlert("Vous ne pouvez pas effectuer cette action tant que vous serez <b>en attente</b> d'acceptation.", info_alerte);
	}		

	if(action == "unwanted")
	{
		jAlert("Vous ne pouvez pas effectuer cette action car cette personne <b>vous a bloquée</b> !", info_alerte);
	}		
}

function true_sharer(where) 
{
	u=location.href;
	t=document.title;
	
	if(where == "facebook")
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'True Sharer','toolbar=0,status=0,width=626,height=436');
	
	if(where == "twitter")
	window.open('http://twitter.com/home?status=Check out at '+encodeURIComponent(u),'True Sharer','toolbar=0,status=0,width=800,height=436');
	
	if(where == "myspace")
	window.open('http://www.myspace.com/index.cfm?fuseaction=postto&t='+encodeURIComponent(t)+'&u='+encodeURIComponent(u)+'&l=3','True Sharer','toolbar=0,status=0,width=626,height=436');
	
	if(where == "wikio")
	window.open('http://www.wikio.fr/vote?url='+encodeURIComponent(u),'True Sharer','toolbar=0,status=0,width=626,height=436');
	
	return false;
}

function limite2(zone,max,n) 
{ 
	$("#comment_carac_left"+n).html(max - zone.value.length);
	if(zone.value.length > max)
	{
		zone.value = zone.value.substring(0,max);
		$("#comment_carac_left"+n).html("0");
	} 
}

function onBlurComment(numero, x)
{
	if(x == 'anonyme')
	{			
			$("#the_comment_"+numero).val('Votre réaction...');
			$("#nickname_comment_"+numero).css('display','none');
			$("#avatar_comment_"+numero).css('display','none');
			$("#the_comment_"+numero).css('height','20px');		
	}
	else
	{
		if($("#the_comment_"+numero).val() == '')
		{ 
			$("#the_comment_"+numero).val('Votre réaction...');
			$("#btn_nb_left_comment"+numero).css('display','none');
			$("#nickname_comment_"+numero).css('display','none');
			$("#avatar_comment_"+numero).css('display','none');
			$("#the_comment_"+numero).css('height','20px');	
		}
	}
}

function onFocusComment(numero, x)
{
	if(x == 'anonyme')
	{
			$("#the_comment_"+numero).val('Vous devez être connecté(e) pour pouvoir réagir.');
			$("#nickname_comment_"+numero).css('display','block');
			$("#avatar_comment_"+numero).css('display','block');
			$("#the_comment_"+numero).css('height','50px');
	}
	else
	{	
		if($("#the_comment_"+numero).val() == 'Votre réaction...')
		{	
			$("#the_comment_"+numero).val('');
			$("#btn_nb_left_comment"+numero).css('display','block');
			$("#nickname_comment_"+numero).css('display','block');
			$("#avatar_comment_"+numero).css('display','block');
			$("#the_comment_"+numero).css('height','80px');
		}
	}
}

function getZikPlayer(r,t,n)
{
	if(t == "Deezer"){
	player = "<embed src='http://www.deezer.com/embed/player?rid="+r+"&ap=1&ln=fr' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' wmode='transparent' allownetworking='internal' width='450' height='375'></embed>"; 
	$("#zikPlayerTitle").html("La radio ( "+n+" ) "+t);
	}
	if(t == "Playlist"){ 
	player = "<embed src='http://www.deezer.com/embed/player?pid="+r+"&ap=1&ln=fr' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' wmode='transparent' allownetworking='internal' width='450' height='375'></embed> <br /><br /><b>Permalien :</b> <input type='text' class='permalien bradius' style='width:240px;' readonly='readonly' value='http://www.truestories.fr/p-"+n+"' onclick='this.select()' />"; 
	$("#zikPlayerTitle").html("La playlist de <a href='m-"+n+"'>"+n+"</a>");
	}
	if(t == "FM"){ 
	player = "<embed type='application/x-mplayer2' pluginspage='http://www.microsoft.com/windows/mediaplayer/' SRC='"+r+"' width='280' height='50' autostart='1' wmode='transparent' showcontrols='1' showpositioncontrols='0' showstatusbar='1' volume='-200' wmode='transparent'></embed>";
	$("#zikPlayerTitle").html("La radio "+n);
	}
	$("#zikPlayer").html(player);
}