// Scroll to anchor
$(function () {
    $('ul.nav a').bind('click', function (event) {
        var $anchor = $(this);

        $('html, body').stop().animate({
            scrollTop: $($anchor.attr('href')).offset().top
        }, 2000, 'easeInOutExpo');
        event.preventDefault();
    });
});


// Portfolio Open
$(function () {
    $('#btPortfolio').click(function () {
        $('#portfolio').show();
        setTimeout(

        function () {
            $('html, body').animate({
                scrollTop: 1455
            }, 500);
        }, 500);
    });
});

$(function () {
    $('#btPortfolio2').click(function () {
        $('#portfolio').slideDown(1000);
        setTimeout(

        function () {
            $('html, body').animate({
                scrollTop: 1455
            }, 500);
        }, 100);
    });
});


// Endless Scroll
$(window).scroll(function () {
    if ($(window).scrollTop() + 10 >= ($(document).height() - ($(window).height()))) {
        $('html, body').animate({
            scrollTop: 0
        }, 0);
    }
});


// Floating Nav
var name = "#floatMenu";
var menuYloc = null;

$(document).ready(function () {
    menuYloc = parseInt($(name).css("top").substring(0, $(name).css("top").indexOf("px")))
    $(window).scroll(function () {
        offset = menuYloc + $(document).scrollTop() + "px";
        $(name).animate({
            top: offset
        }, {
            duration: 500,
            queue: false
        });
    });
});
