// FilterControl
Emerson.FilterControl = function() {}

// Subclass standard GControl
Emerson.FilterControl.prototype = new GControl();

Emerson.FilterControl.prototype.initialize = function(map) {
  var container = document.createElement("div");
  $(container).addClass('filter');

  $.each('Audio Photo Text Video'.split(' '), function(index, type) {
    var checkbox = $(
      '<div><label class="'+type+'"><input type="checkbox" value="' + type.substr(0,1) + '" checked="checked" />' + 
        type + 
      '</label></div>'
    );
    
    checkbox.find('input').click(function() {
      var $$ = $(this);
      Emerson.filters.set($$.val(), $$.attr('checked'));
      Emerson.applyFilters();
    });
    
    container.appendChild(checkbox[0]);
  });
  
      
  // add control to the map
  map.getContainer().appendChild(container);
  
  // listen for zoom events, and re-apply the filter
  // after a zoom
  GEvent.addListener(map, 'zoomend', function(old, current) {
    setTimeout('Emerson.applyFilters()', 100);
  });
  
  return container;      
}

Emerson.FilterControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7));
}

