        Date.prototype.getMonthName = function (lang)
        {
            lang = lang && (lang in Date.locale) ? lang : 'en';
            return Date.locale[lang].month_names[this.getMonth()];
        };

        Date.prototype.getMonthNameShort = function (lang)
        {
            lang = lang && (lang in Date.locale) ? lang : 'en';
            return Date.locale[lang].month_names_short[this.getMonth()];
        };
			
		Date.locale = 
		{
		    en: 
			{
		       month_names: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
		       month_names_short: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
		    }
	    };

	    /**
	    * Parses the date specified by twitter into a Javascript Date object.
	    */
	    function parseDate(dateString)
	    {
	        //split the date string from twitter
	        var parts = dateString.split(" ");
	        //put the date into utc format
	        var utcDate = parts[1] + " " + parts[2] + ", " + parts[5] + " " + parts[3] + " UTC";
	        //parse the utc date (which returns ticks)
	        var dateTicks = Date.parse(utcDate);
	        return new Date(dateTicks);
	    }

		$(document).ready(function ()
		{
		    //get the ul that we want to display the feed in
		    var twitterStream = $("#twitterStream");

		    //get the item template for the tweets
		    var tweetTemplate = $("#tweetTemplate");

		    //go through all the tweets
		    $(twitter).each(function (index, tweet)
		    {
		        //get the tweet details
		        var user = tweet.user;
		        var screenname = user.screen_name;
		        var imageUrl = user.profile_image_url;
		        //construct the tweet url
		        var tweetUrl = "http://twitter.com/#!/" + screenname + "/status/" + tweet.id_str;
		        //parse the date specified by twitter into a Javascript Date object
		        var createdDate = parseDate(tweet.created_at);

		        //create a new item
		        var item = tweetTemplate.clone();
		        //set the id of the li to the tweet id (just incase it's useful)
		        item.attr("id", tweet.id_str);

		        //display the tweet user's thumbnail
		        var tweetUserThumb = item.find(".tweetUserThumb");
		        tweetUserThumb.attr("src", imageUrl);
		        tweetUserThumb.attr("alt", screenname);
		        //display the tweet text
		        item.find(".tweetText").html("<strong>" + screenname + ":</strong> " + tweet.text);
		        //set up the link to the tweet
		        item.find(".tweetLink").attr("href", tweetUrl);
		        //set up the date
		        item.find(".tweetDate").text(createdDate.getDate() + " " + createdDate.getMonthNameShort("en"));

		        //remove the ids from all the children (so we don't get duplicate ids)
		        item.children().removeAttr("id");
		        //add the item to the list
		        twitterStream.append(item);
		    });

		    //finally remove the tweet template
		    tweetTemplate.remove();
		});


			//initilises slider script for twitter feed
			$(document).ready(function(){	
			  $('#twitterStream').bxSlider({
				auto: 			true,
				pager: 			false,
				mode: 			'vertical',
				infiniteLoop: 	true,
				displaySlideQty: 2,
				moveSlideQty: 	 1,
				easing: 		'easeOutQuad',
				speed: 			3000,
				pause:			2500,
				autoHover:		true,
				controls: 		false
			  });
			});

