var org = {p3k: ({url:"http://flayersvlog.tumblr.com/rss", xml:"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss version=\"2.0\"><channel><atom:link rel=\"hub\" href=\"http://tumblr.superfeedr.com/\" xmlns:atom=\"http://www.w3.org/2005/Atom\"/><description>\u2026desde Buenos Aires para toda Latinoam\xe9rica, desde Latinoam\xe9rica para todo el mundo.\nFlayers, periodismo serio sobre m\xfasica electr\xf3nica. \nhttp://www.flayers.com.ar</description><title>_</title><generator>Tumblr (3.0; @flayersvlog)</generator><link>http://flayersvlog.tumblr.com/</link><item><title>Vlog #000.23: M\xe4uss.</title><description>\nDesde mis inicios como redactora para Flayers he conocido artistas con diversas, variadas y...</description><link>http://flayersvlog.tumblr.com/post/26926046</link><guid>http://flayersvlog.tumblr.com/post/26926046</guid><pubDate>Thu, 21 Feb 2008 15:56:00 -0200</pubDate><category>M\xe4uss</category><category>Mauss</category></item><item><title>Flayers vlog #000.22: Vivo eternamente ahora.</title><description>La performances en vivo para la electronica son algo as\xed como las finales de copa para el f\xfatbol,...</description><link>http://flayersvlog.tumblr.com/post/25583048</link><guid>http://flayersvlog.tumblr.com/post/25583048</guid><pubDate>Sat, 19 Jan 2008 15:24:00 -0200</pubDate><category>Eterno Ahora</category><category>PFL</category><category>Porno for Laicos</category><category>Minirocke</category><category>Julie Amadeo</category><category>Natala Garagiola</category><category>One Dot Zero</category><category>4Fav</category></item><item><title>Flayers vlog #000.21: </title><description>Psicho Zeka.\nMientras pasea y disfruta de las playas de Mar del Plata, como cualquiera de sus miles...</description><link>http://flayersvlog.tumblr.com/post/25561714</link><guid>http://flayersvlog.tumblr.com/post/25561714</guid><pubDate>Mon, 14 Jan 2008 11:47:00 -0200</pubDate><category>Luis Zerrillo</category><category>Dj</category><category>Psicho Zeka</category><category>Video Clip</category><category>videoclip</category><category>karakachoff</category><category>aula Heiderscheid</category><category>Mauro Haramboure</category><category>Agust\xedn Gonzalez</category></item><item><title>Flayers vlog #000.20: El coraz\xf3n en continua gira.</title><description>Prepar\xe1ndose para la presentaci\xf3n radial de esta noche en Nueva York v\xeda WFUM FM 91.1 y ultimando...</description><link>http://flayersvlog.tumblr.com/post/25582257</link><guid>http://flayersvlog.tumblr.com/post/25582257</guid><pubDate>Mon, 07 Jan 2008 15:10:00 -0200</pubDate><category>Antiguo Aut\xf3mata Mexicano</category><category>\xc1ngel S\xe1nchez Borges</category><category>AAM</category><category>aka The Brooklyn Sweetheart</category><category>The Order</category><category>Dark Brooklyn</category><category>mix</category></item><item><title>Flayers vlog #000.18: Habemus Trailer.</title><description>  Hay dos caracter\xedsticas infalibles en los eventos firmados por ID&amp;T, la primera es la...</description><link>http://flayersvlog.tumblr.com/post/25582122</link><guid>http://flayersvlog.tumblr.com/post/25582122</guid><pubDate>Wed, 26 Dec 2007 12:18:00 -0300</pubDate><category>Sensation White</category><category>2008</category><category>Tour</category><category>Chile</category><category>Trailer</category><category>Sensation White 2008 Tour Chile Trailer</category><category>ID&amp;T</category><category>Latinoamerica</category><category>ID&amp;t latinoamerica</category></item><item><title>Flayers vlog #000.17: Videoclip de un latinoamericano al rev\xe9s.</title><description>  A punto de subirse al escenario de La Trastienda, en Buenos Aires esta noche, la historia de Kevin...</description><link>http://flayersvlog.tumblr.com/post/25581931</link><guid>http://flayersvlog.tumblr.com/post/25581931</guid><pubDate>Wed, 19 Dec 2007 14:06:00 -0300</pubDate><category>Kevin Johansen</category><category>SOS Tan Fashion</category><category>Kevin Johansen - SOS Tan Fashion</category></item><item><title>Flayers vlog #000.16: Exclusiva!!!.</title><description>  Desde hace ya un tiempo el sitio web Flowmi nos da que hablar, para bien o para mal pero presente...</description><link>http://flayersvlog.tumblr.com/post/25581672</link><guid>http://flayersvlog.tumblr.com/post/25581672</guid><pubDate>Sat, 15 Dec 2007 14:03:00 -0300</pubDate><category>Flowmi</category><category>Creamfields Buenos Aires</category><category>Creamfields Buenos Aires 2007</category><category>Creamfields</category><category>Creamfields Backstage</category><category>Soledad Rodriguez Zubieta</category></item><item><title>Flayers vlog #000.14: La electronica en movimiento.</title><description>  Concluido recientemente a fines de noviembre, el recorrido por la Argentina realizado por el...</description><link>http://flayersvlog.tumblr.com/post/25581396</link><guid>http://flayersvlog.tumblr.com/post/25581396</guid><pubDate>Mon, 03 Dec 2007 14:00:00 -0300</pubDate><category>Nokia Trends Artemotion ARG</category></item><item><title>Flayers vlog #000.13: Televidentes en la era de internet.</title><description>  Ahora si!, no es el numero mas lindo de todos pero al menos no nos jugo en contra, en este vlog...</description><link>http://flayersvlog.tumblr.com/post/25581239</link><guid>http://flayersvlog.tumblr.com/post/25581239</guid><pubDate>Sat, 24 Nov 2007 13:56:00 -0300</pubDate><category>Televidente</category><category>Javier S1erra</category><category>Javier Sierra</category><category>Entrevistas</category><category>entrevistas con musicos electronicos</category><category>colombianos</category><category>colombia</category><category>electronica</category></item><item><title>Flayers vlog #000.12: Planes cambiados, pero siguiendo el camino.</title><description>Ten\xedamos otros planes para este vlog, pero t\xe9cnicamente se nos hizo imposible, lo cual nos frustra...</description><link>http://flayersvlog.tumblr.com/post/25580941</link><guid>http://flayersvlog.tumblr.com/post/25580941</guid><pubDate>Sat, 17 Nov 2007 13:53:00 -0300</pubDate><category>Control Machete</category><category>Los Caballeros del PlanG</category><category>SEKRETO</category><category>En el Camino</category></item><item><title>Flayers vlog #000.11: Navegando por YouTube yo voy mirando\u2026 yo voy linkeando\u2026 muy feliz.</title><description>YouTube es una de las herramientas mas practicas y preferidas de todos hoy d\xeda y aqu\xed en Flayers no...</description><link>http://flayersvlog.tumblr.com/post/25580507</link><guid>http://flayersvlog.tumblr.com/post/25580507</guid><pubDate>Sat, 10 Nov 2007 13:49:00 -0300</pubDate><category>Mylo vs. Miami Sound Machine - Doctor Preasure</category><category>ATB with Heather Nova - Renegade</category><category>Sash - Ecuador</category><category>Chemical Brothers - Out Of Control</category></item><item><title>Flayers vlog #000.10: La vida es un loop.</title><description> Todos los d\xedas aqu\xed juntos, redactores y lectores conocemos artistas, tan solo con diferencias de...</description><link>http://flayersvlog.tumblr.com/post/25579193</link><guid>http://flayersvlog.tumblr.com/post/25579193</guid><pubDate>Sat, 03 Nov 2007 13:34:00 -0300</pubDate><category>Life is a loop</category><category>Fabr\xedcio Pe\xe7anha</category><category>DJ Leozinho</category><category>Rodrigo Paciornik</category><category>life is a loop dvd</category><category>dvd</category></item><item><title>Flayers vlog #000.9: Conejos tecno.</title><description>  Prometemos, cumplimos. Esta semana dimos a conocer uno de las esperanzas que tiene la escena...</description><link>http://flayersvlog.tumblr.com/post/25578057</link><guid>http://flayersvlog.tumblr.com/post/25578057</guid><pubDate>Sat, 27 Oct 2007 13:16:00 -0300</pubDate><category>Ra beat</category><category>Conejos tecno</category><category>Mutaciones: Remixes</category><category>Carlos Shaw</category><category>Soda Stereo</category><category>Gustavo Cerati</category></item><item><title>Flayers vlog #000.8:</title><description>Como creci\xf3 la nena! No solemos hablar dos veces del mismo artista en este blog, esa es una de...</description><link>http://flayersvlog.tumblr.com/post/25570347</link><guid>http://flayersvlog.tumblr.com/post/25570347</guid><pubDate>Sat, 20 Oct 2007 11:43:00 -0300</pubDate><category>Lucrecia</category><category>The Sound Of Lucrecia</category><category>Lucrecia videoclips</category><category>Lucrecia video clips</category><category>videoclip</category><category>thesoundoflucrecia</category></item><item><title>Flayers vlog #000.7:</title><description>La Javi.\n Javiera Mena sin lugar a dudas es la artista del momento en Chile, alternativa para...</description><link>http://flayersvlog.tumblr.com/post/25569479</link><guid>http://flayersvlog.tumblr.com/post/25569479</guid><pubDate>Sat, 13 Oct 2007 11:30:00 -0300</pubDate><category>Javiera Mena</category><category>La Javi</category><category>Yo no te pido la luna</category><category>al siguiente nivel</category><category>videoclip</category><category>videoclips</category><category>de</category><category>video clips de javiera mena</category><category>Javiera Mena en concierto en Compass</category><category>audio</category></item><item><title>Flayers vlog #000.6:</title><description>Tobas en la pista de baile . Seg\xfan nos ha informado nuestro editor en poco tiempo mas, tendremos el...</description><link>http://flayersvlog.tumblr.com/post/25568321</link><guid>http://flayersvlog.tumblr.com/post/25568321</guid><pubDate>Sat, 29 Sep 2007 11:20:00 -0300</pubDate><category>Tonolec</category><category>Tobas</category><category>Toba Electronica</category><category>fusion</category><category>electronica etnica</category><category>aborigen</category></item><item><title>Flayers vlog #000.5:</title><description>Mira este video! Con mayor o menor frecuencia todo ser humano que utilice internet a diario se topa...</description><link>http://flayersvlog.tumblr.com/post/25567598</link><guid>http://flayersvlog.tumblr.com/post/25567598</guid><pubDate>Wed, 26 Sep 2007 11:06:00 -0300</pubDate><category>MOB JAM</category><category>nokia trends</category><category>nokia</category><category>Anderson Noise</category><category>DJ Patife</category><category>DJ Mau Mau</category><category>Mix Hell</category></item><item><title>Flayers vlog #000.4:</title><description>Backtracks!!!Odiado hasta el cansancio y amado hasta la fanatizaci\xf3n; glorificado por la prensa en...</description><link>http://flayersvlog.tumblr.com/post/25567142</link><guid>http://flayersvlog.tumblr.com/post/25567142</guid><pubDate>Sat, 22 Sep 2007 10:58:00 -0300</pubDate><category>Dj Dero</category><category>Dero</category><category>Ezequiel Dero</category><category>Ezequiel Dj Dero</category><category>videos de dero</category><category>videos de</category><category>la campana</category><category>aurora</category><category>revolution</category><category>batucada 2000</category></item><item><title>Flayers vlog #000.1:</title><description>Video entrevista a Matias Aguayo. \u201cDetras de todo gran blog, hay un gran vlog\u201d, no se si...</description><link>http://flayersvlog.tumblr.com/post/25563691</link><guid>http://flayersvlog.tumblr.com/post/25563691</guid><pubDate>Sun, 02 Sep 2007 10:16:00 -0300</pubDate><category>Matias Aguayo</category><category>dj matias aguayo</category><category>entrevista con matias aguayo</category><category>entrevista a matias aguayo</category><category>entrevista con</category><category>entrevista a</category><category>marcela mazzei</category><category>ciudad internet</category></item></channel></rss>\n", message:undefined, modified:(new Date(1265732834945)), baseUri:"http://p3k.org/rss/", query:"url=http://flayersvlog.tumblr.com/rss&maxItems=20&width=480&align=left&showXmlButton=1&frameColor=black&titleBarColor=black&titleBarTextColor=black&boxFillColor=black&textColor=white&fontFace=&", param:{frameColor:"black", textColor:"white", showXmlButton:"1", width:"480", align:"left", fontFace:"", boxFillColor:"black", titleBarColor:"black", maxItems:"20", url:"http://flayersvlog.tumblr.com/rss", titleBarTextColor:"black"}, box:"<table class=\"rssBox\" width=\"${width}\" bgcolor=\"${frameColor}\" \n      style=\"table-layout: fixed; overflow: hidden; font-family: ${fontFace};\" \n      align=\"${align}\" cellspacing=\"1\" cellpadding=\"7\" border=\"0\">\n<tr bgcolor=\"${titleBarColor}\">\n<td>\n   ${xmlButton}\n   <strong>${title}</strong>\n   <div>\n      <small style=\"color: ${titleBarTextColor};\">${date}</small>\n   </div>\n</td>\n</tr>\n<tr bgcolor=\"${boxFillColor}\">\n<td class=\"rssBoxContent\" style=\"color: ${textColor};\">\n   ${image}\n   ${items}\n   ${input}\n   <div class=\"rssBoxPromo\" style=\"margin-top: 0px; text-align: left; \n         font: 9px verdana, sans-serif\">\n      RSS box by <a href=\"http://p3k.org/rss\">p3k.org</a>.\n   </div>\n</td>\n</tr>\n</table>\n\n", image:"<a href=\"${link}\"><img src=\"${source}\" width=\"${width}\" height=\"${height}\" \nalt=\"${title}\" title=\"${title}\" align=\"${align}\" valign=\"${valign}\" \nhspace=\"${hspace}\" vspace=\"${vspace}\" border=\"0\" /></a>\n\n", input:"<form method=\"get\" action=\"${link}\">\n${description}\n<input type=\"text\" name=\"${name}\" size=\"15\" /> <input type=\"submit\" \nvalue=\"${title}\" />\n</form>\n\n", item:"<div class=\"rssBoxItemContent\">\n${title}\n${break}\n${description}\n${buttons}\n</div><br />\n\n", date:"${year}-${month}-${day}, ${hours}:${minutes}h\n\n", link:"<a class=\"${class}\" href=\"${link}\" style=\"${style}\">${text}</a>\n", error:"<?xml version=\"1.0\"?>\n<rss version=\"error\">\n   <channel>\n      <title>RSS Box Error</title>\n      <link>${link}</link>\n      <description>This output was automatically generated to report an error \n      that occurred during a request to the JavaScript RSS Box Viewer.</description>\n      <item>\n         <title>Oops, something went wrong...</title>\n         <description>An error occurred while processing the request to the \n         JavaScript RSS Box Viewer.</description>\n      </item>\n      <item>\n         <title>An error message was returned by the server.</title>\n         <description>${message}</description>\n      </item>\n      <item>\n         <description>Most likely, this might have happened because of a \n         non-existent or invalid RSS feed URL. Please check and possibly correct \n         your input, then try again.</description>\n      </item>\n   </channel>\n</rss>\n\n"})};
function debug(str) {
   return document.write('<p><span style="background-color: yellow;">', 
         str, '</span><p>');
}

