﻿$(document).ready(function () {   
    /********************** Top of page */

    $(".topofpage").click(function (e) {
        e.preventDefault();
        var top = $("#top").offset().top - 30;
        var page = ($.browser.safari) ? $('body') : $('html');
        page.animate({ scrollTop: top }, 1000, "swing");
    });

    /********************** Bottom of page */

    $(".bottomofpage").click(function (e) {
        e.preventDefault();
        var viewportHeight = 0;
        // Mozilla , Netscape
        if (typeof window.innerHeight != 'undefined') {
            viewportHeight = window.innerHeight;
        }
        // IE
        else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientHeight != 'undefined' && document.documentElement.clientHeight != 0) {
            viewportHeight = document.documentElement.clientHeight
        }
        // Old IE :(
        else {
            viewportHeight = document.getElementsByTagName('body')[0].clientHeight;
        }
        var bottom = document.getElementById('MasterContainer').clientHeight - viewportHeight - 30;
        var page = ($.browser.safari) ? $('body') : $('html');
        page.animate({ scrollTop: bottom }, 1000, "easeOutSine");
    });
});