jQuery(document).ready(function($){
	
	$('.showOnMap').click(function(){
		$('.placeMapShow').fadeIn();	
	});
	
	$('.close').click(function(){
		$(this).parent().parent().parent().fadeOut('fast');
	});
	
	$("a[rel=events]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		},
		'overlayOpacity'	: 0.8,
		'overlayColor'		: '#002666'
	});
	
	
	$("a.fancy").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'overlayOpacity'	: 0.8,
		'overlayColor'		: '#002666',
		'autoDimension'		: false,
		'autoScale'			: false
	});
	
	$('.gallery-img').fancybox();
	
	// karta stalego klienta
	$(".ksk-tab").mouseover(function(){
		$(this).animate({"left": "+=332px"}, "slow");
	}).mouseout(function(){
		$(this).animate({"left": "-=332px"}, "slow");
	});
	$(".ksk-tab").click(function(){
		window.location = "?dzial=karta_stalego_klienta";
	});
	
	// rozwijane menu
	function menuSlideDown() {
		$(this).find('a:first').addClass('active');
		$(this).find('.submenu:first').slideToggle();
	}
	
	function menuSlideUp() {
		$(this).find('a:first').removeClass('active');
		$(this).find('.submenu:first').fadeOut('fast');
	}
	
	var config = {
		over: menuSlideDown,
		timeout: 300, // delay przed wykonaniem mouseout
		out: menuSlideUp
	};
	
	$('.sub').hoverIntent(config);
	
	$(".facebook-card").mouseover(function(){
		$(this).animate({"left": "+=166px"}, "slow");
	}).mouseout(function(){
		$(this).animate({"left": "-=166px"}, "slow");
	});
	$(".facebook-card").click(function(){
		window.location = "http://www.facebook.com/pages/Nika-Sport/171750002885956";
	});
	
	$(".benefit-card").mouseover(function(){
		$(this).animate({"left": "+=300px"}, "slow");
	}).mouseout(function(){
		$(this).animate({"left": "-=300px"}, "slow");
	});
	
	$('li.sub').each(function(){
		if($(this).find('.activeSubmenu').length > 0) {
			$('#b-nasza_oferta').attr({'id':'b-nasza_oferta-over'});
		}
	});
	
	$('.cycle').cycle({
		fx: 'fade'
	});
	
});

