function SupprimeMultimedia(id,pageconcernee)
{
var xhr=null;
    var url="";	
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { SupprimeMultimedia2(xhr,pageconcernee); };
	url="appelajax/Supprimemultimedia.php?id="+id;
	alert(url);
	document.getElementById('loader').innerHTML="<img src='images/loader.gif' width='20px'>";
	
    //on appelle le fichier reponse.txt
    xhr.open("GET", url, true);
    xhr.send(null);
}

function SupprimeMultimedia2(xhr,pageconcernee)
{
  if (xhr.readyState==4 && xhr.status == 200) 
    {
    	var docText= xhr.responseText;
		document.getElementById('loader').innerHTML="";
		//location.reload() ; 
		Nouveau();
		AfficheListe(pageconcernee);
	}
	
}



//=========================================================

function AfficheListe(pageconcernee)
{



var xhr=null;
    var url="";	
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { AfficheListe2(xhr,pageconcernee); };
	url="appelajax/AfficheListe.php?pageconcernee="+pageconcernee;
	//alert(url);
	document.getElementById('liste'+pageconcernee).innerHTML="<img src='images/loader.gif' width='20px'>";
	
    //on appelle le fichier reponse.txt
    xhr.open("GET", url, true);
    xhr.send(null);
}

function AfficheListe2(xhr,pageconcernee)
{
if (xhr.readyState==4 && xhr.status == 200) 
    {
    	var docXML= xhr.responseXML;
		var TAGtitre = docXML.getElementsByTagName("titre");
		var TAGid = docXML.getElementsByTagName("id");
		var chaine="";
		chaine+="<table width='100%' cellpadding='0' cellspacing='0'>";
		
		for(var i=0;i<TAGid.length;i++)
		{
		chaine+="<tr>";
		chaine+="<td align='left'  class='rubriquecote'  onclick='Modif("+TAGid.item(i).firstChild.data+",\""+pageconcernee+"\")'>";
		chaine+=TAGtitre.item(i).firstChild.data;
		chaine+="</td>";
		chaine+="</tr>";		
		}
		chaine+="</table>";
		
		
		document.getElementById('liste'+pageconcernee).innerHTML=chaine;


		
		
	}
}


function Modif(id,pageconcernee)
{
var xhr=null;
    var url="";	
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { Modif2(xhr,pageconcernee); };
	url="appelajax/Modif.php?id="+id+"&pageconcernee="+pageconcernee;
	//alert(url);
	document.getElementById('loader').innerHTML="<img src='images/loader.gif' width='20px'>";
	
    //on appelle le fichier reponse.txt
    xhr.open("GET", url, true);
    xhr.send(null);
}

function Modif2(xhr,pageconcernee)
{
	if (xhr.readyState==4 && xhr.status == 200) 
    {
		var docXML= xhr.responseXML;
		var TAGformation = docXML.getElementsByTagName("titre");
		var TAGid = docXML.getElementsByTagName("id");
		var TAGurlimage = docXML.getElementsByTagName("urlimage");		
		var TAGurlvideo = docXML.getElementsByTagName("urlvideo");
		var TAGfichiertexte = docXML.getElementsByTagName("fichiertexte");
		var TAGnomfichier = docXML.getElementsByTagName("nomfichier");
		
		document.getElementById('loader').innerHTML="";
		document.getElementById('idmultimedia').value=TAGid.item(0).firstChild.data;
		document.getElementById('titre').value=TAGformation.item(0).firstChild.data;
		
		if(document.getElementById('nomfichier'))
			{
				if(TAGnomfichier.item(0).firstChild.data!='-')
				document.getElementById('nomfichier').innerHTML="<span style='color:#008012'>Document Actuel : "+TAGnomfichier.item(0).firstChild.data+"</span><img style='cursor:pointer'  onclick='SupprimeDocMultimedia(\""+TAGid.item(0).firstChild.data+"\",\""+pageconcernee+"\",\"document\")' align='absmiddle' src='images/corbeille.jpg' width='25px'>";
				else
				document.getElementById('nomfichier').innerHTML="<span style='color:#F00'>Pas de document chargé</span>";
			}
		
		
		if(document.getElementById('nomimage'))
			{
				if(TAGurlimage.item(0).firstChild.data!='-')
				document.getElementById('nomimage').innerHTML="<span style='color:#008012'>Image Actuelle : "+TAGurlimage.item(0).firstChild.data+"</span><img style='cursor:pointer'  onclick='SupprimeDocMultimedia(\""+TAGid.item(0).firstChild.data+"\",\""+pageconcernee+"\",\"image\")' align='absmiddle' src='images/corbeille.jpg' width='25px'>";
				else
				document.getElementById('nomimage').innerHTML="<span style='color:#F00'>Pas d'image chargée</span>";
			}
			
		if(document.getElementById('nomvideo'))
		{
			if(TAGurlvideo.item(0).firstChild.data!='-')
			document.getElementById('nomvideo').innerHTML="<span style='color:#008012'>Video Acutelle : "+TAGurlvideo.item(0).firstChild.data+"</span><img style='cursor:pointer' onclick='SupprimeDocMultimedia(\""+TAGid.item(0).firstChild.data+"\",\""+pageconcernee+"\",\"video\")' align='absmiddle' src='images/corbeille.jpg' width='25px'>";
			else
			document.getElementById('nomvideo').innerHTML="<span style='color:#F00'>Pas de video chargée</span>";
		}
	
	
	
		document.getElementById('divsubmit').innerHTML="<input type='submit' id='' value='valider'>";
		document.getElementById('divsuppr').innerHTML="<input type='button' id='' value='Supprimer' onclick='SupprimeMultimedia("+document.getElementById("idmultimedia").value+",\""+pageconcernee+"\");'>";
	
		
		ed = window.tinyMCE.get("MonTexte"); // cible le champ à traiter 
		ed.setContent("");		
		
		ed.setContent(ed.getContent() + TAGfichiertexte.item(0).firstChild.data); // Ajoute du texte au texte déjà existant 
		
		
	}
}

