function SelectionObject(Window)
{ 
	this.window=(Window?Window:window)
	this.document=this.window.document
}

function getHTMLOfSelection (window, document)
{
	var range
	if(window.ActiveXObject && document.selection && document.selection.createRange)
	{
		range = document.selection.createRange()
		return range.htmlText
	}
	else if (window.getSelection)
	{
		var selection = window.getSelection()
		if (selection.rangeCount > 0)
		{
			range = selection.getRangeAt(0)
			var clonedSelection = range.cloneContents()
			var div = document.createElement('div')
			div.appendChild(clonedSelection)
			return div.innerHTML
		}
		else
		{
			return ''
		}
	}
	else
	{
		return ''
	}
}

if(!document.selection)
{
	try
	{
		SelectionObject.prototype=
		{
			"clear":
				function()
				{
					try
					{
						var sel = this.window.getSelection()
						sel.collapse(true)
						sel.dettach()
    				}
					catch(ex){}
				},
			"createRange":function()
			{
				if (this.type=="none")
				{
					var range = "no selection"
					range.text=""; range.htmlText=""
					return range
				}
				if (!this.activeElement)
				{
					var txt = window.getSelection()
					var sel = {}
					try{sel=window.getSelection().getRangeAt(0);}
					catch (ex) {}
					var html = getHTMLOfSelection(this.window, this.document)
					var range = null
    		  
					range = new ControlRangeObject();
					range.isControlRange=true;
					range._text=(""+txt+"");
					range._htmlText=html;
					range._range=sel;
					range.base=sel.commonAncestorContainer?sel.commonAncestorContainer:this.document.body
					range.items=new Array()
					range.addElement=range.add
    		  
					try
					{
						while (range.base.nodeName.substr(0,1)=="#"){range.base=range.base.parentNode}
						var index = 0
						var started
						var current = range.base.childNodes[0]
						ma_sel=window.getSelection()
						while (current)
						{
							if(ma_sel.containsNode(current,false)){range.items.push(current)}
//							if (started || current==sel.startContainer || current==sel.commonAncestorContainer)
//							{
//								started = true
//								range.items.push(current)
//							}
//							if (current == sel.endContainer || current==sel.commonAncestorContainer)
//							{
//								break
//							}
							index++;
							current = range.base.childNodes[index]
						}
						range.length=range.items.length
					}
					catch (ex){}
				  
					return range
				}
				else
				{
    		var base = this.activeElement;
    		var range = new ControlRangeObject();
    		range.isControlRange=false;
    		range._text = base.value.substring(base.selectionStart, base.selectionEnd);
    		range._htmlText=range._text;
    		range._range=null;
    		range.base=base;
    		range.items=[range.base];
    		range.addElement=range.add;
    		
    		return range;
    	  }
    	}
    }
    SelectionObject.prototype.empty=SelectionObject.prototype.clear;
    SelectionObject.prototype.createRangeControl=SelectionObject.prototype.createRange;
    SelectionObject.prototype.findActiveElement=function() {
        function haveFocus(inp) {
            try { // IE
                var result = !!(inp.hasFocus||inp==document.activeElement);
                if (result) { return result; }
            } catch (ex) {}
            try { // FF; Safari
                var sel = false;
        		sel=window.getSelection().getRangeAt(0);
                if (!sel.collapsed) { return false; }
                var sel2 = document.createRange();
                sel2.setStartBefore(inp);
                sel2.setEndBefore(inp);
                var result = sel.compareBoundaryPoints(Range.START_TO_START, sel2)==0;
                result = result && sel.compareBoundaryPoints(Range.END_TO_END, sel2)==0;
                result = result && sel.startOffset == sel2.startOffset
                result = result && sel.endOffset == sel2.endOffset
                return result;
            } catch (ex) {}
            try { // Opéra
                return !!(inp.selectionStart||inp.selectionEnd);
            } catch (ex) {}
            return false;
        }
    	try {
    		var allInputs = this.document.getElementsByTagName("INPUT");
    		var allTAreas = this.document.getElementsByTagName("TEXTAREA");
    		var l1 = allInputs.length; var l2 = allTAreas.length;
    		for (var i=0; i<l1; i++) {
    			var inp = allInputs[i];
    			if (inp.type=="" || inp.type=="text") {
    				if (haveFocus(inp)) {
    					this.activeElement = inp;
    					return "Text";
    				}
    			}
    		}
    		for (var i=0; i<l2; i++) {
    			var inp = allTAreas[i];
                if (haveFocus(inp)) {
                    this.activeElement = inp;
    				return "Text";
    			}
    		}
            if (document.activeElement) { return document.activeElement; }
    	} catch (ex) {}
    };
    SelectionObject.prototype.__defineGetter__("type", function() {
      try {
    	  this.activeElement = false;
    	  var sel = false; 
    	  if ((""+window.getSelection()+"")=="") { 
    		this.findActiveElement(); 
    		if (this.activeElement) {
    			return "Text";
    		}
    	  }
    	  try { 
    		sel = window.getSelection().getRangeAt(0);
    	  } catch (ex) {}
    	  if (sel.commonAncestorContainer.nodeName.substr(0,1)=="#") {
    		  return "Text";
    	  } else {
    		  return "Control";
    	  }
      } catch (ex) { }
      return "None";
    });
    SelectionObject.prototype.__defineSetter__("type", function() {
      // Do nothing
    });
    // ControlRangeObject
    function ControlRangeObject() {}
    ControlRangeObject.prototype={
    	"_text":"",
    	"_htmlText":"",
    	"_range":null,
    	"parentElement":function()
			{
    			return this.base
			},
    	"item":function(i)
			{
    			return this.items[i]
			},
    	"add":function(node)
			{
    			try{this._range.insertNode(node)}
				catch (ex){}
			},
    	"execCommand":function(a1,a2,a3,a4) {
    		var mode = document.designMode;
    		document.designMode="on";
    		document.execCommand(a1,a2,a3,a4);
    		document.designMode=mode;
    	}
    }
    // Properties
    ControlRangeObject.prototype.__defineGetter__("text",function() {
    	return this._text;
    });
    ControlRangeObject.prototype.__defineSetter__("text",function(value) {
    	if (this.isControlRange) {
    		var range = this._range;
    		var p=document.createTextNode(value);
    		range.deleteContents();
    		range.insertNode(p)
            try { window.getSelection().collapseToEnd() } catch (ex) {}
    	} else {
    		var beforeText = this.base.value.substr(0, this.base.selectionStart);
    		var middleText = value;
    		var afterText  = this.base.value.substr(this.base.selectionEnd);
    		this.base.value = beforeText+middleText+afterText;
    		this.base.selectionStart = beforeText.length + value.length;
    		this.base.selectionEnd   = this.base.selectionStart;
            this.base.focus();
    	}
    });
    ControlRangeObject.prototype.__defineGetter__("htmlText",function() {
    	return this._htmlText
    });
    ControlRangeObject.prototype.__defineSetter__("htmlText",function(value) {
    	var range = this._range;
    	var p=document.createElement("htmlSection");
    	p.innerHTML=value;
    	range.deleteContents();
    	range.insertNode(p)
    });
    document.selection=new SelectionObject(); 
} catch (ex) {} }

//necessite la librairie "data_conv.js" et "std.js"
//necessite l'image "colpick.jpg" dans dossier "images/boutons"

