Cufon.replace('h1, #content>h2, p big, #news p.title, #quickinfo a, #bottom li, ul.tabs a, #quickinfo h2, #logos span, #newslist h2, p#profesjonalne a, p#do-domu a');

(function($) {

    // Panele:
    $.fn.Panels = function()
    {
        var $this = this;
        var getAnchor = function(element)
        {
            return element.attr('href').split('#')[1];
        };
        
        $(this).addClass('tabs');
        this.current = null;
        
        $('li a', this).each(function() {
            var aElement = $(this);
            $('#'+getAnchor(aElement)).hide();
            
            // Click Event:
            aElement.click(function() {
                if ($this.current)
                {
                    $('#'+getAnchor($this.current)).hide();
                    $this.current.parent().removeClass('active');
                }
                $this.current = $(this);
                $('#'+getAnchor($this.current)).show();
                $this.current.parent().addClass('active');
                return false;
            });
        });
        
        // Init first!
        $('li:first a', this).trigger('click');
    };
    
    // Panele z karuzelą:
    $.fn.PanelsWithCaruzel = function()
    {
        var $this = this;
        var getAnchor = function(element)
        {
            return element.attr('href').split('#')[1];
        };
        
        $this.current = null;
        var naviList = $('ul.navi', $this);
        
        $('ul.navi a', $this).each(function() {
            var aElement = $(this);
            $('#'+getAnchor(aElement)).hide();
            $('span', this).remove();
            
            // Click Event:
            aElement.click(function() {
                if ($this.current)
                {
                    $('#'+getAnchor($this.current)).hide();
                    $this.current.parent().removeClass('current');
                }
                $this.current = $(this);
                $('#'+getAnchor($this.current)).show();
                $this.current.parent().addClass('current');
                
                naviList.next('span').remove();
                naviList.after("<span>"+$(this).attr('title')+"</span>");
                Cufon.replace('#logos span');
                
                return false;
            });
        });
        
        // Init first!
        $('ul.navi li:first a', $this).trigger('click');
        var i = 1;
        var itemsCount = $('ul.navi a', $this).size();
        
        window.setInterval(function() {
            $('ul.navi a', $this).eq(i).click();
            if (i >= itemsCount)
            {
                i = -1;
            }
            i++;
        }, 10000);
    };
    
})(jQuery);

$(document).ready(function() {
    
    $('ul#tabs').Panels();
    $('div#logos').PanelsWithCaruzel();
    $('#quickinfo').tabs();
    
	$("ul.gallery a").attr({rel:"gallery"});
	$("ul.gallery a").fancybox({
//		'titleShow'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'titlePosition' : 'over',
		'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Zdjęcie ' + (currentIndex + 1) + ' z ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
});


