// AFFICHER UN BLOC
function Affiche(nom)
{
	var menu = document.getElementById(nom); 
	menu.style.display = '';	
}

// MASQUER UN BLOC
function Masque(nom)
{
	var menu = document.getElementById(nom); 
	menu.style.display = 'none';	
}

// AFFICHER/MASQUER UN BLOC
function AfficheMasque(nom)
{
	var menu = document.getElementById(nom); 
	if(menu.style.display == 'none')
		menu.style.display = '';	
	else
		menu.style.display = 'none';
}

function affichebg(p_id)
{
	var block = document.getElementById(p_id);
	block.style.background = "url('/images/fete_de_la_musique2.jpg') no-repeat bottom 100%;";
}

function cachebg(p_id)
{
	var block = document.getElementById(p_id);
	block.style.background = "";
}

// POP UP LECTURE PROGRAMME
function popupname(page,nom,largeur,hauteur) 
{
	var windowPop = window.open(page,nom,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width="+largeur+",height="+hauteur);
	windowPop.focus();
	windowPop.moveTo((screen.width-largeur)/2,(screen.height-hauteur)/2);
}

// DEMANADE AFFICHAGE DES UNIVERS
function affiche_univers(p_color_title, p_color_menu, p_bg_name, p_nb_artistes) 
{				
		var xhr_object = null;
		
		if(window.XMLHttpRequest) // Firefox
		  xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject) // Internet Explorer
		  xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else 
		{ // XMLHttpRequest non supporté par le navigateur
		  alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		  return;
		}
		
		xhr_object.open("POST", "../pg/resultat.php", true);
		
		xhr_object.onreadystatechange = function() 
		{
			if(xhr_object.readyState == 4 && xhr_object.status == 200)
			{
				document.body.innerHTML = xhr_object.responseText;
			}
		}
		
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		var data = "affiche_univers=1&color_title="+p_color_title+"&color_menu="+p_color_menu+"&bg_name="+p_bg_name+"&nb_artistes="+p_nb_artistes;
			
		xhr_object.send(data);
}

// DEMANADE AFFICHAGE DES ARTISTES
function affiche_artiste(p_color_title, p_color_menu, p_bg_name, p_nb_artistes, p_height) 
{				
		var xhr_object = null;
		
		if(window.XMLHttpRequest) // Firefox
		  xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject) // Internet Explorer
		  xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else 
		{ // XMLHttpRequest non supporté par le navigateur
		  alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		  return;
		}
		
		xhr_object.open("POST", "../pg/resultat.php", true);
		
		xhr_object.onreadystatechange = function() 
		{
			if(xhr_object.readyState == 4 && xhr_object.status == 200)
				document.body.innerHTML = xhr_object.responseText;
			else
				affiche_chargement();
		}
		
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send("affiche_artiste=1&color_title="+p_color_title+"&color_menu="+p_color_menu+"&bg_name="+p_bg_name+"&nb_artistes="+p_nb_artistes+"&height="+p_height);
}

// AFFICHAGE D'UN PROGRAMME EN FONCTION D'UN UNIVERS
function programme_univers(p_univers, p_color_title, p_color_menu, p_bg_name, p_nb_artistes) 
{		
	if(p_univers)
	{
		var xhr_object = null;
		
		if(window.XMLHttpRequest) // Firefox
		  xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject) // Internet Explorer
		  xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else 
		{ // XMLHttpRequest non supporté par le navigateur
		  alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		  return;
		}
		
		xhr_object.open("POST", "../pg/resultat.php", true);
		
		xhr_object.onreadystatechange = function() 
		{
			if(xhr_object.readyState == 4 && xhr_object.status == 200)
			{
				document.body.innerHTML = xhr_object.responseText;
			}
		}
		
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		var data = "univers="+escape(p_univers)+"&color_title="+p_color_title+"&color_menu="+p_color_menu+"&bg_name="+p_bg_name+"&nb_artistes="+p_nb_artistes;
			
		xhr_object.send(data);
	}
}

