
helpstat = false;
stprompt = true;
basic = false;
text = ""

function thelp(swtch){
	if (swtch == 1){
		basic = false;
		stprompt = false;
		helpstat = true;
	} else if (swtch == 2) {
		helpstat = false;
		stprompt = false;
		basic = true;
	} else if (swtch == 0) {
		helpstat = false;
		basic = false;
		stprompt = true;
	}
}


function getActiveText(selectedtext) { 
	text = (document.all) ? document.selection.createRange().text : document.getSelection();
		if (selectedtext.createTextRange) {	
   			selectedtext.caretPos = document.selection.createRange().duplicate();	
  		}
		return true;
}

function AddText(NewCode) {
if (document.ImageForm.txtContent.createTextRange && document.ImageForm.txtContent.caretPos) {
var caretPos = document.ImageForm.txtContent.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? NewCode + ' ' : NewCode;
}
else {
document.ImageForm.txtContent.value+=NewCode
}
setfocus();
}
function setfocus() {
document.ImageForm.txtContent.focus();
}


function showsize(size) {
	if (helpstat) {
		alert("Size Tag Sets the text size. Possible values are 1 to 6.\n1 being the smallest and 6 the largest.\n\nUSE: [size="+size+"]This is size "+size+" text[/size="+size+"]");
	} else if (basic) {
		AddTxt="<size="+size+">"+text+"</size="+size+">";
		AddText(AddTxt);
	} else {                       
		txt=prompt("Changer la taille du texte "+size,"Insérez votre texte"); 
		if (txt!=null) {             
			AddTxt="<size="+size+">"+txt+"</size="+size+">";
			AddText(AddTxt);
		}        
	}
}

function bold() {
	if (helpstat) {
		alert("Bold Tag Makes the enlosed text bold.\n\nUSE: [b]This is some bold text[/b]");
	} else if (basic) {
		AddTxt="<b>"+text+"</b>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à insérer en caractères Gras.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<b>"+txt+"</b>";
			AddText(AddTxt);
		}       
	}
}

function italicize() {
	if (helpstat) {
		alert("Italicize Tag Makes the enlosed text italicized.\n\nUSE: [i]This is some italicized text[/i]");
	} else if (basic) {
		AddTxt="<i>"+text+"</i>";
		AddText(AddTxt);
	} else {   
		txt=prompt("Texte à insérer en caractères Italiques.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<i>"+txt+"</i>";
			AddText(AddTxt);
		}	        
	}
}



function center() {
 	if (helpstat) {
		alert("Centered tag Centers the enclosed text.\n\nUSE: [center]This text is centered[/center]");
	} else if (basic) {
		AddTxt="<center>"+text+"</center>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à centrer.","Tapez votre texte");     
		if (txt!=null) {          
			AddTxt="<center>"+txt+"</center>";
			AddText(AddTxt);
		}	       
	}
}

function hyperlink() {
	if (helpstat) {
		alert("Hyperlink Tag \nTurns an url into a hyperlink.\n\nUSE: [url]http://www.anywhere.com[/url]\n\nUSE: [url=http://www.anywhere.com]link text[/url]");
	} else if (basic) {
		AddTxt="<url>"+text+"</url>";
		AddText(AddTxt);
	} else { 
		txt2=prompt("Texte à afficher pour le lien.",""); 
		if (txt2!=null) {
			txt=prompt("URL du lien.","http://");      
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="<a href>"+txt+"</a>";
					AddText(AddTxt);
				} else {
					AddTxt="<a href=\""+txt+"\">"+txt2+"</a>";
					AddText(AddTxt);
				}         
			} 
		}
	}
}



