$(document).ready(function (e) {


    // ******************************************* 
    // ************* AUTO SCROLLING ************** 
    // ******************************************* 
    // This is a functions that scrolls to #{blah}link
    function goToByScroll(id) {
        // Remove "link" from the ID
        id = id.replace("link", "");
        // Scroll
        $('html,body').animate({
            scrollTop: $("#" + id).offset().top
        },
        2000);
    }

    // Call the scroll function
    // goToByScroll($('#hpCurrent').attr("id"));


    var me;
    $('.toggle-box').hover(
            function () {
                me = $(this);
                me.css('cursor', 'pointer');
                me.fadeTo(100, 1);
            },
                    function () {
                        me.fadeTo(100, 0.8);
                    }
            );

    // hide early morning rows
    var noReserveInMorning = true;
    $(".cancelTimeSlotGridCells").each(function () {
        var cell = $(this);
        if (cell.parent().is('#morning-time')) {
            $('#early-morning-toggle').attr('disabled', true);
            $('#early-morning-toggle').attr("title", "Can't hide as there are reservations in early morning times");
            noReserveInMorning = false;
            return false;
        }
        else {
        }

    });

    if (noReserveInMorning) {
        $("tr[id$='morning-time']").hide();
    }

    $('#early-morning-toggle').click(function (e) {
        if (noReserveInMorning) {

            if ($("tr[id$='morning-time']").css('display') == 'none') {
                $("tr[id$='morning-time']").fadeIn('fast');
                $('#toggle-box-icon').attr('src', 'images/advrmv.png');
            }
            else {
                $("tr[id$='morning-time']").fadeOut('fast');
                $('#toggle-box-icon').attr('src', 'images/advadd.png');

            }
        }

    });

});
