$(document).ready(function () {

    // Rozwijanie nizszego elementu
    $('.accordion h2').click(function() {
        $(this).next().toggle('slow');
        return false;
    }).next().hide();

    // Elementy o tej klasie beda mialy taka sama wysokosc
    $('.equal-size').equalHeights();
	
    // Nadpisanie funkcji Toogle - plynny toggle
    jQuery.fn.fadeToggle = function(speed, easing, callback) {
        return this.animate({
            opacity: 'toggle'
        }, speed, easing, callback);
    };

    // Zamykanie elementu, plynne znikanie
    $('a.close ').click(function() {
        $('.table').fadeOut('medium');
        $('.table').removeClass();
        return false;
    });
	
    // Cross-browser Hover
    $(".hover").hover( function () {
        $(this).addClass("hover");
    }, function () {
        $(this).removeClass("hover");
    } );

    // Slider wraz z nawigacja generowana automatycznie
    $('#menu-rotator').cycle({ 
        speed:   500, 
        timeout: 0, 
        height:       'auto',
		  after: onAfter

    }); 
	 
	 // Autoheight referencji
function onAfter(curr, next, opts, fwd) {
var index = opts.currSlide;
$('#prev,#prev2,#prev3,#prev4,#prev5')[index == 0 ? 'hide' : 'show']();
$('#next,#next2,#next3,#next4,#next5')[index == opts.slideCount - 1 ? 'hide' : 'show']();
//get the height of the current slide
var $ht = $(this).height();
//set the container's height to that of the current slide
$(this).parent().animate({height: $ht});
}


	
	 $('#card1').addClass('activeSlide');
	$('.menu-nav-option').click(function(){ $('.menu-nav-option').removeClass('activeSlide'); $(this).addClass('activeSlide'); });
	
    $('#card1').click(function() {
        $('#menu-rotator').cycle(0);
        return false;
    });
    $('#card2').click(function() {
        $('#menu-rotator').cycle(1);
        return false;
    });
    $('#card3').click(function() {
        $('#menu-rotator').cycle(2);
        return false;
    });
    $('#card4').click(function() {
        $('#menu-rotator').cycle(3);
        return false;
    });
    $('#card5').click(function() {
        $('#menu-rotator').cycle(4);
        return false;
    });
    $('#card6').click(function() {
        $('#menu-rotator').cycle(5);
        return false;
    });
    $('#card7').click(function() {
        $('#menu-rotator').cycle(6);
        return false;
    });

           $('#card8').click(function() {
        $('#menu-rotator').cycle(7);
        return false;
    });
    $('#card9').click(function() {
        $('#menu-rotator').cycle(8);
        return false;
    });
	
    // Font Replacement CUFON
    Cufon('#nav li a', {
        fontFamily: 'MyriadProCond',
        textShadow: '0px 1px #663105',
        hover: {
            color: '#fcff00'
        }
    });
Cufon('.cufon', {
    fontFamily: 'MyriadProCond',
    textShadow: '0px 1px #fff',
    hover: {
        color: '#197505'
    }
	 
});

Cufon('h1', {
    fontFamily: 'MyriadProCond',
    hover: {
        color: '#000'
    }
	 
});

Cufon('.addfav', {
    fontFamily: 'MyriadProCond',
    textShadow: '0px 1px #663105',
    hover: {
        color: '#fcff00'
    }
});
Cufon('.returntop', {
    fontFamily: 'MyriadProCond',
    textShadow: '0px 1px #fff',
    hover: {
        color: '#197505'
    }
});
	 
// Parzyste, nieparzyste - nadaj styl, klase
//$("#feature-table tr:even").css("background-color", "#fff");
//    $("#feature-table tr:odd").css("background-color", "#f8f8f8").addClass("odd");
//$(".menu-page table tr:odd").addClass("odd");
//$(".menu-page table tr td:odd").addClass("cell-odd");
//$(".menu-page table tr:last-child").addClass("last");
//
//   $(".menu-page table tr").hover( function () {
//        $(this).addClass("hover");
//    }, function () {
//        $(this).removeClass("hover");
//    } );

    // Horizontal Slides ( hSlides Plugin )
    $('.accordion1').hSlides({
        totalWidth: 940,
        totalHeight: 216,
        minPanelWidth: 60,
        maxPanelWidth: 700,
		  activeClass: 'active'

    });



    // Simple Show/Hide Dialog Box
    $(".popup-show").click( function (){
        $(this).next('.popup-dialog').fadeIn('medium');
        return false;
    } );
    $(".popup-show .close").click( function (){
        $(this).prev('.popup-dialog').fadeOut('medium');
        return false;
    } );
    $("a.returntop").click(function(){
        $( 'html, body' ).animate( { scrollTop: 0 }, 0 );
    });
    
    $("td.gluten").hover(function() {
        $(this).append('<div class="gluten-info">danie bezglutenowe</div>');
    }, function() {
        $("div.gluten-info").remove(); 
    });
});



