// ----------------------------------------
// SHOW RECENT COMMENTS
// ----------------------------------------
// This functions takes a blogger-feed in JSON
// format and displays it.
//
// Version: 1.0
// Date:    2006-12-01
// Author:  Hans Oosting
// URL:     beautifulbeta.blogspot.com
// ----------------------------------------

function showrecentcomments(json) {
  for (var i = 0; i < numcomments; i++) {
    var entry = json.feed.entry[i];
    var alturl;

    if (i == json.feed.entry.length) break;
    for (var k = 0; k < entry.link.length; k++) {
      if (entry.link[k].rel == 'alternate') {
        alturl = entry.link[k].href;
        break;
      }
    }
   alturl = alturl.replace("#", "#comment-");
   var postlink = alturl.split("#");
   postlink = postlink[0];
   var linktext = postlink.split("/");
   linktext = linktext[5];
   linktext = linktext.split(".html");
   linktext = linktext[0];
   var posttitle = linktext.replace(/-/g," ");
   posttitle = posttitle.link(postlink);
   var commentdate = entry.published.$t;
   var cdyear = commentdate.substring(0,4);
   var cdmonth = commentdate.substring(5,7);
   var cdday = commentdate.substring(8,10);
   var monthnames = new Array();
   monthnames[1] = "Jan";
   monthnames[2] = "Feb";
   monthnames[3] = "Mar";
   monthnames[4] = "Apr";
   monthnames[5] = "Mei";
   monthnames[6] = "Jun";
   monthnames[7] = "Jul";
   monthnames[8] = "Ags";
   monthnames[9] = "Sep";
   monthnames[10] = "Okt";
   monthnames[11] = "Nov";
   monthnames[12] = "Des";
   var comment = entry.content.$t;
   var re = /<\S[^>]*>/g; 
   comment = comment.replace(re, "");
   if (showcommentdate == true) document.write('<font class=fatur> | <b>' + cdday + monthnames[parseInt(cdmonth,10)] + cdyear + '</b></font>');
   document.write('<font class=fatur>&raquo; <b><a href="' + alturl + '">' + entry.author[0].name.$t + '</a></b>@</font>');
   if (showposttitle == true) document.write('<font class=fatur><b>' + posttitle + ' :</b></font>');
   document.write('<br/>');
   if (comment.length < numchars)
         document.write('<font class=fatur>' + comment + '</font><br/><br/>');
   else
         document.write('<font class=fatur>'+ comment.substring(0, numchars) + '...</font><br/><br/>');
  }

}