

 


(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<body>\n\n<style type=\"text\/css\" media=\"screen\">\n#newswhip-trending .stats {width: 90px !important;}\n#newswhip-trending .comments i { float: left; background: url(http:\/\/static.newswhip.com\/static\/images\/DailyKos\/socials.png?domain=www) no-repeat 0 0; width: 11px; height: 11px; margin: 2px 3px 0 0; }\n#newswhip-trending .recs{ float: right !important; }\n#newswhip-trending .recs i { float: left; background: url(http:\/\/static.newswhip.com\/static\/images\/DailyKos\/socials.png?domain=www) no-repeat 0 -12px; width: 11px; height: 11px; margin: 2px 3px 0 0; }\n#newswhip-trending .navigation {display: none !important;}\n#newswhip-trending .collapsable-panel{margin-bottom: 0px !important;}\n.nw-powered { margin-bottom: 20px;font-size: 11px; padding: 0 0.5em 0.5em;}\n.nw-powered, .nw-powered a { color: #666; }\n<\/style>\n\n<script type=\"text\/javascript\">\n  \n(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\n<div id=\"newswhip_shared_div\" class=\"featured-articles collapsable-panel ajax-paged\">\n<a class=\"collapsor\" href=\"#\"><h2 class=\"tight\" id=\"newswhip_shared\">Most Shared<\/h2><\/a>\n<ul class=\"articles ajax-paged-content\">\n\n\t\n\t\t<li class=\"clearfix\"> <div><a class=\"title\" href=\"http:\/\/www.dailykos.com\/story\/2014\/11\/14\/1344851\/-McConnell-brings-Republican-hypocrisy-to-a-new-low-and-that-s-saying-something\" onClick=\"ga( \'send\', \'event\', \'click\', \'DailyKos\', \'http:\/\/www.dailykos.com\/story\/2014\/11\/14\/1344851\/-McConnell-brings-Republican-hypocrisy-to-a-new-low-and-that-s-saying-something\');\">McConnell brings Republican hypocrisy to a new low, and that\'s saying something<\/a><\/div>\n\t\t\n\t\t\n\t\t\t<span class=\"byline\"><span class=\"by\">by<\/span> <a href=\"http:\/\/www.dailykos.com\/user\/Ian Reifowitz\" class=\"author\" onClick=\"ga( \'send\', \'event\', \'click\', \'DailyKos\', \'Ian Reifowitz\');\">Ian Reifowitz<\/a><\/span> \n\t\t\n\t\t<span class=\"stats\">\n\t\t\t<span class=\"comments\">\n\t\t\t\t<i><\/i>7721\n\t\t\t<\/span>\t\n\t\t\t<span class=\"recs\">\n\t\t\t\t<i><\/i>277\n\t\t\t\t<\/span>\n\t\t<\/span>\n\t\t<\/li>\n\t\n\t\t<li class=\"clearfix\"> <div><a class=\"title\" href=\"http:\/\/www.dailykos.com\/story\/2014\/11\/14\/1344981\/-Rich-Californians-use-the-most-water-and-a-black-market-is-springing-up\" onClick=\"ga( \'send\', \'event\', \'click\', \'DailyKos\', \'http:\/\/www.dailykos.com\/story\/2014\/11\/14\/1344981\/-Rich-Californians-use-the-most-water-and-a-black-market-is-springing-up\');\">Rich Californians use the most water and a black market is springing up<\/a><\/div>\n\t\t\n\t\t\n\t\t\t<span class=\"byline\"><span class=\"by\">by<\/span> <a href=\"http:\/\/www.dailykos.com\/user\/Walter Einenkel\" class=\"author\" onClick=\"ga( \'send\', \'event\', \'click\', \'DailyKos\', \'Walter Einenkel\');\">Walter Einenkel<\/a><\/span> \n\t\t\n\t\t<span class=\"stats\">\n\t\t\t<span class=\"comments\">\n\t\t\t\t<i><\/i>1394\n\t\t\t<\/span>\t\n\t\t\t<span class=\"recs\">\n\t\t\t\t<i><\/i>18\n\t\t\t\t<\/span>\n\t\t<\/span>\n\t\t<\/li>\n\t\n\t\t<li class=\"clearfix\"> <div><a class=\"title\" href=\"http:\/\/www.dailykos.com\/story\/2014\/11\/14\/1344969\/-Obamacare-enrollees-overwhelming-approve-of-quality-and-affordability-of-their-new-nbsp-insurance\" onClick=\"ga( \'send\', \'event\', \'click\', \'DailyKos\', \'http:\/\/www.dailykos.com\/story\/2014\/11\/14\/1344969\/-Obamacare-enrollees-overwhelming-approve-of-quality-and-affordability-of-their-new-nbsp-insurance\');\">Obamacare enrollees overwhelming approve of quality and affordability of their new\u00A0insurance<\/a><\/div>\n\t\t\n\t\t\n\t\t\t<span class=\"byline\"><span class=\"by\">by<\/span> <a href=\"http:\/\/www.dailykos.com\/user\/Joan McCarter\" class=\"author\" onClick=\"ga( \'send\', \'event\', \'click\', \'DailyKos\', \'Joan McCarter\');\">Joan McCarter<\/a><\/span> \n\t\t\n\t\t<span class=\"stats\">\n\t\t\t<span class=\"comments\">\n\t\t\t\t<i><\/i>1431\n\t\t\t<\/span>\t\n\t\t\t<span class=\"recs\">\n\t\t\t\t<i><\/i>46\n\t\t\t\t<\/span>\n\t\t<\/span>\n\t\t<\/li>\n\t\n\t\t<li class=\"clearfix\"> <div><a class=\"title\" href=\"http:\/\/www.dailykos.com\/story\/2014\/11\/14\/1344947\/-DC-Court-Of-Appeals-Rules-In-Favor-Of-Obamacare-Contraceptive-Mandate\" onClick=\"ga( \'send\', \'event\', \'click\', \'DailyKos\', \'http:\/\/www.dailykos.com\/story\/2014\/11\/14\/1344947\/-DC-Court-Of-Appeals-Rules-In-Favor-Of-Obamacare-Contraceptive-Mandate\');\">DC Court Of Appeals Rules In Favor Of Obamacare Contraceptive Mandate<\/a><\/div>\n\t\t\n\t\t\n\t\t\t<span class=\"byline\"><span class=\"by\">by<\/span> <a href=\"http:\/\/www.dailykos.com\/user\/Richard Lyon\" class=\"author\" onClick=\"ga( \'send\', \'event\', \'click\', \'DailyKos\', \'Richard Lyon\');\">Richard Lyon<\/a><\/span> \n\t\t\n\t\t<span class=\"stats\">\n\t\t\t<span class=\"comments\">\n\t\t\t\t<i><\/i>4801\n\t\t\t<\/span>\t\n\t\t\t<span class=\"recs\">\n\t\t\t\t<i><\/i>16\n\t\t\t\t<\/span>\n\t\t<\/span>\n\t\t<\/li>\n\t\n\t\t<li class=\"clearfix\"> <div><a class=\"title\" href=\"http:\/\/www.dailykos.com\/story\/2014\/11\/14\/1344972\/-The-American-Ebola-panic-is-over-everyone-Great-job\" onClick=\"ga( \'send\', \'event\', \'click\', \'DailyKos\', \'http:\/\/www.dailykos.com\/story\/2014\/11\/14\/1344972\/-The-American-Ebola-panic-is-over-everyone-Great-job\');\">The American Ebola panic is over, everyone. Great job.<\/a><\/div>\n\t\t\n\t\t\n\t\t\t<span class=\"byline\"><span class=\"by\">by<\/span> <a href=\"http:\/\/www.dailykos.com\/user\/Hunter\" class=\"author\" onClick=\"ga( \'send\', \'event\', \'click\', \'DailyKos\', \'Hunter\');\">Hunter<\/a><\/span> \n\t\t\n\t\t<span class=\"stats\">\n\t\t\t<span class=\"comments\">\n\t\t\t\t<i><\/i>753\n\t\t\t<\/span>\t\n\t\t\t<span class=\"recs\">\n\t\t\t\t<i><\/i>40\n\t\t\t\t<\/span>\n\t\t<\/span>\n\t\t<\/li>\n\t\n<\/ul>\n<ul class=\"navigation\">\n<li class=\"next\"><a class=\"do-page-next ajaxON\" href=\"\/part\/sidebar\/stories\/editors_choice?page=1\">Next<\/a><\/li>\n<\/ul>\n<\/div>\n\n<\/body>\n\n\n\n\n\n\n\n\n";
		

		  
          

function checkCookie(clicked) {
    var compact = getCookie("newswhip-compact");
    if (compact != "") {
        if (clicked == "true") {
            setCookie("newswhip-compact", true, -1);
        } else {
            var a = $("#newswhip-trending .collapsor");
            a.parent("div.collapsable-panel").toggleClass("collapsed");
            a.blur();
            kck.set_coll_pref(a.parent());
        }


    } else {
        if (clicked == "true") {
            setCookie("newswhip-compact", true, 365);
        }
    }
}

function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = "expires=" + d.toGMTString();
    document.cookie = cname + "=" + cvalue + "; " + expires;
}


function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i].trim();
        if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
    }
    return "";
}

checkCookie("false");
$("#newswhip-trending .collapsor").click(function () {
    checkCookie("true")
});
$("#newswhip-trending .collapsor").click(App.onAjaxButtonCollapse);
          
          
        });
    
    
    


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



