jQuery(document).ready(function($) {

    $(".tx-pilmailform-pi1 .show").parent().next('fieldset').addClass('hidden').hide();
    $(".tx-pilmailform-pi1 .show").click(
        function(){
            if($(this).parent().next('fieldset').css("display")=="none" ){
                $(this).parent().next('fieldset').slideDown("fast");
            }
        }
    );
    $(".tx-pilmailform-pi1 .hide").click(
        function(){
            if($(this).parent().next('fieldset').css("display")=="block" ){
                $(this).parent().next('fieldset').slideUp("fast");
                $(this).parent().next('fieldset').child().val('');
            }
        }
    );

    //$("#content ul li a.download").parent("li").addClass("js-download");
    
    // fancybox
    $("a.lightbox").fancybox({
        'zoomSpeedIn': 300,
        'zoomSpeedOut': 300,
        'overlayShow': true
    });

    /*****************************
        gallery start
    */
    
    // Bild vertival vermitteln
   
    $('.gallery .csc-textpic-imagerow dl').each(function() {
        var wrapHeight = $(this).find('a').height();
        var imgHeight = $(this).find('img').height();
        var diff = (imgHeight - wrapHeight) / 2;
        var imgHeight = $(this).find('img').css({ 'margin-top': '-' + diff + 'px' });
    });
    
    // container für pagination hinzufügen
    $('.gallery .csc-textpic').before('<div class="pagination-container"></div>');

    $('.csc-textpic-imagerow .csc-textpic-image').unwrap();
    
    // pagination initialisieren
	$('.gallery .csc-textpic-imagewrap').quickPager( {
		pageSize: 6,
		currentPage: 1,
		pagerLocation: 'before'
	});
    /*
        gallery end
    ****************************/
    
});

$.fn.unwrap = function() {
  this.parent(':not(body)')
    .each(function(){
      $(this).replaceWith( this.childNodes );
    });

  return this;
};
