// <![CDATA[
/*
(c)copyright 2008 Medial - Gesellschaft für digitale Medien mbH
Letzter Bearbeitungstand: 28.04.2008
Author: Torsten Jaeschke
*/
// --------------------------------------------------------------------------------------------------------
/*
function readRSS()
RSS-Reader-Objekt
*/
function readRSS() {
    this.id=0;
    this.RSS = [];
    this.proxy = "";
    this.cntArticle = 5;
    this.arMonth = ["Januar", "Februar", "M&auml;rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"];
    this.title="";
    this.init = function(url, rId, cnt){
            var r = this;
            this.id = rId;
            this.cntArticle = (cnt != null)?cnt:this.cntArticle;
            if(this.proxy != "") {
                url=this.proxy+"?url="+url;
            }
            $.get(url, function(xml){ 
                r.loadItems(xml); 
            });
        };
    this.loadItems = function(xml) {
            this.title = $("channel > title", xml).text();
            var rAr = this.RSS;
            $("item",xml).each(function(){
                rAr.push(this);
            });
            //this.showTitle();
            this.showRSS();
        };
    this.showRSS=function() {
            var info = this.RSS;
            var feed = this;
            var rId = "#"+this.id;
            var cnt = this.cntArticle;
            $.each(info, function(i) {
        if(i < cnt) {
            if($("pubDate", this).text() != "") {
                var d = new Date($("pubDate", this).text());
            } else {
                var d = new Date();
            }
            var date = day+". "+m+" "+year
            var m = feed.arMonth[d.getMonth()];
            var day = (d.getDate().length == 1)?"0"+d.getDate():d.getDate();
            var year = d.getFullYear();
            var dateString = day+". "+m+" "+year;
            var inline = "";
            inline+= "<p class='date'>"+dateString+"</p>";
            inline+= "<h3>"+$("title", this).text()+"</h3>";
            inline+= "<div class='teaser'>"+$("description", this).text();
            //inline+= "<a class='link_internal' href='"+$("link", this).text()+"'>"+$("title", this).text()+"</a>";
            inline+= "</div>";
            $(rId).append(inline);
        }
            });
        };
    this.showTitle=function() {
            var info = this.title;
            var rId = "#"+this.id;
        var inline = "<h2>"+info+"</h2>";
        $(rId).append(inline);    
        };
    this.setProxy = function(prox) {
        this.proxy = prox;
    }
}
// ]]>
