function nextmember(note,photoid,sex)
{
	$("#tb_vote").hide();
	$("#resultats").hide();
	$("#loading_bar").show();
	var Ajax = $.ajax({   
			type: "GET", 
			url: "getjaxpublic.php",
			data: "note="+note+"&photoid="+photoid+"&sex="+sex,
			dataType: "xml",
			success: function(datas){updating(datas);},
			error: function(datax,erreur,objet){Ajax=null;nextmember(note,photoid,sex);},
			complete : function(data, status){}//if(status!="success") {nextmember(note,photoid,sex);}} 
			});

function updating(fiche)
{
	var pseudo = $(fiche).find('membre').text();
	var aboutme = $(fiche).find('about').text();
	var connecte = $(fiche).find('membre').attr("connecte");
	var nbpic = $(fiche).find('photos').find('image').size(); //on compte le nombre de photos
	var nbcom = $(fiche).find('commentaires').find('comment').size(); // idem commentaires
	var old_note = $(fiche).find('old_note').text();
	var stars = $(fiche).find('stars').text();
	var firstid = $(fiche).find('photos').find('image:first-child').attr("id");
	var actu_pic = $(fiche).find('photos').find('image:first-child').text();
	var allpics = "<font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">Ses autres photos: </font>";
	if (connecte == "0") $("#aff_pseudo").html(pseudo);
	else $("#aff_pseudo").html(pseudo+"<img src='online.gif' width='45' height='13' hspace=4 align='absmiddle' alt='' />");
	$("#about_me").html(aboutme);
	$("#actu_pic").attr("src","pics/"+actu_pic);
	$("#actu_pic").load(function(){$("#tb_vote").show(); $("#loading_bar").hide();}); //Nvelle Image chargee = affichage
	$("#img_profil").attr("href","index.php?cmd=20&username="+pseudo);
	$("#link_profil").attr("href","index.php?cmd=20&username="+pseudo);
	$("#img_message").attr("href","index.php?cmd=19&username="+pseudo);
	$("#link_message").attr("href","index.php?cmd=19&username="+pseudo);
	$("#img_sexlist").attr("href","index.php?cmd=611&add="+pseudo);
	$("#link_sexlist").attr("href","index.php?cmd=611&add="+pseudo);
	$("#link_commentaire").attr("href","index.php?cmd=12&phid="+firstid+"&mec="+pseudo);
	$("#img_transfer:parent").removeAttr('onclick');
	$("#link_transfer").removeAttr('onclick');
	$("#img_transfer").click(function(){window.open('http://maqueue.pixcatcher.com/download/?lang=fr&url=http://www.ma-queue.com/'+$("#actu_pic").attr("src")+'','_blank','width=650,height=600,status=1,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=0');});
	$("#link_transfer").click(function(){window.open('http://maqueue.pixcatcher.com/download/?lang=fr&url=http://www.ma-queue.com/'+$("#actu_pic").attr("src")+'','_blank','width=650,height=600,status=1,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=0');});
	$("#link_abus").click(function(){window.open('reportabuse.php?username='+pseudo+'&phid='+firstid+'','_abus','toolbar=0, location=0, directories=0, status=1, scrollbars=0, resizable=1, copyhistory=0, menuBar=0, width=525, height=280')});
	$("#etoiles").empty();
	$("#etoiles").html(stars);
	$("#etoiles img").each(function() {$(this).mouseout(resetstars)});
	if(old_note>0) //Le membre a vote ( != de zapper)
	{
		$("#old_pic_rating").html(old_note+" sur 10");
		$("#resultats").show();
	}
	$("#tab_commentaires").empty();
	//Boucles photos et commentaires
	var nbfoto = 1;
	$(fiche).find('photos').each(function(){ 
		$(this).find('image').each(function(){ 
			//on ajoute un lien vers la photo
			allpics += "<a href='index.php?username="+pseudo+"&phid="+$(this).attr("id")+"'>"+nbfoto+"</a> ";
			nbfoto++;
		}); 
	});
	$("#other_pics").empty();
	$("#other_pics").html(allpics);
	
	if(nbcom<1) //Aucun commentaire
	{
			$("#tab_commentaires").html('<font color="#990000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>&raquo; Aucun commentaire pour le moment !</b></font><br><font color="#131B24"> Soyez le premier à lui laisser un commentaire... </font>');
	}
	else //Affichage des commentaires
	{
		$(fiche).find('commentaires').each(function(){ 
			$(this).find('comment').each(function(){ 
				//on ajoute chaque commentaire à la liste
				$("#tab_commentaires").append('<font color="#990000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><b>&raquo; <a href="http://www.ma-queue.com/index.php?cmd=20&username='+$(this).attr("pseudo")+'"><font color="#990000">'+$(this).attr("pseudo")+'</font></a> le '+$(this).attr("date")+'</b><br><font color="#131B24">'+$(this).text()+'</font><br><br>');
			}); 
		});
	}
	
	Ajax = null; //suppression de la variable ajax pour éviter le cache du fichier xml
}

}

function resetstars()
{
	$("#etoiles img").attr('src','stars2.gif');
}

function staron(id)
{
	$("#"+id).prevAll("#etoiles img").attr('src','stars1.gif');
	$("#"+id).attr('src','stars1.gif');
}

function vote(pseudo,note,idphoto,sex)
{
	var oldsrc = $("#actu_pic").attr("src");
	$("#old_pic_link").attr("href","index.php?username="+pseudo+"&phid="+idphoto);
	$("#old_pic_img").attr("src",oldsrc);
	nextmember(note,idphoto,sex);
}

$(document).ready(function(){	$("#etoiles img").each(function() {$(this).mouseout(resetstars)});	});