//format:	id_nuancier=nom de l'objet
//			mode= defini le format de valeur_init : "hex"=>(#rrggbb),"rgb"=>(r(0a255),g,b) ou "teinte"=>%r,0,%g,0,%b,0,100(alpha),0
//			largeur,hauteur = largeur et hauteur de la palette de couleur
//			nb_nuance = nombre de nuance de luminosité
//			valeur_init = couleur init dans le format "#rrggbb"
function creer_nuancier(id_nuancier,mode,largeur,hauteur,nb_nuance,valeur_init)
{
	code="<div style='display:inline;width:1px;height:1px;border:1px solid #aaa' id='"+id_nuancier+"_bt'><img src='images/spacer.gif' width=60 height=12 onclick='"+id_nuancier+"_palette.afficher(event)'></div>"
	code+="<input type='hidden' name='"+id_nuancier+"'>"
	code+="<table id='"+id_nuancier+"_palette' border='0' cellspacing='0' cellpadding='0' style='cursor:crosshair;position:absolute;display:none'><tr><td rowspan='"+(nb_nuance+1)+"'><img src='../images/boutons/std/colpick.jpg' width='"+largeur+"' height='"+hauteur+"' onclick='"+id_nuancier+"_palette.lire_palette1(event)' onmouseover='clearTimeout("+id_nuancier+"_palette.timeout)'></td><td id='"+id_nuancier+"_palette0' style='background-color:#000000;width:20px;height:"+Math.round(hauteur/nb_nuance)+"px' onclick='"+id_nuancier+"_palette.lire_palette2(this)' onmouseover='clearTimeout("+id_nuancier+".timeout)'></td></tr>"
	for(cpt=1;cpt<nb_nuance;cpt++)
	{
		code+="<tr><td id='"+id_nuancier+"_palette"+cpt+"' style='background-color:#000000;width:20px;height:"+Math.round(hauteur/nb_nuance)+"px' onclick='"+id_nuancier+"_palette.lire_palette2(this)' onmouseover='clearTimeout("+id_nuancier+"_palette.timeout)'></td></tr>"
	}
	code+="</td></tr></table>"

	document.write(code)

	obj=document.getElementById(id_nuancier+"_palette")
	obj.largeur=largeur
	obj.hauteur=hauteur
	obj.nb_nuance=nb_nuance
	obj.mode=mode
	obj.data=document.getElementById(id_nuancier)
	obj.bouton=document.getElementById(id_nuancier+"_bt")

	obj.afficher=function(){afficher(this)}
	
	obj.code_couleur_pixel=function(x,y)
	{
		// calcul de la couleur à partir des coordonnées du clic
		var part_width =  (this.largeur+1)/6
		var part_nb_nuance = this.nb_nuance/2
		var im_height = this.hauteur
		
		var rouge = (x >= 0)*(x < part_width)*255
				+ (x >= part_width)*(x < 2*part_width)*(2*255 - x * 255 / part_width)
				+ (x >= 4*part_width)*(x < 5*part_width)*(-4*255 + x * 255 / part_width)
				+ (x >= 5*part_width)*(x < 6*part_width)*255;
		var bleu = (x >= 2*part_width)*(x < 3*part_width)*(-2*255 + x * 255 / part_width)
				+ (x >= 3*part_width)*(x < 5*part_width)*255
				+ (x >= 5*part_width)*(x < 6*part_width)*(6*255 - x * 255 / part_width);
		var vert = (x >= 0)*(x < part_width)*(x * 255 / part_width)
				+ (x >= part_width)*(x < 3*part_width)*255
				+ (x >= 3*part_width)*(x < 4*part_width)*(4*255 - x * 255 / part_width);
		
		var coef = (im_height-y)/im_height;

		// composantes de la couleur choisie sur la "palette"
		rouge = 128+(rouge-128)*coef;
		vert = 128+(vert-128)*coef;
		bleu = 128+(bleu-128)*coef;
		
		code_couleur=new Array()
		code_couleur.rouge=rouge
		code_couleur.vert=vert
		code_couleur.bleu=bleu
		code_couleur.hex="#"+dechex(rouge)+dechex(vert)+dechex(bleu)
			
		return code_couleur
	}

	obj.maj_palette2=function(code_couleur)
	{
		rouge=code_couleur.rouge
		vert=code_couleur.vert
		bleu=code_couleur.bleu
		
		for(i = 0; i < this.nb_nuance; i++)
		{
			if (i>=0 && i<this.nb_nuance/2)
			{
				var final_coef = i/(this.nb_nuance/2)
				var final_rouge = dechex(255 - (255 - rouge) * final_coef)
				var final_vert = dechex(255 - (255 - vert) * final_coef)
				var final_bleu = dechex(255 - (255 - bleu) * final_coef)
			}
			else
			{
				var final_coef = 2 - i/(this.nb_nuance/2)
				var final_rouge = dechex(rouge * final_coef)
				var final_vert = dechex(vert * final_coef)
				var final_bleu = dechex(bleu * final_coef)
			}
			document.getElementById(this.id+i).style.backgroundColor='#'+final_rouge+final_vert+final_bleu
		}
	}

	obj.lire_palette1=function(e)
	{
		switch(navigateur())
		{
			case "Safari":
				x=e.clientX+2
				y=e.clientY+2
			break
			case "Internet Explorer":
				x=e.x+document.body.scrollLeft
				y=e.y+document.body.scrollTop
			break
			case "Firefox":
				x=e.clientX+document.body.scrollLeft+2
				y=e.clientY+document.body.scrollTop+2
			break
		}
		x-=this.x_off
		y-=this.y_off
		
		code_couleur=this.code_couleur_pixel(x,y)
		this.maj_palette2(code_couleur)
		
		//mise a jour de la couleur du bouton
		this.bouton.style.backgroundColor=code_couleur.hex

		switch (this.mode)
		{
			case "hex":
				this.data.value=code_couleur.hex
			break
			case "rgb":
				this.data.value=Math.round(code_couleur.rouge)+","+Math.round(code_couleur.vert)+","+Math.round(code_couleur.bleu)
			break
			case "teinte":
				r=code_couleur.rouge
				v=code_couleur.vert
				b=code_couleur.bleu
				this.data.value=Math.round(r/255*100)+",0,"+Math.round(v/255*100)+",0,"+Math.round(b/255*100)+",0,100,0"
			break
		}
	}

	obj.lire_palette2=function(e)
	{
		//mise a jour de la couleur du bouton
		code_hex=e.style.backgroundColor
		this.bouton.style.backgroundColor=code_hex

		r=hexdec(code_hex.substring(1,3))
		v=hexdec(code_hex.substring(3,5))
		b=hexdec(code_hex.substring(5,7))

		switch (this.mode)
		{
			case "hex":this.data.value=code_hex;break
			case "rgb":
				this.data.value=Math.round(r)+","+Math.round(v)+","+Math.round(b)
			break
			case "teinte":
				this.data.value=Math.round(r/255*100)+",0,"+Math.round(v/255*100)+",0,"+Math.round(b/255*100)+",0,100,0"
			break
		}
	}

	obj.onmouseout=function()
	{
		this.timeout=setTimeout(this.id+".style.display='none'",100)
	}

	if(valeur_init!="")
	{
		code_couleur=new Array()

		switch (obj.mode)
		{
			case "hex":
				obj.data.value=valeur_init
				obj.bouton.style.backgroundColor=valeur_init

				code_couleur.rouge=hexdec(valeur_init.substring(1,3))
				code_couleur.vert=hexdec(valeur_init.substring(3,5))
				code_couleur.bleu=hexdec(valeur_init.substring(5,7))
				code_couleur.hex=valeur_init
				obj.maj_palette2(code_couleur)
			break
			case "rgb":
				obj.data.value=valeur_init

				valeur_init=valeur_init.split(",")
				code_couleur.rouge=parseInt(valeur_init[0])
				code_couleur.vert=parseInt(valeur_init[1])
				code_couleur.bleu=parseInt(valeur_init[2])
				code_couleur.hex="#"+dechex(code_couleur.rouge)+dechex(code_couleur.vert)+dechex(code_couleur.bleu)
				obj.bouton.style.backgroundColor=code_couleur.hex
				obj.maj_palette2(code_couleur)
			break
			case "teinte":
				obj.data.value=valeur_init
				valeur_init=valeur_init.split(",")
				code_couleur.rouge=Math.round(parseInt(valeur_init[0])/100*255)
				code_couleur.vert=Math.round(parseInt(valeur_init[2])/100*255)
				code_couleur.bleu=Math.round(parseInt(valeur_init[4])/100*255)
				code_couleur.hex="#"+dechex(code_couleur.rouge)+dechex(code_couleur.vert)+dechex(code_couleur.bleu)
				
				obj.bouton.style.backgroundColor=code_couleur.hex
				obj.maj_palette2(code_couleur)
			break
		}
	}
}


