$(document).ready(function() {

    // SLIDE PRO SEZNAM KURZU
	
    $('.categName').click(function() {
        $('.tabiconinner').attr('src','/graphic/layouts/icons/categ/arrow_down.png');
		var tohle = $(this);
                
        $('.slide').slideUp('slow', function(){
            $(this).parent().children('.categName').removeClass('selectedC');
			$(this).addClass('hidden');
			
        });
        divElement = $('#slide' + $(this).parent().parent().attr('rel'));


        if (divElement.hasClass("hidden")) {
			$(this).children('img').attr('src','/graphic/layouts/icons/categ/arrow_up.png');
            divElement.slideDown('slow',function(){
                

                });
            divElement.removeClass('hidden');
            tohle.addClass('selectedC');
        } else {
            $(this).children('img').attr('src','/graphic/layouts/icons/categ/arrow_down.png');
            divElement.slideUp('slow',function(){
                divElement.addClass('hidden');
                tohle.removeClass('selectedC');


            });
        }
 
    });

    $('.category').mouseover(function() {
        $(this).addClass('selectedCategory');
        $(this).removeClass('trOut');
        $(this).addClass('trOver');
                
		
    });
	
    $('.category').mouseout(function() {
        $(this).removeClass('selectedCategory');
        $(this).removeClass('trOver');
        $(this).addClass('trOut');
                
		
    });



    $('.bonusOrder').click(function(){
        linkto = confirm("Přejete si skutečně obědnat tento kurz?");
        return linkto;
    });
	
	
});
//// CAROUSEL  /////////////////////////////////////////////////////////////////
var carouselTimer;
var carouselAllowScroll = true;

    $(document).ready(function() {
        //$("#runme").click(function(){carouselSlideUp()});
        $("#lastminute-carousel").mouseenter(function(){
            carouselAllowScroll = false;
        });
        $("#lastminute-carousel").mouseleave(function(){
            carouselAllowScroll = true;
        });
        carouselTimerInit();

        $('#carousel_up_arrow').click(function(){
            carouselSlideDown();
            return false;
        });
        $('#carousel_down_arrow').click(function(){

            carouselSlideUp();
            return false;
        });
    });


    function carouselTimerInit(){
        carouselTimer = setTimeout("carouselAutoScroll()",6000);
    }

    function carouselAutoScroll(){
        if(carouselAllowScroll){
            carouselSlideUp();
        }
        carouselTimerInit();
    }

    function carouselSlideUp(){
        $("#lastminute-carousel-items").animate({"top": "-=150px"}, 1000,function(){
            $(".carousel-item:first").appendTo("#lastminute-carousel-items");
            $(this).css({top: 0});
        });
    }
    function carouselSlideDown(){
        $("#lastminute-carousel-items").css({top: -150});
        $(".carousel-item:last").prependTo("#lastminute-carousel-items");
        $("#lastminute-carousel-items").animate({"top": "+=150px"}, 1000,function(){
                        
        });
    }


//////////////////////////////////////////////////////////////////////////////////////

        var addIcon = "/graphic/layouts/icons/categ/arrow_down.png";
        
        var delIcon = "/graphic/layouts/icons/categ/arrow_up.png";
        function slideUpmainTabs(){
            $('img.tabicon').attr('src',addIcon);
            $('.tabiconinner').attr('src',addIcon);
            $('div.innerWrapperDiv').slideUp('slow',function(){

            });
            $('.slide').slideUp('slow', function(){
                $(this).parent().children('.categName').removeClass('selectedC');
                $(this).addClass('hidden');
            });    
        }

        $(document).ready(function() {
            $('.tabulkaPrehledu thead').click(function() {
                slideUpmainTabs();

                var tab = $(this).parent();
                var img = $(this).children('tr').children('td').children('img');
                var tbody = tab.children('tbody').children('tr').children('td').children('div');//.children('.innerWrapperDiv');

                if(tbody.css('display')== 'none'){

                    img.attr('src',delIcon);
                    tbody.slideDown('slow',function(){

                    });
                }

                tab.css({width: 537});
                tbody.css({width: 537});


            });

        });
		
		
/////////////////////////////////////////////////////////////////////////////////////////// TIMETABLE TOOLTIPS
$(document).ready(function() {
		$(".timetableTriger").tooltip({
			
			effect: 'slide',
			relative: true
		}).dynamic({ bottom: { direction: 'down', bounce: true } });
});


