// ----------------------------------------
// SHOW RECENT COMMENTS
// ----------------------------------------
// This functions takes a blogger-feed in JSON
// format and displays it.
//
// Version: 2.1
// Date:    2007-01-03
// 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);
   if (cdday.substring(0,1) == "0") cdday = cdday.substring(1,2);
   var monthnames = new Array();
   monthnames[1] = "de enero";
   monthnames[2] = "de febrero";
   monthnames[3] = "de marzo";
   monthnames[4] = "de abril";
   monthnames[5] = "de mayo";
   monthnames[6] = "de junio";
   monthnames[7] = "de julio";
   monthnames[8] = "de agosto";
   monthnames[9] = "de septiembre";
   monthnames[10] = "de octubre";
   monthnames[11] = "de noviembre";
   monthnames[12] = "de diciembre";
   var comment = entry.content.$t;
   var re = /<\S[^>]*>/g; 
   comment = comment.replace(re, "");
   if (!standardstyling) document.write('<div class="bbrecpost">');
   if (standardstyling) document.write('<br/>');
   if (showcommentdate == true) document.write('El ' + cdday + ' ' + monthnames[parseInt(cdmonth,10)] + ' ');
   document.write('<a href="' + alturl + '">' + entry.author[0].name.$t + '</a> dijo:');
   if (showposttitle == true) document.write(' acerca de ' + posttitle + ': ');
   if (!standardstyling) document.write('</div><div class="bbrecpostsum">');
   if (standardstyling) document.write('<br/>');
   if (comment.length < numchars) {
         if (standardstyling) document.write('<i>');
         document.write(comment);
         if (standardstyling) document.write('</i>');}
   else
        { 
         if (standardstyling) document.write('<i>');
         comment = comment.substring(0, numchars);
         var quoteEnd = comment.lastIndexOf(" ");
         comment = comment.substring(0, quoteEnd);
         document.write(comment + ' [...] <a href="' + alturl + '">leer al pie de entrada</a>');
         if (standardstyling) document.write('</i>');}
   if (!standardstyling) document.write('</div>');
   if (standardstyling) document.write('<br/>');
  }
if (!standardstyling) document.write('<div class="bbwidgetfooter">');
if (standardstyling) document.write('<br/>');
document.write('<span style="font-size:80%;">Prototipo <a href="http://hackosphere.blogspot.com">Hackosphere</a><br/>Desarrollo <a href="http://beautifulbeta.blogspot.com">Beautiful Beta</a><br/>Idioma <a href="http://arcen2007.blogspot.com/2007/10/localizacin.html">es</a></span>');
if (!standardstyling) document.write('</div>');}