$(function(){

    // Monitor all course inputs to see if they are ever marked as complete
    $('.assignment input:checkbox').live('click', function(){
        $(this).attr('disabled','true').closest('div').addClass('active');

        //Ajax call to set_complete URL
        $.post(link_url+'utils/get', {'data-url' : $(this).attr('data-url')}, function(data){
           //On success of AJAX, check if all boxes are checked, and if so, mark "Week X Complete" button           
            $courses = $('.assignment input:checkbox');
            if ($courses.length == $courses.filter(':checked').length){
                $('.fundamentals-ortho-buttons input:checkbox').attr('checked', true).attr('disabled','true');
            }
        });

    });

/********   Removed ability to mark entire week as completed

    // Monitor the overall week complete input, to see if anyone ever tries to mark the whole week as complete 
    $('.fundamentals-ortho-buttons input:checkbox').live('click', function(){
        $courses = $('.assignment input:checkbox');
        // Check if there are still incomplete courses
        if ($courses.length != $courses.filter(':checked').length){
            // If there are still incomplete courses, then make sure they want to mark everything complete
            if (confirm("This will mark every course, as well as the quiz, as completed. Proceed?")){
                $courses.each(function(){
                    if (!($(this).is(':checked'))) $(this).attr('checked',true).click();
                });
                $(this).attr('checked', true).attr('disabled','true');             
            } else {
            // If they dont want to mark everything complete, cancel the checkbox selection
                $(this).attr('checked', false);            
            }
        } else {
        // If there are no incomplete courses, just mark the box as checked, and disable it
            $(this).attr('disabled','true');        
        }
    });
    
*******************/

});

