jQuery.noConflict();

function getLatestForumPosts(threadid, maxposts){
	
    var Wochentag = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
    var threadcount = 0;
    if (!jQuery('#forenrss')) {
        return;
    }
    
    jQuery.getFeed({
    
        url: '/typo3conf/ext/escmid_rssimporter/rss.php?id=' + threadid + '&max=' + maxposts,
        username: 'preview',
        password: 'demo',
        success: function(feed){
			
            feed.items.each(function(feedItem){
				
                threadcount++;
                var clock = new Date(feedItem.updated);
                var clock_minutes = clock.getMinutes();
                if(clock_minutes < 10){
                    clock_minutes = "0"+clock_minutes;
                }
                var time = Wochentag[clock.getDay()] + ',&nbsp;' + clock.getDate() + '.' + (clock.getMonth()+1) + '.' + clock.getFullYear() + '&nbsp;' + clock.getHours() + ':' + clock_minutes + '&nbsp;';
                var item = "<div class=\"item\" ><div class=\"date\"><a class=\"tooltip\" href=\"" + feedItem.link + "\" title=\"" + feedItem.title + "\"><div class=\"time\">" + time + "</div>" + "<div class=\"name\">&nbsp;by&nbsp;" + feedItem.creator +":&nbsp;</div>" +"<div class=\"title\">" +feedItem.title.substr(0, 27) +"</a></div><div class=\"clear\"></div></div>" +"<div class=\"content\" ><div class=\"description\" >" +feedItem.description.substr(0, 150) +"&nbsp;[...]</div><div class=\"more\"><a class=\"tooltip\" href=\"" +feedItem.link +"\" title=\"" +feedItem.title +"\">more</a></div></div><div class=\"clear\"></div></div>";
				if (threadcount <= maxposts) {
                    jQuery('#forenrss').append(item);				
                }
                else {
                    return;
                }
                
                
            });
            
            /*var forenlink = "insgesamt " + threadcount + " Beiträge */
            //var forenlink = "<a href=\"http://forum.escmid.org/forumdisplay.php?" + threadid + "\" title=\"Go to Forum\">Go to Forum</a>"
            //jQuery('#forenrss .header .rechts').append(forenlink);
            
            /*jQuery('#forenrss span').hide();*/
            
            
        }
    });

    /*var emptyfeed = "Noch keine Einträge vorhanden.";
    if (!threadcount) {
        jQuery('#forenrss').append(emptyfeed);
    }*/
    
    
    
}