function SupprimeDocMultimedia(id,pageconcernee,typedoc)
{
var xhr=null;
    var url="";	
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { SupprimeDocMultimedia2(xhr,id,pageconcernee); };
	url="appelajax/SupprimeDocMultimedia.php?id="+id+"&pageconcernee="+pageconcernee+"&typedoc="+typedoc;
	//alert(url);
	
    //on appelle le fichier reponse.txt
    xhr.open("GET", url, true);
    xhr.send(null);

}

function  SupprimeDocMultimedia2(xhr,id,pageconcernee)
{
if (xhr.readyState==4 && xhr.status == 200) 
    {
		//reactualise
		Modif(id,pageconcernee);
	}
}

function Nouveau()
{
document.getElementById('loader').innerHTML="";
		if(document.getElementById('idmultimedia'))
		document.getElementById('idmultimedia').value="";
		if(document.getElementById('titre'))
		document.getElementById('titre').value="";
		if(document.getElementById('nomimage'))
		document.getElementById('nomimage').innerHTML="";
		if(document.getElementById('nomvideo'))
		document.getElementById('nomvideo').innerHTML="";
		if(document.getElementById('nomfichier'))
		document.getElementById('nomfichier').innerHTML="";
		ed = window.tinyMCE.get("MonTexte"); // cible le champ à traiter 
		ed.setContent("");
}

//===================================================

function AffichePage(id,pageconcernee)
{
var xhr=null;
    var url="";	
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { AffichePage2(xhr); };
	url="appelajax/AffichePage.php?id="+id+"&pageconcernee="+pageconcernee;
	//alert(url);
	document.getElementById('texte').innerHTML="<img src='images/loader.gif' width='20px'>";
	
    //on appelle le fichier reponse.txt
    xhr.open("GET", url, true);
    xhr.send(null);

}

function AffichePage2(xhr)
{
 if (xhr.readyState==4 && xhr.status == 200) 
    {
    	var docXML= xhr.responseXML;
		var TAGformation = docXML.getElementsByTagName("valeurtitre");
		var TAGfichiertexte = docXML.getElementsByTagName("fichiertexte");
		var TAGurlimage = docXML.getElementsByTagName("urlimage");
		var TAGurlvideo = docXML.getElementsByTagName("urlvideo");
		var TAGrepertoireMultimedia = docXML.getElementsByTagName("repertoireMultimedia");
		var TAGlang = docXML.getElementsByTagName("lang");
var chaine="";
var video="";


var video=TAGurlvideo.item(0).firstChild.data;
var image=TAGurlimage.item(0).firstChild.data;
var lang=TAGlang.item(0).firstChild.data;

	if(lang=="fr")
		var rep = "agence/";
		if(lang=="en")
		var rep = "agence_en/";


if(video!='-')
{
	var attributes = {};
		var params = {};
	 	// for fullscreen
		params.allowfullscreen = "true";

		var flashvars = {};
		// the video file or the playlist file
		if(lang=="fr")
		flashvars.file = "agence/"+video;
		if(lang=="en")
		flashvars.file = "agence_en/"+video;
		// the PHP script
		//flashvars.streamscript = "flash/flvprovider.php";
		//flashvars.bufferlength = "1.5";

		// width and height of the player (h is height of the video + 20 for controlbar)
		// required for IE7
		flashvars.width = "320";
		flashvars.height = "260";
		// width  and height of the video
		flashvars.displaywidth = "320";
		flashvars.displayheight = "240";
		flashvars.autostart = "false";
		flashvars.showdigits = "true";

	 	// for fullscreen
		flashvars.showfsbutton = "true";

		// 9 for Flash Player 9 (for ON2 Codec and FullScreen)
		swfobject.embedSWF("phpsflvplayer.swf", "video", "320", "260", "9.0.0", "playerProductInstall.swf", flashvars, params, attributes);
}



//titre
document.getElementById('titre').innerHTML=TAGformation.item(0).firstChild.data;

//alert(TAGfichiertexte.item(0).firstChild.data);
//texte
document.getElementById('texte').innerHTML=TAGfichiertexte.item(0).firstChild.data;

//image
if(TAGurlimage.item(0).firstChild.data!='-')
document.getElementById('image').innerHTML="<img src='"+rep+TAGurlimage.item(0).firstChild.data+"' width='200px' >";

//on rempli le div video
//document.getElementById('video').innerHTML=video;



	}

	
}
