(function () { var special = jQuery.event.special, uid1 = 'D' + (+new Date()), uid2 = 'D' + (+new Date() + 1); special.scrollstart = { setup: function () { var timer, handler = function (evt) { var _self = this, _args = arguments; if (timer) { clearTimeout(timer) } else { evt.type = 'scrollstart'; jQuery.event.handle.apply(_self, _args) } timer = setTimeout(function () { timer = null }, special.scrollstop.latency) }; jQuery(this).bind('scroll', handler).data(uid1, handler) }, teardown: function () { jQuery(this).unbind('scroll', jQuery(this).data(uid1)) } }; special.scrollstop = { latency: 100, setup: function () { var timer, handler = function (evt) { var _self = this, _args = arguments; if (timer) { clearTimeout(timer) } timer = setTimeout(function () { timer = null; evt.type = 'scrollstop'; jQuery.event.handle.apply(_self, _args) }, special.scrollstop.latency) }; jQuery(this).bind('scroll', handler).data(uid2, handler) }, teardown: function () { jQuery(this).unbind('scroll', jQuery(this).data(uid2)) } } })(); function floatMenu(name) { var menuTop = null; var menuBottom = null; var menuTopDefault = null; var menuSize = parseInt($(name).offset().top) + parseInt($(name).height()) + 50; var footer = parseInt($("#footer").offset().top); if (menuSize < footer) { $(name).css("position", "absolute"); $(name).css("top", "10px"); menuTopDefault = $(name).offset().top; menuBottom = parseInt($(name).offset().top + $(name).height() + 50); menuTop = parseInt($(name).css("top").substring(0, $(name).css("top").indexOf("px"))); (function () { jQuery(window).bind('scrollstop', function () { try { if ($(document).scrollTop() > menuBottom) { var offset = parseInt($(document).scrollTop()); offset = offset - parseInt(menuTopDefault); offset = offset + 30; if ((offset + menuTopDefault + parseInt($(name).height())) > parseInt($("#footer").offset().top)) { offset = (parseInt($("#footer").offset().top) - parseInt($(name).height()) - menuTopDefault - 30) } offset = offset + "px"; $(name).animate({ top: offset }, { duration: 500, queue: false }) } else { $(name).animate({ top: "10px" }, { duration: 500, queue: false }) } } catch (error) { } }) })() } }
