function suppression_element(flag) {
	// var flag = "flag_"+lg;
//		var noeud = document.getElementById("myform").getElementsByTagName("p")[0].getElementsByTagName("a")[0];
//		var noeud = document.getElementById(flag).firstChild;
	var noeud = document.getElementById(flag);
	// var lg = flag.substring(flag.length-2,flag.length);
	// alert("Les champs de saisie ont été ajoutés pour une version "+lg);
//		disparu = document.getElementById("myform").getElementsByTagName("p")[0].removeChild(noeud);
//		disparu = document.getElementById(flag).removeChild(noeud);
	disparu = document.getElementById(flag).parentNode.removeChild(noeud);
	// alert(disparu.firstChild.nodeValue)
}

function add_input_mosaique(field,indice) {	
	// un champ input hidden doit etre prŽsent avec l'id "upfields"
	// pour stocker les noms des champs input file crŽŽs	
	var ch = document.getElementById(field).value;
	var tab = ch.split(",");
	var nb = tab.length;
	if( nb > 10){
		alert("Vous ne pouvez envoyer plus de 10 fichiers attachés");
	}else{
		var new_block = document.createElement('div');
		lenom = indice+'_'+nb;
		new_block.innerHTML = '<div>';
		new_block.innerHTML += '<label for="'+lenom+'_fold">Nom du dossier contenant les images de ce bloc :</label>';
		new_block.innerHTML += '<input id="'+lenom+'_fold" name="'+lenom+'_fold" value="" /><br />';
		var views = new Array("top","bottom","right","face","left");	
		for( var x=0; x<views.length; x++ ){
			var view = views[x];
			new_block.innerHTML += '<input name="'+lenom+'_'+view+'" type="file" /> <label for="'+lenom+'_'+view+'">Vue '+view+'</label><br />';
		}	
		new_block.innerHTML += '<div>';
		document.getElementById(field).parentNode.appendChild(new_block);
		document.getElementById(field).value += lenom +",";
	}
}

function add_input_file(field,indice) {	
	// un champ input hidden doit etre prŽsent avec l'id "upfields"
	// pour stocker les noms des champs input file crŽŽs	
	var ch = document.getElementById(field).value;
	var tab = ch.split(",");
	var nb = tab.length;
	if( nb > 10){
		alert("Vous ne pouvez envoyer plus de 10 fichiers attachés");
	}else{
		var lenom = indice+"_"+nb;
	
		var nouveau_champ = document.createElement("input");
		var nouveau_attribut = document.createAttribute("id");
			nouveau_attribut.nodeValue = lenom;
			nouveau_champ.setAttributeNode(nouveau_attribut);
		var nouveau_attribut = document.createAttribute("name");
			nouveau_attribut.nodeValue = lenom;
			nouveau_champ.setAttributeNode(nouveau_attribut);
		var nouveau_attribut = document.createAttribute("type");
			nouveau_attribut.nodeValue = "file";
			nouveau_champ.setAttributeNode(nouveau_attribut);
	
		var br = document.createElement('br');
		document.getElementById(field).parentNode.appendChild(br);
		document.getElementById(field).parentNode.appendChild(nouveau_champ);
		document.getElementById(field).value += lenom +",";
	}
}

