


/* ------------------------------------------------------- */
function showFeed(url,type,numToShow) {

  // get the feed
  $.get(url, {}, function(xml){
    //console.log('getting ' + url);
    var output = '<ul>';
    var dest = "#" + type;
    var cntr = 0;
    $('item',xml).each(function(){
      cntr++;
      var dateLine = "";

      if (type == 'twitter .contain') { 
	dateLine = "<br /><span class=\"date\">" + $(this).find('pubDate').text().replace(/ \+0000/, "") + "</span>";
      }

      output += "<li onclick='javascript:window.location=\"" + $(this).find('link').text() +  "\";'><a href=\"" + $(this).find('link').text() + "\" target=\"_blank\">" + $(this).find('title').text() + "</a>" + dateLine + "</li>\n";
      if (cntr == numToShow) { return false; }
    });
    output += "</ul>";
    //console.log(dest);
    $(dest).html(output);
  });

}


/* ------------------------------------------------------- */
function openWindow(url) {
  window.open(url, 'newWindow', 'status=1,toolbar=1,width=702,height=274,resizeable=1,scrollbars=0');
}


/* ------------------------------------------------------- */
function limit_words(str, limit) {
  var words = str.split(/\s/);
  if (words.length > limit)  {
    words.length = limit;
    var ret = words.join(' ');
    ret += '...';
    return ret;
  } 
  else { return str; }
}


