checking text area for ling and changing them into hyperlink
<p>So I have this function here:</p>

<pre><code>function ShowMessage()
{
   var themessege = document.getElementById("Form").textarea1.value;
   var dat = new Date(); 
   var fileName = document.getElementById("theFile").value;
   var image = '&lt;img src="' + fileName + '"/&gt;' + '&lt;br&gt;';
   document.getElementById("Form").textarea1.value = ""; 
   document.getElementById("Form").countdown.value = "160"; 
   document.getElementById("theFile").value = "";
   if (themessege==null || themessege=="") 
       {
       alert("There is no text to submit, please fill out the text box");
       return false;
       }

   document.getElementById("blog").innerHTML = document.getElementById("blog").innerHTML + image +  "Guest post: " + themessege + "&lt;br /&gt;" +  dat +"&lt;br /&gt;";   
}
</code></pre>

<p>I can get the text from the text area, as well as the image the user uploads. I'm wondering how I can divide the strings in the text area into subsrtings to check if they start with "www" or "htt".</p>

<p>This is what I've written so far:</p>

<pre><code>function linkify(inputText) {
   var replaceText, replacePattern1, replacePattern2;

   //URLs starting with http://, https://
   replacePattern1 =https;
   replacedText = inputText.replace(replacePattern1, '&lt;a href= &gt;&lt;/a&gt;');

   //URLs starting with "www." (without // before it, or it'd re-link the ones done above).
   replacePattern2 = www.;
   replacedText = replacedText.replace(replacePattern2, &lt;a href="http:  &gt;&lt;/a&gt;');
   var x = getelementbyid("blog");
   for(var i = 0;i &lt; x.length;i++){
      if(blog.charAt(i) == replacePattern1){
      return replacedText;
      }
   }
   else if(blog.charAt(i) == replacePattern2){
     return replacedText;
   }
}
</code></pre>

<p>I know that the <code>charAt(i)</code> only checks for 1 letter....</p>

<p>Most of the answers that I found were on PHP, I'm trying to find a solution using JavaScript.</p>