function list() {
	if (helpstat) {
		alert("List Tag Builds a bulleted, numbered, or alphabetical list.\n\nUSE: <list> <*>item1</*> <*>item2</*> <*>item3</*> </list>");
	} else if (basic) {
		AddTxt="[<list>"+text+"<*>  </*>"+text+"<*>  </*>"+text+"<*>  </*>"+text+"</list>";
		AddText(AddTxt);
	} else {  
		type=prompt("Choisissez quelle liste vous désirez \'A\' pour Alphabétique, \'1\' pour Numérique.","");               
		while ((type!="") && (type!="A") && (type!="a") && (type!="1") && (type!=null)) {
			type=prompt("Erreur!  Les valeurs autorisées pour cette liste sont 'A' et '1'.","");               
		}
		if (type!=null) {
			if (type=="") {
				AddTxt="<list>";
			} else {
				AddTxt="<list="+type+">";
			} 
			txt="1";
			while ((txt!="") && (txt!=null)) {
				txt=prompt("Insérez les lignes une à une, pour clore votre liste laisser la fenêtre vide et cliquez sur Ok",""); 
				if (txt!="") {             
					AddTxt+="<li>"+txt+"</li>"; 
				}                   
			} 
			if (type=="") {
				AddTxt+="</list> ";
			} else {
				AddTxt+="</list="+type+">";
			} 
			AddText(AddTxt); 
		}
	}
}

function underline() {
  	if (helpstat) {
		alert("Underline Tag Underlines the enclosed text.\n\nUSE: [u]This text is underlined[/u]");
	} else if (basic) {
		AddTxt="<u>"+text+"</u>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à souligner.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<u>"+txt+"</u>";
			AddText(AddTxt);
		}	        
	}
}

function showfont(font) {
 	if (helpstat){
		alert("Font Tag Sets the font face for the enclosed text.\n\nUSE: [font="+font+"]The font of this text is "+font+"[/font]");
	} else if (basic) {
		AddTxt="<font="+font+">"+text+"</font="+font+">";
		AddText(AddTxt);
	} else {                  
		txt=prompt("Texte à formater en "+font,"Insérez votre texte");
		if (txt!=null) {             
			AddTxt="<font="+font+">"+txt+"</font="+font+">";
			AddText(AddTxt);
		}        
	}  
}

