// The credits below were as found.
// I tried to find the original owner but to no avail.
// Credits:
// "whole credits are devoted to orignal author"
var gototoptype = -1;
var gototopinterval = 0;

function goto_top_timer() {
    var y = (gototoptype == 1) ? document.documentElement.scrollTop : document.body.scrollTop;

    var moveby = 15; // set this to control scroll seed. minimum is fast

    y -= Math.ceil(y * moveby / 100);
    if (y < 0)
        y = 0;

    if (gototoptype == 1)
        document.documentElement.scrollTop = y;
    else
        document.body.scrollTop = y;

    if (y == 0) {
        clearInterval(gototopinterval);
        gototopinterval = 0;
    }
}

function goto_top()
{
    if (gototopinterval == 0)
    {
        if (document.documentElement && document.documentElement.scrollTop)
            gototoptype = 1;
        else if (document.body && document.body.scrollTop)
            gototoptype = 2;
        else
            gototoptype = 0;

        if (gototoptype > 0)
            gototopinterval = setInterval('goto_top_timer()', 25);
    }
}

