$(function() {
    var topDistance = 450;
    var showDistance = 1;
    var gotopCon = "<div class='go-top'><a href='#'><img src='images/gotop.gif' /></a></div>"
    var thisTop = $(window).scrollTop() + topDistance;
    $("body").css("position", "relative");
    $("body").append(gotopCon);
    $(".go-top").css("top", thisTop);
    if ($(window).scrollTop() < showDistance) {
        $(".go-top").hide();
    }
    $(window).scroll(function() {
        thisTop = $(this).scrollTop() + topDistance;
        $(".go-top").css("top", thisTop);
        if ($(this).scrollTop() < showDistance) {
            $(".go-top").fadeOut("fast")
        } else {
            $(".go-top").fadeIn("fast")
        }
    });
    $("a", ".go-top").click(function() {
        $("html").animate({
            scrollTop: 0
        },
        "fast");
        $("body").animate({
            scrollTop: 0
        },
        "fast");
        return false
    })
});
