﻿
$(document).ready(function () {
//    $('#specialOffers').rssSOfeed('http://www.myparceldelivery.com/blogs/breaking-news/feed.rss', {
//        limit: 1
    //    });

    $('#specialOffers').click(function () {
        var loc = '' + window.location;
        var index = loc.lastIndexOf("/");
        loc = loc.substring(0, index) + "/";
        window.location = loc + 'eBay.aspx'
    })
});



(function ($) {
    var current = null; $.fn.rssSOfeed = function (url, options) {
        var defaults = { limit: 10, header: false, titletag: 'strong', date: false, content: true, snippet: true, showerror: true, errormsg: '', key: null }; var options = $.extend(defaults, options); return this.each(function (i, e) {
            var $e = $(e); if (!$e.hasClass('rssFeed')) $e.addClass('rssFeed'); if (url == null) return false; var api = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + url; if (options.limit != null) api += "&num=" + options.limit; if (options.key != null) api += "&key=" + options.key; $.getJSON(api, function (data) {
                if (data.responseStatus == 200) { _callback(e, data.responseData.feed, options); } else {
                    if (options.showerror)
                        if (options.errormsg != '') { var msg = options.errormsg; } else { var msg = data.responseDetails; }; $(e).html('<div class="rssError"><p>' + msg + '</p></div>');
                };
            });
        });
    }; var _callback = function (e, feeds, options) {
        if (!feeds) {
            return false;
        }
        var html = '';
        var row = 'odd';
        for (var i = 0; i < feeds.entries.length; i++) {
            var entry = feeds.entries[i];
            var entryDate = new Date(entry.publishedDate);
            var pubDate = entryDate.toLocaleDateString() + ' ' + entryDate.toLocaleTimeString();
            var content = entry.content;

            

            html += '' + entry.title + ''

            if (options.content) {
                if (options.snippet && entry.contentSnippet != '') {
                    var content = entry.contentSnippet;
                }
                else {
                    var content = entry.content;
                }
                html += '<br><div id="newsContent">' + content + '</div>'
            }
            
            if (row == 'odd') {
                row = 'even';
            }
            else {
                row = 'odd';
            }
        }
        
        //html += ''
        $(e).html(html);
    };
})(jQuery);
