(function($){

var url = /(^|&lt;|\s)(((https?|ftp):\/\/).+?)(\s|&gt;|$)/g,
//	url_modifier = /([^"])(http|https):\/\/(([^<>\/]*)\.)+([^<>\/]*)(\/[^<>\/]*)*(<\/a>)/g,

linkifyThis = function () {
	var childNodes = this.childNodes,
	i = childNodes.length;
	
	while(i--)
	{
		var n = childNodes[i];
 		if (n.nodeType == 3) {
			var html = $.trim(n.nodeValue);
   			if (html)
   			{
     			html = html.replace(/&/g, '&amp;')
                	.replace(/</g, '&lt;')
                	.replace(/>/g, '&gt;')
                	.replace(url, '$1<a href="$2">$2</a>$5')
//     				.replace(url_modifier, '>$2://$3$5</a>')
					$(n).after(html).remove();
   				}
 			}
 			else if (n.nodeType == 1  &&  !/^(a|button|textarea)$/i.test(n.tagName)) {
   				linkifyThis.call(n);
 			}
		}
	};

	$.fn.linkify = function () {
		return this.each(linkifyThis);
	};

})(jQuery);
