﻿/// <reference path="jquery-1.4.1-vsdoc.js" />

function initBackTop(imageUrl) {
    $(window).scroll(function (event) {
        var btnBackTop = $('#goTopButton');
        if ($(this).scrollTop() > 0) {
            if (btnBackTop.length == 0) {
                $(document.body).append("<img id=\"goTopButton\" style=\"position: fixed; right: 20px; bottom: 20px; cursor: pointer; display : none\" />");
                btnBackTop = $('#goTopButton');
                btnBackTop.attr("src", imageUrl);
                btnBackTop.click(function () {
                    $("html, body").animate({ scrollTop: 0 }, 1000);
                });
                if ($.browser.msie && $.browser.version < 7)
                    btnBackTop.css("position", "absolute");
            }
            if ($.browser.msie && $.browser.version < 7) {
                btnBackTop.css("top", $(this).scrollTop() + $(window).height() - 20 - btnBackTop.height());
            }
            btnBackTop.fadeIn(1000);
        } else
            btnBackTop.fadeOut(700);
    });
}