function add_input_qcm(cible,name,nat,label) {		
	// var form = document.getElementById('myform');
	// var table = new Array("titre","resume","contenu");
	var attributes = new Array("type","size","cols","rows","maxlength");	
	// var ref = "field_ref_"+nat;
	var ref = cible;
	// var flag = cible+"_flag_";	
	var nb = document.getElementById(cible).childNodes.length;
	var lenom = name+"_"+nb;
	// flag_to_copy = document.getElementById(flag).cloneNode(true);	
	// document.getElementById(flag).parentNode.appendChild(flag_to_copy.firstChild);
	// var nat = document.getElementById(ref).tagName;
	var nouveau_champ = document.createElement(nat);
	var nouveau_attribut = document.createAttribute("id");
		nouveau_attribut.nodeValue = "field_"+lenom;
		nouveau_champ.setAttributeNode(nouveau_attribut);
	var nouveau_attribut = document.createAttribute("name");
		nouveau_attribut.nodeValue = lenom;
		nouveau_champ.setAttributeNode(nouveau_attribut);
	for( var x=0; x<attributes.length; x++ ){
		var quoi = attributes[x];
		var u = document.getElementById(ref).getAttribute(quoi);
		
		if(u){	
			var nouveau_attribut = document.createAttribute(quoi);
				nouveau_attribut.nodeValue = u;
				nouveau_champ.setAttributeNode(nouveau_attribut);
		}
	}
	if(nat=="textarea" || nat=="TEXTAREA"){
		var br = document.createElement('br');
		document.getElementById(cible).appendChild(br);
		var plus_moins = document.createElement('span');
		var intitule = document.createElement('span');
		var radio = document.createElement('span');
		plus_moins.innerHTML = '<a onclick="reduire(\''+lenom+'\')" title="Réduire ce champ">(-)</a><a onclick="agrandir(\''+lenom+'\')" title="Agrandir ce champ">(+)</a>';
		intitule.innerHTML = '<label for="field_'+lenom+'">'+label+' : </label>';
		radio.innerHTML = '<b>Valeur : </b>';
		radio.innerHTML += '<label for="correct'+lenom+'">correct : </label><input type="radio" id="correct'+lenom+'" name="valeur'+lenom+'" value="1" />';
		radio.innerHTML += '<label for="incorrect'+lenom+'">incorrect : </label><input type="radio" id="incorrect'+lenom+'" name="valeur'+lenom+'" value="0" checked="checked"/>';
		document.getElementById(cible).appendChild(intitule);
		document.getElementById(cible).appendChild(plus_moins);
		document.getElementById(cible).appendChild(radio);
	}	
	document.getElementById(cible).appendChild(nouveau_champ);
	//var br = document.createElement('br');
	// document.getElementById(cible).appendChild(br);

	document.getElementById("content_ids").value += lenom +",";
	var ch = document.getElementById("content_ids").value;
	var tab = ch.split(",");
}

function add_input_newsletter(cible,nat) {		
	// var form = document.getElementById('myform');
	// var table = new Array("titre","resume","contenu");
	var attributes = new Array("type","size","cols","rows","maxlength");	
	var ref = "field_ref_"+nat;
	// var flag = cible+"_flag_";	
	var nb = document.getElementById(cible).childNodes.length;
	var lenom = nb+"_"+nat;
	// flag_to_copy = document.getElementById(flag).cloneNode(true);	
	// document.getElementById(flag).parentNode.appendChild(flag_to_copy.firstChild);
	// var nat = document.getElementById(ref).tagName;
	var nouveau_champ = document.createElement(nat);
	var nouveau_attribut = document.createAttribute("id");
		nouveau_attribut.nodeValue = lenom+"_field";
		nouveau_champ.setAttributeNode(nouveau_attribut);
	var nouveau_attribut = document.createAttribute("name");
		nouveau_attribut.nodeValue = lenom;
		nouveau_champ.setAttributeNode(nouveau_attribut);
	for( var x=0; x<attributes.length; x++ ){
		var quoi = attributes[x];
		var u = document.getElementById(ref).getAttribute(quoi);
		
		if(u){	
			var nouveau_attribut = document.createAttribute(quoi);
				nouveau_attribut.nodeValue = u;
				nouveau_champ.setAttributeNode(nouveau_attribut);
			}
	}
	// alert(ref+"/"+nb);
	if(nat=="textarea" || nat=="TEXTAREA"){
		var plus_moins = document.createElement('span');
		plus_moins.innerHTML = '<a onclick="reduire(\''+lenom+'\')" title="Réduire ce champ">(-)</a><a onclick="agrandir(\''+lenom+'\')" title="Agrandir ce champ">(+)</a>';
		document.getElementById(cible).appendChild(plus_moins);
		var br = document.createElement('br');
		document.getElementById(cible).appendChild(br);
	}	
	document.getElementById(cible).appendChild(nouveau_champ);
	var br = document.createElement('br');
	document.getElementById(cible).appendChild(br);
	
	document.getElementById("content_ids").value += lenom +",";
	var ch = document.getElementById("content_ids").value;
	var tab = ch.split(",");
	// alert(tab.length);
}