// AFFICHAGE D'UN PROGRAMME EN FONCION D'UN ARTISTE OU D'UN TITRE
function programme_avance(p_id, p_type, p_color_title, p_color_menu, p_bg_name, p_nb_artistes, p_height) 
{		
	if(p_type && p_id != 0)
	{
		var xhr_object = null;
		
		if(window.XMLHttpRequest) // Firefox
		  xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject) // Internet Explorer
		  xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else 
		{ // XMLHttpRequest non supporté par le navigateur
		  alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		  return;
		}
		
		xhr_object.open("POST", "pg/resultat.php", true);
		
		xhr_object.onreadystatechange = function() 
		{
			if(xhr_object.readyState == 4 && xhr_object.status == 200)
				document.body.innerHTML = xhr_object.responseText;
			else
				affiche_chargement();	
		}
		
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send(p_type+"="+p_id+"&color_title="+p_color_title+"&color_menu="+p_color_menu+"&bg_name="+p_bg_name+"&nb_artistes="+p_nb_artistes+"&height="+p_height);
	}
	else
		affiche_chargement();
}

// MODIFICATION DE LA LISTE DES ARTISTES
function change_liste_artistes(p_bloc, p_lettre, p_color_title, p_color_menu, p_bg_name, p_nb_artistes, p_height) 
{
	var xhr_object = null;
	
	if(window.XMLHttpRequest) // Firefox
	  xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // Internet Explorer
	  xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else 
	{ // XMLHttpRequest non supporté par le navigateur
	  alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	  return;
	}
	
	xhr_object.open("POST", "pg/resultat.php", true);
	
	xhr_object.onreadystatechange = function() 
	{
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
			document.getElementById(p_bloc).innerHTML = xhr_object.responseText;
		else
			affiche_chargement_div(p_bloc);
	}
	
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhr_object.send("lettre="+p_lettre+"&color_title="+p_color_title+"&color_menu="+p_color_menu+"&bg_name="+p_bg_name+"&nb_artistes="+p_nb_artistes+"&height="+p_height);
}

// AFFICHAGE DES TITRES D'UN ARTISTE CHOISI
function listing_titre(p_artiste, p_bloc, p_color_title, p_color_menu, p_bg_name, p_nb_artistes, p_height) 
{
	if(p_artiste != 0)
	{
		var xhr_object = null;
		
		if(window.XMLHttpRequest) // Firefox
		  xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject) // Internet Explorer
		  xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else 
		{ // XMLHttpRequest non supporté par le navigateur
		  alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		  return;
		}
		
		xhr_object.open("POST", "pg/resultat.php", true);
		
		xhr_object.onreadystatechange = function() 
		{
			if(xhr_object.readyState == 4 && xhr_object.status == 200)
				document.getElementById(p_bloc).innerHTML = xhr_object.responseText;
			else
				affiche_chargement_div(p_bloc);
		}
		
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhr_object.send("artiste_select="+p_artiste+"&color_title="+p_color_title+"&color_menu="+p_color_menu+"&bg_name="+p_bg_name+"&nb_artistes="+p_nb_artistes+"&height="+p_height);
	}
	else
		affiche_chargement_div(p_bloc);
}

// AFFICHAGE DE LA BARRE DE CHARGEMENT
function affiche_chargement() 
{
		document.body.innerHTML = '<div id="resultat" name="resultat" style="height: 400px; text-align: center; padding-top: 190px;"><img src="../images/loadingAnimation.gif" /></div>';
}

// AFFICHAGE DE LA BARRE DE CHARGEMENT
function affiche_chargement_div(p_bloc) 
{
		document.getElementById(p_bloc).innerHTML = '<img src="../images/loadingAnimation.gif" />';
}

// AFFICHAGE DE LA LISTE D'ARTISTE CORRESPONDANT A LA RECHERCHE
function recherche_artistes(p_recherche, p_liste, p_color_title, p_color_menu, p_bg_name, p_nb_artistes, p_height)
{
	if(p_recherche != '')
	{
		var xhr_object = null;
		var liste = document.getElementById(p_liste);

		if(window.XMLHttpRequest) // Firefox
		  xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject) // Internet Explorer
		  xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else 
		{ // XMLHttpRequest non supporté par le navigateur
		  alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		  return;
		}
		
		xhr_object.open("POST", 'pg/resultat.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+"&liste="+p_liste+"&color_title="+p_color_title+"&color_menu="+p_color_menu+"&bg_name="+p_bg_name+"&nb_artistes="+p_nb_artistes+"&height="+p_height);
	}	
}
	

