jQuery(document).ready( function (jQuery) { var stt = jQuery('#scrolltobottom'); var stb = jQuery('#scrolltotop'); stt.css('opacity', 1); var scrollBottom = 0; //=================================================================== jQuery(window).load(function (event, ui) { if (typeof (event) == 'undefined') return; scrollBottom = jQuery(window).scrollTop(0); var v_max = jQuery("#the_page").height(); //=================================================================== jQuery(window).scroll(function () { scrollBottom = jQuery(window).scrollTop(); v_max = jQuery("#the_page").height() - jQuery(window).height(); if (scrollBottom > 100) { if (stt.css('opacity') == 0) { stt.stop().fadeTo(1000, 1); } } if (scrollBottom > v_max - 100) { if (stb.css('opacity') == 0) { stb.stop().fadeTo(1000, 1); } } return; if (scrollBottom < v_max) { if (stb.css('opacity') > 0) { stb.stop().fadeTo(1000, 0); stb.css("display", "none"); } } else { if (stb.css('opacity') == 0) { stb.stop().fadeTo(1000, 1); stb.css("display", "block"); } } //========================================= if (scrollBottom < v_max) { if (stt.css('opacity') == 0) { stt.stop().fadeTo(1000, 1); stt.css("display", "block"); } } else { if (stt.css('opacity') > 0) { stt.stop().fadeTo(1000, 0); stt.css("display", "none"); } } }); }); jQuery('#scrolltobottom a').click(function () { pos = jQuery('#the_page').outerHeight(); jQuery('html, body').animate({ scrollTop: pos + 'px' }, 1000, function () { stt.stop().fadeTo(1000, 0); stb.stop().fadeTo(1000, 1); }); }); jQuery('#scrolltotop a').click(function () { pos = 0; jQuery('html, body').animate({ scrollTop: pos + 'px' }, 1000, function () { stb.stop().fadeTo(1000, 0); stt.stop().fadeTo(1000, 1); }); }); function gotoPos(pos) { jQuery('html, body').animate({ scrollTop: jQuery('body').outerHeight() + 'px' }, 0, function () { scrollBottom = jQuery(window).scrollTop(); }); return false; } //=================================================================== // jQuery(window).resize(); jQuery(window).scroll(); }); //=========================================================