Index: apachesolr_ajax.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr_ajax/apachesolr_ajax.js,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 apachesolr_ajax.js
--- apachesolr_ajax.js  24 Jan 2011 04:24:31 -0000      1.1.2.4
+++ apachesolr_ajax.js  24 Jan 2011 04:44:13 -0000
@@ -6,14 +6,33 @@ Drupal.behaviors.apachesolr_ajax = funct
     var content = Drupal.settings.apachesolr_ajax.content;
     var regions = Drupal.settings.apachesolr_ajax.regions;
     var spinner = Drupal.settings.apachesolr_ajax.spinner;
+    var target  = Drupal.settings.apachesolr_ajax.target;
 
     function apachesolr_ajax_url_to_state(url) {
       return url.replace(/http:\/\/[^\/]+/, '').replace(/\/?search\/apachesolr_\w+/, '');
     }
 
     function apachesolr_ajax_request_callback(state) {
-      if (spinner) {
-        $(content).html($('<img/>').attr('src', spinner));
+      if (spinner && content) {
+        $(content).html('<div id="apachesolr-ajax-spinner-container"><img src="' + spinner + '" class="apachesolr-ajax-spinner" /></div>');
+      }
+      if (target) { // taken from views/js/ajax_view.js
+        // Scroll to the top of the view. This will allow users
+        // to browse newly loaded content after e.g. clicking a pager
+        // link.
+        var offset = $(target).offset();
+        // We can't guarantee that the scrollable object should be
+        // the body, as the view could be embedded in something
+        // more complex such as a modal popup. Recurse up the DOM
+        // and scroll the first element that has a non-zero top.
+        var scrollTarget = target;
+        while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).parent()) {
+          scrollTarget = $(scrollTarget).parent()
+        }
+        // Only scroll upward
+        if (offset.top - 10 < $(scrollTarget).scrollTop()) {
+          $(scrollTarget).animate({scrollTop: (offset.top - 10)}, 500);
+        }
       }
       $.post('/search/apachesolr_ajax' + state, {}, apachesolr_ajax_response_callback, 'json');
     }
@@ -84,7 +103,7 @@ Drupal.behaviors.apachesolr_ajax = funct
 
     if (Drupal.apachesolr) {
       if (Drupal.apachesolr.addCheckbox) {
-        Drupal.apachesolr.addCheckbox = function() {
+        Drupal.apachesolr.addCheckbox = function() { // taken from apachesolr.js
           // Put href in context scope to be visible in the anonymous function.
           var href = $(this).attr('href');
           $(this).before($('<input type="checkbox" />')
@@ -97,7 +116,7 @@ Drupal.behaviors.apachesolr_ajax = funct
       }
 
       if (Drupal.apachesolr.makeCheckbox) {
-        Drupal.apachesolr.makeCheckbox = function() {
+        Drupal.apachesolr.makeCheckbox = function() { // taken from apachesolr.js
           // Create a checked checkbox.
           var checkbox = $('<input type="checkbox" />')
             .attr('class', 'facet-checkbox')