var org = {p3k: ({url:"http://www.fda.gov/oc/po/firmrecalls/rssRecalls.xml", xml:"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n\n\t\n\n<rss version=\"2.0\">\n<channel>\n\t<title>Food and Drug Administration--Recalls/Safety Alerts</title>\n\t<description>Recall Information from FDA</description>\n\t<link>http://www.fda.gov/AboutFDA/ContactFDA/StayInformed/RSSFeeds/Recalls/rss.xml</link>\n\t<language>en-us</language>\n\t<lastBuildDate>Tue, 09 Feb 2010 10:01:00 -0500</lastBuildDate>\n \n\t<webMaster>tina.gilliam@fda.hhs.gov</webMaster>\n\t<item>\n\t <title>BD Announces Worldwide Voluntary Recall ofBD Q-Syte\u2122 Luer Access Devices and BD Nexiva\u2122 Closed IV Catheter Systems</title>\n\t <description>BD (Becton, Dickinson and Company) (NYSE:BDX) has voluntarily executed a product recall of certain lots ofBD Q-Syte\u2122 Luer Access Devices and BD Nexiva\u2122 Closed IV Catheter Systems. Use of the affected devices may cause an air embolism or leakage of blood and/or therapy, which may result in serious injury or death.</description>\n\t <pubDate>Tue, 09 Feb 2010 10:01:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM200121</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM200121</guid>\n\t</item>\n\t<item>\n\t <title>Cousins Products, Llc, Issues An Allergy Alert On Undeclared Egg, Soy, And Wheat In Spinach Vinaigrette</title>\n\t <description>Cousins Products, LLC, of Covington, LA is voluntarily recalling the following Spinach Vinaigrette in 16 oz. jars</description>\n\t <pubDate>Fri, 05 Feb 2010 08:56:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM199957</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM199957</guid>\n\t</item>\n\t<item>\n\t <title>Haifa Smoked Fish Inc. Issues An Allert On Uneviscerated Whole Schmaltz Herring</title>\n\t <description>Haifa Smoked Fish, located in Queens, New York, is recalling Haifa brand vacuum packaged Whole Schmaltz Herring with the lot number 20, because the product was found to be uneviscerated.</description>\n\t <pubDate>Thu, 04 Feb 2010 14:45:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM199917</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM199917</guid>\n\t</item>\n\t<item>\n\t <title>Pierino Frozen Foods Inc. Issues an Allergy Alert on Undeclared Eggs in Its Jumbo Shells with Cheese</title>\n\t <description>Pierino Frozen Foods Inc. of Lincoln Park, Michigan is recalling its 24 oz. packages of Pierino Frozen Foods\u2019 \u201cJumbo Shells with Cheese\u201d because they contain undeclared eggs.  People who have an allergy or severe sensitivity to eggs run the risk of serious or life-threatening allergic reaction if they consume these products.</description>\n\t <pubDate>Wed, 03 Feb 2010 17:15:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM199796</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM199796</guid>\n\t</item>\n\t<item>\n\t <title>Global Commodities Inc. Issues Allergy Alert On Undeclared Sulfites In Aahu Barah Brand Dry Apricot</title>\n\t <description>Global Commodities Inc. of Hicksville, NY is recalling its 0.50 lbs. packages of Aahu Barah brand Dry Apricot food treats because they contain undeclared Sulfites.  People who have allergies to Sulfites run the risk of serious or life-threatening allergic reaction if they consume this product.</description>\n\t <pubDate>Tue, 02 Feb 2010 16:39:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM199682</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM199682</guid>\n\t</item>\n\t<item>\n\t <title>Hettich Centrifuges with 2050 and 2076 Plastic Rotors: Recall</title>\n\t <description>Plastic centrifuge rotor may crack, break apart and be forcefully ejected.</description>\n\t <pubDate>Thu, 28 Jan 2010 21:32:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/MedWatch/SafetyInformation/SafetyAlertsforHumanMedicalProducts/UCM199202</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/MedWatch/SafetyInformation/SafetyAlertsforHumanMedicalProducts/UCM199202</guid>\n\t</item>\n\t<item>\n\t <title>Infusion Set Needles [Manufactured by Nipro for Exelint]: Recall</title>\n\t <description>Class I recall due to &quot;coring&quot; or dislodging of silicone cores or slivers from the ports into which they are inserted.</description>\n\t <pubDate>Tue, 26 Jan 2010 13:07:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/MedWatch/SafetyInformation/SafetyAlertsforHumanMedicalProducts/UCM198728</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/MedWatch/SafetyInformation/SafetyAlertsforHumanMedicalProducts/UCM198728</guid>\n\t</item>\n\t<item>\n\t <title>FDA Announces Class I Recall of Certain Infusion Set Needles</title>\n\t <description>The U.S. Food and Drug Administration today announced a Class I recall of Exel/Exelint Huber needles, Exel/Exelint Huber Infusion Sets and Exel/Exelint \u201cSecuretouch+\u201d Safety Huber Infusion Sets, manufactured by Nipro Medical Corporation for Exelint International Corporation.</description>\n\t <pubDate>Tue, 26 Jan 2010 11:19:00 -0500</pubDate>\n\t <link>http://www.fda.gov/NewsEvents/Newsroom/PressAnnouncements/UCM198676</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/NewsEvents/Newsroom/PressAnnouncements/UCM198676</guid>\n\t</item>\n\t<item>\n\t <title>Hettich Centrifuges Issues a North America and Canada Recall of Plastic Hematocrit Rotors</title>\n\t <description>Hettich Centrifuges, Beverly, MA, is initiating a North America and Canada recall of\n2050 and 2076 plastic hematocrit rotors that are used in combination with the Mikro 12-\n24, Mikro 20, Haematokrit 20 and Haematokrit 24 bench top plastic centrifuges. These\nplastic rotors have the potential to break apart resulting in pieces of the rotor to be\nforcefully ejected through the plastic centrifuge housing.</description>\n\t <pubDate>Fri, 22 Jan 2010 18:43:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM198490</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM198490</guid>\n\t</item>\n\t<item>\n\t <title>Nipro Medical Corporation Issues a Voluntary Recall of All GlucoPro Insulin Syringes</title>\n\t <description>Nipro Medical Corporation, Miami FL, is initiating a nationwide recall of all GlucoPro Insulin Syringes (This does not include the GlucoPro syringe specific for use with the Amigo Insulin pump). These syringes may have needles that detach from the syringe.</description>\n\t <pubDate>Fri, 22 Jan 2010 14:05:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM198429</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM198429</guid>\n\t</item>\n\t<item>\n\t <title>The Wisconsin Cheeseman\xae Recalls Cheese Logs/Cheese Balls</title>\n\t <description>The Wisconsin Cheeseman\xae announced today that it is recalling cheese log/cheese ball products in conjunction with the voluntary recall initiated by Parkers Farm, Inc. on January 15, 2010.  Parkers Farm, Inc., located in Coon Rapids, Minnesota, believes some of its food items have the potential to be contaminated with Listeria monocytogenes bacteria</description>\n\t <pubDate>Thu, 21 Jan 2010 15:16:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM198319</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM198319</guid>\n\t</item>\n\t<item>\n\t <title>Hines Nut Company Announces Recall of Pine Nuts Because of Possible Health Risk</title>\n\t <description>Hines Nut Company has initiated a recall of 270 packages of Pine Nuts, packaged under the brand name Harris Teeter Farmers Market. The Pine Nuts were purchased from Red River Foods in Camarillo, CA, and have the potential to be contaminated with Salmonella.</description>\n\t <pubDate>Fri, 15 Jan 2010 16:30:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM197825</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM197825</guid>\n\t</item>\n\t<item>\n\t <title>MuscleMaster.com Conducts a Voluntary Nationwide Recall of Certain Body Building Products</title>\n\t <description>MuscleMaster.com, Inc. (\u201cMuscleMaster.com\u201d) announced today that it is conducting a voluntary nationwide recall of all lots and expiration dates of the seventeen below listed dietary supplements sold between June 1, 2009 and November 17, 2009 (hereinafter &quot;Recalled Products&quot;).  FDA informed MuscleMaster.com that it believes that the Recalled Products contain ingredients that are steroids. Specifically, FDA advised MuscleMaster.com of its concern that the Recalled Products may contain the following ingredients that are currently classified, or the FDA believes should be classified, as steroids: &quot;Superdrol,&quot; &quot;Madol,&quot; &quot;Tren,&quot; &quot;Androstenedione,&quot; and/or &quot;Turinabol.&quot;</description>\n\t <pubDate>Fri, 15 Jan 2010 16:15:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM197824</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM197824</guid>\n\t</item>\n\t<item>\n\t <title>Parkers Farm, Inc. Expands Recall to Include All of Its Products, Regardless of Code Dates, Because of Possible Health Risk</title>\n\t <description>PARKERS FARM, INC. OF COON RAPIDS, MINNESOTA TODAY EXPANDED THE PREVIOUSLY ANNOUNCED RECALL OF PRODUCTS TO INCLUDE ALL DATE CODES BECAUSE THEY HAVE THE POTENTIAL TO BE CONTAMINATED WITH LISTERIA MONOCYTOGENES, AN ORGANISM WHICH CAN CAUSE SERIOUS AND SOMETIMES FATAL INFECTION IN YOUNG CHILDREN, FRAIL OR ELDERLY PEOPLE, AND OTHERS WITH WEAKENED IMMUNE SYSTEMS.  ALTHOUGH HEALTHY INDIVIDUALS MAY SUFFER ONLY SHORT-TERM SYMPOTMS SUCH AS HIGH FEVER, SEVERE HEADACHE, STIFFNESS, NAUSEA, ABDOMINAL PAIN AND DIARRHEA, LISTERIA INFECTION CAN CAUSE MISCARRIAGES AND STILLBIRTHS AMONG PREGNANT WOMEN.</description>\n\t <pubDate>Fri, 15 Jan 2010 15:59:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM197823</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM197823</guid>\n\t</item>\n\t<item>\n\t <title>PEO Chapter FO Recalls Roasted Hazelnuts Because of Possible Health Risk</title>\n\t <description>PEO Chapter FO of Ashland, Oregon is recalling 75 - 1 lb packages of roasted hazelnuts, because they have the potential to be contaminated with Salmonella.  Salmonella is an organism which can cause serious and sometimes fatal infections in young children, frail or elderly people, and others with weakened immune systems. Healthy persons infected with Salmonella often experience fever, diarrhea (which may be bloody), nausea, vomiting and abdominal pain.</description>\n\t <pubDate>Fri, 15 Jan 2010 15:35:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM197816</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM197816</guid>\n\t</item>\n\t<item>\n\t <title>McNeil Consumer Healthcare Announces Voluntary Recall of Certain Over-The-Counter (OTC) Products in the Americas, UAE, and Fiji</title>\n\t <description>In consultation with the U.S. Food and Drug Administration (FDA), McNeil Consumer Healthcare, Division of McNEIL-PPC, Inc., is voluntarily recalling certain lots of OTC products in the Americas, the United Arab Emirates (UAE), and Fiji (FULL RECALLED PRODUCT LIST BELOW).  The company is initiating this recall following an investigation of consumer reports of an unusual moldy, musty, or mildew-like odor that, in a small number of cases, was associated with temporary and non-serious gastrointestinal events.  These include nausea, stomach pain, vomiting, or diarrhea.</description>\n\t <pubDate>Fri, 15 Jan 2010 12:58:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM197746</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM197746</guid>\n\t</item>\n\t<item>\n\t <title>FDA Health Alert for Merrick Beef Filet Squares Dog Treats Packaged and Distributed by Merrick Pet Care</title>\n\t <description>The U. S. Food and Drug Administration is warning consumers not to use Merrick Beef Filet Squares for dogs distributed by Merrick Pet Care with a package date of \u201cBest By 111911\u201d because the product may be contaminated with Salmonella.</description>\n\t <pubDate>Thu, 14 Jan 2010 17:35:00 -0500</pubDate>\n\t <link>http://www.fda.gov/NewsEvents/Newsroom/PressAnnouncements/UCM197700</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/NewsEvents/Newsroom/PressAnnouncements/UCM197700</guid>\n\t</item>\n\t<item>\n\t <title>HAPPYTOT Stage 4 and HAPPYBABY Stage 1 &amp; Stage 2 Pouch Meals - Recall</title>\n\t <description>Selected varieties recalled due to packaging defect that could cause possible bacterial contamination.</description>\n\t <pubDate>Wed, 13 Jan 2010 19:07:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/MedWatch/SafetyInformation/SafetyAlertsforHumanMedicalProducts/UCM197570</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/MedWatch/SafetyInformation/SafetyAlertsforHumanMedicalProducts/UCM197570</guid>\n\t</item>\n\t<item>\n\t <title>Nurture, Inc. Issues Voluntary Recall on select HAPPYTOT Stage 4 and HAPPYBABY Stage 1 &amp; Stage 2 Pouch Meals Due to a Packaging Defect that could cause a Possible Bacterial Contamination</title>\n\t <description>Nurture, Inc., is voluntarily recalling selected varieties and date codes of HAPPYTOT Stage 4 and HAPPYBABY Stage 1 and Stage 2 pouch meals with date codes expiring between November 2010 and January 2011. These products are being recalled due to a packaging defect that potentially could cause the pouches to swell or leak.  Swollen or leaking pouches could indicate that the products may contain bacteria that could potentially cause illness.</description>\n\t <pubDate>Wed, 13 Jan 2010 15:37:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM197522</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM197522</guid>\n\t</item>\n\t<item>\n\t <title>Heluva Good Recalls Cold Pack Cheese Products Because of Possible Health Risk</title>\n\t <description>HP Hood is recalling select Heluva Good branded 8 oz. plastic cup containers of  Cold Pack Cheese Food because they may contain Listeria monocytogenes, an organism which can cause serious and sometimes fatal infections in young children, frail or elderly people, and others with weakened immune systems. Although healthy individuals may suffer only short term symptoms such as high fever, severe headache, stiffness and nausea, abdominal pain and diarrhea, listeria infection can cause miscarriages and stillbirths among pregnant women.</description>\n\t <pubDate>Wed, 13 Jan 2010 11:04:00 -0500</pubDate>\n\t <link>http://www.fda.gov/Safety/Recalls/UCM197441</link>\n\t <guid isPermaLink=\"true\">http://www.fda.gov/Safety/Recalls/UCM197441</guid>\n\t</item>\n</channel>\n</rss>\n<!-- the HEAD element is required by SiteStudio\n\t<head><script type=\"text/javascript\">\n   var _U = \"undefined\";\n   var g_HttpRelativeWebRoot = \"/ucm/\";\n   var SSContributor = false;\n   var SSForceContributor = false;\n   var SSHideContributorUI = false;\n   var ssUrlPrefix = \"/\";\n   var ssUrlType = \"1\";\n   \n   var g_navNode_Path = new Array();\n       g_navNode_Path[0] = '1201';\n       g_navNode_Path[1] = '1839';\n       g_navNode_Path[2] = '1842';\n       g_navNode_Path[3] = '2145';\n       g_navNode_Path[4] = '2152';\n       g_navNode_Path[5] = '4037';\n   var g_ssSourceNodeId = \"4037\";\n   var g_ssSourceSiteId = \"FDAgov\";\n   var g_strLanguageId = \"en\";\n</script>\n<script id=\"SSNavigationFunctionsScript\" type=\"text/javascript\" src=\"/ucm/websites/FDAgov/sitenavigationfunctions.js\"></script>\n<script id=\"SSNavigationScript\" type=\"text/javascript\" src=\"/ucm/websites/FDAgov/sitenavigation.js\"></script>\n\n\t<script type=\"text/javascript\" src=\"/ucm/resources/wcm/sitestudio/wcm.toggle.js\"></script>\n\t<script type=\"text/javascript\" src=\"/ucm/resources/sitestudio/ssajax/ssajax.js\"></script>\n\n\t</head>\n--> \n", message:undefined, modified:(new Date(1265730438597)), baseUri:"http://p3k.org/rss/", query:"frameColor=#669966&textColor=black&_=1241127844180&titleBarColor=#b28000&compact=true&fontFace=&align=&showXmlButton=true&maxItems=1&boxFillColor=white&titleBarTextColor=black&width=175&url=http://www.fda.gov/oc/po/firmrecalls/rssRecalls.xml&", param:{textColor:"black", width:"175", align:"", fontFace:"", url:"http://www.fda.gov/oc/po/firmrecalls/rssRecalls.xml", compact:"true", frameColor:"#669966", showXmlButton:"true", boxFillColor:"white", _:"1241127844180", titleBarColor:"#b28000", maxItems:"1", 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();

