// déclaration des images
gras1 = new Image();
gras1.src = "./toolbar/images/gras.gif";
gras2 = new Image();
gras2.src = "./toolbar/images/gras2.gif"; 
italic1 = new Image();
italic1.src = "./toolbar/images/italic.gif";
italic2 = new Image();
italic2.src = "./toolbar/images/italic2.gif"; 
souligne1 = new Image();
souligne1.src = "./toolbar/images/souligne.gif";
souligne2 = new Image();
souligne2.src = "./toolbar/images/souligne2.gif"; 
gauche1 = new Image();
gauche1.src = "./toolbar/images/gauche.gif";
gauche2 = new Image();
gauche2.src = "./toolbar/images/gauche2.gif"; 
droite1 = new Image();
droite1.src = "./toolbar/images/droite.gif";
droite2 = new Image();
droite2.src = "./toolbar/images/droite2.gif"; 
centre1 = new Image();
centre1.src = "./toolbar/images/centre.gif";
centre2 = new Image();
centre2.src = "./toolbar/images/centre2.gif"; 
justifie1 = new Image();
justifie1.src = "./toolbar/images/justifie.gif";
justifie2 = new Image();
justifie2.src = "./toolbar/images/justifie2.gif"; 
couleur1 = new Image();
couleur1.src = "./toolbar/images/couleur.gif";
couleur2 = new Image();
couleur2.src = "./toolbar/images/couleur2.gif"; 
voir1 = new Image();
voir1.src = "./toolbar/images/voir.gif";
voir2 = new Image();
voir2.src = "./toolbar/images/voir2.gif";


// fonctions diverses
function insererStyle(Tag, fTag){  
	var obj = document.getElementById("info"), sel;
	obj.focus();
	if (document.selection && document.selection.createRange){//si IE
		sel = document.selection.createRange(); 
	   	if (sel.parentElement()==obj && sel.text!="")//si sel est dans obj ET que la séléction n'est pas vide
			sel.text = Tag+sel.text+fTag; 
	 }
	 else if(String(typeof obj.selectionStart)!="undefined"){//si Mozilla ou autre
		var longueur= parseInt(obj.textLength);
		var selStart = obj.selectionStart;
		var selEnd = obj.selectionEnd;
		if (selEnd == 2 || selEnd == 1)
			selEnd = longueur;
	   	obj.value = (obj.value).substring(0,selStart) + Tag + (obj.value).substring(selStart,selEnd) + fTag + (obj.value).substring(selEnd,longueur);
	}
	else 
		obj.value+=Tag+fTag;
	obj.focus();
}

function insererCouleur(Tag, fTag, color){  
	var obj = document.getElementById("info"), objFond=document.getElementById("toolbar"), sel;
	obj.focus();
	objFond.style.backgroundColor=color;
	if (document.selection && document.selection.createRange){//si IE
		sel = document.selection.createRange(); 
	   	if (sel.parentElement()==obj && sel.text!="")//si sel est dans obj ET que la séléction n'est pas vide
			sel.text = Tag+"style=color:'"+color+"'>"+sel.text+fTag; 
	 }
	 else if(String(typeof obj.selectionStart)!="undefined"){//si Mozilla ou autre
		var longueur= parseInt(obj.textLength);
		var selStart = obj.selectionStart;
		var selEnd = obj.selectionEnd;
		if (selEnd == 2 || selEnd == 1)
			selEnd = longueur;
	   	obj.value = (obj.value).substring(0,selStart) + Tag + (obj.value).substring(selStart,selEnd) + fTag + (obj.value).substring(selEnd,longueur);
	}
	else 
		obj.value+=Tag+fTag;
	obj.focus();
}

function insererAlign(Tag, fTag, align){  
	var obj = document.getElementById("info"), sel;
	obj.focus();
	if (document.selection && document.selection.createRange){//si IE
		sel = document.selection.createRange(); 
	   	if (sel.parentElement()==obj && sel.text!="")//si sel est dans obj ET que la séléction n'est pas vide
			sel.text = Tag+" style='width:625px; text-align:"+align+";'>"+sel.text+fTag; 
	 }
	 else if(String(typeof obj.selectionStart)!="undefined"){//si Mozilla ou autre
		var longueur= parseInt(obj.textLength);
		var selStart = obj.selectionStart;
		var selEnd = obj.selectionEnd;
		if (selEnd == 2 || selEnd == 1)
			selEnd = longueur;
	   	obj.value = (obj.value).substring(0,selStart) + Tag + (obj.value).substring(selStart,selEnd) + fTag + (obj.value).substring(selEnd,longueur);
	}
	else 
		obj.value+=Tag+fTag;
	obj.focus();
}

function visuResultat(){ 
	var info=document.getElementById("info").value;
	info=info.replace(/\n/g,"<br />");
	document.all.visu.innerHTML=info;	
}

function montrer(id){
	document.getElementById(id).style.visibility = "visible";
}

function cacher(id){
	document.getElementById(id).style.visibility = "hidden";
}

function changeImage(image,newImage) {
 	document.images[image].src = newImage.src;
}