 var Twitter = {
                init: function (username,maxim) {
                    this.insertLatestTweets(username,maxim); // Pass in the username you want to display feeds for
                },

                insertLatestTweets: function (username,maxim) {  // This replaces the <p>Loading...</p> with the tweets
                    var limit= maxim;    // How many feeds do you want?
                    var url= 'http://twitter.com/statuses/user_timeline.json?screen_name=' + username + '&count=' + limit + '&callback=?';
                    var i=0;

                    $.getJSON(url, function (data) { // Now ajax in the feeds from twitter.com

                        var html = '<marquee behavior="scroll" scrollamount="1" direction="left">'; // We'll start by creating a normal marquee-element for the tweets

                        for (i=0;i<limit;i++) { // Loop through all the tweets and create a link for each (var i in data)
                            html += '<a href="http://twitter.com/' + username + '#status_' + data[i].id_str + '" target="_blank">' + data[i].text + ' <i>' + Twitter.relativeTime(data[i].created_at) + '</i></a>';
                        }

                        html += '</marquee>';

                        $('#twitter p').replaceWith(html); // Now replace the <p> with our <marquee>-element

                        Twitter.fancyMarquee(); // The marquee element looks quite shite so we'll use Remy Sharp's plug-in to replace it with a smooth one
                    });
                },

                fancyMarquee: function () { // Replaces the marquee-element with a fancy one

                $('#twitter marquee').marquee('pointer') // Replace the marquee and do some fancy stuff (taken from remy sharp's website)
                    .mouseover(function () {
                        $(this).trigger('stop');
                    })
                    .mouseout(function () {
                        $(this).trigger('start');
                    })
                    .mousemove(function (event) {
                        if ($(this).data('drag') == true) {
                            this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
                        }
                    })
                    .mousedown(function (event) {
                        $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
                    })
                    .mouseup(function () {
                        $(this).data('drag', false);
                    });
                },

                daysAgo: function (date) { // Takes a date and return the number of days it's been since said date
                    // TODO: Fix date for IE...
                    if ($.browser.msie) {
                        return '1 day ago';
                    }

                    var d = new Date(date).getTime();
                    var n = new Date().getTime();

                    var numDays = Math.round(Math.abs(n - d) / (1000 * 60 * 60 * 24));
                    var daysAgo = numDays + ' days ago';

                    if (numDays == 0) {
                        daysAgo = 'today';
                    }
                    else if (numDays == 1) {
                        daysAgo = numDays + ' day ago';
                    }

                    return daysAgo;
                },

				relativeTime: function (pastTime)	{ // Generate a JavaScript relative time for the tweets ALTERNATIU + ACURAT
					// TODO: Fix date for IE...
				    if ($.browser.msie) {
                        return '1 day ago';
                    }

					var origStamp = Date.parse(pastTime);
				    var curDate = new Date();
				    var currentStamp = curDate.getTime();
				    var difference = parseInt((currentStamp - origStamp)/1000);

				    if(difference < 0) return false;

				    if(difference <= 5)          return "Just now";
				    if(difference <= 20)         return "Seconds ago";
				    if(difference <= 60)         return "A minute ago";
				    if(difference < 3600)        return parseInt(difference/60)+" minutes ago";
				    if(difference <= 1.5*3600)   return "One hour ago";
				    if(difference < 23.5*3600)   return Math.round(difference/3600)+" hours ago";
				    if(difference < 1.5*24*3600) return "One day ago";

				    // If the tweet is older than a day, show an absolute date/time value;

				    var dateArr = pastTime.split(' ');

				    return dateArr[4].replace(/\:\d+$/,'')+' '+dateArr[2]+' '+dateArr[1]+
				    (dateArr[3]!=curDate.getFullYear()?' '+dateArr[3]:'');
				}
            };
