// include Home news feed
$(document).ready(function() {
// Format 5 items of newsfeed for City's Home Page.    
  $('#newsTable').each(function() {
    // Create and empty a unique container for feed.
    var $container = $(this);
    $container.empty();
    // Get feed xml and format title and link.
    $.get('/rss/home/home.xml', function(data) {
		var feedCount = 5;
      $('rss item', data).each(function(i) {
        if(feedCount && ($('category', this).text() !== 'archiveonly')) {
          // Format pubDate RFC 822 to mm/dd/yy.
          var pubDate = new Date(
          $('pubDate', this).text());
          var pubMonth = pubDate.getMonth() + 1;
          var pubDay = pubDate.getDate();
          var pubYear = pubDate.getFullYear();
          pubYear = pubYear.toString().slice(2);
          // Wrap pubDate in div with class tag.
          var $publication = $('<td>')
          .addClass('publication-date')
          .text(pubMonth + '/' + pubDay + '/' + pubYear);
          // Get headline
		  if($('link', this).text()){
			  var $link = $('<a>').attr('href',$('link', this).text()).append($('title',this).text());
			  var $headline = $('<td>').append($link);
			  if ($('link', this).text().match(".pdf")) {
                    $($headline).append(' (PDF)');
                }
	          
		  } else {
		  	var $headline = $('<td>').append($('title', this).text());
		  }
          var $headline = $headline.append($('description', this).text());
          // Wrap complete item in div of class tag ("headline").
          $('<tr>')
          .addClass('headline')
          .append($publication, $headline)
          .appendTo($container);
		  feedCount = feedCount - 1;
        }
      });
    $('table#newsTable tr:nth-child(odd)').addClass('alt');     
	 
    });
  });
 // if($.cookie('tranDisc')==='accepted'){
//		$('#newsTable').translate('english', $.cookie('destLang'), { //translate from english to the selected language
//	    not: '.jq-translate-ui, .no-translate', //by default the generated element has this className
//	    fromOriginal: true //always translate from english (even after the page has been translated)
//	});
//	}
});

