$(function(){
    $('.blockgallery').jCarouselLite({
                btnNext: ".arr_left",
                btnPrev: ".arr_right",
                circular: true,
                mouseWheel: true,
                visible: 1,
                speed: 1000,
                auto: 3000,
                afterEnd: function (a) {
                    
                	//atext1 = a.children('a')[0];
                	atext1 = a.children();
                	atext2 = atext1[0].href;
                	atext1 = atext1.children()[0].title;
                	
                	//console.log(atext1);
                	top.blockgallery	= atext2;
                	//console.log(top.blockgallery);
                	//atext1 = a.children('a img')[0].title;
                    $('.imageText span').fadeOut(500, function(){
                        $('.imageText span').text(atext1).fadeIn(500);
                    });
                    
                    
                }
            });
    
    
    $('.slider').jCarouselLite({
                btnNext: ".btnPrev",
                btnPrev: ".btnNext",
                circular: true,
                mouseWheel: true,
                visible: 1,
                speed: 1000,
                auto: 2000,
                afterEnd: function (a) {
                    try{
                       // atext2 = a.children('img')[0].title;
                    	atext2 = a.children();
                    	atext2 = atext2.children()[0].title;

                        $('.overlay p').fadeOut(500, function(){
                            $('.overlay p').text(atext2).fadeIn(500);
                        });
                    }catch(e){

                    }
                }
            });

    $('.imageText span').text($('.blockgallery_inner li:last img').attr('title'));
    $('.overlay p').text($('.slider li:last img').attr('title'));

    $('.arrows').hover(function(){
        $('.arrows > *').fadeIn(300);
	$('.blockgallery').jCarouselLite({'pause':true});
    },function(){
        $('.arrows > *').fadeOut(300);
	$('.blockgallery').jCarouselLite({'unpause':true});
    });

    $('.arrows a').hide();

    $('.slider').hover(function(){
        $('.slider .btnNext, .slider .btnPrev').fadeIn(300);
	$('.slider').jCarouselLite({'pause':true});
    },function(){
        $('.slider .btnNext, .slider .btnPrev').fadeOut(300);
	$('.slider').jCarouselLite({'unpause':true});
    });

    $('.slider .btnNext, .slider .btnPrev').hide();
    
    $('.afisha_tbl td > div, .date_line').each(function () {
        //$(this).height($(this).parent().height() - parseInt($(this).css('paddingTop')) - parseInt($(this).css('paddingBottom')) - parseInt($(this).css('marginTop')) - parseInt($(this).css('marginBottom')));
    	//alert($(this).parent().height());
    	$(this).height($(this).parent().height());
    });
    
});
