$(document).ready(function() {

	// Gallery
	$('.gallery li:nth-child(4n)').css({ 'margin-right':0 });
	
	$('.gallery a', '#main').fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	600, 
			'speedOut'		:	200,
			overlayOpacity	:	0.8,
			overlayColor	:	'#000000',
			titlePosition	:	'inside',
			centerOnScroll	:	true
	});


	// Menu
	$('#menu span').css({ opacity: 0 });
	
	$('#menu li:not(.active) a').hover(function () {
		$(this).children('span').stop().animate({
			opacity: 1,
			top: 0
		}, 'slow');
	},
	function () {
		$(this).children('span').stop().animate({
			opacity: 0,
			top: '-79'
		}, 'fast');
	});

	// Slider
	$('#slider').jqFancyTransitions({
		delay: 3000,
		width: 960,
		height: 294,
		strips: 25,
		navigation: true
	 });
	
	// Hacks to slider
	var sliderButtons = $('#ft-buttons-slider');
		sliderButtons.css({ width: '450px' });
		
	$('#slider').append(sliderButtons);
	$('#ft-title-slider').css({ bottom: '3px', left: '3px' });

	// Social Tooltip
	$('.facebook a, .twitter a').hover(function(){
		$(this).next('em').stop(true, true).animate({ opacity: 'show', top: '-40' }, 'slow');
	}, function(){
		$(this).next('em').animate({ opacity: 'hide', top: '-60' }, 'fast');
	});
	
	// Thumb
	$('.thumb', '#clients').each(function(){
		
		$(this).css({
			width: $(this).width()
		});
		
		$(this).children('span').css({
			width: $(this).width()
		});
	});
	
	$('.thumb').hover(function(){
	
		var imgsrc = $('img', this).attr('src');
	
		$(this).css({ 'background' : 'url(' + imgsrc + ') no-repeat center bottom' });
	
		$(this).children('span').stop().fadeTo('normal', 0 , function() {
			$(this).hide();
		});
		
	}, function(){
		$(this).children('span').stop().fadeTo('normal', 1).show();
	});
	
	// Quotes
	$('.scrollable').scrollable({ circular: true }).autoscroll({ autoplay: true, interval: 10000 }).navigator();
	
	// In field label
	$('.infield label').inFieldLabels({
		fadeOpacity: 0.2,
		top: 4
	});
	
	$.tools.validator.localize('pl', {
		':email'  		: 'Proszę wprowadzić poprawny adres e-mail',
		':number' 		: 'Proszę wprowadzić wartość numeryczną',
		'[max]'	 		: 'Proszę wprowadzić wartość mniejszą niż $1',
		'[min]'	 		: 'Proszę wprowadzić wartość większą niż $1',
		'[required]' 	: 'Proszę wypełnić to wymagane pole'
	});
	
});
