
(function($) { 
    $.fn.jFloat = function(o) {
    
        o = $.extend({
            top:60,  //����ҳ�涥������
            left:0,//���������
            right:0,//����Ҳ����
            width:100,  //�������Ŀ��
            height:360, //�������ĸ߶�
            minScreenW:800,//���ֹ�����С��Ļ��ȣ�����Ļ�ֱ���С�ڴˣ��������ֶ�j���
            position:"left", //��j����λ��left-��������,right-���Ҳ����
            allowClose:true //�Ƿ�����ر� 
        }, o || {});
		var h=o.height;
      var showAd=true;
      var fDiv=$(this);
      if(o.minScreenW>=$(window).width()){
          fDiv.hide();
          showAd=false;
       }
       else{
		   fDiv.css("display","block")
           var closeHtml='<div align="right" style="padding:2px;z-index:2000;font-size:12px;cursor:pointer;height:11px;" class="closeFloat"><div id="closeFloat" style="background:url(/static/site4/images/closeButton.png);height:12px;display:block;width:12px;margin-top:-30px;position:relative;margin-right:7px; overflow:hidden"></div></div>';
           switch(o.position){
               case "left":
                    if(o.allowClose){
                       fDiv.prepend(closeHtml);
					   $("#closeFloat",fDiv).click(function(){$(this).hide();fDiv.hide();showAd=false;})
					   h+=20;
					}
                    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.append(closeHtml)
					   $(".closeFloat",fDiv).click(function(){$(this).hide();fDiv.hide();showAd=false;})
					   h+=20;
					}
                    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");
               $(fDiv).stop().animate({'top':o.top+windowTop+'px'},200); 

        };

      $(window).scroll(ylFloat) ;
      $(document).ready(ylFloat);     
       
    }; 
})(jQuery);







