(function () {

    // Localize jQuery variable
    var jQuery;

    /******** Load jQuery if not present *********/
    if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2') {
        var script_tag = document.createElement('script');
        script_tag.setAttribute('type', 'text/javascript');
        script_tag.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
        if (script_tag.readyState) {
          script_tag.onreadystatechange = function () { // Same thing but for IE
              if (this.readyState == 'complete' || this.readyState == 'loaded') {
                script_tag.onreadystatechange = null;
                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);
        // Call our main function
        main();
    }

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

    function main() {
        jQuery(document).ready(function ($) {

            /******* Load HTML *******/

            var jsonp_base_url = '//cf.nearsay.com/static/widget_sc_data/lvsc3db6a4b0';
            
            var date = new Date();
            var hours = date.getHours();
            var month = date.getMonth();
            var day = date.getDate();
            var year = date.getFullYear();
            var newdate = new Date(year, month, day, hours);
            unixstamp_of_the_hour = (newdate).getTime() / 1000 ;
            var jsonp_url = jsonp_base_url + '/' + unixstamp_of_the_hour;
            var widget_id = 'lvsc3db6a4b0';
            var callback = widget_id.replace(/[0-9]/g, ''); //no numbers... odd.
            $.ajax({
                dataType: 'jsonp',
                url: jsonp_url,
                jsonpCallback: callback,
                success: function (data) {
                    $('#lvsc3db6a4b0-outer').html(data.html);
                }
            });
            var height = $('#lvsc3db6a4b0').parent().height() - 2;
            $('#lvsc3db6a4b0-outer').css('height', height);
            $('#lvsc3db6a4b0-outer').css('overflow-y', 'auto');

        });

    }
      
})();
