jQuery(document).ready(function() {
    promanchester.jsonnewsfeed.init();
});

/*check that the 'promanchester' namespace doesn't already exist*/
if(typeof promanchester === 'undefined') {
    promanchester = {};
}

promanchester.jsonnewsfeed = {
    //gets data from YQL web service in JSONb format with '?' as the callback function
    //and parses it to display the feed
    restURL: "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%3D%22http%3A%2F%2Fwww.thebusinessdesk.com%2Frss%2Fnorthwest%2F%22&format=json&diagnostics=false&callback=?",

    init: function() {
        jQuery.getJSON(this.restURL, function(data) {
            jQuery.each(data.query.results.item, function(index, item) {
                var fontSize = index !== 0 ? 'auto' : '1.1em';
                jQuery('#newsdeskTick').append(
                    '<li>'+ item.title + ' <a style="color: #0c529f; text-decoration:none;" href="' + item.guid + '">more&nbsp;></a></li>'
                );
                return (index !== 3);
            });
        });
    }
}
