;(function($) {
  var app = new Sammy.Application(function() { with(this) {
    var $title = $('title').text();

    bind('run', function() {

      $('.page').hide();
      $('.page:first').show();

      $('.page').hover(function(){
        if($(this).attr('id') != 'treten-sie-ein'){
          $(this).find('.bild').css({cursor:'pointer'}).fadeOut(1200);
        }
      },function(){
        $(this).find('.bild').fadeIn('slow');
      });
      if($('#tooltips li').length > 0){
        $('#tooltips li').each(function(){
          var text = $(this).text();
          $(this).simpletip({
            content: text,
            fixed: false,
            offset: [20,20]
          });
        });
        $('#tooltips li:nth-child(1)').css({top:'54px',left:'120px'});
        $('#tooltips li:nth-child(2)').css({top:'65px',left:'190px'});
        $('#tooltips li:nth-child(3)').css({top:'35px',left:'250px'});
        $('#tooltips li:nth-child(4)').css({top:'47px',left:'350px'});
        $('#tooltips li:nth-child(5)').css({top:'94px',left:'280px'});
        $('#tooltips li:nth-child(6)').css({top:'150px',left:'330px'});
        $('#tooltips li:nth-child(7)').css({top:'98px',left:'430px'}); 
        $('#tooltips li:nth-child(8)').css({top:'170px',left:'480px'}); 
        $('#tooltips li:nth-child(9)').css({top:'190px',left:'60px'}); 
        $('#tooltips li:nth-child(10)').css({top:'130px',left:'10px'}); 
        $('#tooltips li:nth-child(11)').css({top:'280px',left:'70px'}); 
        $('#tooltips li:nth-child(12)').css({top:'250px',left:'180px'}); 
        $('#tooltips li:nth-child(13)').css({top:'330px',left:'140px'}); 
        $('#tooltips li:nth-child(14)').css({top:'240px',left:'300px'}); 
        $('#tooltips li:nth-child(15)').css({top:'270px',left:'370px'});
      }
    });
    
    get('#/', function() { with(this) {    
      
    }});              
    
    get('#/:slug', function() { with(this) {  
      $('#logo a').fadeIn('slow');
      var thisId = '#' + params['slug'],
        navId = '#nav_' + params['slug'];
      
      $(thisId + ' .bild img').show();
      $('#navigation a').removeClass('active');
      $(navId).addClass('active');      

      // $('title').text($title + ' - ' + $(navId).text());
      $('.page').fadeOut(300);
      $(thisId).fadeIn(1000);
    }});  
    
  }});
  
  $(function() {
    app.run();
  });

})(jQuery);