function red() {
	if (helpstat) {
		alert("Red Tag Makes the enlosed text Red.\n\nUSE: [red]This is some red text[/red]");
	} else if (basic) {
		AddTxt="<red>"+text+"</red>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en rouge.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=red>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}

function blue() {
	if (helpstat) {
		alert("Blue Tag Makes the enlosed text Blue.\n\nUSE: [blue]This is some blue text[/blue]");
	} else if (basic) {
		AddTxt="<blue>"+text+"</font>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en bleu.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=blue>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}

function pink() {
	if (helpstat) {
		alert("Pink Tag Makes the enlosed text Pink.\n\nUSE: [pink]This is some pink text[/pink]");
	} else if (basic) {
		AddTxt="<pink>"+text+"</pink>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en saumon.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=pink>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}

function brown() {
	if (helpstat) {
		alert("Brown Tag Makes the enlosed text Brown.\n\nUSE: [brown]This is some brown text[/brown]");
	} else if (basic) {
		AddTxt="<brown>"+text+"</brown>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en bordeaux.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=brown>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}

function black() {
	if (helpstat) {
		alert("Black Tag Makes the enlosed text Black.\n\nUSE: [black]This is some black text[/black]");
	} else if (basic) {
		AddTxt="<black>"+text+"</black>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en noir.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=black>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}

function orange() {
	if (helpstat) {
		alert("Orange Tag Makes the enlosed text Orange.\n\nUSE: [orange]This is some orange text[/orange]");
	} else if (basic) {
		AddTxt="<orange>"+text+"</orange>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en orange.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=orange>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}

function violet() {
	if (helpstat) {
		alert("Violet Tag Makes the enlosed text Violet.\n\nUSE: [violet]This is some violet text[/violet]");
	} else if (basic) {
		AddTxt="<violet>"+text+"</violet>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en rose.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=violet>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}

function yellow() {
	if (helpstat) {
		alert("Yellow Tag Makes the enlosed text Yellow.\n\nUSE: [yellow]This is some yellow text[/yellow]");
	} else if (basic) {
		AddTxt="<yellow>"+text+"</yellow>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en jaune.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=yellow>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}

function green() {
	if (helpstat) {
		alert("Green Tag Makes the enlosed text Green.\n\nUSE: [green]This is some green text[/green]");
	} else if (basic) {
		AddTxt="<green>"+text+"</green>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en vert.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=green>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}

function gold() {
	if (helpstat) {
		alert("Gold Tag Makes the enlosed text Gold.\n\nUSE: [gold]This is some gold text[/gold]");
	} else if (basic) {
		AddTxt="<gold>"+text+"</gold>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en or.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=gold>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}

function white() {
	if (helpstat) {
		alert("White Tag Makes the enlosed text White.\n\nUSE: [white]This is some white text[/white]");
	} else if (basic) {
		AddTxt="<white>"+text+"</white>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en blanc.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=white>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}

function purple() {
	if (helpstat) {
		alert("Purple Tag Makes the enlosed text Purple.\n\nUSE: [purple]This is some purple text[/purple]");
	} else if (basic) {
		AddTxt="<purple>"+text+"</purple>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en violet.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=purple>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}

function beige() {
	if (helpstat) {
		alert("Beige Tag Makes the enlosed text Beige.\n\nUSE: [beige]This is some Beige text[/beige]");
	} else if (basic) {
		AddTxt="<beige>"+text+"</beige>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en beige.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=beige>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}


function navy() {
	if (helpstat) {
		alert("Navy Tag Makes the enlosed text Navy.\n\nUSE: [navy]This is some navy text[/navy]");
	} else if (basic) {
		AddTxt="<navy>"+text+"</navy>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en bleu marine.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=navy>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}

function maroon() {
	if (helpstat) {
		alert("Maroon Tag Makes the enlosed text Maroon.\n\nUSE: [maroon]This is some maroon text[/maroon]");
	} else if (basic) {
		AddTxt="<maroon>"+text+"</maroon>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en rouge foncé.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=maroon>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}

function limegreen() {
	if (helpstat) {
		alert("Limegreen Tag Makes the enlosed text Limegreen.\n\nUSE: [limegreen]This is some limegreen text[/limegreen]");
	} else if (basic) {
		AddTxt="<limegreen>"+text+"</limegreen>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à formater en vert clair.","Tapez votre texte");     
		if (txt!=null) {           
			AddTxt="<font color=limegreen>"+txt+"</font>";
			AddText(AddTxt);
		}       
	}
}



function aleft() {
 	if (helpstat) {
		alert("Align left tag aligns the enclosed text left.\n\nUSE: [left]This text is aligned left[/left]");
	} else if (basic) {
		AddTxt="<left>"+text+"</left>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à aligner à gauche.","Tapez votre texte");     
		if (txt!=null) {          
			AddTxt="<left>"+txt+"</left>";
			AddText(AddTxt);
		}	       
	}
}

function aright() {
 	if (helpstat) {
		alert("Align right tag aligns the enclosed text right.\n\nUSE: [right]This text is aligned right[/right]");
	} else if (basic) {
		AddTxt="<right>"+text+"</right>";
		AddText(AddTxt);
	} else {  
		txt=prompt("Texte à aligner à droite.","Tapez votre texte");     
		if (txt!=null) {          
			AddTxt="<right>"+txt+"</right>";
			AddText(AddTxt);
		}	       
	}
}



function hr() {
  	if (helpstat) {
		alert("Horizontal Rule Tag adds a horizontal rule.\n\nUSE: Horizontal Rule[hr]");
	} else if (basic) {
		AddTxt="<hr>";
		AddText(AddTxt);
	} else {  
		AddTxt="<hr>";
		AddText(AddTxt);
	}
}


function br() {
  	if (helpstat) {
		alert("Horizontal Rule Tag adds a horizontal rule.\n\nUSE: Horizontal Rule[hr]");
	} else if (basic) {
		AddTxt="<br>";
		AddText(AddTxt);
	} else {  
		AddTxt="<br>";
		AddText(AddTxt);
	}
}

function validate(){
	if (document.PostTopic.Subject) {
		if (trim(document.PostTopic.Subject.value)=="") {
			alert("You must enter a Subject")
			return false
		}
	}
	if (document.PostTopic.Message) {
		if (trim(document.PostTopic.Message.value)=="") {
			alert("You must enter a Message")
			return false
		}
	}
	return true
}

function ltrim(s) {
	return s.replace( /^\s*/, "" );
}
function rtrim(s) {
	return s.replace( /\s*$/, "" );
}
function trim ( s ) {
	return rtrim(ltrim(s));
}
