////////////////////////////////////////////////////////////////////
///// JAVASCRIPT CONTENANT TOUTES LES ACTIONS RELATIVES AU ARTISTES
////////////////////////////////////////////////////////////////////

// RECHERCHE D'ARTISTES
function recherche_artistes(p_recherche, p_liste)
{
	if(p_recherche != '')
	{
		verif_xhr();
		var liste = document.getElementById(p_liste);
		
		xhr_object.open("POST", 'pg/resultats_art.php',true);
			
		xhr_object.onreadystatechange = function()
		{
			if (xhr_object.readyState == 4 && xhr_object.status == 200) 
			{
				//write_div(xhr_object.responseText,p_id_rep);
				if(xhr_object.responseText)
				{
					liste.innerHTML = xhr_object.responseText;
					liste.style.display = 'block';
				}
			}
		}
		
		xhr_object.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr_object.send("recherche="+p_recherche);
	}	
}

// DEVENIR FAN 
function devenir_fan(p_ins_id, p_art_id) 
{				
	verif_xhr();
	
	xhr_object.open("POST", "pg/resultats_art.php", true);
	
	xhr_object.onreadystatechange = function() 
	{
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			document.getElementById('devenir_fan').innerHTML = xhr_object.responseText;
		}
		else
		{
			document.getElementById('devenir_fan').innerHTML = '<img name="image" src="images/loadingAnimation.gif" />';
		}
	}
	
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");			
	xhr_object.send("action=devenir_fan&ins_id="+p_ins_id+"&art_id="+p_art_id);
}

// AFFICHAGE DE LA GALERIE PHOTO 
function affiche_photos(p_section, p_art_id, p_art_dossier, p_page) 
{				
	verif_xhr();
	
	xhr_object.open("POST", "pg/resultats_art.php", true);
	
	xhr_object.onreadystatechange = function() 
	{
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			document.getElementById(p_section).innerHTML = xhr_object.responseText;
		}
		else
		{
			document.getElementById(p_section).innerHTML = '<p class="chargement"><img name="image" src="images/loadingAnimation.gif" /></p>';
		}
	}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");			
	xhr_object.send("action=affiche_photos&art_id="+p_art_id+"&art_dossier="+p_art_dossier+"&numpg="+p_page+"&section="+p_section);
}

// AFFICHAGE DES LIENS DE L'ARTISTE 
function affiche_liens(p_section, p_art_id) 
{				
	verif_xhr();
	
	xhr_object.open("POST", "pg/resultats_art.php", true);
	
	xhr_object.onreadystatechange = function() 
	{
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			document.getElementById(p_section).innerHTML = xhr_object.responseText;
		}
		else
		{
			document.getElementById(p_section).innerHTML = '<p class="chargement"><img name="image" src="images/loadingAnimation.gif" /></p>';
		}
	}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");			
	xhr_object.send("action=affiche_liens&art_id="+p_art_id);
}

// AFFICHAGE DES FANS DE L'ARTISTE 
function affiche_fans(p_section, p_art_id) 
{				
	verif_xhr();
	
	xhr_object.open("POST", "pg/resultats_art.php", true);
	
	xhr_object.onreadystatechange = function() 
	{
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			document.getElementById(p_section).innerHTML = xhr_object.responseText;
		}
		else
		{
			document.getElementById(p_section).innerHTML = '<p class="chargement"><img name="image" src="images/loadingAnimation.gif" /></p>';
		}
	}
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");			
	xhr_object.send("action=affiche_fans&art_id="+p_art_id);
}

// DEVENIR FAN 
function demande(p_ins_login, p_tit_nom, p_art_nom) 
{				
	verif_xhr();
	
	xhr_object.open("POST", "pg/resultats_art.php", true);
	
	xhr_object.onreadystatechange = function() 
	{
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			document.getElementById('demande').innerHTML = xhr_object.responseText;
		}
		else
		{
			document.getElementById('demande').innerHTML = '<img name="image" src="images/loadingAnimation.gif" />';
		}
	}
	
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");			
	xhr_object.send("action=demande&ins_login="+p_ins_login+"&tit_nom="+p_tit_nom+"&art_nom="+p_art_nom);
}
