google.load("feeds", "1") 

function rssdisplayer2(divid, url, feedlimit, showoptions){
this.showoptions=showoptions || "" 
var feedpointer=new google.feeds.Feed(url) 
feedpointer.setNumEntries(feedlimit) 
document.write('<div id="'+divid+'">Зареждам...</div>')
this.feedcontainer=document.getElementById(divid)
var displayer=this
feedpointer.load(function(r){displayer.formatoutput(r)}) 
}


rssdisplayer2.prototype.formatdate=function(datestr){
var itemdate=new Date(datestr)
return "<span style='color:gray; font-size: 90%'>"+itemdate.toLocaleString()+"</span>"
}


rssdisplayer2.prototype.formatoutput=function(result){
if (!result.error){ 
var thefeeds=result.feed.entries 
var rssoutput="<ul>"
for (var i=0; i<thefeeds.length; i++){ 
var itemtitle="<a href=\"" + thefeeds[i].link + "\">" + thefeeds[i].title + "</a>"
var itemdate=/date/i.test(this.showoptions)? this.formatdate(thefeeds[i].publishedDate) : ""
var itemdescription=/description/i.test(this.showoptions)? "<br />"+thefeeds[i].content : /snippet/i.test(this.showoptions)? "<br />"+thefeeds[i].contentSnippet  : ""
rssoutput+="<li>" + itemtitle + " " + itemdate + itemdescription + "</li>"
}
rssoutput+="</ul>"
this.feedcontainer.innerHTML=rssoutput
}
else 
alert("Емисията не е достъпна: "+result.error.message)
}

