$(document).ready(function() {
  $('.startpage .entry').hover(
    function() {
      $(this).css('z-index','100');
      $(this).find('img').css('z-index','101');
      $(this).find('.entryTop').css('z-index','102');
      $(this).find('.entryBottom').css('z-index','102');
      $(this).animate({ height: 325 }, 100);
    },
    function() {
      $(this).css('z-index','1');
      $(this).find('img').css('z-index','1');
      $(this).find('.entryTop').css('z-index','2');
      $(this).find('.entryBottom').css('z-index','2');
      $(this).animate({ height: 160 }, 100);
    }
  );
  $('#speisekarte .karte .items').hide();

  $('#speisekarte .karte h2').click(
    function() {
      if(! $(this).hasClass('open')) {
        $(this).addClass('open');
        $(this).parent().find('.items').slideDown('fast');
      } else {
        $(this).removeClass('open');
        $(this).parent().find('.items').slideUp('fast');
      }
    }
  );
  $('#rezeptliste .rzpt .items').hide();

  $('#rezeptliste .rzpt h2').click(
    function() {
      if(! $(this).hasClass('open')) {
        $(this).addClass('open');
        $(this).parent().find('.items').slideDown('fast');
      } else {
        $(this).removeClass('open');
        $(this).parent().find('.items').slideUp('fast');
      }
    }
  );


  $('#rezepte .karte .items').hide();

  $('#rezepte .karte h2').click(
    function() {
      if(! $(this).hasClass('open')) {
        $(this).addClass('open');
        $(this).parent().find('.items').slideDown('fast');
      } else {
        $(this).removeClass('open');
        $(this).parent().find('.items').slideUp('fast');
      }
    }
  );

  $(".fancyAjax").fancybox({
   'width' : '80%',
   'height' : '60%',
   'autoScale' : true,
   'transitionIn' : 'none',
   'transitionOut' : 'none',
   'type' : 'iframe',
   'overlayShow' : true,
   'overlayOpacity' : 0.6,
   'overlayColor' : '#000000'
  });
  $.fn.fancyzoom.defaultsOptions.imgDir='/res/image/layout/';

  $('.imageLink').fancyzoom({overlay:0.8});
  $('.imageLink').each(function () {
    var img = $(this).find('img');
    var h = img.height();
    var w = img.width();
    $(this).after('<span class="lupeBack" style="line-height: '+h+'px; width: '+w+'px; height: '+h+'px;">Bild VERGRÖßERN</span>');
  });
/*
  $('.imageLink').hover(
    function() {
      $(this).parent().find('.lupeBack').css('visibility','visible');
    },
    function() {
    }
  );
  $('.lupeBack').hover(
    function() {
    },
    function() {
      $(this).css('visibility','hidden');
    }
  );
  $('.lupeBack').click(function() {
    $(this).parent().find('.imageLink').trigger('click');
  });
*/
  $('#filterflow').each(function() { 
    var instanceOne = new ImageFlow();
    instanceOne.init({
      ImageFlowID: 'filterflow',
      scrollbarP: 0.8,
      reflectionP: 0.0,
      reflections: false,
      imageCursor: 'pointer',
      onClick: function() {
        window.location = $(this).attr('path');
      }
    });
  });
});
