(function($) { 
	$.fn.jFloat = function(o) {
		o = $.extend({
            top:60,  //广告距页面顶部距离
            left:0,//广告左侧距离
            right:0,//广告右侧距离
            width:100,  //广告容器的宽度
            height:110, //广告容器的高度
            minScreenW:800,//出现广告的最小屏幕宽度，当屏幕分辨率小于此，将不出现对联广告
            position:"left", //对联广告的位置left-在左侧出现,right-在右侧出现
            allowClose:true //是否允许关闭 
		}, o || {});
		var h=o.height;
		var showAd=true;
		var fDiv=$(this);
		var closeHtml = '';
		if(o.minScreenW>=$(window).width()){
			fDiv.hide();
			showAd=false;
		}else{
		   fDiv.css("display","block")
           var closeHtml='<div align="right" style="background:#CCD0D3;padding:2px;z-index:2000;cursor:pointer;line-height:10px;font-size:10px;" class="closeFloat">' +
           		'	<span style="height:10px;display:block;color:#000;">×关闭</span>' +
           		'</div>';
           switch(o.position){
               case "left":
                    if(o.allowClose){
                       fDiv.prepend(closeHtml);
					   $(".closeFloat",fDiv).click(function(){$(this).hide();fDiv.hide();showAd=false;})
					   h+=10;
					}
                    fDiv.css({position:"absolute",left:o.left+"px",top:o.top+"px",width:o.width+"px",height:h+"px",overflow:"hidden"});
                    break;
               case "right":
                    if(o.allowClose){
                       fDiv.prepend(closeHtml)
					   $(".closeFloat",fDiv).click(function(){$(this).hide();fDiv.hide();showAd=false;})
					   h+=10;
					}
                    fDiv.css({position:"absolute",left:"auto",right:o.right+"px",top:o.top+"px",width:o.width+"px",height:h+"px",overflow:"hidden"});
                    break;
            };
        };
		function ylFloat(){
            if(!showAd){return}
            var windowTop=$(window).scrollTop();
            if(fDiv.css("display")!="none")
				fDiv.css("top",o.top+windowTop+"px");
		};
		$(window).scroll(ylFloat) ;
		$(document).ready(ylFloat);     
	}; 
})(jQuery);
