            var start = chkboxes.indexOf(lastChecked);
                        var end = chkboxes.indexOf(this);

                        var positive = start < end;

                        for (var i = (positive ? start: end );
                        (positive ? i <= end : i <= start); i++) {
                            chkboxes[i].checked = lastChecked.checked;
                        }
                        lastChecked = null;
                    }
                    else {
                        l