/**
 * handles select visibility helper
 */
jQuery.fn.selectVisibility = function(s) {
  return this.each(function() {
    var element = $(this);
    var form = element.parents('form:first');
    
    if (!form.length) {
      return false;
    } // if
    
    element.change(function () {      
      // update select assignees
      form.find('div.select_asignees').each(function () {
        this.filterByVisibility(element.val());
      });
      
      // update select subscribers
      form.find('select.select_subscribers').each(function () {
        this.filterByVisibility(element.val());
      });
    });
    
    // refresh picker if exists
    setTimeout(function () {
      element.change();
    }, 100);
  });
};