$(function (){
    function timerhomepage() {
        var now = new Date();
        var eventDate = new Date($(".timer-countdown").data("date"));
        var currentTime = now.getTime();
        var evenTime = eventDate.getTime();
        var remTime = evenTime - currentTime;
        var sec = Math.floor(remTime / 1000);
        var min = Math.floor(sec / 60);
        var hur = Math.floor(min / 60);
        var day = Math.floor(hur / 24);

        hur %= 24;
        min %= 60;
        sec %= 60;

        if (hur < 0 && min < 0 && sec < 0) {
            $('.timer-countdown').hide();
            return false;
        }

        day = (day < 10) ? '0' + day : day;
        hur = (hur < 10) ? '0' + hur : hur;
        min = (min < 10) ? '0' + min : min;
        sec = (sec < 10) ? '0' + sec : sec;

        $('.seconds-digit').text(sec);
        $('.minutes-digit').text(min);
        $('.hours-digit').text(hur);
        $('.days-digit').text(day);

        setTimeout(timerhomepage, 1000);
    }

    timerhomepage();
});
