$(document).ready(function() {
  
    // set your twitter id
    var user = 'studio_dog';
    var userLink = 'http://twitter.com/#!/studio_dog';
    var HTML = '';  
    // using jquery built in get json method with twitter api, return only one result
    $.getJSON('http://twitter.com/statuses/user_timeline.json?screen_name=' + user + '&count=3&callback=?', function(data) {
        

        // result returned
        var tweet1 = data[0].text;
         // process links and reply
        tweet1 = tweet1.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, function(url) {
            return '<a href="'+url+'">'+url+'</a>';
        }).replace(/B@([_a-z0-9]+)/ig, function(reply) {
            return  reply.charAt(0)+'<a href="http://twitter.com/%27+reply.substring%281%29+%27">'+reply.substring(1)+'</a>';
        });
        
        var tweet2 = data[1].text;
         // process links and reply
        tweet2 = tweet2.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, function(url) {
            return '<a href="'+url+'">'+url+'</a>';
        }).replace(/B@([_a-z0-9]+)/ig, function(reply) {
            return  reply.charAt(0)+'<a href="http://twitter.com/%27+reply.substring%281%29+%27">'+reply.substring(1)+'</a>';
        });
        
        var tweet3 = data[2].text;
         // process links and reply
        tweet3 = tweet3.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, function(url) {
            return '<a href="'+url+'">'+url+'</a>';
        }).replace(/B@([_a-z0-9]+)/ig, function(reply) {
            return  reply.charAt(0)+'<a href="http://twitter.com/%27+reply.substring%281%29+%27">'+reply.substring(1)+'</a>';
        });
        
        HTML += "<div class='twitter-feed active'>\
            <p><a href='" + userLink + "'>STUDIO_DOG</a>: " + tweet1 + " <a href='" + userLink + "'>[tweet]</a></p>\
        </div>\
\
        <div class='twitter-feed'>\
            <p><a href='" + userLink + "'>STUDIO_DOG</a>: " + tweet2 + " <a href='" + userLink + "'>[tweet]</a></p>\
        </div>\
\
        <div class='twitter-feed opaq'>\
            <p><a href='" + userLink + "'>STUDIO_DOG</a>: " + tweet3 + " <a href='" + userLink + "'>[tweet]</a></p>\
        </div>";

    
        // output the result
        $("#twitter_response").append(HTML);
    });

});
