﻿;if(typeof(jQuery)!="undefined")
{
   jQuery.fn.extend({
         scrollFollow:function (opts){
           var os=this;
           var duration=200;
           var offset=200;           
           if(opts)
           {
               if(!isNaN(opts.duration))
               {
                   duration=parseInt(opts.duration);
               }
               if(!isNaN(opts.offset))
               {
                   offset=parseInt(opts.offset);
               }
           }
           os.each(function (){
               var o=$(this);
               o.css("position","absolute").appendTo("body");
           });
           $(window).scroll(function (){
                var scrollPos; 
	            if (typeof window.pageYOffset != 'undefined') { 
		            scrollPos = window.pageYOffset; 
	            } 
	            else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') { 
		            scrollPos = document.documentElement.scrollTop; 
	            } 
	            else if (typeof document.body != 'undefined') { 
		            scrollPos = document.body.scrollTop; 
	            }
	            os.stop();
               os.each(function (){
                   var o=$(this);
                   o.animate({"right":0,"top":offset+scrollPos},duration);
               });
           });
          
           return this;
       }
   });
}
document.writeln("<style type=\"text\/css\">#qq{ background:none; width:auto; height:auto;position: absolute; top: 102px; right: 0px;}<\/style>");
$(function(){$("#qq").scrollFollow({speed:200,offset:100});})