//retourne un select d'une serie de couleur réduite
function creer_palette_couleur(name_obj,valeur_init)
{
	palette=document.createElement("select")
	
	hexa=Array("44","77","bb","ff")
		
	option=document.createElement("option")
	option.value="#000000"
	option.style.background=option.value
	option.innerText="    "
	palette.appendChild(option)
	option.unselectable="on"

	for(cpt in hexa)
	{
		option=document.createElement("option")
		option.value="#"+hexa[cpt]+"0000"
		option.style.background=option.value
		option.innerText="    "
		palette.appendChild(option)
		option.unselectable="true"
		if(valeur_init==option.value){option.selected='on'}
	}
	for(cpt in hexa)
	{
		option=document.createElement("option")
		option.value="#00"+hexa[cpt]+"00"
		option.style.background=option.value
		option.innerText="    "
		palette.appendChild(option)
		option.unselectable="true"
		if(valeur_init==option.value){option.selected='on'}
	}
	for(cpt in hexa)
	{
		option=document.createElement("option")
		option.value="#0000"+hexa[cpt]
		option.style.background=option.value
		option.innerText="    "
		palette.appendChild(option)
		option.unselectable="true"
		if(valeur_init==option.value){option.selected='on'}
	}

	for(cpt in hexa)
	{
		option=document.createElement("option")
		option.value="#"+hexa[cpt]+hexa[cpt]+"00"
		option.style.background=option.value
		option.innerText="    "
		palette.appendChild(option)
		option.unselectable="true"
		if(valeur_init==option.value){option.selected='on'}
	}
	for(cpt in hexa)
	{
		option=document.createElement("option")
		option.value="#00"+hexa[cpt]+hexa[cpt]
		option.style.background=option.value
		option.innerText="    "
		palette.appendChild(option)
		option.unselectable="true"
		if(valeur_init==option.value){option.selected='on'}
	}

	for(cpt in hexa)
	{
		option=document.createElement("option")
		option.value="#"+hexa[cpt]+"00"+hexa[cpt]
		option.style.background=option.value
		option.innerText="    "
		palette.appendChild(option)
		option.unselectable="true"
		if(valeur_init==option.value){option.selected='on'}
	}
	for(cpt in hexa)
	{
		option=document.createElement("option")
		option.value="#"+hexa[cpt]+hexa[cpt]+hexa[cpt]
		option.style.background=option.value
		option.innerText="    "
		palette.appendChild(option)
		option.unselectable="true"
		if(valeur_init==option.value){option.selected='on'}
	}

	palette.onchange=function(){this.parentNode.focus()}

	if(name_obj!="")
	{
		palette.name=name_obj
		palette.id=name_obj
	}
	return palette
}

//verifie que la selection courante est bien dans un editeur html
//=>utilisé dans la fonction creer_editeur_html
function is_selection_in_editor(editeur,accept_control)
{
	if(document.all)
	{
		if(document.selection.type=="Control")//si la selection est une image (ou un bouton)
		{
			if(accept_control){return true}else{return false}
		}
		tempo=document.selection.createRange().parentElement()
		ok=0
		while(ok==0)
		{
			if(tempo==editeur){ok=1}
			if(tempo.tagName=="BODY"){ok=-1}
			if(ok==0){tempo=tempo.parentNode}
		}
		if(ok==1){return true}else{return false}
	}
	else
	{//firefox ou safari: pas besoin de ce test
		return true
	}
}

//necessite la librairie "data_conv.js" et "std.js"
//necessite dans le dossier "images/boutons":"colpick.jpg"
//necessite dans le dossier "images/boutons":"gras.gif","italic.gif","souligne.gif","barre.gif","lien.gif","gomme.gif"

//format:	id_editeur=nom de l'objet
//			mode = pas utile (a voir pour les type de commande d'edition possible)
//			largeur,hauteur = largeur et hauteur de la zone d'edition
//			contenu = contenu html(en escaped) dans la zone d'edition

