var twURL = "http://twitter.com/statuses/user_timeline/273481611.rss";

// must have twURL defined in containing page!
jQuery(function(){
	google.setOnLoadCallback(initializeFeeds);
});
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
google.load("feeds", "1");

function initializeFeeds() {
  var feed = new google.feeds.Feed(twURL);
  
  feed.setResultFormat(google.feeds.Feed.XML_FORMAT);
  feed.setNumEntries(21);
  
  feed.load(function(result) {
	  var xmldoc = result.xmlDocument;
		//twitter is stupid, atom uses 'entries' rss uses 'items'
	  var title,tlink,twittersource,description,guid,dcdate,pubdate,li;
	  var items  	= xmldoc.getElementsByTagName("item");
	  var titles 	= xmldoc.getElementsByTagName("title"); 
	  var links  	= xmldoc.getElementsByTagName("link");
	  var pubDates 	= xmldoc.getElementsByTagName("pubDate"); 
		
	  for (var i = items.length; i > 0; i--) {
		  title 	= titles[i].childNodes[0].nodeValue;  //same as guid on twittr
		  title 	= title != "undefined" ? title.replace("MagicValleyMall:", '') : ''; //same as description on twittr
		  tlink  	= links[i].childNodes[0].nodeValue;  //same as guid on twittr
		  
			//pubdate 	= pubDates[i].childNodes[0].nodeValue;
			//console.log(title);
			//console.log(tlink);
			//console.log(pubDates);
			//li 		= '<li class="twitter-item"><a href="' + tlink + '">' + title + '</a><br />' + '' + '</li>';
			
			li 		= '<li class="twitter-item"><a href="' + tlink + '">' + title + '</a></li>';
			
		  jQuery("#twitter-widget").append(li);
	  }
	  if (typeof postResultCallback == 'function') {
			postResultCallback();
	  }
	
  });
	
	   
} 		


/*

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:georss="http://www.georss.org/georss" xmlns:twitter="http://api.twitter.com">
  <channel>
    <title>Twitter / MagicValleyMall</title>
    <link>http://twitter.com/MagicValleyMall</link>
    <atom:link type="application/rss+xml" href="http://twitter.com/statuses/user_timeline/273481611.rss" rel="self"/>
    <description>Twitter updates from Magic Valley Mall / MagicValleyMall.</description>
    <language>en-us</language>
    <ttl>40</ttl>
  <item>
    <title>MagicValleyMall: Magic Valley has arrived on Twitter! Stay tuned for twitter-only deals and promotions.</title>
    <description>MagicValleyMall: Magic Valley has arrived on Twitter! Stay tuned for twitter-only deals and promotions.</description>
    <pubDate>Mon, 28 Mar 2011 18:26:04 +0000</pubDate>
    <guid>http://twitter.com/MagicValleyMall/statuses/52436308584439808</guid>
    <link>http://twitter.com/MagicValleyMall/statuses/52436308584439808</link>
    <twitter:source>web</twitter:source>
    <twitter:place/>
  </item>
  </channel>

</rss>


*/



