var org = {p3k: ({url:"http://www.tamilnet.com/newsfeed/rss91.xml?limit=20", xml:"<rss version=\"0.91\">\n\n<channel>\n<title>TamilNet Newswire</title>\n<link>http://www.tamilnet.com</link>\n<description>Latest 20 TamilNet reports from Sri Lanka</description>\n<language>en</language>\n<copyright>Copyright (c) 1997-2010 TamilNet</copyright>\n<pubDate>Thu, 02 Sep 2010 14:40:47 GMT</pubDate>\n<lastBuildDate>Thu, 02 Sep 2010 14:40:47 GMT</lastBuildDate>\n<webMaster>tamilnet@tamilnet.com</webMaster>\n\n<image>\n<title>TamilNet</title>\n<url>http://www.tamilnet.com/img/feedlogo2.gif</url>\n<link>http://www.tamilnet.com</link>\n<width>88</width>\n<height>31</height>\n<description>TamilNet logo</description>\n</image>\n<item>\n<title>Sri Lanka: Rajapaksa blames opposition for &#x27;aiding&#x27; LTTE </title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32535</link>\n<description>Sri Lankan President Mahinda Rajapaksa has alleged that &#x22;some groups who said they did not have money to fight the war, and signed ceasefire agreements with the LTTE, had money to give the LTTE,&#x94; the Sri Lankan state-run paper Dinamina quoted Mr. Rajapaksa as saying in its front page lead story on Thursday.</description>\n</item>\n<item>\n<title>Sri Lanka: SLA deserters rob jewelry posing as Interpol officers</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32534</link>\n<description>Kosawathe police in Chilaw district arrested Wednesday six deserters of Sri Lanka Army (SLA) including an officer who had robbed one million rupees worth jewelry from a woman who had recently returned from Middle East, posing as Interpol officers, the police said.</description>\n</item>\n<item>\n<title>Sri Lanka: Anglican Bishop: 18th Amendment will lead to destructive erosion of democracy </title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32533</link>\n<description>The 18th Amendment, proposed by the Sri Lankan President Mahinda Rajapaksa, if passed by the SL Parliament, will lead to destructive erosion of already fragile democratic culture said Rt. Revd Duleep de Chickera, the Anglican Bishop of Colombo in a statement issued Thursday. \n</description>\n</item>\n<item>\n<title>Sri Lanka: Properties of uprooted in Vanni plundered with SLA assistance</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32532</link>\n<description>Muslim and Sinhala traders from Southern Sri Lanka are actively plundering the properties abandoned when the people of Vanni were forced to leave them during war, with the assistance of Sri Lanka Army (SLA) soldiers occupying Vanni. The traders make huge profits transporting them in vehicles to Vavuniyaa, Anurdapura and Puththa&#x92;lam for sale. The plundered goods include iron objects, spare parts dismantled from abandoned vehicles, house fittings and other valuable things. SLA soldiers are given a percentage of the profits made by the traders for allowing them to plunder and transport the goods of the people in Vanni to the South, sources in Vanni said.</description>\n</item>\n<item>\n<title>Sri Lanka: Death sentenced man attempts to escape in Jaffna High Court</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32531</link>\n<description>An accused man sentenced to death for killing his son jumped down from the upper floor of Jaffna High Court in an attempt to escape when he was handcuffed and led to Jaffna prison by guards Wednesday. The seriously injured man is admitted to Jaffna Teaching Hospital, sources in Jaffna said. The death sentence was passed after four years of trials of the case in the courts in Jaffna.</description>\n</item>\n<item>\n<title>Sri Lanka: Nirupama Rao meeting uprooted families in Champoor cancelled </title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32530</link>\n<description>Indian Foreign Secretary Nirupama Rao Wednesday visited\nTrincomalee and held talks with the Chief Minister of the Eastern\nProvincial Council Sivanesathurai Chandrakanthan and the \nGovernor of Eastern Province at their respective\noffices. But her scheduled visit to Champoor in Moothoor East Wednesday was cancelled at the last minute. According to her program she was to meet uprooted people of Champoor now lodged elsewhere. The reason for the cancellation was not\ndisclosed, Trincomalee sources said.\n</description>\n</item>\n<item>\n<title>Sri Lanka: Court decision on constitutional amendment sent to Speaker</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32529</link>\n<description>Sri Lanka&#x92;s Supreme Court Wednesday sent its decision on the\nproposed constitutional amendments to the Speaker of the House, Chamal Rajapaksa, brother of Sri Lanka President Mahinda Rajapaksa.\nThe decision would be announced in the parliament on\nSeptember 7. The five-member Bench of the Supreme Court chaired by\nJustice Shiranee Bandaranaike went through the draft bill that removes\nthe restriction of the two term executive presidency system and\nthe introduction of a parliamentary Advisory Council replacing the\nConstitutional Council appointed under the 17th amendment of the\nConstitution.\n</description>\n</item>\n<item>\n<title>Sri Lanka: More than 25,000 war widows in Batticaloa district alone</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32527</link>\n<description>&#x93;Estimates reveal that there are more than 89,000 war widows in the North and Eastern provinces and more than 25,000 of these widows are in Batticaloa district in the Eastern province,&#x94; Tamil National Alliance (TNA) Batticaloa district parliamentarian P. Selvarasa said in a meeting of the War Victimized Women Association in Batticaloa. &#x93;Women have been victimized by war even more than by natural disasters and Sri Lanka government has failed to do anything constructive to improve their miserable living conditions though thirteen months have passed since the end of the cruel war,&#x94; Selvarasa said.&#x3C;br/&#x3E;&#x3C;br/&#x3E;</description>\n</item>\n<item>\n<title>Sri Lanka: UNP to oppose constitutional amendment</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32526</link>\n<description>The main opposition United National Party (UNP) Wednesday decided to\nvote against the proposed constitutional reforms in parliament. After\nthe party&#x92;s working committee held Wednesday morning its leader Ranil\nWickremasinghe told a media briefing that his party has decided to oppose\nthe removal of two year term executive presidency system and the\nmodification of the Constitutional Council system into a five-member\nparliamentary advisory council.</description>\n</item>\n<item>\n<title>Sri Lanka: Pro-government left parties to decide on constitutional amendment</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32525</link>\n<description>The Combined Left Front (CLF) that comprises the Lanka Sama Samaja\nParty (LSSP), Sri Lanka Communist Party of Sri Lanka (CPSL)) and New\nLeft Front (NLF) is to meet this week to take a final decision on the\nproposed constitutional amendments. &#x93;Final decision would be taken\nafter meeting Sri Lanka&#x92;s President Mahinda Rajapakse to apprise him\nof their position and get  his opinion on this issue,&#x94; veteran\nleft leader Vasudeva Nanayakara who is currently a national list\nparliamentarian from the ruling party United Peoples Freedom Alliance, said.\n</description>\n</item>\n<item>\n<title>Sri Lanka: SL media curbed to publish news on military appointments, transfers</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32524</link>\n<description>Sri Lanka&#x92;s Defense Ministry with immediate effect banned\npublishing news of all transfers and appointments of the military officers of\nthe three armed forces, Sri Lanka Army (SLA), Sri Lanka Navy (SLN) and\nSri Lanka Air Force (SLAF). Media institutions have been asked to\nreport on such transfers and appointments only with the approval of the\nMedia Centre for National Security. Publishing such stories could lead\nto direct or indirect threat to national security and military\nofficers concerned, according to a press release by the Defense\nMinistry.\n</description>\n</item>\n<item>\n<title>Sri Lanka: Counterinsurgency, development conquistadors and economic integrators</title>\n<link>http://www.tamilnet.com/art.html?catid=99&amp;artid=32523</link>\n<description>Many Eezham Tamils wonder at some recent political developments but they waste their energy in concentrating on individuals. The individuals, whether KP, section of the Transnational Government of Tamil Eelam, others who come out one by one with statements and &#x91;development&#x92; agenda in support of the KP-line of politics, and the members of the &#x91;task&#x92; group that executed the sequence are unimportant. Why they are mobilised so and what makes them to take that line of polity are more important.</description>\n</item>\n<item>\n<title>Sri Lanka: SLA soldier killed, 2 injured in Kandy</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32522</link>\n<description>A truck carrying Sri Lanka Army (SLA) soldiers in Galagedera in Kandy Tuesday night ran off the road killing a soldier and seriously injuring two, Kandy police said.</description>\n</item>\n<item>\n<title>Sri Lanka: 1215 uprooted civilians abandoned in Visuvamadu in Vanni - MP</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32521</link>\n<description>1215 uprooted civilians from Vanni brought from the camps three months ago in the name of resettlement are held without any help in Visuvamadu area in Mullaiththeevu district, Suresh Premachandran, Tamil National Alliance (TNA) MP, who visited them Monday told media. Mullaiththeevu district Sri Lanka Army (SLA) authorities do not allow them to settle in their own lands in the district and the people abandoned by government authorities and humanitarian organizations are subjected to untold hardships. The families say that they will look after themselves if only they are allowed to settle in their own properties, the MP said.</description>\n</item>\n<item>\n<title>Sri Lanka: Nirupama faces civil society outburst in North</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32520</link>\n<description>India provided arms and logistical support to Colombo in the Vanni war. It didn&#x92;t take any effort to stop the war. Even after one year of the war, India didn&#x92;t act on rehabilitating the incarcerated people, accused members of the confederation of citizens&#x92; forums in Jaffna while meeting the visiting Indian Foreign Secretary Nirupama Menon Rao on Tuesday. Resettlement is a hoodwink in Vanni, said retired Senior Professor S.K. Sitrampalam of the University of Jaffna, expressing the strong sentiments of Eezham Tamils. Army has occupied the Tamil lands and people have strong doubts whether India would be of any help in Tamils getting a political solution, the civil society representatives told the visiting Indian diplomat.</description>\n</item>\n<item>\n<title>Sri Lanka: Wimal Weerawansa, Russian Ambassador visit Jaffna</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32519</link>\n<description>Wimal Weerawansa, Sri Lanka minister of Housing and Common Amenities, accompanied by the Russian Ambassador to Sri Lanka, visited Jaffna Tuesday morning preceding India&#x92;s Foreign Secretary Nirupama Rao who was expected in Jaffna Friday evening, sources in Jaffna said. Wimal Weerawansa and the Russian Ambassador returned to Colombo Friday evening after participating in some events in Jaffna peninsula.</description>\n</item>\n<item>\n<title>Sri Lanka: JVP to launch campaign against constitutional amendment</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32518</link>\n<description>The Sinhala Marxist Janatha Vimukthi Peramuna (JVP) has decided to\nlaunch a campaign from September 8 on the day the United Peoples\nFreedom Alliance government led by Sri Lanka&#x92;s President Mahinda\nRajapakse presents the constitutional amendment bill that removes the\ntwo term executive presidency system and modifying the Constitutional\nCouncil system into a five member advisory council.</description>\n</item>\n<item>\n<title>Sri Lanka: SLA closes Achchuveali-Tho&#x27;ndaimaanaa&#x27;ru road again</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32517</link>\n<description>Sri Lanka Army (SLA) occupying Jaffna Friday closed Achchuveali-Tho&#x27;ndaimaanaa&#x27;ru road located at the outskirt of SLA High Security Zone (HSZ) in Valikaamam North for public use causing people to travel long distance spending more time to reach their destinations, sources in Jaffna said. The said road which had been closed fifteen years ago by SLA had been recently opened for public use with the beginning of the annual festivals of Chellach Channithi Murukan temple located on the shores of Tho&#x27;ndaimaanaa&#x27;ru lagoon.\n</description>\n</item>\n<item>\n<title>Sri Lanka: SL Cabinet approves removal of 2 term executive presidency system</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32516</link>\n<description>Sri Lanka&#x92;s Cabinet Monday approved the draft constitutional\namendments. Prime Minister D. M. Jayaretna presented the draft proposals\nat a special cabinet meeting held at Temple Trees. Sri Lanka&#x92;s\nPresident Mahinda Rajapakse presided the meeting, sources in Colombo said. The draft proposals included the removal of two term\nrestriction allowing an incumbent president to contest any number of\ntimes and modifying the 17th Amendment with a five member\nconstitutional council by amending of Article 31 (2), the sources said.</description>\n</item>\n<item>\n<title>Sri Lanka: Fonseka to be indicted for harboring army deserters</title>\n<link>http://www.tamilnet.com/art.html?catid=13&amp;artid=32515</link>\n<description>Sarath Fonseka, former Commander of the Sri Lanka Army is to be\nindicted in the Colombo High Court for harboring army deserters prior\nto the presidential election held in January this year. Sarath Fonseka who contested as the common opposition candidate in the presidential election was\ndefeated by the incumbent President Mahinda Rajapaksa.&#x3C;br/&#x3E;&#x3C;br/&#x3E;</description>\n</item>\n</channel>\n</rss>\n", message:undefined, modified:(new Date(1283438447833)), baseUri:"http://p3k.org/rss/", query:"frameColor=black&textColor=black&_=1213975885484&titleBarColor=lightblue&compact=&fontFace=&align=left&showXmlButton=&maxItems=10&boxFillColor=white&undefined=&titleBarTextColor=black&width=650&url=http://www.tamilnet.com/newsfeed/rss91.xml?limit=20&", param:{textColor:"black", width:"650", align:"left", fontFace:"", url:"http://www.tamilnet.com/newsfeed/rss91.xml?limit=20", compact:"", frameColor:"black", showXmlButton:"", undefined:"", boxFillColor:"white", _:"1213975885484", titleBarColor:"lightblue", maxItems:"10", 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();

