

 


(function() {

// Localize jQuery variable
var jQuery;

/******** Load jQuery if not present *********/
if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.7.2') {

    var script_tag = document.createElement('script');
    script_tag.setAttribute("type","text/javascript");
    script_tag.setAttribute("src",
        "http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js");
    if (script_tag.readyState) {
      script_tag.onreadystatechange = function () { // For old versions of IE
          if (this.readyState == 'complete' || this.readyState == 'loaded') {
              scriptLoadHandler();
          }
      };
    } else {
      script_tag.onload = scriptLoadHandler;
    }
    // Try to find the head, otherwise default to the documentElement
    (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);

    
} else {
    // The jQuery version on the window is the one we want to use
    jQuery = window.jQuery;
    main();
}

/******** Called once jQuery has loaded ******/
function scriptLoadHandler() {
    // Restore $ and window.jQuery to their previous values and store the
    // new jQuery in our local jQuery variable
    jQuery = window.jQuery.noConflict(true);

   
}

/******** Our main function ********/ 

(function(funcName, baseObj) {
    // The public function name defaults to window.docReady
    // but you can pass in your own object and own function name and those will be used
    // if you want to put them in a different namespace
    funcName = funcName || "docReady";
    baseObj = baseObj || window;
    var readyList = [];
    var readyFired = false;
    var readyEventHandlersInstalled = false;
    
    // call this when the document is ready
    // this function protects itself against being called more than once
    function ready() {
        if (!readyFired) {
            // this must be set to true before we start calling callbacks
            readyFired = true;
            for (var i = 0; i < readyList.length; i++) {
                // if a callback here happens to add new ready handlers,
                // the docReady() function will see that it already fired
                // and will schedule the callback to run right after
                // this event loop finishes so all handlers will still execute
                // in order and no new ones will be added to the readyList
                // while we are processing the list
                readyList[i].fn.call(window, readyList[i].ctx);
            }
            // allow any closures held by these functions to free
            readyList = [];
        }
    }
    
    function readyStateChange() {
        if ( document.readyState === "complete" ) {
            ready();
        }
    }
    
    // This is the one public interface
    // docReady(fn, context);
    // the context argument is optional - if present, it will be passed
    // as an argument to the callback
    baseObj[funcName] = function(callback, context) {
        // if ready has already fired, then just schedule the callback
        // to fire asynchronously, but right away
        if (readyFired) {
            setTimeout(function() {callback(context);}, 1);
            return;
        } else {
            // add the function and context to the list
            readyList.push({fn: callback, ctx: context});
        }
        // if document already ready to go, schedule the ready function to run
        if (document.readyState === "complete") {
            setTimeout(ready, 1);
        } else if (!readyEventHandlersInstalled) {
            // otherwise if we don't have event handlers installed, install them
            if (document.addEventListener) {
                // first choice is DOMContentLoaded event
                document.addEventListener("DOMContentLoaded", ready, false);
                // backup is window load event
                window.addEventListener("load", ready, false);
            } else {
                // must be IE
                document.attachEvent("onreadystatechange", readyStateChange);
                window.attachEvent("onload", ready);
            }
            readyEventHandlersInstalled = true;
        }
    }
})("docReady", window);

         /******* Load HTML *******/
        //this nees to come back in json format 
         
         docReady(function() {
         document.getElementById("newswhip-trending").innerHTML= "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<!doctype html>\n<html lang=\"en\">\n<head>\n\t<meta charset=\"utf-8\" \/>\n\t<title>NewsWhip - Widget<\/title>\n\t<script type=\"text\/javascript\">\n  \n\t(function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){\n\t  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n\t  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n\t  })(window,document,\'script\',\'\/\/www.google-analytics.com\/analytics.js\',\'ga\');\n\n\t  ga(\'create\', \'UA-18201240-5\', \'newswhip.com\');\n\t  ga(\'send\', \'pageview\');\n\n\n<\/script>\n<\/head>\n<body>\n<br>\n<br>\n<style type=\"text\/css\" media=\"screen\">\n\n\n\/* Fonts *\/\n\t\t@font-face {\n\t\t    font-family: \'EJRoundedDemi\';\n\t\t    src: url(\'http:\/\/static.newswhip.com\/static\/fonts\/ej_rounded_demi-webfont.eot\');\n\t\t    src: url(\'http:\/\/static.newswhip.com\/static\/fonts\/ej_rounded_demi-webfont.eot?#iefix\') format(\'embedded-opentype\'),\n\t\t         url(\'http:\/\/static.newswhip.com\/static\/fonts\/ej_rounded_demi-webfont.woff\') format(\'woff\'),\n\t\t         url(\'http:\/\/static.newswhip.com\/static\/fonts\/ej_rounded_demi-webfont.ttf\') format(\'truetype\'),\n\t\t         url(\'http:\/\/static.newswhip.com\/static\/fonts\/ej_rounded_demi-webfont.svg#EJRoundedDemiRegular\') format(\'svg\');\n\t\t    font-weight: normal;\n\t\t    font-style: normal;\n\t\t}\n\n\t\t@font-face {\n\t\t    font-family: \'EJRoundedLight\';\n\t\t    src: url(\'http:\/\/static.newswhip.com\/static\/fonts\/ej_rounded_light-webfont.eot\');\n\t\t    src: url(\'http:\/\/static.newswhip.com\/static\/fonts\/ej_rounded_light-webfont.eot?#iefix\') format(\'embedded-opentype\'),\n\t\t         url(\'http:\/\/static.newswhip.com\/static\/fonts\/ej_rounded_light-webfont.woff\') format(\'woff\'),\n\t\t         url(\'http:\/\/static.newswhip.com\/static\/fonts\/ej_rounded_light-webfont.svg#EJRoundedLightRegular\') format(\'svg\');\n\t\t    font-weight: normal;\n\t\t    font-style: normal;\n\t\t}\n\n\t\t\/* Reset *\/\n\t\t* { padding: 0; margin: 0; outline: 0; }\n\n\t\t\/* Base *\/\n\t\t\n\t\t#newswhip-trending  { height: 100%; }\n\n\t\t#newswhip-trending  { background: #fff; font-size: 13px; font-family: arial, sans-serif; color: #595959; line-height: 1.2 !important;}\n\n\t\t#newswhip-trending a { text-decoration: none; color: #385175; cursor: pointer; }\n\t\t#newswhip-trending a:hover { color: #385175 !important;}\n\n\t\t#newswhip-trending img { border: 0; vertical-align: middle; }\n\n\t\t\/* Widget *\/\n\t\t#newswhip-trending .container { width: 95%; padding: 12px 5px; background: #eaedec; margin: 0 auto; border-radius: 7px; position: relative; right: 5px;}\n\n\t\t#newswhip-trending .logo { display: block; text-align: center; height: 101px; }\n\t\t#newswhip-trending .logo img,\n\t\t#newswhip-trending .logo span,\n\t\t#newswhip-trending .logo small { display: block; }\n\t\t#newswhip-trending .logo img { margin: 0 auto 4px; }\n\t\t#newswhip-trending .logo span { font-size: 23px; font-family: \'EJRoundedDemi\', sans-serif; }\n\t\t#newswhip-trending .logo small { font-size: 14px; font-family: \'EJRoundedLight\', sans-serif; }\n\n\t\t#newswhip-trending .menu { height: 32px; border: 1px solid #fff; border-radius: 4px; font-family: \'EJRoundedDemi\', sans-serif; text-transform: uppercase; font-size: 20px; color: #385175; cursor: pointer; margin: 8px 0 0; }\n\t\t#newswhip-trending .menu .current { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; padding: 4px 29px 0 9px; display: block; background: url(http:\/\/static.newswhip.com\/static\/images\/arrow-down.png) no-repeat right 11px; }\n\n\t\t#newswhip-trending .menu-list { position: absolute; top: 121px; left: 0; right: 0; bottom: 0; background: #eaedec; font-family: \'EJRoundedDemi\', sans-serif; text-transform: uppercase; font-size: 20px; color: #9d9d9d; cursor: pointer; border-radius: 0 0 7px 7px; display: none; }\n\t\t#newswhip-trending .menu-list ul { list-style: none outside none; position: absolute; top: 0; left: 0; right: 0; bottom: 102px; overflow: auto; }\n\t\t#newswhip-trending .menu-list li { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; height: 28px; padding: 4px 29px 0 9px; border: 1px solid #fff; border-radius: 4px; margin: 0 5px; }\n\t\t#newswhip-trending .menu-list li + li { margin-top: 5px; }\n\t\t#newswhip-trending .menu-list li:hover,\n\t\t#newswhip-trending .menu-list li.current { color: #385175 !important; }\n\t\t#newswhip-trending .menu-list li.current { background: url(http:\/\/static.newswhip.com\/static\/images\/arrow-up-2.png) no-repeat right 10px; }\n\n\t\t#newswhip-trending .menu-list .collapse { position: absolute; bottom: 65px; left: 50%; margin-left: -14px; width: 28px; height: 20px; background: url(http:\/\/static.newswhip.com\/static\/images\/arrow-up.png) no-repeat 0 0; }\n\t\t#newswhip-trending .menu-list .collapse:hover { background-position: 0 bottom !important; }\n\n\t\t#newswhip-trending .menu-list .back-link { position: absolute; bottom: 22px; left: 10px; right: 10px; height: 23px; background: #385175; border-radius: 12px; font-family: \'EJRoundedDemi\', sans-serif; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; font-size: 16px; text-transform: none; color: #fff; text-align: center; padding: 3px 10px 0; }\n\t\t#newswhip-trending .menu-list .back-link:hover { background: #fff; color: #385175 !important; }\n\n\t\t#newswhip-trending .posts { list-style: none outside none; padding: 5px 0 0; }\n\t\t#newswhip-trending .posts li { background: #fff; border-radius: 5px; overflow: hidden; margin: 0px; padding: 0px; line-height: 1.2 !important; }\n\t\t#newswhip-trending .posts li + li { margin-top: 5px; }\n\t\t#newswhip-trending .posts h5 { overflow: hidden; font-size: 14px; padding-top: 8px; min-height: 50px; clear: none !important; font-weight: bold !important; min-height: 80px; margin-right: 10px;}\n\n\t\t#newswhip-trending .posts .thumb { float: left; margin: 10px 10px 0 10px; }\n\t\t#newswhip-trending .posts .thumb img { display: block; max-width: 100%; height: auto; }\n\n\t\t#newswhip-trending .posts .meta { border-top: 2px solid #eaedec; overflow: hidden; font-size: 10px; font-family: \'EJRoundedDemi\', sans-serif; padding: 10px; margin-top: 15px; }\n\t\t#newswhip-trending .posts .meta .facebook,\n\t\t#newswhip-trending .posts .meta .twitter { float: left; background-repeat: no-repeat; background-position: 0 0; height: 14px; padding-top: 1px; }\n\t\t#newswhip-trending .posts .meta .facebook { background-image: url(http:\/\/static.newswhip.com\/static\/images\/icon-facebook.png); padding-left: 20px; }\n\t\t#newswhip-trending .posts .meta .twitter { background-image: url(http:\/\/static.newswhip.com\/static\/images\/icon-twitter.png); padding-left: 26px; margin-left: 10px; }\n\t\t#newswhip-trending .posts .meta .timestamp { float: right; padding-top: 1px; }\n\n\t\t#newswhip-trending .bottom-back-link { text-align: center; font-family: \'EJRoundedLight\', sans-serif; font-size: 14px; padding: 0px !important; margin: 0px !important; line-height: 1.2 !important; }\n\t\t#newswhip-trending .bottom-back-link a { display: block; font-size: 18px; font-family: \'EJRoundedDemi\', sans-serif; }\n\n\t\t#newswhip-trending  .posts.loading { background: url(http:\/\/static.newswhip.com\/static\/images\/ajax-loader.gif) no-repeat center center; }\n\n<\/style>\n\n<div class=\"container\">\n\t<a href=\"http:\/\/www.newswhip.com\/\" class=\"logo\" target=\"_blank\">\n\t\t<img src=\"http:\/\/static.newswhip.com\/static\/images\/logo-widget-new.png\" alt=\"\" \/>\n\t\t<span>NewsWhip<\/span>\n\t\t<small>People Powered News<\/small>\n\t<\/a><!-- \/.logo -->\n\n\t<div class=\"menu\">\n\t\t<span class=\"current\">IRELAND<\/span>\n\t<\/div><!-- \/.menu -->\n\n\t<div class=\"menu-list\">\n\t\t<ul>\n\t\t\t<li data-value=\"\">World<\/li>\n\t\t\t<li data-value=\"U.S.\">U.S.<\/li>\n\t\t\t<li data-value=\"U.K.\">U.K.<\/li>\n\t\t\t<li data-value=\"AUSTRALIA\">AUSTRALIA<\/li>\n\t\t\t<li class=\"current\" data-value=\"IRELAND\">IRELAND<\/li>\n\t\t\t\n\t\t\t<li data-value=\"Ireland\/News\">News<\/li>\n\t\t\t<li data-value=\"Ireland\/Gossip\">Gossip<\/li>\n\t\t\t<li data-value=\"Ireland\/Tech\">Tech<\/li>\n\t\t\t<li data-value=\"Ireland\/Fun\">Fun<\/li>\n\t\t\t<li data-value=\"Ireland\/Culture\">Culture<\/li>\n\t\t\t<li data-value=\"Ireland\/Science\">Science<\/li>\n\t\t\t<li data-value=\"Ireland\/Life\">Life<\/li>\n\t\t\t<li data-value=\"Ireland\/Opinion\">Opinion<\/li>\n\t\t\t<li data-value=\"Ireland\/Business\">Business<\/li>\n\t\t\t<li data-value=\"Ireland\/Sports\">Sports<\/li>\n\t\t\t\n\t\t\t\n\t\t<\/ul>\n\n\t\t<a href=\"#\" class=\"collapse\"><\/a>\n\t\t<a href=\"http:\/\/www.newswhip.com\/\" class=\"back-link\" target=\"_blank\">www.newswhip.com<\/a>\n\t<\/div><!-- \/.menu-list -->\n\n\t<ul class=\"posts\">\n\t\n\t\n\t\n\t\n\t\t<li>\n\t\t\n\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t<a onClick=\"ga( \'send\', \'event\', \'click\', \'BroadSheet\', \'http:\/\/www.joe.ie\/entertainment\/pic-ed-sheeran-and-damien-rice-in-2004-on-the-night-that-ed-says-changed-his-life\/482333\');\" href=\"http:\/\/www.joe.ie\/entertainment\/pic-ed-sheeran-and-damien-rice-in-2004-on-the-night-that-ed-says-changed-his-life\/482333\" target=\"_blank\" class=\"thumb\">\n\t\t<img src=\"http:\/\/img.newswhip.com\/safeImage?url=http%3A%2F%2Fm0.joe.ie%2FYToyOntzOjQ6ImRhdGEiO3M6MTczOiJhOjM6e3M6MzoidXJsIjtzOjExMToiaHR0cDovL21lZGlhLWpvZS5tYXhpbXVtbWVkaWEuaWUuczMuYW1hem9uYXdzLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxNS8wMS8yMzIwMDQzMy9FZC1TaGVlcmFuLVBob3Rvc2dvb3kuanBnIjtzOjU6IndpZHRoIjtpOjY0NztzOjY6ImhlaWdodCI7aTozNDA7fSI7czo0OiJoYXNoIjtzOjQwOiI4ODVlMmQwMzZmMTNiNmY1NWI5ZmVmNGY2MDZmZjI4YzhjYmQ4NjA5Ijt9%2Fed-sheeran-photosgooy.jpg&width=80&height=80&d=yhqQR5_R7ScmhxOnoFUQtCUYnuX4vhl5Af_4Yywjaqs\" \/>\n\t\t<\/a>\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t<h5>\n\t\t\t<a onClick=\"ga( \'send\', \'event\', \'click\', \'BroadSheet\', \'http:\/\/www.joe.ie\/entertainment\/pic-ed-sheeran-and-damien-rice-in-2004-on-the-night-that-ed-says-changed-his-life\/482333\');\" href=\"http:\/\/www.joe.ie\/entertainment\/pic-ed-sheeran-and-damien-rice-in-2004-on-the-night-that-ed-says-changed-his-life\/482333\" target=\"_blank\">\n\t\t\tPic: Ed Sheeran and Damien Rice in 2004 on the night that Ed says \"changed his life\"\n\t\t\t<\/a>\n\t\t\t<\/h5>\n\t\t\t\n\t\t\t<div class=\"meta\">\n\t\t\t\t\n\t\t\t\t\t<span class=\"timestamp\">\n\t\t\t\t\t\t\t\t\t\t\tin the last 3 Hours\n\t\t\t\t\t\t\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t<span class=\"facebook\">\n\t\t\t\t3534\n\t\t\t\t<\/span>\n\t\t\t\t<span class=\"twitter\">\n\t\t\t\t26\n\t\t\t\t<\/span>\n\t\t\t\t<span class=\"time-ago\"><\/span>\n\t\t\t\n\t\t\t<\/div>\n\t\t<\/li>\n\t\t\n\t\t<li>\n\t\t\n\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t<a onClick=\"ga( \'send\', \'event\', \'click\', \'BroadSheet\', \'http:\/\/www.irishtimes.com\/culture\/tv-radio-web\/irish-times-takes-five-first-prizes-at-photographer-of-the-year-awards-1.2077612\');\" href=\"http:\/\/www.irishtimes.com\/culture\/tv-radio-web\/irish-times-takes-five-first-prizes-at-photographer-of-the-year-awards-1.2077612\" target=\"_blank\" class=\"thumb\">\n\t\t<img src=\"http:\/\/img.newswhip.com\/safeImage?url=http%3A%2F%2Fwww.irishtimes.com%2Fpolopoly_fs%2F1.2077606.1422039133%21%2Fimage%2Fimage.jpg&width=80&height=80&d=qnp-1VfwSN3eR5Br_EIcBM9u8GNPNiCJ28nrbzaAaj0\" \/>\n\t\t<\/a>\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t<h5>\n\t\t\t<a onClick=\"ga( \'send\', \'event\', \'click\', \'BroadSheet\', \'http:\/\/www.irishtimes.com\/culture\/tv-radio-web\/irish-times-takes-five-first-prizes-at-photographer-of-the-year-awards-1.2077612\');\" href=\"http:\/\/www.irishtimes.com\/culture\/tv-radio-web\/irish-times-takes-five-first-prizes-at-photographer-of-the-year-awards-1.2077612\" target=\"_blank\">\n\t\t\tIrish Times takes five first prizes at photographer of the year awards\n\t\t\t<\/a>\n\t\t\t<\/h5>\n\t\t\t\n\t\t\t<div class=\"meta\">\n\t\t\t\t\n\t\t\t\t\t<span class=\"timestamp\">\n\t\t\t\t\t\t\t\t\t\t\tin the last 3 Hours\n\t\t\t\t\t\t\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t<span class=\"facebook\">\n\t\t\t\t215\n\t\t\t\t<\/span>\n\t\t\t\t<span class=\"twitter\">\n\t\t\t\t20\n\t\t\t\t<\/span>\n\t\t\t\t<span class=\"time-ago\"><\/span>\n\t\t\t\n\t\t\t<\/div>\n\t\t<\/li>\n\t\t\n\t\t<li>\n\t\t\n\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t<a onClick=\"ga( \'send\', \'event\', \'click\', \'BroadSheet\', \'http:\/\/www.irishcentral.com\/roots\/How-Irish-are-you-Take-the-quiz.html\');\" href=\"http:\/\/www.irishcentral.com\/roots\/How-Irish-are-you-Take-the-quiz.html\" target=\"_blank\" class=\"thumb\">\n\t\t<img src=\"http:\/\/img.newswhip.com\/safeImage?url=http%3A%2F%2Fmedia.irishcentral.com%2Fimages%2FMI-fmpQuiz.jpg&width=80&height=80&d=jZptqG-zCePtI26Zf3IHi1-Wgac-iADDERdklNq8kXc\" \/>\n\t\t<\/a>\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t<h5>\n\t\t\t<a onClick=\"ga( \'send\', \'event\', \'click\', \'BroadSheet\', \'http:\/\/www.irishcentral.com\/roots\/How-Irish-are-you-Take-the-quiz.html\');\" href=\"http:\/\/www.irishcentral.com\/roots\/How-Irish-are-you-Take-the-quiz.html\" target=\"_blank\">\n\t\t\tTest your Irishness with this new quiz\n\t\t\t<\/a>\n\t\t\t<\/h5>\n\t\t\t\n\t\t\t<div class=\"meta\">\n\t\t\t\t\n\t\t\t\t\t<span class=\"timestamp\">\n\t\t\t\t\t\t\t\t\t\t\tin the last 3 Hours\n\t\t\t\t\t\t\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t<span class=\"facebook\">\n\t\t\t\t860\n\t\t\t\t<\/span>\n\t\t\t\t<span class=\"twitter\">\n\t\t\t\t2\n\t\t\t\t<\/span>\n\t\t\t\t<span class=\"time-ago\"><\/span>\n\t\t\t\n\t\t\t<\/div>\n\t\t<\/li>\n\t\t\n\t\t<li>\n\t\t\n\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t<a onClick=\"ga( \'send\', \'event\', \'click\', \'BroadSheet\', \'http:\/\/www.irishcentral.com\/roots\/history\/Little-known-tale-of-generous-Turkish-aid-to-the-Irish-during-the-Great-Hunger.html\');\" href=\"http:\/\/www.irishcentral.com\/roots\/history\/Little-known-tale-of-generous-Turkish-aid-to-the-Irish-during-the-Great-Hunger.html\" target=\"_blank\" class=\"thumb\">\n\t\t<img src=\"http:\/\/img.newswhip.com\/safeImage?url=http%3A%2F%2Fmedia.irishcentral.com%2Fimages%2FMI%2BSultan%2BAbdulmecid%2BWikimedia%2BFamine%2BTurkey%2BOttoman%2Baid.jpg&width=80&height=80&d=SQkOf2myAlKEVe9dTZIdvrflv9fm_mg4I6pujRbTf6w\" \/>\n\t\t<\/a>\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t<h5>\n\t\t\t<a onClick=\"ga( \'send\', \'event\', \'click\', \'BroadSheet\', \'http:\/\/www.irishcentral.com\/roots\/history\/Little-known-tale-of-generous-Turkish-aid-to-the-Irish-during-the-Great-Hunger.html\');\" href=\"http:\/\/www.irishcentral.com\/roots\/history\/Little-known-tale-of-generous-Turkish-aid-to-the-Irish-during-the-Great-Hunger.html\" target=\"_blank\">\n\t\t\tLittle known tale of generous Turkish aid to the Irish during the Great Hunger\n\t\t\t<\/a>\n\t\t\t<\/h5>\n\t\t\t\n\t\t\t<div class=\"meta\">\n\t\t\t\t\n\t\t\t\t\t<span class=\"timestamp\">\n\t\t\t\t\t\t\t\t\t\t\tin the last 3 Hours\n\t\t\t\t\t\t\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t<span class=\"facebook\">\n\t\t\t\t3265\n\t\t\t\t<\/span>\n\t\t\t\t<span class=\"twitter\">\n\t\t\t\t68\n\t\t\t\t<\/span>\n\t\t\t\t<span class=\"time-ago\"><\/span>\n\t\t\t\n\t\t\t<\/div>\n\t\t<\/li>\n\t\t\n\t\t<li>\n\t\t\n\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t<a onClick=\"ga( \'send\', \'event\', \'click\', \'BroadSheet\', \'http:\/\/www.breakingnews.ie\/ireland\/dublin-is-the-second-best-place-in-the-world-for-americans-to-live-659362.html\');\" href=\"http:\/\/www.breakingnews.ie\/ireland\/dublin-is-the-second-best-place-in-the-world-for-americans-to-live-659362.html\" target=\"_blank\" class=\"thumb\">\n\t\t<img src=\"http:\/\/img.newswhip.com\/safeImage?url=http%3A%2F%2Fmedia.central.ie%2Fmedia%2Fimages%2Fo%2FOConnellStreet_large.jpg&width=80&height=80&d=6lWH2YxNsHcKYp7r5zvvJErCGtIsLNkLYBuyyheZIrM\" \/>\n\t\t<\/a>\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t<h5>\n\t\t\t<a onClick=\"ga( \'send\', \'event\', \'click\', \'BroadSheet\', \'http:\/\/www.breakingnews.ie\/ireland\/dublin-is-the-second-best-place-in-the-world-for-americans-to-live-659362.html\');\" href=\"http:\/\/www.breakingnews.ie\/ireland\/dublin-is-the-second-best-place-in-the-world-for-americans-to-live-659362.html\" target=\"_blank\">\n\t\t\tDublin is the second best place in the world for Americans to live\n\t\t\t<\/a>\n\t\t\t<\/h5>\n\t\t\t\n\t\t\t<div class=\"meta\">\n\t\t\t\t\n\t\t\t\t\t<span class=\"timestamp\">\n\t\t\t\t\t\t\t\t\t\t\tin the last 3 Hours\n\t\t\t\t\t\t\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t<span class=\"facebook\">\n\t\t\t\t1221\n\t\t\t\t<\/span>\n\t\t\t\t<span class=\"twitter\">\n\t\t\t\t31\n\t\t\t\t<\/span>\n\t\t\t\t<span class=\"time-ago\"><\/span>\n\t\t\t\n\t\t\t<\/div>\n\t\t<\/li>\n\t\t\n\t\n\t<\/ul><!-- \/.posts -->\n\n\t<p class=\"bottom-back-link\">\n\t\n\t\tMore at\n\t\t<a href=\"http:\/\/www.newswhip.com\/\" target=\"_blank\">www.newswhip.com<\/a>\n\t<\/p>\n\n\t<script id=\"tpl\" type=\"text\/tpl\">\n\t\t<li>\n\t\t\t<a href=\"{link}\" target=\"_blank\" class=\"thumb\">\n\t\t\t\t<img src=\"{image}\" alt=\"\" width=\"80px\" height=\"53px\">\n\t\t\t<\/a>\n\t\t\t<h5><a href=\"{link}\" target=\"_blank\">{headline}<\/a><\/h5>\n\n\t\t\t<div class=\"meta\">\n\t\t\t\t<span class=\"timestamp\">{urlDiscovery}<\/span>\n\t\t\t\t<span class=\"facebook\">{fbScore}<\/span>\n\t\t\t\t<span class=\"twitter\">{twScore}<\/span>\n\t\t\t<\/div>\n\t\t<\/li>\n\t<\/script>\n<\/div><!-- \/.container -->\n\n<br>\n<br>\n<\/body>\n<\/html>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
		

		  
          

// vars
var $current = $('#newswhip-trending .container .menu .current'),
	$list = $('#newswhip-trending .container .menu-list'),
	$collapse = $list.find('#newswhip-trending .container .collapse'),
	$postsList = $('#newswhip-trending .container .posts'),
	tpl = $('#newswhip-trending .container #tpl').html();

// show menu list
$current.on('click', function(){
	$list.stop(true,true).fadeIn(300);
});

// hide menu list
$collapse.on('click', function(e){
	$list.stop(true,true).fadeOut(300);
	e.preventDefault();
});

// handle menu list items 
$list.find('li').on('click', function(){
	var $this = $(this);
	$this.addClass('current').siblings().removeClass('current');
	$current.text($this.text());
	$list.stop(true,true).fadeOut(300);
	loadFeed($this.data('value').toLowerCase());
});

// helper function
function loadFeed(key){
	// setup height of list
	$postsList.css('min-height', $postsList.height());
	$postsList.empty();

	// add loading class
	$postsList.addClass('loading');

	// get the feed
	$.getJSON('http://json.newswhip.com/' + key, function(data, a, b){
		var results = data['newswhip'].slice(0, 5),
			items = [];

		$postsList.removeClass('loading'); 

		$.each(results, function(index, obj){
			var tmp = tpl;
			$.each(obj, function(key, value){
			
				var regex = new RegExp('{'+key+'}', 'gi');
				
				tmp = tmp.replace(regex, value);
			});
			items.push(tmp);
		});

		$postsList.append(items.join(''));

		$postsList.css('min-height', 0);
	});
}
          
          
        });
    
    
    


})(); // We call our anonymous function immediately
