$(document).ready(function() {
  // Tabs
  $('#tabs').tabs();
  
  $('table#referenzen tr').hover(
    function()
    {
      $(this).addClass('hover');
    },
    function()
    {
      $(this).removeClass('hover');
    });
  $('a.backLink').click(
    function()
    {
      window.back();
      return false;
    }
  );
  
  $('div#date').css('cursor','pointer')
    .mouseenter(
      function()
      {
        $('#Profilbild img')
          .animate(
            {
              opacity: 0.25
            }, 220
          )
          .animate(
            {
              opacity: 1
            }, 280
          );
      }
    )
    .click(
      function()
      {
        $('#Profilbild img').jqPuzzle(
          {
            shuffle: false,
            numbers: false,
            language: 'de',
            rows: 3,
            cols: 3,
            hole: 9,
            control: { 
              shufflePieces: true,
              confirmShuffle: false,
              toggleOriginal: true,   // display 'Original' button [true|false] 
              toggleNumbers: false,
              counter: true,
              timer: true,  
              pauseTimer: true
            },
            success: { 
              fadeOriginal: true
            },
            animation: { 
              shuffleRounds: 2
            }
          }
        );
      }
    );
  
  $('#projectsView').isotope({
    // options
    itemSelector : '.projectsItem',
    layoutMode : 'fitRows',
    getSortData : {
      kunde : function ( $elem ) {
        return $elem.find('h3').text();
      },
      datum : function ( $elem ) {
        return parseInt($elem.find('.datum').text(), 10);
      },
      domain : function ( $elem ) {
        return $elem.find('.referenzLink').text();
      },
      ort : function ( $elem ) {
        return $elem.find('.data-standort').text();
      }
    }
  });
  
  $('#projectsFilters a').click(
    function()
    {
      $('#projectsFilters a.current').removeClass('current');
      $(this).addClass('current');
      var selector = $(this).attr('data-filter');
      $('#projectsView').isotope({ filter: selector });
      return false;
    }
  );
  
  $('#projectsSort a').click(
    function()
    {
      $('#projectsSort a.current').removeClass('current');
      $(this).addClass('current');
      // get href attribute, minus the '#'
      var sortName = $(this).attr('href').slice(1);
      $('#projectsView').isotope({ sortBy : sortName });
      return false;
    });
  
  
});

