
		(function(){
		/*
		Customized callback to show an error message on the tweets's lookup
		This callback is optional, the default error callback shows an alert(errorMessage)
		*/
		var tweetsErrorCallback = function(errorMessage, tweet){
			var msg = 'Oops! \
				<a href="http://dev.twitter.com/pages/rate-limiting">Twitter Rate Limit Exceeded</a>. \
				Try again later or search \
				<a href="http://twitter.com/search?q=' + tweet.toQuery() + '">directly on Twitter</a>';
			$('#tweets').html(msg);
		}
		/*
		Customized callback to show the tweets
		Remember that, this plugin is only for tweets's search, it does not generate view
		*/
		var tweetsSuccessCallback = function(data){
			var tweetsLi = '';
			for(var i = 0; i < data.results.length; i++){
				var tweet = data.results[i];
				// Calculate how many hours ago was the tweet posted
				// http://www.lupomontero.com/fetching-tweets-with-jquery-and-the-twitter-json-api/
				var dateTweet = new Date(tweet.created_at);
				var dateNow   = new Date();
				var dateDiff  = dateNow - dateTweet;
				var hours     = Math.round(dateDiff/(1000*60*60));
				var minutes   = Math.round(dateDiff/(1000*60));			
				
					if(hours == 1){
						var hoursText	= hours + ' hour ago';
					}else{
						var hoursText	= hours + ' hours ago';
					}	
					
					if(minutes == 1){
						var minutesText	= minutes + ' minute ago';
					}else{
						var minutesText	= minutes + ' minutes ago';
					}
					
				if (minutes >= 60){
					var when = hoursText;
				}else{
					var when = minutesText;
				}
					
				function zero(number, length) {
				   
					var str = '' + number;
					while (str.length < length) {
						str = '0' + str;
					}
					return str;
				}
				
				var month=new Array(12);
				month[0]="Jan";
				month[1]="Feb";
				month[2]="Mar";
				month[3]="Apr";
				month[4]="May";
				month[5]="Jun";
				month[6]="Jul";
				month[7]="Aug";
				month[8]="Sep";
				month[9]="Oct";
				month[10]="Nov";
				month[11]="Dec";
				
				var twit_sec = dateTweet.getSeconds();
				var twit_min = zero(dateTweet.getMinutes(), 2);
				var twit_hour = dateTweet.getHours();
				
				var twit_date = dateTweet.getDate();
				var twit_month = month[dateTweet.getMonth()];
				var twit_year = dateTweet.getFullYear();

				
		  		tweetsLi += '<li> \
		  		      <dl> \
		  		              <dt><img src="' + tweet.profile_image_url + '" height="37"/></dt> \
		  		              <dd> \
		  		                      <span><a href="http://twitter.com/' + tweet.from_user + '">' + tweet.from_user + '</a></span> \
		  		                      <span><a class="timeTweet" href="#" title="'+ twit_date +' '+ twit_month +' '+ twit_year +' '+ twit_hour +':'+ twit_min +'">' + when + '</a></span></dd></dl> \
		  		      <div>' + tweet.text + '</div> \
		  		</li>';
			}
			$('#tweets').html('<ul id="pittugTweets">' + tweetsLi + '</ul>');
			
	
			$('ul#pittugTweets').innerfade({
				speed: 1200,
				timeout: 7000,
				type: 'sequence'
			});
		}

		$(document).ready(function(){
			/*
			Here is the example of the plugin usage
			*/
			var tweets = Twitter.tweets();
			tweets.containing('pittug').all(tweetsSuccessCallback, tweetsErrorCallback);
		});
	})();
/*
$(document).ready(
		function(){
			$('ul#pittugTweets').innerfade({
				animationtype: 'slide',
				speed: 750,
				timeout: 2000,
				type: 'random',
				containerheight: '1em'
			});
			
			$('ul#pittugTweets').innerfade({
				speed: 1000,
				timeout: 5000,
				type: 'sequence',
				containerheight: '220px'
			});
			
			$('#pittugTweets').innerfade({
				speed: 1000,
				timeout: 6000,
				type: 'random_start',
				containerheight: '1.5em'
			});
			
			$('#pittugTweets').innerfade({
				speed: 'slow',
				timeout: 5000,
				type: 'random',
				containerheight: '150px'
			});

	});
*/
