(function () {
  var checkVersion = function (slug, version) {
    var versionURL = ["//readthedocs.org/api/v1/version/", slug,
                      "/highest/", version, "/?callback=?"].join("");

    $.getJSON(versionURL, onData);

    function onData (data) {
      if (data.is_highest) {
        return;
      }

      var currentURL = window.location.pathname.replace(version, data.slug),
          warning = $('<div class="admonition note"> <p class="first \
                       admonition-title">Note</p> <p class="last"> \
                       You are not using the most up to date version \
                       of the library. <a href="#"></a> is the newest version.</p>\
                       </div>');

      warning
        .find('a')
        .attr('href', currentURL)
        .text(data.version);

      $("div.body").prepend(warning);
    }

  };

  var getVersions = function (slug, version) {
    var versionsURL = ["//readthedocs.org/api/v1/version/", slug,
                       "/?active=True&callback=?"].join("");

    return $.getJSON(versionsURL, gotData);

    function gotData (data) {
      var items = $('<ul />')
        , currentURL
        , versionItem
        , object

      for (var key in data.objects) {
        object = data.objects[key]
        currentURL = window.location.pathname.replace(version, object.slug)
        versionItem = $('<a href="#"></a>')
          .attr('href', currentURL)
          .text(object.slug)
          .appendTo($('<li />').appendTo(items))
      }

      // update widget and sidebar
      $('#version_menu, .version-listing, #sidebar_versions').html(items.html())
    }
  };

  $(function () {
    // Code executed on load
    var slug = window.doc_slug,
        version = window.doc_version;

    // Show action on hover
    $(".module-item-menu").hover(
      function () {
        $(".hidden-child", this).show();
      }, function () {
        $(".hidden-child", this).hide();
      }
    );

    checkVersion(slug, version);
    getVersions(slug, version);


  });

})();

/*
 * Grok the Docs event handling
 * This will allow you to better 
 * understand whats happening in your docs,
 * once fully rolled out.
*/


$(document).ready(function () {

  // Page-level variables
  var gtd_project = doc_slug
  var gtd_version = doc_version
  if (typeof page_name != "undefined") {
      var gtd_page = page_name
  } else {
      var gtd_page = null
  }

  $(window).bind('hashchange', function(ev) {
    // Element-level variables
    var element = document.getElementById((window.location.hash || '').slice(1))
    var id = element.id
    if (typeof element.hash != "undefined") {
        var hash = element.hash
    } else {
      var hash = null
    }
    logHashChange(gtd_project, gtd_version, gtd_page, id, hash);
  });

  $("a.rtd-badge.rtd").hover(
    function (ev) { 
      logHover(gtd_project, gtd_version, gtd_page);
    },
    function (ev) {
      // We only want hover in  
    }
  )

});

function logHover(project, version, page) {
  $.ajax({
    type: 'POST',
    url: '//api.grokthedocs.com/api/v1/actions/',
    crossDomain: true,
    data: {
      project: project,
      version: version,
      page: page,
      url: window.location.href,
        type: "iconhover"
    },
    success: function(data, textStatus, request) {
      console.log("Sent Icon hover data")
    },
    error: function(request, textStatus, error) {
      console.log("Error sending Icon hover data")
    }
  });
}

function logHashChange(project, version, page, id, hash) {
  $.ajax({
    type: 'POST',
    url: '//api.grokthedocs.com/api/v1/actions/',
    crossDomain: true,
    data: {
      project: project,
      version: version,
      page: page,
      object_slug: id,
      hash: hash,
      url: window.location.href,
        type: "hashchange"
    },
    success: function(data, textStatus, request) {
      console.log("Sent hash change data")
    },
    error: function(request, textStatus, error) {
      console.log("Error sending hash change data")
    }
  });
}

@@ -2201,876 +2201,22 @@
 %0A%0A%0A$
-(document).ready(function () %7B%0A%0A  // Page-level variables%0A  var gtd_project = doc_slug%0A  var gtd_version = doc_version%0A  if (typeof page_name != %22undefined%22) %7B%0A      var gtd_page = page_name%0A  %7D else %7B%0A      var gtd_page = null%0A  %7D%0A%0A  $(window).bind('hashchange', function(ev) %7B%0A    // Element-level variables%0A    var element = document.getElementById((window.location.hash %7C%7C '').slice(1))%0A    var id = element.id%0A    if (typeof element.hash != %22undefined%22) %7B%0A        var hash = element.hash%0A    %7D else %7B%0A      var hash = null%0A    %7D%0A    logHashChange(gtd_project, gtd_version, gtd_page, id, hash);%0A  %7D);%0A%0A  $(%22a.rtd-badge.rtd%22).hover(%0A    function (ev) %7B %0A      logHover(gtd_project, gtd_version, gtd_page);%0A    %7D,%0A    function (ev) %7B%0A      // We only want hover in  %0A    %7D%0A  )%0A%0A%7D);%0A%0Afunction logHover(project, version, page) %7B%0A  $.ajax(%7B%0A    type: 'POST',%0A    
+.ajax(%7B%0A
 url: 
-'
+%22
 //ap
@@ -2237,969 +2237,78 @@
 com/
-api/v1/actions/',%0A    crossDomain: true,%0A    data: %7B%0A      project: project,%0A      version: version,%0A      page: page,%0A      url: window.location.href,%0A        type: %22iconhover%22%0A    %7D,%0A    success: function(data, textStatus, request) %7B%0A      console.log(%22Sent Icon hover data%22)%0A    %7D,%0A    error: function(request, textStatus, error) %7B%0A      console.log(%22Error sending Icon hover data%22)%0A    %7D%0A  %7D);%0A%7D%0A%0Afunction logHashChange(project, version, page, id, hash) %7B%0A  $.ajax(%7B%0A    type: 'POST',%0A    url: '//api.grokthedocs.com/api/v1/actions/',%0A    crossDomain: true,%0A    data: %7B%0A      project: project,%0A      version: version,%0A      page: page,%0A      object_slug: id,%0A      hash: hash,%0A      url: window.location.href,%0A        type: %22hashchange%22%0A    %7D,%0A    success: function(data, textStatus, request) %7B%0A      console.log(%22Sent hash change data%22)%0A    %7D,%0A    error: function(request, textStatus, error) %7B%0A      console.log(%22Error sending hash change data%22)%0A    %7D%0A  %7D);%0A%7D%0A
+static/client.js%22,%0AcrossDomain: true,%0AdataType: %22script%22,%0Acache: true,%0A%7D);

Load the script dynamic-like