function creer_editeur_html(id_editeur,mode,largeur,hauteur,contenu)
{
	contenu=unescape(contenu)
	if(navigateur()=="Safari")
	{
		/*liste cmd pour execCommand safari:
		BackColor
Bold
Copy
Cut
Delete
FontName
FontSize
FontSizeDelta
ForeColor
ForwardDelete
Indent
InsertLineBreak
InsertParagraph
InsertText
Italic
JustifyCenter
JustifyFull
JustifyLeft
JustifyNone
JustifyRight
Outdent
Paste
PasteAndMatchStyle
Print
Redo
SelectAll
Subscript
Superscript
Underline
Undo
Unselect
*/
		//contenu=noHtml(contenu);
		//document.write("<div align=center style='border:1px solid aaa;background:#999999'>(Editeur Mac simplifi&eacute;)<br><textarea style='border:1px solid #aaa;width:"+largeur+"px;height:"+hauteur+"px' id='"+id_editeur+"' name='"+id_editeur+"' onblur='this.innerHTML=modifie(this.innerHTML)'>"+contenu+"</textarea></div>")
		//return false
		document.write("<table border=0><tr><td><input type=button value='Gras' onclick=document.execCommand('Bold')><input type=button value='Italic' onclick=document.execCommand('Italic')><input type=button value='Souligner' onclick=document.execCommand('Underline')>&nbsp;&nbsp;&nbsp;<input type=button value='Ferrer gauche' onclick=document.execCommand('JustifyLeft')><input type=button value='Centrer' onclick=document.execCommand('JustifyCenter')><input type=button value='Ferrer droite' onclick=document.execCommand('JustifyRight')>&nbsp;&nbsp;&nbsp;<input type=button value='>>' onclick=document.execCommand('Indent')><input type=button value='<<' onclick=document.execCommand('Outdent')></td></tr>")
		document.write("<tr><td><div id=tempo_editeur style='width:"+largeur+"px;height:"+hauteur+"px;border:1px solid #aaa' contentEditable=true onblur=this.donnees.value=this.innerHTML>"+contenu+"</div></td></tr></table><input type=hidden name='"+id_editeur+"' id='"+id_editeur+"'>")
		obj=document.getElementById("tempo_editeur")
		obj.id=null
		obj.donnees=document.getElementById(id_editeur)
		return false
		//document.write("<input type=button value='test' onclick=alert("+id_editeur+".value)>")
	}

	
	if(largeur<500){largeur=500}

	largeur_ext=largeur+4
	hauteur_ext=hauteur+4+20
	code="<table border='0'><tr><td id='cmd_"+id_editeur+"' style='border:1px solid #aaa;background:#aaa'></td></tr><tr><td><div style='border:1px solid #aaa;width:"+largeur+"px;height:"+hauteur+"px;overflow:auto;vertical-align:top'><div id='zoneEdit_"+id_editeur+"' contentEditable=true></div></div></td></tr></table><input type=hidden id='"+id_editeur+"' name='"+id_editeur+"'>"
	document.write(code)

	zone_edit=document.getElementById("zoneEdit_"+id_editeur)
	
	if(!document.editeurs){document.editeurs=new Array()}
	edit=new Array()
	edit["zone_edit"]=zone_edit
	edit["innerHTML"]=contenu
	document.editeurs.push(edit)

	zone_edit.code=document.getElementById(id_editeur)
	zone_edit.code.zone_edit=zone_edit

	zone_edit.contentEditable="true"
	zone_edit.unselectable="off"
	zone_edit.cleanAfterPaste=function()
	{
		chaine=this.innerHTML

		do{
			old_chaine=chaine
			chaine=old_chaine.replace(/<\?xml:[ #\"a-zA-Z0-9=:\-;]*\/>/,"")
		}while(old_chaine!=chaine)

		do{
			old_chaine=chaine
			chaine=old_chaine.replace(/<\/{0,1}SPAN[ #\"=a-zA-Z0-9:\-;\.]*>/,"")
		}while(old_chaine!=chaine)

		do{
			old_chaine=chaine
			chaine=old_chaine.replace(/style=\"[ #a-zA-Z0-9:\-;\.]*[Mm]so[ #a-zA-Z0-9:\-;\.]*\"/,"")
		}while(old_chaine!=chaine)

		chaine=chaine.split("<o:p>").join("")
		chaine=chaine.split("</o:p>").join("")

		if(chaine.substring(0,5)=="<DIV>"){chaine=chaine.substring(5,chaine.length-6)}

		chaine=chaine.join("")

		do{
			old_chaine=chaine
			chaine=old_chaine.replace(/<\/{0,1}P[ #\"a-zA-Z0-9=:\-;]*>/,"")
		}while(old_chaine!=chaine)

		this.innerHTML=chaine
		//alert(this.innerHTML)

//		if(chaine!=this.innerHTML)
//		{
//			alert("Certains éléments de la mise en page du texte copier risquent d'être effacés. Le résultat obtenu ne sera donc pas forcément comme l'original.")
//		}
	}
	zone_edit.onpaste=function()
	{
		setTimeout("zoneEdit_"+id_editeur+".firstChild.cleanAfterPaste()",1)
	}
	zone_edit.change_touche=function(keycode)
	{
		switch(keycode)
		{
			case 13://transforme le saut de ligne en <br> (et non en <p> par defaut)
				//ma_selection=document.selection.createRange()
				//ma_selection.pasteHTML("<BR>")
				//return false
			break
//			case 16://SHIFT
//				document.shiftMode=true
//			break
//			case 17://CTRL
//				document.ctrlMode=true
//			break
//			case 18://ALT
//				document.altMode=true
//			break
			case 32://barre espace
				if(event.shiftKey)
				{//transforme l'espace en &nbsp; 
					ma_selection=document.selection.createRange()
					ma_selection.pasteHTML("&nbsp;")
					return false
				}
			break
		}
	}
	zone_edit.onkeydown=function(){return this.change_touche(event.keyCode)}
	zone_edit.onkeyup=function()
	{
		switch(event.keyCode)
		{
//			case 16://SHIFT
//				document.shiftMode=false
//			break
//			case 17://CTRL
//				document.ctrlMode=false
//			break
//			case 18://ALT
//				document.altMode=false
//			break
		}
	}


	zone_edit.ajouter_element=function(data,style)
	{
		if(tempo_selection_editeur)
		{
			switch(navigateur())
			{
				case "Firefox":
					tempo_selection_editeur.deleteContents()
					new_element=document.createElement('img')
					new_element.setAttribute("style",style)
					new_element.id=escape(data)
					new_element.src="images/std/spacer.gif"
					new_element.className="wm_module"
					new_element.ondblclick=function()
					{
						tempo_data=this.id
						this.id='element_module_change'
						form_edition_article.data.value='change_element=element_module_change&'+tempo_data
						form_edition_article.target='popup'
						form_edition_article.cmd.value='choix_element'
						afficher_obj(document.getElementById('popup'))
						form_edition_article.submit()
					}
					tempo_selection_editeur.insertNode(new_element)
				break
				case "Internet Explorer":
					tempo_selection_editeur.pasteHTML("<img class=wm_module src='images/std/spacer.gif' ondblclick=\"this.id='element_module_change';form_edition_article.data.value='change_element=element_module_change&'+this.data;form_edition_article.target='popup';form_edition_article.cmd.value='choix_element';afficher_obj(document.getElementById('popup'));form_edition_article.submit()\" style=\""+style+"\" id=\""+escape(data)+"\">")
				break
			}
		}
//		if(obj=document.getElementById("current_cursor_editor"))
//		{
//			obj.outerHTML="<img class=wm_module src='images/std/spacer.gif' ondblclick=\"this.id='element_module_change';form_edition_article.data.value='change_element=element_module_change&'+this.data;form_edition_article.target='popup';form_edition_article.cmd.value='choix_element';afficher_obj(document.getElementById('popup'));form_edition_article.submit()\" style=\""+style+"\" data=\""+escape(data)+"\">"
//			new_obj=document.createElement("img")
//			style=style.split(";")
//			for(cpt in style)
//			{
//				params_style=style[cpt].split(":")
//				new_obj.style.setAttribute(params_style[0],params_style[1])
//			}
//			new_obj.setAttribute("className","wm_module")
//			new_obj.src="images/std/spacer.gif"
//			new_obj.setAttribute("data",escape(data))
//			new_obj.ondblclick="this.id='element_module_change';form_edition_article.data.value='change_element=element_module_change&'+this.data;form_edition_article.target='popup';form_edition_article.cmd.value='choix_element';afficher_obj(document.getElementById('popup'));form_edition_article.submit()"
//
//			obj.parentNode.replaceChild(new_obj,obj)

//		}

//		if(is_selection_in_editor(this,false))
//		{
//			tempo=document.selection.createRange()
//			tempo.pasteHTML("<img class=wm_module src='images/std/spacer.gif' ondblclick=\"this.id='element_module_change';form_edition_article.data.value='change_element=element_module_change&'+this.data;form_edition_article.target='popup';form_edition_article.cmd.value='choix_element';afficher_obj(document.getElementById('popup'));form_edition_article.submit()\" style=\""+style+"\" data=\""+escape(data)+"\">")
//		}
	}

	zone_edit.code.nettoyer=function()
	{
		chaine=this.zone_edit.innerHTML

		//??? le outerHTML renvoie un %0A%0D en debut de chaine...??!!!
		chaine=escape(chaine)
		chaine=chaine.split("%0A").join("")
		chaine=chaine.split("%0D").join("")
		chaine=unescape(chaine)

		chaine=chaine.split(" unselectable=\"on\"").join("")
		chaine=chaine.split(" unselectable=\"off\"").join("")
		chaine=chaine.split(" contentEditable=true").join("")
		chaine=chaine.split(" just_objdrop=\"false\"").join("")

		chaine=chaine.split("<OL><LI>").join("####olli####")
		chaine=chaine.split("<UL><LI>").join("####ulli####")
		chaine=chaine.split("<LI").join("</LI><LI")
		chaine=chaine.split("####olli####").join("<OL><LI>")
		chaine=chaine.split("####ulli####").join("<UL><LI>")
		
		chaine=chaine.split("</P><P>&nbsp;").join("<BR>")

		chaine=chaine.split("'").join("&#39;")

		chaine=chaine.split("«").join("&#171;")
		chaine=chaine.split("»").join("&#187;")
		chaine=chaine.split("“").join("&#147;")
		chaine=chaine.split("”").join("&#148;")
		chaine=chaine.split("…").join("&#133;")
		chaine=chaine.split("ƒ").join("&#131;")
		chaine=chaine.split("„").join("&#132;")
		chaine=chaine.split("ˆ").join("&#136;")
		chaine=chaine.split("‰").join("&#137;")
		chaine=chaine.split("Œ").join("&#142;")
		chaine=chaine.split("‘").join("&#145;")
		chaine=chaine.split("’").join("&#146;")
		chaine=chaine.split("•").join("&#149;")
		chaine=chaine.split("™").join("&#153;")
		chaine=chaine.split("œ").join("&#156;")
		chaine=chaine.split("˜").join("&#152;")
		chaine=chaine.split("©").join("&#169;")
		chaine=chaine.split("°").join("&#176;")
		chaine=chaine.split("±").join("&#177;")
		chaine=chaine.split("´").join("&#180;")
		chaine=chaine.split("º").join("&#186;")
		chaine=chaine.split("¼").join("&#188;")
		chaine=chaine.split("½").join("&#189;")
		chaine=chaine.split("¾").join("&#190;")
		chaine=chaine.split("¿").join("&#191;")
		chaine=chaine.split("®").join("&#174;")

		chaine=chaine.split("<DIV>").join("")
		chaine=chaine.split("</DIV>").join("")

		this.value=chaine
	}


	zone_edit.ondrop=function()
	{
		this.just_objdrop=true
	}

	zone_edit.onmousemove=function()
	{
		if(this.just_objdrop)
		{
			this.just_objdrop=false
			if(document.selection.type=="Control")
			{
				range=document.selection.createRange()
				image=range.item(0)

				if(image.tagName=="IMG")
				{
					nom_image=image.src.split("/").pop()
					image.border=0
					
					//cas d'un fichier autre qu'une image (pdf, doc, swf, zip...)
					if(image.data)
					{
						nom_fichier=image.data.split("<>")
						switch(nom_fichier[0])
						{
							case "pdf":
								image.outerHTML="<a href=\"pdf/user/"+nom_fichier[1]+"/"+nom_fichier[2]+"\"><img src='images/std/icones/wm-icone-pdf.gif' border='0'>"+nom_fichier[2]+"</a>"
							break;
							case "doc":
							break;
							case "zip":
							break;
							case "swf":
								image.outerHTML="<img class=wm_module src='images/std/spacer.gif' style=\"width:150px;height:150px;background:url(images/std/icones/wm-icone-swf.jpg)\"  data=\""+escape("id_element=8&dossier_src=swf/user/"+nom_fichier[1]+"&nom_fichier="+nom_fichier[2])+"\">"
							break;
						}
					}
				}
			}
		}
	}

	cmd=document.getElementById("cmd_"+id_editeur)

	bt=new Array()

	bt[0]=document.createElement("img")
	bt[0].src="images/boutons/editeurHTML/gras.gif"
	bt[0].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,false)){document.execCommand("bold", false, null)}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[0])

	bt[1]=document.createElement("img")
	bt[1].src="images/boutons/editeurHTML/italic.gif"
	bt[1].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,false)){document.execCommand("Italic", false, null)}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[1])

	bt[2]=document.createElement("img")
	bt[2].src="images/boutons/editeurHTML/souligne.gif"
	bt[2].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,false)){document.execCommand("Underline", false, null)}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[2])

	bt[3]=document.createElement("img")
	bt[3].src="images/boutons/editeurHTML/barre.gif"
	bt[3].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,false)){document.execCommand("strikeThrough", false, null)}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[3])

	bt[4]=document.createElement("img")
	bt[4].src="images/boutons/editeurHTML/gomme.gif"
	bt[4].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,false)){document.execCommand("RemoveFormat", false, null)}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[4])

	bt[5]=document.createElement("img")
	bt[5].src="images/boutons/editeurHTML/couleur.gif"
	bt[5].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,false)){document.execCommand("ForeColor",false,this.code_couleur.value)}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[5])