org.p3k.RssBox = function() {
   var ref;
   var ISOPATTERN = /([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9:]+).*$/;
   
   var data = org.p3k;
   data.defaults = {
      url: "http://blog.p3k.org/rss",
      maxItems: 7,
      width: 200,
      align: "",
      frameColor: "black",
      titleBarColor: "lightblue",
      titleBarTextColor: "black",
      boxFillColor: "white",
      textColor: "black",
      showXmlButton: "",
      compact: ""
   };
   
   var baseUri = data.baseUri;
    
   var getColor = function(str) {
      if (str.length === 6 && parseInt(str, 16) && str.indexOf("#") !== 0) {
         str = "#" + str;
      }
      return str.toLowerCase();
   }

   var value;
   for (var i in data.defaults) {
      value = data.param[i];
      if (!value || value.length === 0) {
         data.param[i] = data.defaults[i];
      } else if (i.indexOf("Color") > 0) {
         data.param[i] = getColor(value);
      }
   }

   // FIXME: Ugly work-around for many boxes using too small width 
   // values because the former version did not show the exact output.
   if (data.param.javascript && data.param.width < 200) {
      data.param.width = 200;
   }
   // Remove obsolete parameters from param and query
   delete data.param.javascript;
   data.query = data.query.replace("javascript=true", "");   

   var NAMESPACES = {
      dc: "http://purl.org/dc/elements/1.1/",
      rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   };

   var getUrl = function(url) {
      url = baseUri + "proxy.r?" + encodeURIComponent(url);
   
      var HttpRequest = function() {
         return (typeof XMLHttpRequest !== "undefined") ?
            new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP");
      }
   
      var request = new HttpRequest();
      request.open("GET", url, false);
      request.send(null);   
      if (!request.getResponseHeader("Date")) {
         var cached = request;
         var ifModifiedSince = cached.getResponseHeader("Last-Modified") || 
               new Date(0); // January 1, 1970
         request = new HttpRequest();
         request.open("GET", url, false);
         request.setRequestHeader("If-Modified-Since", ifModifiedSince);
         request.send("");
         if (request.status === 304) {
            request = cached; 
         }
      }
      return request;
   }
   
   var getDocument = function(source) {
      if (source) {
         if (document.implementation.createDocument) {
            var parser = new DOMParser();
            var doc = parser.parseFromString(source, "text/xml");
            return doc;
         } else if (window.ActiveXObject) {
            var doc = new ActiveXObject("Microsoft.XMLDOM");
            doc.async = "false";
            doc.loadXML(source);
            return doc;
         }
      }
      return null;
   }
   
   var getError = function() {
      var msg = null, root;
      if (!xml || data.message) {
         msg = data.message || "Unknown error.";
      } else if (xml.parseError && xml.parseError.errorCode) {
         msg = xml.parseError.reason; // IExplore
      } else if (root = xml.documentElement) {
         var errorNode;
         if (root.nodeName === "parsererror") {
            msg = xml.documentElement.textContent; // Mozilla
         } else if ((errorNode = root.childNodes[0]) && 
               errorNode.nodeName === "parsererror") {
            msg = errorNode.textContent; // Safari
         } else if (!/rss|rdf|scriptingNews/i.test(xml.documentElement.nodeName)) {
            msg = "Incompatible data format. Are you sure this is an RSS feed?";
         }
      }
      return msg;
   }
   
   var getNode = function(parent, name, namespace) {
      if (namespace) {
         if (typeof parent.getElementsByTagNameNS === "undefined") {
            var elements = parent.getElementsByTagName(namespace + ":" + name);
         } else {
            var elements = parent.getElementsByTagNameNS(NAMESPACES[namespace], name);
         }
      } else {
         var elements = parent.getElementsByTagName(name);
      }
      if (elements && elements[0]) {
         return elements[0];
      }
      return null;
   }
   
   var getText = function(node) {
      if (node && node.childNodes && node.childNodes.length > 0) {
         return node.childNodes[0].nodeValue || "";
      }
      return "";
   }
   
   var trim = function(str) {
      if (str) {
         return str.replace(/^\s*(\S*)\s*$/, "$1");
      }
      return "";
   }
   
   var padZero = function(n) {
      if (n < 10) {
         return "0" + n
      }
      return n;
   }

   var encodeXml = function(str) {
      if (!str) {
         return "";
      }
      return str.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/&/g, "&amp;");
   }
      
   var render = function(template, param) {
      if (!template || !param) {
         return template;
      }
      template = template.replace(/\$\{([^}]+)\}/g, function() {
         var key = arguments[1];
         return param[key] || "";
      });
      return template;
   }
   
   var renderDate = function(date) {
      if (date.constructor !== Date) {
         var str = String(date);
         var millis = Date.parse(str.replace(ISOPATTERN, "$1/$2/$3 $4"));
         if (millis) {
            date = new Date(millis);
         } else {
            date = new Date;
         }
      }

      return render(data.date, {
         year: date.getFullYear(),
         month: padZero(date.getMonth() + 1),
         day: padZero(date.getDate()),
         hours: padZero(date.getHours()),
         minutes: padZero(date.getMinutes()),
         seconds: padZero(date.getSeconds()),
         timeZone: "" // date.getTimezoneOffset()
      });
   }
   
   var renderButtons = function(enclosure, source) {
      var result = "";
      if (enclosure && enclosure.link) {
         result += render(data.image, {
            source: baseUri + "enclosure.gif",
            title: enclosure.type,
            link: encodeURI(enclosure.link),
            width: 13,
            height: 16
         });
      }
      if (source && source.link) {
         result += render(data.image, {
            source: baseUri + "source.gif",
            title: source.title,
            link: encodeURI(source.link),
            width: 15,
            height: 15
         });
      }
      return result;         
   }
   
   var param = data.param;
   var rss = data.rss = {items: []};
   var xml = getDocument(data.xml);

   rss.error = getError();
   if (rss.error !== null) {
      xml = getDocument(render(data.error, {
         link: baseUri + "?" + encodeXml(data.query),
         message: encodeXml(rss.error)
      }));
      param.compact = 0;
      param.showXmlButton = 1;
   }

   var root = xml.documentElement;
   var type = root.nodeName;

   if (type === "scriptingNews") {
      var channel = getNode(xml, "header");
      rss.format = "Scripting News";
      rss.version = getText(getNode(channel, "scriptingNewsVersion"));
      rss.title = getText(getNode(channel, "channelTitle"));
      rss.description = getText(getNode(channel, "channelDescription"));
      rss.link = getText(getNode(channel, "channelLink"));
      if (ref = getText(getNode(channel, "imageUrl"))) {
         ref = rss.image = {source: ref};
         ref.title = getText(getNode(channel, "imageTitle"));
         ref.link = getText(getNode(channel, "imageLink"));
         ref.width = getText(getNode(channel, "imageWidth"));
         ref.height = getText(getNode(channel, "imageHeight"));
         ref.description = getText(getNode(channel, "imageCaption"));
      }
   } else {
      var channel = getNode(xml, "channel");
      rss.format = "RSS";
      rss.version = (type === "rdf:RDF") ? "1.0" : 
            root.getAttribute("version");
      rss.title = getText(getNode(channel, "title"));
      rss.description = getText(getNode(channel, "description"));
      rss.link = getText(getNode(channel, "link"));
      var image = getNode(xml, "image");
      if (image) {
         ref = rss.image = {};
         ref.source = getText(getNode(image, "url"));
         ref.title = getText(getNode(image, "title"));
         ref.link = getText(getNode(image, "link"));
         ref.width = getText(getNode(image, "width"));
         ref.height = getText(getNode(image, "height"));
         ref.description = getText(getNode(image, "description"));
      }
   }
   
   if (type === "rdf:RDF") {
      rss.date = renderDate(getText(getNode(channel, "date", "dc")) || data.modified);
      rss.rights = getText(getNode(channel, "creator", "dc"));
      var input = getNode(root, "textinput");
      if (input && !getNode(input, "link")) {
         input = root.getElementsByTagName("textinput")[1];
      }
      if (input) {
         ref = rss.input = {};
         ref.link = getText(getNode(input, "link"));
         ref.description = getText(getNode(input, "description"));
         ref.name = getText(getNode(input, "name"));
         ref.title = getText(getNode(input, "title"));
      }
   } else {
      rss.date = renderDate(getText(getNode(channel, "lastBuildDate") || getText(getNode(channel, "pubDate"))) || data.modified);
      rss.rights = getText(getNode(channel, "copyright"));
   }
   
   var item, text, node;
   var items = xml.getElementsByTagName("item");

   for (var i=0; i<Math.min(items.length, param.maxItems); i+=1) {
      item = items[i];

      if (type === "scriptingNews") {
         ref = {title: ""};
         ref.description = getText(getNode(item, "text")).replace(/\n/g, " ");
         ref.link = getText(getNode(item, "link"));
         if (text = trim(getText(getNode(item, "linetext")).replace(/\n/g, " "))) {
            ref.description = ref.description.replace(new RegExp(text), 
                  '<a href="' + getText(getNode(item, "url")) + '">' + text + '</a>');
         }
      } else {
         ref = {
            title: getText(getNode(item, "title")),
            description: getText(getNode(item, "description")),
            link: getText(getNode(item, "link") || getNode(item, "guid"))
         };
     }

     if (node = getNode(item, "source")) {
        ref.source = {
           link: node.getAttribute("url"),
           title: getText(node)
        }
     }
     
     if (node = getNode(item, "enclosure")) {
        ref.enclosure = {
           link: node.getAttribute("url"),
           length: node.getAttribute("length"),
           type: node.getAttribute("type")
        }
     }
     
     if (node = getNode(item, "category")) {
        ref.category = {
           domain: node.getAttribute("domain") || "",
           content: getText(node)
        }
     }
     
     rss.items.push(ref);
   }
   
   var item, items = "";
   for (var i=0; i<rss.items.length; i+=1) {
      item = rss.items[i];
      items += render(data.item, {
         title: new function() {
            var title = (!param.compact ? "<strong>" : "");
            if (item.link) {
               title += render(data.link, {
                  link: encodeURI(item.link),
                  text: item.title,
                  'class': "rssBoxItemTitle"
               });
            } else {
               title += item.title;
            }
            !param.compact && (title += "</strong>");
            return new String(title); // FIXME: Funny, title alone will be rendered as [object]
         }(),
         'break': item.title && item.description ? "<br />" : "",
         description: (!param.compact || !item.title) && item.description,
         buttons: renderButtons(item.enclosure, item.source)
      });
   }
   
   var box = render(data.box, {
      title: rss.link ? render(data.link, {
         link: encodeURI(rss.link),
         text: rss.title,
         'class': "rssBoxTitle",
         style: "color: " + param.titleBarTextColor
      }) : rss.title,
      description: rss.description,
      items: items,

      xmlButton: param.showXmlButton && render(data.image, {
         link: param.url,
         source: baseUri + "rss.png",
         title: rss.format + " " + rss.version,
         width: 16,
         height: 16,
         align: "right",
         hspace: 3
      }),
      
      image: !param.compact && rss.image && render(data.image, {
         link: encodeURI(rss.image.link),
         source: rss.image.source,
         width: rss.image.width,
         height: rss.image.height,
         title: rss.image.title,
         align: "right",
         valign: "baseline",
         hspace: 5,
         vspace: 5
      }),
      
      input: !param.compact && rss.input && render(data.input, {
         link: encodeURI(rss.input.link),
         description: rss.input.description,
         name: rss.input.name,
         title: rss.input.title
      }),
      
      date: rss.date,
      width: param.width,
      frameColor: param.frameColor,
      fontFace: param.fontFace,
      align: param.align,
      titleBarColor: param.titleBarColor,
      titleBarTextColor: param.titleBarTextColor,
      boxFillColor: param.boxFillColor,
      textColor: param.textColor
   });

   if (!window.rssBoxSetup) {
      document.write(box);
   }
   
   return box;
};

org.p3k.RssBox();

