function ajaxPaginator(url) {
    jQuery.ajax({
        type:'POST',
        dataType:'html',
        success:function(data, textStatus){
           
            jQuery('#gallery').hide().html(data).fadeIn(500);
            $("a[rel=gallery]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">Obraz ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
		}
            });
             
        },
        url:url
    });
    return false;
}
function showPopUpMessage(message){
            $.fancybox(message,{
                'padding' : 30,
                'transitionIn' : 'fade',
                'transitionOut' : 'none'
            });
        };

$(document).ready(function() {
    
    
    // ochrona przeciwspamowa dla e-maili
    $('a.email').each(function(){
        e = this.rel.replace('/','@');
        this.href = 'mailto:' + e;
        $(this).text(e);
    });
    
    
    //galeria zdjęć
         $("a[rel=gallery]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">Obraz ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
		}
	});

	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});

        //linki do zaprzyjaźnionych stron hover za pomocą jquery
	$('#top_friendly_sites img').imghover();
        //koniec

        //nadawanie klasy pierwszego i ostatniego elementu lewego menu

        $('ul#secondmenu li:first').addClass('first');
        $('ul#secondmenu li:last').addClass('last');

	

         $('ul#secondmenu a').click(function(){
            
            if($(this).attr('href') != '#s') {
                return true;
            }
            else {
                $("ul.level1").hide();
		$("#secondmenu li").removeClass('active');
		$(this).parent().parent().addClass('active');
		$(this).parent().next().show('fast');
            }
		

	});
	theRotator();
	$('div.rotator').fadeIn(1000);
	$('div.rotator ul li').fadeIn(1000); // tweek for IE

});


		function theRotator() {
			//Set the opacity of all images to 0
			$('div.rotator ul li').css({opacity: 0.0});

			//Get the first image and display it (gets set to full opacity)
			$('div.rotator ul li:first').css({opacity: 1.0});

			//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds

			setInterval('rotate()',6000);

		}

		function rotate() {
			//Get the first image
			var current = ($('div.rotator ul li.show')?  $('div.rotator ul li.show') : $('div.rotator ul li:first'));

		    if ( current.length == 0 ) current = $('div.rotator ul li:first');

			//Get next image, when it reaches the end, rotate it back to the first image
			var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div.rotator ul li:first') :current.next()) : $('div.rotator ul li:first'));

			//Un-comment the 3 lines below to get the images in random order

			//var sibs = current.siblings();
		        //var rndNum = Math.floor(Math.random() * sibs.length );
		        //var next = $( sibs[ rndNum ] );


			//Set the fade in effect for the next image, the show class has higher z-index
			next.css({opacity: 0.0})
			.addClass('show')
			.animate({opacity: 1.0}, 1000);

			//Hide the current image
			current.animate({opacity: 0.0}, 1000)
			.removeClass('show');

		};


$(function(){

    $.extend($, {"tabChanger":{
        "timeLength": 10000 // czas w milisekundach po którym ma nastąpić zmiana zakładki
        ,"curentSelected": 0
        ,"timeoutObj": null
        ,"timeoutFunction": function(){

            var tabLength = $("#center_col ul.tabs li").length;
            $.tabChanger.curentSelected++;
            var select = $.tabChanger.curentSelected % tabLength;
            $("#center_col ul.tabs li").eq(select).click();
        }
    }});
    $("#center_col ul.tabs li").click(function(){
        $.tabChanger.curentSelected = $(this).index();
    });
    $("#center_col div.tab_container").hover(function(){
        clearInterval($.tabChanger.timeoutObj);
    }, function(){
        $.tabChanger.timeoutObj = setInterval(function(){$.tabChanger.timeoutFunction();}, $.tabChanger.timeLength);
    });

//    $.tabChanger.setInterval = setTimeout($.tabChanger.timeoutFunction(), 3000);
    $.tabChanger.timeoutObj = setInterval(function(){$.tabChanger.timeoutFunction();}, $.tabChanger.timeLength);


});
