var FeatureControl = Behavior.create({
  initialize: function() {
    this.link = this.element;
    this.link.observe('click', this.updateFeature.bind(this)); 
  },
  
  updateFeature: function(event) {
    event.stop();
    this.deselectLinks();
    this.selectLink();
    this.hideFeatures();
    this.showFeature();
  },
  
  deselectLinks: function() {
    this.link.up().down('a.selected').removeClassName('selected');
  },
  
  selectLink: function() {
    this.link.addClassName('selected'); 
  },
  
  hideFeatures: function() {
    this.link.up("#featured_remix").select('.feature').each(function(feature){ 
      feature.hide();
    });
  },
  
  showFeature: function() {
    var targetId = this.link.getAttribute('data-target');
    this.link.up("#featured_remix").down("#"+targetId).show();
  }
});

Event.addBehavior ({
  'body.home.index #featured_remix .sub_header a': FeatureControl
});