/*
	creer_nuancier("nuancier_"+id_editeur,"hex",100,100,10,"#ff0000")
	tempo_obj=document.getElementById("nuancier_"+id_editeur+"_bt")
	cmd.appendChild(tempo_obj)
	tempo_obj=document.getElementById("nuancier_"+id_editeur)
	bt[5].code_couleur=tempo_obj
*/

	nuancier=creer_palette_couleur()
	cmd.appendChild(nuancier)
	bt[5].code_couleur=nuancier

	bt[6]=document.createElement("img")
	bt[6].code_couleur=nuancier
	bt[6].src="images/boutons/editeurHTML/pinceau.gif"
	bt[6].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,true))
		{
			switch(document.selection.type)
			{
				case "None":
					obj=document.selection.createRange()
					obj=obj.parentElement()
					while(obj.tagName!="LI" && obj.tagName!="P" && obj.tagName!="DIV" && obj.tagName!="TD"){obj=obj.parentNode}
					if(obj!=this.zone_edit)
					{
						//alert(obj.style.backgroundColor)
						style=obj.style.getAttribute("cssText").split("BACKGROUND")
						if(style[1])
						{
							style[1]=style[1].split(";")
							style[1].shift()
							style=style[0]+style[1].join(";")
							obj.style.setAttribute("cssText",style);
						}
						else
						{
							obj.style.setAttribute("cssText",style+";background:"+this.code_couleur.value);
						}
					}
				break
				case "Text":
					document.execCommand("ForeColor",false,this.code_couleur.value)
				break
				case "Control":
					range=document.selection.createRange()
					obj=range.item(0)
					switch(obj.tagName)
					{
						case "IMG":
						case "TABLE":
//							width=obj.style.width
//							height=obj.style.height
//							border=obj.style.border
//							obj.style.setAttribute("cssText","background:"+this.code_couleur.value+";width:"+width+";height:"+height+";border:"+border);
								style=obj.style.getAttribute("cssText").split("BACKGROUND")
								if(style[1])
								{
									style[1]=style[1].split(";")
									style[1].shift()
									style=style[0]+style[1].join(";")
									obj.style.setAttribute("cssText",style);
								}
								else
								{
									obj.style.setAttribute("cssText",style+";background:"+this.code_couleur.value);
								}
						break
					}
				break
			}
		}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[6])

	espace=document.createElement("span")
	espace.style.width="30px"
	cmd.appendChild(espace)

	bt[7]=document.createElement("img")
	bt[7].src="images/boutons/editeurHTML/aligner_gauche.gif"
	bt[7].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,true))
		{
			tempo=document.selection.createRange().parentElement()
			while(tempo.tagName!="LI" && tempo.tagName!="P" && tempo.tagName!="DIV" && tempo.tagName!="TD")
			{
				tempo=tempo.parentNode
			}
			if(tempo!=this.zone_edit){tempo.style.textAlign=""}
		}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[7])

	bt[8]=document.createElement("img")
	bt[8].src="images/boutons/editeurHTML/aligner_droite.gif"
	bt[8].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,true))
		{
			tempo=document.selection.createRange()
			tempo=tempo.parentElement()
			while(tempo.tagName!="LI" && tempo.tagName!="P" && tempo.tagName!="DIV" && tempo.tagName!="TD")
			{
				tempo=tempo.parentNode
			}
			if(tempo!=this.zone_edit){tempo.style.textAlign="right"}
		}

		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[8])

	bt[9]=document.createElement("img")
	bt[9].src="images/boutons/editeurHTML/centrer.gif"
	bt[9].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,true))
		{
			tempo=document.selection.createRange()
			tempo=tempo.parentElement()
			while(tempo.tagName!="LI" && tempo.tagName!="P" && tempo.tagName!="DIV" && tempo.tagName!="TD")
			{
				tempo=tempo.parentNode
			}
			if(tempo!=this.zone_edit){tempo.style.textAlign="center"}
		}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[9])

	bt[10]=document.createElement("img")
	bt[10].src="images/boutons/editeurHTML/justifier.gif"
	bt[10].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,true))
		{
			tempo=document.selection.createRange()
			tempo=tempo.parentElement()
			while(tempo.tagName!="LI" && tempo.tagName!="P" && tempo.tagName!="DIV" && tempo.tagName!="TD")
			{
				tempo=tempo.parentNode
			}
			if(tempo!=this.zone_edit){tempo.style.textAlign="justify"}
		}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[10])

	espace=document.createElement("span")
	espace.style.width="30px"
	cmd.appendChild(espace)

	bt[11]=document.createElement("img")
	bt[11].src="images/boutons/editeurHTML/flottant_gauche.gif"
	bt[11].onclick=function()
	{
		if(document.selection.type=="Control")
		{
			range=document.selection.createRange()
			image=range.item(0)
			if(image.tagName=="IMG")
			{
				image.style.styleFloat="left"
				image.style.cssFloat="left"
			}
		}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[11])

	bt[12]=document.createElement("img")
	bt[12].src="images/boutons/editeurHTML/flottant_droite.gif"
	bt[12].onclick=function()
	{
		if(document.selection.type=="Control")
		{
			range=document.selection.createRange()
			image=range.item(0)
			if(image.tagName=="IMG")
			{				
				image.style.styleFloat="right"
				image.style.cssFloat="right"
			}
		}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[12])

	bt[13]=document.createElement("img")
	bt[13].src="images/boutons/editeurHTML/non_flottant.gif"
	bt[13].onclick=function()
	{
		if(document.selection.type=="Control")
		{
			range=document.selection.createRange()
			image=range.item(0)
			if(image.tagName=="IMG")
			{
				image.style.styleFloat=""
				image.style.cssFloat=""
			}
			this.zone_edit.code.value=this.zone_edit.innerHTML
			
		}
	}
	cmd.appendChild(bt[13])

	espace=document.createElement("span")
	espace.style.width="30px"
	cmd.appendChild(espace)

	bt[14]=document.createElement("img")
	bt[14].src="images/boutons/editeurHTML/lien.gif"
	bt[14].onclick=function()
	{//lienhypertext, reste a faire le point d'ancrage =>'createbookmark'
		if(is_selection_in_editor(this.zone_edit,true))
		{
//			tempo=document.selection.createRange()
//			tempo.pasteHTML("<span id=current_cursor_editor></span>")
//
//			form_edition_article.data.value="id_editeur="+escape(this.zone_edit.id)
//			form_edition_article.target='popup'
//			form_edition_article.cmd.value='choix_lien_page'
//
//			afficher_obj(document.getElementById('popup'))
//			form_edition_article.submit()
			if(navigateur()=="Firefox")
			{
				url = prompt('Entrer l\'URL du lien', 'http://');
				if(url)
				{
					document.execCommand("CreateLink", false, url)
				}
			}
			else
			{
				document.execCommand("CreateLink", true, null)
			}
		}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[14])

	bt[15]=document.createElement("img")
	bt[15].src="images/boutons/editeurHTML/lien_casse.gif"
	bt[15].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,true)){document.execCommand('Unlink', false, null)}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[15])

	saut_ligne=document.createElement("br")
	cmd.appendChild(saut_ligne)

	bt[16]=document.createElement("img")
	bt[16].src="images/boutons/editeurHTML/hr.gif"
	bt[16].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,false)){document.execCommand("InsertHorizontalRule", false, null)}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[16])

	bt[17]=document.createElement("img")
	bt[17].src="images/boutons/editeurHTML/ol.gif"
	bt[17].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,false)){document.execCommand("InsertOrderedList", false, null)}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[17])

	bt[18]=document.createElement("img")
	bt[18].src="images/boutons/editeurHTML/ul.gif"
	bt[18].unselectable='off'
	bt[18].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,false)){document.execCommand("InsertUnorderedList", false, null)}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[18])

	cmd.appendChild(espace)

	bt[19]=document.createElement("img")
	bt[19].src="images/boutons/editeurHTML/table.gif"
	bt[19].unselectable='off'
	bt[19].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,false))
		{
			code=""
			colonne=""
			for(cpt=0;cpt<this.nb_colonne.value;cpt++){colonne+="<td style=\"border:1px dotted gray\"></td>"}
			for(cpt=0;cpt<this.nb_ligne.value;cpt++){code+="<tr>"+colonne+"</tr>"}
			switch(navigateur())
			{
				case "Firefox":
					tempo=window.getSelection().getRangeAt(0)
					tempo.deleteContents()
					obj=document.createElement('table')
					obj.innerHTML=code
					tempo.insertNode(obj)
				break
				case "Internet Explorer":
					tempo=document.selection.createRange()
					tempo.pasteHTML("<table border=0 cellpadding=0>"+code+"</table>")
				break
			}
		}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[19])

	ligne_table=document.createElement("span")
	code_option=""
	for(cpt=1;cpt<=10;cpt++)
	{
		if(cpt>1){s="s"}else{s=""}
		code_option+="<option value="+cpt+">"+cpt+" ligne"+s+"</option>"
	}
	ligne_table.innerHTML="<select style='font-size:9px'>"+code_option+"</select>"
	cmd.appendChild(ligne_table)
	ligne_table.unselectable='off'
	bt[19].nb_ligne=ligne_table.firstChild
	
	colonne_table=document.createElement("span")
	code_option=""
	for(cpt=1;cpt<=10;cpt++)
	{
		if(cpt>1){s="s"}else{s=""}
		code_option+="<option value="+cpt+">"+cpt+" col"+s+"</option>"
	}
	colonne_table.innerHTML="<select style='font-size:9px'>"+code_option+"</select>"
	cmd.appendChild(colonne_table)
	colonne_table.unselectable='off'
	bt[19].nb_colonne=colonne_table.firstChild

	bt[20]=document.createElement("img")
	bt[20].code_couleur=nuancier
	bt[20].src="images/boutons/editeurHTML/bordure_cadre.gif"
	bt[20].unselectable='off'
	bt[20].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,true))
		{
			switch(document.selection.type)
			{
				case "None":
				case "Text":
					obj=document.selection.createRange()
					obj=obj.parentElement()
					while(obj.tagName!="LI" && obj.tagName!="P" && obj.tagName!="DIV" && obj.tagName!="TD"){obj=obj.parentNode}
					if(obj!=this.zone_edit)
					{
						background=obj.style.background
						if(obj.style.border==""){border="border:"+this.code_couleur.value+" 1px dotted;"}else{border=""}
						obj.style.setAttribute("cssText",border+"background:"+background);
					}
				break
				case "Control":
					range=document.selection.createRange()
					obj=range.item(0)
					switch(obj.tagName)
					{
						case "IMG":
						case "TABLE":
							width=obj.style.width
							height=obj.style.height
							background=obj.style.background
							if(obj.style.border==""){border="border:"+this.code_couleur.value+" 1px dotted;"}else{border=""}
							obj.style.setAttribute("cssText",border+"width:"+width+";height:"+height+";background:"+background);
						break
					}
				break
			}
		}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[20])

	cmd.appendChild(espace)

	bt[21]=document.createElement("img")
	bt[21].src="images/boutons/editeurHTML/font.gif"
	bt[21].unselectable='off'
	bt[21].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,false))
		{
			document.execCommand('fontname', false,this.nom_font.value)
			document.execCommand('fontSize', false,this.taille_font.value)
		}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[21])

	nom_font=document.createElement("span")
	font=new Array("Arial","Times","Verdana","Garamond","Courier New")
	code_option=""
	for(cpt in font){code_option+="<option value="+font[cpt]+">"+font[cpt]+"</option>"}
	nom_font.innerHTML="<select style='font-size:9px'>"+code_option+"</select>"
	cmd.appendChild(nom_font)
	bt[21].nom_font=nom_font.firstChild

	taille_font=document.createElement("span")
	taille=new Array("1","2","4","6")
	code_option=""
	for(cpt in taille){code_option+="<option value="+taille[cpt]+">"+taille[cpt]+"</option>"}
	taille_font.innerHTML="<select style='font-size:9px'>"+code_option+"</select>"
	cmd.appendChild(taille_font)
	bt[21].taille_font=taille_font.firstChild

	bt[22]=document.createElement("img")
	bt[22].src="images/boutons/editeurHTML/zoomable.gif"
	bt[22].unselectable='off'
	bt[22].onclick=function()
	{
		if(document.selection.type=="Control")
		{
			range=document.selection.createRange()
			image=range.item(0)
			if(image.tagName=="IMG")
			{
				if(image.alt=="zoom"){image.alt=""}else{image.alt="zoom"}
			}
		}
		this.zone_edit.code.value=this.zone_edit.innerHTML
		
	}
	cmd.appendChild(bt[22])

	bt[23]=document.createElement("img")
	bt[23].src="images/boutons/editeurHTML/puzzle.gif"
	bt[23].unselectable='off'
	bt[23].onclick=function()
	{
		if(is_selection_in_editor(this.zone_edit,false))
		{
			if(navigateur()=="Firefox")
			{
				tempo_selection_editeur=window.getSelection().getRangeAt(0)
			}
			if(navigateur()=="Internet Explorer")
			{
				tempo_selection_editeur=document.selection.createRange().duplicate()
//				tempo=document.selection.createRange()
//				tempo.pasteHTML("<span id=current_cursor_editor></span>")
			}
			form_edition_article.data.value="id_editeur="+escape(this.zone_edit.id)
			form_edition_article.target='popup'
			form_edition_article.cmd.value='choix_element'

			afficher_obj(document.getElementById('popup'))
			form_edition_article.submit()
		}
	}
	cmd.appendChild(bt[23])