function add_trad(cible,lg) {		
	// var form = document.getElementById('myform');
	// var table = new Array("titre","resume","contenu");
	var attributes = new Array("type","size","cols","rows","maxlength");
	
	//for( var z=0; z<table.length; z++ ){
		//	var xhtml = "http://www.w3.org/1999/xhtml";
		var ref = "field_"+cible+"_fr";
		var lenom = cible+"_"+lg;
		var flag = cible+"_flag_"+lg;
		
		var nb = document.getElementById(flag).parentNode.childNodes.length;
		flag_to_copy = document.getElementById(flag).cloneNode(true);
		
		document.getElementById(flag).parentNode.appendChild(flag_to_copy.firstChild);
		var nat = document.getElementById(ref).tagName;

		var nouveau_champ = document.createElement(nat);
		var nouveau_attribut = document.createAttribute("id");
			nouveau_attribut.nodeValue = "field_"+lenom;
			nouveau_champ.setAttributeNode(nouveau_attribut);
		var nouveau_attribut = document.createAttribute("name");
			nouveau_attribut.nodeValue = lenom;
			nouveau_champ.setAttributeNode(nouveau_attribut);
		for( var x=0; x<attributes.length; x++ ){
			var quoi = attributes[x];
			var u = document.getElementById(ref).getAttribute(quoi);
			
			if(u){	
				var nouveau_attribut = document.createAttribute(quoi);
					nouveau_attribut.nodeValue = u;
					nouveau_champ.setAttributeNode(nouveau_attribut);
				}
		}
		if(nat=="textarea" || nat=="TEXTAREA"){
			var plus_moins = document.createElement('span');
			plus_moins.innerHTML = '<a onclick="reduire(\''+lenom+'\')" title="Réduire ce champ">(-)</a><a onclick="agrandir(\''+lenom+'\')" title="Agrandir ce champ">(+)</a>';
			document.getElementById(flag).parentNode.appendChild(plus_moins);
			var br = document.createElement('br');
			document.getElementById(flag).parentNode.appendChild(br);
		}	
		document.getElementById(flag).parentNode.appendChild(nouveau_champ);
		var br = document.createElement('br');
		document.getElementById(flag).parentNode.appendChild(br);
		/*
		var br = document.createElement('plusmoins');
		br.innerHTML = '<b>hello</b>';
		document.getElementById(flag).parentNode.appendChild(br);
		// document.getElementById(flag).parentNode.insertBefore(nouveau_champ,document.getElementById(flag).parentNode.firstChild);
		var nouveau_champ = '<input type="text" name="truc_'+lg+'" size="25" value="" />';
		document.getElementById(flag).parentNode.innerHTML += nouveau_champ;
		*/
		//document.getElementById(ref).parentNode.innerHTML += st;
		suppression_element(flag);
	//}	
}

function restore_flag(id_field){
}
/* UTILISE pour ajouter un champ de texte a chacune des entrees de $table
function suppression_element(lg) {
	var flag = "flag_"+lg;
//		var noeud = document.getElementById("myform").getElementsByTagName("p")[0].getElementsByTagName("a")[0];
//		var noeud = document.getElementById(flag).firstChild;
	var noeud = document.getElementById(flag);
	alert("Les champs de saisie ont été ajoutés pour une version "+lg);
//		disparu = document.getElementById("myform").getElementsByTagName("p")[0].removeChild(noeud);
//		disparu = document.getElementById(flag).removeChild(noeud);
	disparu = document.getElementById(flag).parentNode.removeChild(noeud);
	// alert(disparu.firstChild.nodeValue)
}
function addInput(lg) {		
	var form = document.getElementById('myform');
	var table = new Array("titre","resume","contenu");
	var attributes = new Array("type","size","cols","rows","maxlength");
	var flag = "flag_"+lg;
	for( var z=0; z<table.length; z++ ){
		//	var xhtml = "http://www.w3.org/1999/xhtml";
		var ref = "field_"+table[z];
		var lenom = table[z]+"_"+lg;
		flag_to_copy = document.getElementById(flag).cloneNode(true);
		document.getElementById(ref).parentNode.appendChild(flag_to_copy.firstChild);
		// alert(flag_to_copy.firstChild.getAttribute("src"));
	
		var nat = document.getElementById(ref).tagName;
		var nouveau_champ = document.createElement(nat);
		var nouveau_attribut = document.createAttribute("id");
			nouveau_attribut.nodeValue = "field_"+lenom;
			nouveau_champ.setAttributeNode(nouveau_attribut);
		var nouveau_attribut = document.createAttribute("name");
			nouveau_attribut.nodeValue = lenom;
			nouveau_champ.setAttributeNode(nouveau_attribut);
		// var st = '<'+nat+' id="field_'+lenom+'" name="'+lenom+'" ';
		for( var x=0; x<attributes.length; x++ ){
			var quoi = attributes[x];
			var u = document.getElementById(ref).getAttribute(quoi);
			
			if(u){		
			var nouveau_attribut = document.createAttribute(quoi);
				nouveau_attribut.nodeValue = u;
				nouveau_champ.setAttributeNode(nouveau_attribut);
				// st += quoi+'="'+u+'" ';
			}
		}
		// st += "/>";
		// alert(lenom+" : "+ nat+" : "+st);
		document.getElementById(ref).parentNode.appendChild(nouveau_champ);
		//document.getElementById(ref).parentNode.innerHTML += st;
	}	
	suppression_element(lg);
}
*/