function linkify(text) {
    var linked_text = text;
    linked_text = linked_text.replace(new RegExp(" https?://[\\S]+", "g"), " <a href=\"$&\">$&</a>");
    linked_text = linked_text.replace(new RegExp("#[\\S]+", "g"), function(match) {
       return "<a href=\"http://twitter.com/#!/search?q=" + escape(match) + "\">" + match + "</a>";
    });
    linked_text = linked_text.replace(new RegExp("@([a-z0-9_]+)", "gi"), "<a href=\"http://twitter.com/#!/$1\">$&</a>");
    return linked_text;
}