//rollover sur les boutons de l'editeur
	for(cpt in bt)
	{
		bt[cpt].zone_edit=zone_edit
		bt[cpt].style.border="1px solid #aaa"
		bt[cpt].onmouseover=function(){this.style.border="1px solid #999"}
		bt[cpt].onmouseout=function(){this.style.border="1px solid #aaa"}
	}
}

//rendre tout le document non selectionnable sauf aux endroit indiqués par (unselectable="off")
function unselectable_document()
{
	all_obj=document.getElementsByTagName("body")[0].getElementsByTagName("*")
	//if(document.all)
	//{
		for(cpt in all_obj){if(all_obj[cpt].unselectable!="off"){all_obj[cpt].unselectable="on"}}
		for(cpt in document.editeurs)
		{
			zone_edit=document.editeurs[cpt]["zone_edit"]
			zone_edit.innerHTML=document.editeurs[cpt]["innerHTML"]
			zone_edit.code.value=document.editeurs[cpt]["innerHTML"]
		}
	//}
}

//format:	url_dossier_dest= url depuis la racine du dossier dest d'uploader (autorisation doit être défini dans la base)
//			nom_fichier_dest = nom du fichier sur le serveur
//			is_ancien_fichier = boolean : indique si un fichier "nom_fichier_dest" est déjà sur le serveur
//			url_page_suivante= url de retour après validation : si "" (chaine vide), retour a la page actuelle
//			datas= format url (donnee=blablba&donnee2=zeir&...) : ajoute des champs cachés au formulaire
//			ex de datas: largeur et hauteur qui définissent les dimensions max de l'image
function creer_form_upload(url_dossier_dest,nom_fichier_dest,is_ancien_fichier,hidden_data,select_size,url_page_suivante)
{
	tempo_data=hidden_data.split("&")
	data=new Array()
	for(cpt in tempo_data)
	{
		tempo=tempo_data[cpt].split("=")
		data[tempo[0]]=unescape(tempo[1])
	}

	if(data["intitule_bt1"]){intitule_bt1=data["intitule_bt1"];data["intitule_bt1"]=""}else{intitule_bt1="Effacer le fichier"}
	if(data["intitule2"]){intitule_bt2=data["intitule_bt2"];data["intitule_bt2"]=""}else{intitule_bt2="Charger le fichier"}	
	if(data["fichier_taille_max"]){fichier_taille_max=data["fichier_taille_max"];data["fichier_taille_max"]=""}else{fichier_taille_max="500000"}
	if(data["largeur_affichage"]){largeur_affichage="width="+data["largeur_affichage"];data["largeur_affichage"]=""}else{largeur_affichage=""}
	if(data["hauteur_affichage"]){hauteur_affichage="height="+data["hauteur_affichage"];data["hauteur_affichage"]=""}else{hauteur_affichage=""}
	code=""

	if(is_ancien_fichier)
	{
		code="<div class='wm_upload'>"

		ext=nom_fichier_dest.split(".")[1]
		switch(ext)
		{
			case "jpg":
			case "gif":
				code+="<img unselectable=\"off\" src=\""+url_dossier_dest+"/"+nom_fichier_dest+"?"+Math.random()+"\" border=\"0\" hspace=\"5\" vspace=\"4\" "+largeur_affichage+" "+hauteur_affichage+">"
			break
			case "pdf":
			case "doc":
			case "html":
			case "zip":
				code+="<img unselectable=\"off\" src=\"images/std/icones/wm-icone-"+ext+".gif\" url_pdf=\""+url_dossier_dest+"/"+nom_fichier_dest+"\" border=\"0\" hspace=\"5\" vspace=\"4\">"
			break
		}
		
		code+="</div>"
		code+="<form action=\""+url_page_suivante+"\" method=\"POST\" name='form_effacer' id='tempo_form'>"
		code+="<input type=\"hidden\" name=\"dossier\" value=\""+url_dossier_dest+"\">"
		code+="<input type=\"hidden\" name=\"fichier_a_effacer\" value=\""+nom_fichier_dest+"\">"
		code+="<input type=\"submit\" value=\""+intitule_bt1+"\">"
		for(cpt in data)
		{
			if(data[cpt]!=""){code+="<input type=\"hidden\" name=\""+cpt+"\" value=\""+escape(data[cpt])+"\">"}
		}
		code+="</form>"
	}
	else
	{
		//code+="<br>Aucun fichier."
	}
	code+="<form enctype=\"multipart/form-data\" action=\""+url_page_suivante+"\" method=\"POST\" id=\"tempo_form\">"
	code+="<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\""+fichier_taille_max+"\">"
	code+="<input type=\"hidden\" name=\"dossier_dest\" value=\""+url_dossier_dest+"\">"
	code+="<input type=\"hidden\" name=\"nom_fichier_dest\" value=\""+nom_fichier_dest+"\">"
	code+="<br>Choisissez un fichier<br>sur votre disque dur:"
	code+="<br><div class=\"cadre_file\"><input type=\"file\" name=\"fichier_a_uploader\" class=\"file\" onchange=\"this.form.submit()\"></div>"
	
	if(select_size!="")
	{
		code+="<br>Taille de l'image&nbsp;<select onchange=\"v=this.value.split('x');this.parentNode.largeur.value=v[0];this.parentNode.hauteur.value=v[1]\">";
		liste=select_size.split("<>")
		for(cpt in liste)
		{
			tempo=unescape(liste[cpt]).split("/")
			if(!tempo[1]){tempo[1]=tempo[0]}
			code+="<option value='"+tempo[0]+"'>"+tempo[1]+"</option>";
		}
		code+="</select>";
	}
	//code+="<br><input type=\"submit\" value=\""+intitule_bt2+"\">"
	for(cpt in data)
	{
		if(data[cpt]!=""){code+="<input type=\"hidden\" name=\""+cpt+"\" value=\""+escape(data[cpt])+"\">"}
	}
	code+="</form>"
	document.write(code)

	formulaire=document.getElementById("tempo_form")
	formulaire.id=null

	return formulaire
}

