
   function rs() {}
   
   var start;
   var startMargin;
   
   var scrolled = false;
   var hide = false;
   var active = 0;
   
   var showImages = function() {
     var count = Math.ceil($("#l-container").width() / 50)+1;
     var start = Math.floor(Math.abs(parseInt($("#tape").css('marginLeft')) / 50))-1;          
     for (var i = start; i<start+count;i++) {
       var img = $("#tape img:eq("+i+")");       
       img.attr('src',img.data('source'));                
     }
   }
   
   var setMargin = function(margin) {
     margin = Math.min(margin, 0);
     margin = Math.max($("#l-container").width()-$("#tape img").length * 50 + 6, margin);
     $("#tape").css('marginLeft', margin+'px');
     showImages();
   }
   
   var getActive = function(x) {
     var leftOffset = ($("body").width() - $("#l-container").width()) / 2;
     if (leftOffset < 0) leftOffset = 0;
     x = x - leftOffset;
     return Math.floor( (x - parseInt($("#tape").css('marginLeft'))) / 50 );
   }
   
   var move = function(e) {
     var newX = e.clientX;
     var margin = startMargin;
     margin += newX - start;   
     setMargin(margin);  
     e.stopPropagation();
     e.preventDefault();
   }  
   
   
   
   $(function(){
     $("#scroll").mousemove(function(e){       
       $("#scroll").attr('title', $("#tape img:eq("+getActive(e.clientX)+")").attr('title'));          
     });
     $("#scroll").mouseover(function(){
       $("#tape img").css('opacity',1);
       hide = false;
     }).mouseout(function(){
       if (!scrolled) { 
         $("#tape img").css('opacity',0.4);
         $("#tape img:eq("+active+")").css('opacity',1);
         hide = false;
       }
       hide = true;     
     });   
     
     $("#scroll").mousedown(function(e){
       start = e.clientX;
       startMargin = parseInt($("#tape").css('marginLeft'));
       scrolled = true;
       $(document).bind('mousemove',move);
       $("#scroll").css('cursor','move');
       e.stopPropagation();
       e.preventDefault();
       $(document).one('mouseup',function(e){
         if (hide) {
           $("#tape img").css('opacity',0.4);
           hide = false;
         }
         scrolled = false;
         $(document).unbind('mousemove',move);
         $("#scroll").css('cursor','pointer');
         var stop = e.clientX;       
         if (stop == start) {                    
             location.href = $("#tape img:eq("+getActive(stop)+")").attr('longdesc'); 
         }              
       });
     }).css('cursor','pointer');
     
     var i = $("#tape img[longdesc='']");
     
     while (i.prev().length != 0) {
       active++;
       i = i.prev();
     }     
     $("#tape img").each(function(){
       $(this).data('source',$(this).attr('src'))              
              .css('width','50px')
              .css('height','50px').attr('width',50).attr('height',50);
       if (!$.browser.mozilla) {
         $(this).attr('src','none');
       }
     });
     $("#tape img:eq("+active+")").css('opacity',1);                
     setMargin(-50*active + $("#l-container").width()/2);
   });

