Hello Everyone,
The code works very well when converting break lines to html, smart characters and so on.
I like to add the functionallity to convert text links to hmtl hyperlinks.
How can I make it work with the main file?
Thank you in advance

The function is:
Code:
function replaceURLWithHTMLLinks(text) 
{
        var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi;
	return text.replace(exp,'<a href="$1">$1</a>'); 
}
Main file:
Code:
<!--[if IE 6]><style type="text/css">#main {width:575px;}#content {margin:0 10px 80px 10px;}#sidebar ul li {margin-bottom:-15px;background-color:#531717;}</style><![endif]-->
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

<script type="text/javascript" >
function convertText(){
var brPref = document.getElementById("oldbr").checked;
if(brPref == 1 || brPref == true){
var linebs = '<br>';
}else{
var linebs = '<br />';
}
var jpTag = document.getElementById("pTag").checked;
var jpTagbrTag = document.getElementById("pTagbrTag").checked;
var jbrTag = document.getElementById("brTag").checked;
var noBreaks = document.getElementById("oldText").value;

//var tfEncode = $('#tfEncode:checked').val();
var tfEncode = $('input:checkbox[name=tfEncode]:checked').val();

noBreaks = noBreaks.replace(/\r\n/g,"XiLBXZ");
noBreaks = noBreaks.replace(/\n/g,"XiLBXZ");
noBreaks = noBreaks.replace(/\r/g,"XiLBXZ");

	var i = noBreaks.length,
	      aRet = [];

if(tfEncode == "yes"){	
	while (i--) {
		var iC = noBreaks [i].charCodeAt();
		if (iC == 34 || iC == 38 || (iC ==96) || iC > 127) {
			aRet[i] = '&#'+iC+';';
		} else {
			aRet[i] = noBreaks[i];
		}
}
	
		noBreaks = aRet.join('');    
	//Get rid of some odd balls
	relq = /\&\#32\;/g;
	noBreaks = noBreaks.replace(relq," ");
	relq = /\&\#10\;/g;
	noBreaks = noBreaks.replace(relq," ");
	relq = /\&\#9\;/g;
	noBreaks = noBreaks.replace(relq," ");
	//make some friendly replacements
	var tf1 =new Array("","","","",""","&","","","","","","","","","","′","″","","","","","","","♠","♣","♥","♦","◊","←","→","↑","↓","↔","","","","","","","","","","","","","*","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","");
	var tf2=new Array("&copy;","&reg;","&sup2;","&sup3;","&quot;","&amp;","&ndash;","&mdash;","&lsquo;","&rsquo;","&ldquo;","&rdquo;","&bull;","&dagger;","&Dagger;","&prime;","&Prime;","&lsaquo;","&rsaquo;","&euro;","&trade;","&tilde;","&circ;","&spades;","&clubs;","&hearts;","&diams;","&loz;","&larr;","&rarr;","&uarr;","&darr;","&harr;","&not;","&iexcl;","&cent;","&pound;","&curren;","&yen;","&brvbar;","&sect;","&uml;","&ordf;","&laquo;","&not;","*","&macr;","&deg;","&plusmn;","&acute;","&micro;","&para;","&middot;","&cedil;","&sup1;","&ordm;","&raquo;","&frac14;","&frac12;","&frac34;","&iquest;","&Agrave;","&Aacute;","&Acirc;","&Atilde;","&Auml;","&Aring;","&AElig;","&Ccedil;","&Egrave;","&Eacute;","&Ecirc;","&Euml;","&Igrave;","&Iacute;","&Icirc;","&Iuml;","&ETH;","&Ntilde;","&Ograve;","&Oacute;","&Ocirc;","&Otilde;","&Ouml;","&times;","&Oslash;","&Ugrave;","&Uacute;","&Ucirc;","&Uml;","&Yacute;","&THORN;","&szlig;","&agrave;","&aacute;","&acirc;","&atilde;","&auml;","&aring;","&aelig;","&ccedil;","&egrave;","&eacute;","&ecirc;","&euml;","&igrave;","&iacute;","&icirc;","&iuml;","&eth;","&ntilde;","&ograve;","&oacute;","&ocirc;","&otilde;","&ouml;","&divide;","&oslash;","&ugrave;","&uacute;","&ucirc;","&uuml;","&yacute;","&thorn;","&yuml;");
	for (var ii = 0; ii < tf1.length; ii++) {
		noBreaks = noBreaks.replace(new RegExp(tf1[ii],"g"),tf2[ii]);	
	}
}
//relq = /\&amp\;/g;
//oBreaks = noBreaks.replace(relq,'&amp;amp;');
re1 = /\s+/g;
noBreaks = noBreaks.replace(re1," ");
noBreaks = $.trim(noBreaks);

if(jbrTag != 0 || jbrTag !=  false){
re4 = /XiLBXZXiLBXZ/gi;
noBreaks = noBreaks.replace(re4,linebs+"\r\n"+linebs+"\r\n");
}else{
re4 = /XiLBXZXiLBXZ/gi;
noBreaks = noBreaks.replace(re4,"</p><p>");
}
if(jpTag == 0 || jpTag ==  false){
re5 = /XiLBXZ/gi;
noBreaks = noBreaks.replace(re5,linebs+"\r\n");
}else{
re5 = /XiLBXZ/gi;
noBreaks = noBreaks.replace(re5," ");
}
if(jbrTag == 0 || jbrTag ==  false){
noBreaks ='<p>'+noBreaks+'</p>';
}
noBreaks = noBreaks.replace("<p><\/p>","");
noBreaks = noBreaks.replace("\r\n\r\n","");
noBreaks = noBreaks.replace(/<\/p><p>/g,"</p>\r\n\r\n<p>");
noBreaks = noBreaks.replace(new RegExp("<p><br />","g"),"<p>");
noBreaks = noBreaks.replace(new RegExp("<p><br>","g"),"<p>");
document.getElementById("newCode").value = noBreaks;
}

</script>

<form method="post">
<input type="radio" id="pTag" name="linebreaks" value="p" checked="checked" /> <strong>&lt;p&gt;</strong> only</p>
<input type="radio" id="pTagbrTag" name="linebreaks" value="pbr" /> <strong>&lt;p&gt;</strong> &amp; <strong>&lt;br /&gt;</strong></p>
<input type="radio" id="brTag" name="linebreaks" value="br" /> <strong>&lt;br /&gt;</strong>: Use line break tags only</p><p>
<input type="radio" id="newbr" name="thebr" value="yes" checked="checked" /> <strong>&lt;br /&gt;</strong> or 
<input type="radio" id="oldbr" name="thebr" value="yes" /> <strong>&lt;br&gt;</strong></p><p>
<input type="checkbox" name="tfEncode" class="tfEncode" value="yes"  checked="checked" /> Encode characters with accents and similar</p><p>

<textarea id="oldText" name="oldText" rows="23" cols="100"></textarea></p><p>

<input type="button" name="Convert-Text-HTML" value="Convert Text to HTML" onclick="javascript:convertText()" class="frmbtn" /></p><p>

<textarea id="newCode" name="newCode" rows="23" cols="100"></textarea> </p>
</form>