/*
* Updates the list of the stars and the title (h1) of the page in function of a criteria.
* This function is called in liste-stars.php when the user selects a value in the dropdown.
* @param value (String) : the criteria of the stars list to display.
*				"all" 		>	All the celebrities
*				"f"  			>	Female celebrities
*				"m"   		>	Male celebrities
*				"fr"  		>	French stars
*				"int" 		>	International stars
*				"mu"  		>	Music
*				"ci"  		>	Cinema / Television
*				"sp" 			>	Sport
*				"ma"  		> Supermodels
*				"popular"	> Popular celebrities
*/
function updateStarsList(value) {
	if (value) {
		// This token is useful to force the ajax request not to use the browser's cache
		var token = randomString(8);

		if(texte = file(domainUrl+'/modules/ajax/get-liste-star.php?criteria='+value+'&token='+token)) { 
			if (texte.substring(texte.length-2)=="-1") {
				writediv(js_PasEncorePortaits);
			} else writediv(texte);
		}
		
		if (value=='f') {
			document.getElementById('titleStars').innerHTML = titleF;
		}
		if (value=='m') {
			document.getElementById('titleStars').innerHTML = titleM;
		}
		if (value=='ci') {
			document.getElementById('titleStars').innerHTML = titleCi;
		}
		if (value=='mu') {
			document.getElementById('titleStars').innerHTML = titleMu;
		}
		if (value=='sp') {
			document.getElementById('titleStars').innerHTML = titleSp;
		}
		if (value=='ma') {
			document.getElementById('titleStars').innerHTML = titleMa;
		}
		if (value=='fr') {
			document.getElementById('titleStars').innerHTML = titleFr;
		}
		if (value=='int') {
			document.getElementById('titleStars').innerHTML = titleInt;
		}
		if (value=='all') {
			document.getElementById('titleStars').innerHTML = titleAll;
		}
		if (value=='po') {
			document.getElementById('titleStars').innerHTML = titlePo;
		}
		if (value=='popular') {
			document.getElementById('titleStars').innerHTML = titlePopular;
		}
	}
	else {
			writediv("");	
	}
	// clear the focus on the dropdown to avoid scroll problems
	var dropdown = document.getElementById('criteria');
	var button = document.getElementById('searchButton');
	if (dropdown && button) {
		button.focus();
	}
}

function writediv(texte)
{
	thediv = document.getElementById('divListeStar');	
  if (texte=="") {
		thediv.className ="";
		thediv.innerHTML = "";
	}
	else {
		thediv.className ="divListeStar";
		thediv.innerHTML = texte;
	}
}

function showHideDiv(divId, showIt) {
	var mydiv = document.getElementById(divId);
	if (mydiv) {
		if (!showIt && mydiv.style.display == "block") {
			mydiv.style.display = "none";
		}
		else if (showIt) {
			mydiv.style.display = "block";
		}
	}
}
