// jquery jfeed plugin: source: https://github.com/jfhovinne/jFeed/blob/master/build/dist/jquery.jfeed.pack.js commit: 1e5d740cbfac8d644642256e065bce48d74ef992
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('2.1b=a(b){b=2.N({w:x,H:x,G:1a,v:x,F:x},b);h(b.w){$.19({u:\'18\',w:b.w,H:b.H,G:b.G,17:(2.P.O)?"6":"4",v:a(4){f i=k E(4);h(2.S(b.v))b.v(i)},16:a(15,R,e){h(2.S(b.F))b.F(R,e)}})}};a E(4){h(4)3.Q(4)};E.s={u:\'\',m:\'\',d:\'\',c:\'\',j:\'\',Q:a(4){h(2.P.O){f D=k 14("13.12");D.11(4);4=D}h(2(\'8\',4).A==1){3.u=\'z\';f t=k B(4)}L h(2(\'i\',4).A==1){3.u=\'10\';f t=k C(4)}h(t)2.N(3,t)}};a p(){};p.s={d:\'\',c:\'\',j:\'\',l:\'\',o:\'\'};a C(4){3.r(4)};C.s={r:a(4){f 8=2(\'i\',4).9(0);3.m=\'1.0\';3.d=2(8).5(\'d:g\').6();3.c=2(8).5(\'c:g\').q(\'M\');3.j=2(8).5(\'Z:g\').6();3.y=2(8).q(\'4:Y\');3.l=2(8).5(\'l:g\').6();3.n=k K();f i=3;2(\'X\',4).J(a(){f 7=k p();7.d=2(3).5(\'d\').9(0).6();7.c=2(3).5(\'c\').9(0).q(\'M\');7.j=2(3).5(\'W\').9(0).6();7.l=2(3).5(\'l\').9(0).6();7.o=2(3).5(\'o\').9(0).6();i.n.I(7)})}};a B(4){3.r(4)};B.s={r:a(4){h(2(\'z\',4).A==0)3.m=\'1.0\';L 3.m=2(\'z\',4).9(0).q(\'m\');f 8=2(\'8\',4).9(0);3.d=2(8).5(\'d:g\').6();3.c=2(8).5(\'c:g\').6();3.j=2(8).5(\'j:g\').6();3.y=2(8).5(\'y:g\').6();3.l=2(8).5(\'V:g\').6();3.n=k K();f i=3;2(\'7\',4).J(a(){f 7=k p();7.d=2(3).5(\'d\').9(0).6();7.c=2(3).5(\'c\').9(0).6();7.j=2(3).5(\'j\').9(0).6();7.l=2(3).5(\'U\').9(0).6();7.o=2(3).5(\'T\').9(0).6();i.n.I(7)})}};',62,74,'||jQuery|this|xml|find|text|item|channel|eq|function|options|link|title||var|first|if|feed|description|new|updated|version|items|id|JFeedItem|attr|_parse|prototype|feedClass|type|success|url|null|language|rss|length|JRss|JAtom|xmlDoc|JFeed|failure|cache|data|push|each|Array|else|href|extend|msie|browser|parse|msg|isFunction|guid|pubDate|lastBuildDate|content|entry|lang|subtitle|atom|loadXML|XMLDOM|Microsoft|ActiveXObject|xhr|error|dataType|GET|ajax|true|getFeed'.split('|')));

/*
 * CityDirectory / SiteBuilder Web Site Framework
 * Copyright 2003-2006, Robyn N. Blair
 */
function zeroFill(number, width) {
  width -= number.toString().length;
  if (width > 0) {
    return new Array( width + (/\./.test( number ) ? 2 : 1) ).join( '0' ) + number;
  }
  return number;
}

var dateFormatter = {
  'MM/dd/yyyy hh:mm': function(date) {
    var mo = zeroFill(date.getMonth(), 2),
        dd = zeroFill(date.getDate(), 2),
        yyyy = date.getFullYear(),
        hh = zeroFill(date.getHours(), 2),
        min = zeroFill(date.getMinutes(), 2),
        gmtHours = -date.getTimezoneOffset()/60.0;
    gmtHours = gmtHours > 0 ? '+' + gmtHours : '' + gmtHours;
    return mo + '/' + dd + '/' + yyyy + ' ' + hh + ':' + min + ' GMT';
  }
};

// defintes a rss plugin that is a wrapper around the jquery jfeed plugin
(function($){
  var hasInitCss = false;
  $.fn.rss = function(url, options) {
    var container = this,
        url = "/?ajaxurl=" + encodeURIComponent(url),
        _dateFormatter = (options && options.dateFormatter) || 'MM/dd/yyyy hh:mm',
        formatDate;

    if (typeof _dateFormatter === 'string') {
      _dateFormatter = dateFormatter[_dateFormatter];
    }

    formatDate = function(s) { return s; };

    options = $.extend(options || {}, {
      url: url,
      success: function(feed) {
        // if default CSS has not been created yet, do so
        if (!hasInitCss) {
          $(document.body).append(
            '<style type="text/css">' +
            '.rssItem {margin-bottom:8px;clear:both;}' +
            '.rssItemUpdated {}' +
            '.rssItemTitle {}' +
            '.rssItemLink:link, .rssItemLink:active, .rssItemLink:visited {}' +
            '.rssItemDescription {clear:both;}' +
            '</style>'
          );
          hasInitCss = true;
        }

        // keep track of the # of items, and set the default limit to 1000
        var itemCount = 0,
            limit = (options && options.limit || 1000);

        // empty the contents of the container that the feed will go in
        container.empty();

        var totalItemCount = Math.min(limit, feed.items.length);
        $.each(feed.items, function(index, item) {
          if (itemCount >= totalItemCount) {
            return false;
          } 

          var updated = formatDate(item.updated);
          if (itemCount === 0) {
            $(container).append(
              '<div class="rssFeedTitle">' + options.title + '</div>' +
              '<div class="rssFeedLastUpdated">' + updated + '</div>'
            );
          }
          $(container).append(
            '<div class="rssItem"><div class="rssItemTitle">' + item.title + '</div>' +
            '<div class="rssItemUpdated">' + updated + '</div>' +
            '<div class="rssItemDescription">' + item.description + '</div>' +
            '<div class="rssItemReadMore">' +
            '<a href="' + item.link + '" class="rssItemLink" target="_blank">...READ MORE</a></div>' +
            '<div style="clear:both"></div></div>'
          );

          if (itemCount < totalItemCount - 1) {
            $(container).append('<div class="rssItemSeparator"></div>');
          }

          ++itemCount;
        });
      }
    });
    url = "/?ajaxurl=" + url;
    $.getFeed(options);
  };
})(jQuery);

