//$(document).ready(function(){
						   
	google.load("feeds", "1");
 	var loadingCache = '';
	var dataCache = '';
	
    function loadTweets() {
		loadedCache = $("#feed-loaded").html();
		loadedCacheTxt = $("#feed-loaded").text();
		var feed = new google.feeds.Feed("http://search.twitter.com/search.atom?q=huskers%20-nebraskabuzztap%20%20-huskerheadlines");
		feed.setNumEntries(50);
      	feed.load(function(result) {
		
		var newEntries = '';

		if (!result.error) {
			for (var i = 0; i < result.feed.entries.length; i++) {
				
				var entry = result.feed.entries[i];
				var attributes = ["title", "link", "publishedDate", "author", "contentSnippet"];
				
				//if story is new - if loadedCache is empty, then they're all new
				if(loadedCacheTxt.indexOf(entry[attributes[0]]) == -1 && !hj_utils.hasSwearing(entry[attributes[0]])){
					var author = entry[attributes[3]];
					author = author.substring(0, author.indexOf(' ('));
					
					var daysAgo = hj_utils.calcDaysAgo(entry[attributes[2]]);
					
					//format desc
					var desc = '';
					var descArr = entry[attributes[0]].split(' ');
					var reps = descArr.length;
					//alert(descArr.length);
					for(y=0; y<reps; y++){
						var word = descArr[y];
						if(word.length > 30){
							word = word.substring(0, 27) + '...';
						}
						
						desc += word + ' ';
					}
					
					var txtEntry = '<div class="twit-entry">';
					txtEntry += '  <div class="twit-title"><a href="' + entry[attributes[1]] + '">';
					txtEntry += '@' + author + ': ' + desc + '</a></div>';
                    txtEntry += '<div class="twit-date">' + daysAgo + '</div>';
					txtEntry += '</div>';
					
					newEntries  += txtEntry;
				}
			}
        }
		
		$("#feed-loading").hide(2000);
		$("#feed-loaded").show();
		$("#feed-loaded").html(newEntries + loadedCache);
		
      });
    }
	
	function initializeTwitter(){
		window.setInterval(function(){
			loadTweets();							
		}, 600000);
	}
	
    google.setOnLoadCallback(initializeTwitter);
	
//});