var betbruk = {
	init: function() {
		this.menuAnim();

                if($('#secslider').length > 0)
                {
                    this.secSlider();
                }
		
		$('#container div div, div.scrollpane').jScrollPane({scrollbarWidth: 10, scrollbarMargin: 5, showArrows: true});
		
		$('#gallery').vTicker();
		$("a[rel='gallery']").lightBox({
			imageLoading:			'/media/img/lightbox/lightbox-ico-loading.gif',		
			imageBtnPrev:			'/media/img/lightbox/lightbox-btn-prev.gif',
			imageBtnNext:			'/media/img/lightbox/lightbox-btn-next.gif',		
			imageBtnClose:			'/media/img/lightbox/lightbox-btn-close.gif',
			imageBlank:			'/media/img/lightbox/lightbox-blank.gif',
			txtImage:				'Obrazek',	
			txtOf:					'z'
		});
	},
	
	menuAnim: function() {
		var handler = $('#sections li');
		var op = 0.6;
		
		//$(handler).css({opacity: 1});
                $(handler).children('a').css({opacity: op});
                $(handler).children('span').css({opacity: 0});
			
		$(handler).hover(function() {
			$(this).children('a').stop().animate({opacity: 1});
                        $(this).children('span').stop().animate({opacity: 1});
                        //$(this).children('a').css({opacity: 1});
		}, function() {
			$(this).children('a').stop().animate({opacity: op});
                        $(this).children('span').stop().animate({opacity: 0});
                        //$(this).children('a').css({opacity: op});
		});
	},

        secSlider: function() {
            var act = 0;
            var speed = 5000;
            var count = 4;

            var handler = $('#secslider');

            $(handler).children('li:gt('+act+')').css({opacity: 0});

            setInterval(function() {
                $(handler).children('li').eq(act).animate({opacity: 0});
                if(act < count)
                {
                    act++;
                    $(handler).children('li').eq(act).animate({opacity: 1});
                } else {
                    act = 0;
                    $(handler).children('li').eq(act).animate({opacity: 1});
                }
            }, speed);
        }
};

$(document).ready(function() {
	betbruk.init();
});


/*
* Tadas Juozapaitis ( kasp3rito@gmail.com )
* modified by Gorgeus
*/

(function($){
$.fn.vTicker = function(options) {
	var defaults = {
		speed: 1000,
		pause: 5000,
		showItems: 3,
		animation: 'fade',
		mousePause: true
	};

	var options = $.extend(defaults, options);

	moveUp = function(obj){
		obj = obj.children('ul');
		first = obj.children('li:first').clone(true).hide();
		height = obj.children('li:first').height();

		obj.animate({top: '-=' + height + 'px'}, options.speed, function() {
			$(this).children('li:first').remove();
			$(this).css('top', '0px');
		});

			if(options.animation == 'fade')
			{
				obj.children('li:first').fadeOut(options.speed);
				obj.children('li:eq('+options.showItems+')').hide().fadeIn(options.speed * 1.5);
			}

		first.appendTo(obj);
	};
	
	return this.each(function() {
		obj = $(this);
		objHeight = 0;

		obj.css({overflow: 'hidden', position: 'relative'})
			.children('ul').css({position: 'absolute', margin: 0, padding: 0})
			.children('li').css({margin: 0, padding: 0});

                   num = obj.children('ul').children('li');
                   if(num.length < 3)
                       return;

		obj.children('ul').children('li').each(function(){
			objHeight += $(this).height();
		});

		obj.height(objHeight);
		
		obj.children('ul').children('li:gt('+(options.showItems-1)+')').hide();

		interval = setInterval('moveUp(obj)', options.pause);
		
		if(options.mousePause)
		{
			obj.bind("mouseenter",function(){
				clearInterval(interval);
			}).bind("mouseleave",function(){
				interval = setInterval('moveUp(obj)', options.pause);
			});
		}
	});
};
})(jQuery);
