
function moveRov() {
    var offset = $(window).scrollTop();
    if (offset < 150) {
        offset = 150;
    }
    
    if (Modernizr.csstransitions) {
        $('#rov-device').css('top', offset);
    } else {
        $('#rov-device').stop().animate({top: offset}, 5000);
    }
}

$(function() {

    $(window).load(function() {

        if ($(window).width() > 800) {
            $('<div id="rov-device"></div>').appendTo('#sea-content');
            moveRov();
            $(window).bind('scrollstop', function() {
                moveRov();
            });
        }

        $('a[href*=#]').each(function() {
            var path = $(this).attr('href'),
                target = path.substr(path.indexOf('#'))
            ;
            if ($(target).length > 0) {
                var offset = $(target).offset().top;
                $(this).click(function(event) {
                    event.preventDefault();
                    $('html,body').stop().animate(
                        {scrollTop: offset}, 1000, 'easeInOutQuint',
                        function() {
                            location.hash = target;
                        }
                    );
                });
            }
        });
    });

});

