﻿//    Jquery 浮动 v0.1
(function(){
	jQuery.fn.floats = function(s){
		var isHide = false;
		var _this = $(this);
		var opts = $.extend({close_element:null,callback:function(){},duration:800,bottom:0,queue:false},s);
		$(opts.close_element).click(function(){
			isHide = true;
			_this.fadeOut("slow",opts.callback);			  
		});
		_this.css({position:'absolute','z-index':10000});
		if($.browser.msie){
			$('<iframe style="width:100%;" scrolling="no" frameborder="0"></iframe>').appendTo(_this).css('opacity','0.0');
		}
		var initScroll = function(){
			//var offset = $(window).height() - _this.height() + $(document).scrollTop() - opts.bottom;
			var offset = $(document).scrollTop() + opts.bottom;
			_this.animate({top:offset},{duration:opts.duration,queue:opts.queue});
		}
		
		initScroll();
		if(isHide == false){
			//随滚动条
			$(window).scroll(initScroll);
		}
	}
})()
