$(document).ready(function(){
  // de que usuario es el feed?
  var twitterUser = "iugo_uruguay";
  // cuantos tweets hay que mostrar?
  var tweets = 5;
  // lanzamos la llamada ajax cross-domain...
  $.getJSON("http://twitter.com/status/user_timeline/"+twitterUser+".json?count=" + (tweets*2) +"&callback=?",function(json){
    html = "<ul>";
    //var urlregex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi;
    //var userregex = /(\@([-A-Z0-9+&\/%?=~_|!:,.;]*))/gi;
    //var hashtagregex = /(\#([-A-Z0-9+&\/%?=~_|!:,.;]*))/gi;
    var count = 0;
    for (i=0;i<json.length;i++)
    {
      if (json[i].in_reply_to_screen_name==null)
      {
        var class_act = "";  
        if (i == 0)
        {
            class_act = 'class="active"';
        }
        var date_tweet = new Date(json[i].created_at);
        html += "<li " + class_act + "><a href='http://www.twitter.com/" + twitterUser + "/status/" + json[i].id_str + "' target='_blank'>" + json[i].text + "</a><br/>";
        html += "<span>"+ date_tweet.getDate() + "." + date_tweet.getMonth() + "." + date_tweet.getFullYear() +"</span></li>";
        count++;
      }
      if (count >= tweets) break;
    }
    html += "</ul>";
    // incluimos el html dentro del div myTwitter
    $("#Twitter").append(html);
  })
  
  setInterval( "slideTwitter()", 5000 );
  
});

function slideTwitter() {
    var $active = $('#Twitter li.active');
    
    if ( $active.length == 0 ) $active = $('#Twitter li:last');
    var $next =  $active.next().length ? $active.next() : $('#Twitter li:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

