/*!
* jQuery reflectStatusOn
* Examples and documentation at: ..
* Copyright (c) 2011 S. Hougaard, www.netsi.dk
* Version: 0.01 (2011-05-27)
* Dual licensed under the MIT and GPL licenses.
* http://jquery.malsup.com/license.html
* Requires: jQuery v1.3.1 or later
* Use: jQuer('#myCheckbox').reflectStatusOn('#no2checkbox, #no3Checkbox')
* What it does is bind the "checked" state of one checkbox to any number of checkboxes
*/


(function ($) {

    $.fn.reflectStatusOn = function (reflectOn, options) {

        var con = (typeof console != 'undefined') ? console : { 'log': function (s) { window.status = ''; } };
        var settings = {
            'inverse': false,
            'reflectCheckedOn': null // Not implemented
        };

        return this.each(function () {
            // If options exist, lets merge them
            // with our default settings
            if (options) {
                $.extend(settings, options);
            }
    
            // Tooltip plugin code here
            var $this = jQuery(this);
            if ($this.attr('type') === 'checkbox') {
                var $reflectOn = jQuery(reflectOn);
                $this.change(function () {
                    $reflectOn.data('checkedFromReflectStautsOn', true);
                    var bState = $this.attr('checked') == 'checked';
                    bState = (settings.inverse) ? !bState : bState;
                    $reflectOn.attr('checked', bState);
                    con.log('checked ' + bState + ' ' + $reflectOn.selector);
                    $reflectOn.trigger('change').find('label');
                });
                $reflectOn.add($this).trigger('change');


            };


        });

    };
})(jQuery);


