var xmlhttps= new Array();
function execAjax(url, id, valeurs) {

  var i= xmlhttps.length;
  if(window.XMLHttpRequest) {// Mozilla
    xmlhttps[i]= new XMLHttpRequest();
    xmlhttps[i].onreadystatechange= function() { xmlhttpChange(i, url, id); };
    xmlhttps[i].open('POST', url, true);
    xmlhttps[i].setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=iso-8859-1');
    xmlhttps[i].send(valeurs);
  }
  else if(window.ActiveXObject) {// IE
    xmlhttps[i]= new ActiveXObject("Microsoft.XMLHTTP");
    if(xmlhttps[i]) {
      xmlhttps[i].onreadystatechange= function() { xmlhttpChange(i, url, id); };
      xmlhttps[i].open('POST', url, true);
      xmlhttps[i].setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=iso-8859-1');
      xmlhttps[i].send(valeurs);
    }
  }
}

function xmlhttpChange(i, url, id) {
  if(xmlhttps[i].readyState==4 && xmlhttps[i].status == 200) {
    setInnerHTML(document.getElementById(id), xmlhttps[i].responseText);
  }
}

// SetInnerHTML Sécurisé
function setInnerHTML(divContent, HTML) {
  divContent.innerHTML=HTML; 
  var All=divContent.getElementsByTagName("*");
  for (var i=0; i<All.length; i++) {
    All[i].id=All[i].getAttribute("id")
    All[i].name=All[i].getAttribute("name")
    All[i].className=All[i].getAttribute("class")
  }
  var AllScripts=divContent.getElementsByTagName("script")
  for (var i=0; i<AllScripts.length; i++) {
    var s=AllScripts[i];
    if (s.src && s.src!=""){
      // Précédement asynchrone, mis en synchrone pour éviter des problèmes de dépendances de scripts
      eval(getFileContent(s.src))
    }
    else {
      eval(s.innerHTML)
    }
  }
}


// Renvoie le texte de l'objet ActiveXObject le plus récent depuis une liste
var pickRecentProgID = function (idList){
  var bFound = false; // found progID flag
  for(var i=0; i < idList.length && !bFound; i++){
    try{
      var oDoc = new ActiveXObject(idList[i]);
      o2Store = idList[i];
      bFound = true;
    } catch (objException){};
  }
  if (!bFound)
    throw ("Aucun ActiveXObject n'est valide sur votre ordinateur, pensez à mettre à jour votre navigateur");
  
  idList = null;
  return o2Store;
}
 
    
// Retourne un nouvel objet XmlHttpRequest
var GetXmlHttpRequest_AXO=null
var GetXmlHttpRequest=function () {
  if (window.XMLHttpRequest) {
    return new XMLHttpRequest()
  }
  else if (window.ActiveXObject) {
    if (!GetXmlHttpRequest_AXO) {
	  GetXmlHttpRequest_AXO=pickRecentProgID(["Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"]);
	}
	return new ActiveXObject(GetXmlHttpRequest_AXO)
  }
  return false;
}

function scrollingDetector(){
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		document.getElementById('floteur').style.margin = document.body.scrollTop + 30 +'px 0px 0px 0px';
	}
	else
	{
		document.getElementById('floteur').style.margin = window.pageYOffset + 30 +'px 0px 0px 0px';
	}
}
//setInterval("scrollingDetector()", 250);

function closeDiv(){
	document.getElementById('divBack').style.visibility = "hidden";
	document.getElementById('floteur').style.visibility = "hidden";
}

function openDiv(idFolder, idParent, idZic){
	scrollingDetector();
	execAjax("pages/showFolder.php", "artist", "idFolder="+idFolder+"&idParent="+idParent+"&idZic="+idZic);
	document.getElementById('divBack').style.visibility = "visible";
	document.getElementById('floteur').style.visibility = "visible";

}

function updateStar(star){
	for(i=1; i<6; i++){
		if(document.getElementById('star['+i+']').id <= star.id) document.getElementById('star['+i+']').src = 'pages/starf.gif';
		else document.getElementById('star['+i+']').src = 'pages/stare.gif';
	}
}