

var Projects = {

  'navigations_punkte': false,

  'alle_projekte': false,
 
  'current_filter': false,

  'delay': 500, //milliseconds

  'init': function() {
  
    Projects.navigations_punkte = $$('#projekt_subnavi li a')
  
    Projects.alle_projekte = $$('#articleMedia .thumb');
  
  
    Projects.navigations_punkte.each(function(item) {
      item.observe('click', function(event) {
        
        
        var category = ""+this.classNames();
        category = category.replace('active', '').strip();
        
        $('content').addClassName('moving');
        
        Projects.filter_by( category );  
        
        Projects.highlight_current(event.currentTarget);
            
        event.stop();
        
      });//observe
    });//each
    
  },//init()


  'highlight_current': function(item) {
  
    Projects.navigations_punkte.each(function(npunkt) {
      npunkt.removeClassName('active');
    });
  
    item.addClassName('active');  
    
  },//highlight_current()


  'filter_by': function(category) {
  
    if (Projects.current_filter !== category) {
  
      Projects.current_filter = category;

      Projects.hide_all_projects();

      window.setTimeout(Projects.show_all_projects_with_current_filter, Projects.delay);

        
    }//if
    
  },//filter_by()


  'hide_all_projects': function() {
  
    Projects.alle_projekte.each( function(project) {
      project.hide();
    });
    
    $('loading').show();
  
  },//hide_all_projects()


  'show_all_projects_with_current_filter': function() {
  
      $('loading').hide();
      
      Projects.alle_projekte.each( function(project) {
      
        if (project.hasClassName(Projects.current_filter))
          project.show();
        
      });
      
      $('content').removeClassName('moving');
  
  }//show_all_projects_with_current_filter()


}//Projects




document.observe("dom:loaded", function() {
  
  Projects.init();

});//document.observe