﻿(function($) { $.fn.jFloat = function(o) { o = $.extend({ top: 60, left: 0, right: 0, width: 100, height: 360, minScreenW: 1024, position: "left", 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;border-bottom:1px solid #f1f1f1; height:18px;" class="closeFloat"><span style="border:1px solid #000;height:18px;display:block;width:18px; background-color:#E6E6E6;font-size:25px; line-height:18px;text-align:center;">×</span></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.prepend(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"); } }; $(window).scroll(ylFloat); $(document).ready(ylFloat); }; })(jQuery);