//format:	******************************************************************************
// nom_liste: nom du champ
//style_table: style ajouté pour la table contenant les listes
//style_listes: style des listes
//titre_src: titre de la liste de choix
//titre_dest: titre de la liste de selection
//liste_src: description de la liste de choix au format v1<>v2<>v3... ou escape(v1<>intitule1)<>escape(v2<>intitule2)...
//liste_dest: description de la liste de selection (meme format que liste_src)
//mode: unique (pas de doublon dans liste2:effacement du choix dans liste1 si dans liste2)
// ou mode multiple (possibilité de doublon, donc pas d'effacement)
//nb_ligne_listes: nombre de ligne d'affichage des listes
function creer_liste_transfert(nom_liste,style_table,style_listes,titre_src,titre_dest,liste_src,liste_dest,mode,nb_ligne_listes)
{
	code="<table border=\"0\" "+style_table+">\n<tr><td align=\"center\">"+titre_src+"<br><select name=\""+nom_liste+"_src\" id=\""+nom_liste+"_src\" size="+nb_ligne_listes+" "+style_listes+">\n"
	if(liste_src!="")
	{
		liste_src=liste_src.split("<>")
		tempo_liste_dest=liste_dest.split("<>")
		for(cpt in liste_src)
		{
			if(mode=="unique")
			{
				cpt2=0
				while(cpt2<tempo_liste_dest.length)
				{
					if(unescape(unescape(tempo_liste_dest[cpt2]))==unescape(unescape(liste_src[cpt]))){liste_src[cpt]="";cpt2=tempo_liste_dest.length}else{cpt2++}
				}
			}

			if(liste_src[cpt]!="")
			{
				tempo=unescape(liste_src[cpt])
				tempo=tempo.split("<>")
				if(!tempo[1]){tempo[1]=tempo[0]}
				code+="<option value=\""+unescape(tempo[0])+"\">"+unescape(tempo[1])+"</option>\n"
			}
		}
	}
	code+="</select></td><td align=\"center\" style=\"vertical-align:middle\"><INPUT type=\"button\" value=\"Ajouter >>>\" onClick=\""+nom_liste+".ajouter()\"><BR><BR><INPUT type=\"button\" value=\"&lt;&lt;&lt; Enlever\" onClick=\""+nom_liste+".effacer()\"></td><td align=\"center\">"+titre_dest+"<br><select name=\""+nom_liste+"_dest\" id=\""+nom_liste+"_dest\" size="+nb_ligne_listes+" "+style_listes+">\n"

	if(liste_dest!="")
	{
		liste_dest=liste_dest.split("<>")
		for(cpt in liste_dest)
		{
			tempo=unescape(liste_dest[cpt])
			tempo=tempo.split("<>")
			if(!tempo[1]){tempo[1]=tempo[0]}
			code+="<option value=\""+unescape(tempo[0])+"\">"+unescape(tempo[1])+"</option>\n"
		}
	}
	code+="</select></td></tr></table><input type=\"hidden\" id=\""+nom_liste+"\" name=\""+nom_liste+"\">\n"

	document.write(code)

	l=document.getElementById(nom_liste)
	l.source=document.getElementById(nom_liste+"_src")
	l.mode=mode
	l.dest=document.getElementById(nom_liste+"_dest")

	l.ajouter=function()
	{
		if (this.source.options.selectedIndex>=0)
		{
			o=new Option(this.source.options[this.source.options.selectedIndex].text,this.source.options[this.source.options.selectedIndex].value);
			this.dest.options[this.dest.options.length]=o;
			if(this.mode=="unique"){this.source.options[this.source.options.selectedIndex]=null;}
			this.init()
		}
	}

	l.effacer=function()
	{
		if (this.dest.options.selectedIndex>=0)
		{
			if(this.mode=="unique")
			{
				o=new Option(this.dest.options[this.dest.options.selectedIndex].text,this.dest.options[this.dest.options.selectedIndex].value);
				this.source.options[this.source.options.length]=o;
			}
			this.dest.options[this.dest.options.selectedIndex]=null;
			this.init()
		}
	}

	l.init=function()
	{
		this.value=""
		for(cpt=0;cpt<this.dest.options.length;cpt++)
		{
			if(this.value!=""){this.value+="<>"}
			this.value+=escape(this.dest.options[cpt].value+"<>"+escape(this.dest.options[cpt].text))
		}
	}
	l.init()
}