$(document).ready(function () {

    setInterval(function () {
        var seconds = new Date().getSeconds();
        var sdegree = seconds * 6;
        var srotate = "rotate(" + sdegree + "deg)";

        $("#sec").css({ "-moz-transform": srotate, "-webkit-transform": srotate });

    }, 1000);


    setInterval(function () {
        var hours = new Date().getHours();
        var mins = new Date().getMinutes();
        var hdegree = hours * 30 + (mins / 2);
        var hrotate = "rotate(" + hdegree + "deg)";

        $("#hour").css({ "-moz-transform": hrotate, "-webkit-transform": hrotate });

    }, 1000);


    setInterval(function () {
        var mins = new Date().getMinutes();
        var mdegree = mins * 6;
        var mrotate = "rotate(" + mdegree + "deg)";

        $("#min").css({ "-moz-transform": mrotate, "-webkit-transform": mrotate });

    }, 1000);

    if ($(document).width() > 500) {
        skrollr.init({
            smoothScrolling: true,
            smoothScrollingDuration: 500
        });
    }


});

$(function () {
    $('#foo4').carouFredSel({
        auto: 5000,
        pagination: "#pager2",
        mousewheel: true,
        swipe: {
            onMouse: true,
            onTouch: true
        },
        scroll: {
            fx: "crossfade",
            items: 1,
            //duration        : 5000,
            onBefore: function (data) {
                //unhighlight(data.items.old);
            },
            onAfter: function (data) {
                $('#foo4 .caption-box a').removeClass('active');
                $(data.items.visible).find('.caption-box a').addClass('active');
            }
        }

    });
    $('#foo4 .caption-box a:first').addClass('active');
});
new mlPushMenu(document.getElementById('mp-menu'), document.getElementById('trigger'));

$('*[data-src]').hide();

$(window).on('load', function () {
    $('*[data-src]').each(function () {
        $(this).attr('src', $(this).data('src'));
        if ($(this).prop("tagName") == 'EMBED') {
            $(this).show();
        }
        else {
            $(this).on('load', function () {
                $(this).fadeIn();
            });
        }
    });
});

$(document).ready(function () {
    $('.main-menu a[href*=#]:not([href=#])').click(function () {
        if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
            var target = $(this.hash);
            var _X = $(target).data('start');
            target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
            if (target.length) {
                $('html,body').animate({
                    scrollTop: _X //target.offset().top + 2000
                }, 1);
                //return false;
            }
        }
    });
    $(window).scroll(function () {
        clearTimeout($.data(this, 'scrollTimer'));
        $.data(this, 'scrollTimer', setTimeout(function () {
            setCurrentActive();            
        }, 1000));
    });
    function setCurrentActive() {
        $('.main-menu li').removeClass('active');
        var _current = $('section').filter(function () {
            return ($(this).offset().left + $(this).width()) > 0;
        }).eq(0);
        $('[href*=' + $(_current).attr('id') + ']').parent().addClass('active');
    }
});