$(function(){
	$("a.thickbox").fancybox({
		padding			:	0,
		overlayColor	:	'#333333',
		overlayOpacity 	: 	0.9,
		'titleFormat'	:	formatTitle
	});
	function formatTitle(title, currentArray, currentIndex, currentOpts) {
		return '<div id="title">' + (title && title.length ? '' + title + '' : '' ) +  '</div>';
	}
	jQuery('ul.sf-menu').superfish({
		delay		:	100, 
		animation:{
			height	:	'show'
		},
		speed		:	'fast',
		autoArrows	:	false,
		dropShadows	:	false
	});
	
	
	$("a.nextPage").click(function(){
		$('div.#scroll').stop().scrollTo('+=174', 500 );
	});
	$("a.prevPage").click(function(){
		$('div.#scroll').stop().scrollTo( '-=174', 500 );
	});
	$('#gfxUnder').cycle({ 
		fx:	'fade',
		speed:  1000,                
		timeout: 6000,               
		pager: '#thumbs',         
		next:   '#nextp',            
		prev:   '#prevp',            
		pagerEvent: 'click',
		pause: true,
		pauseOnPagerHover: true ,
		pagerAnchorBuilder: function(idx, slide) {
			return '<a href="#" title="' + slide.alt + '"><img src="' + slide.src + '" width="55" height="55" alt="' + slide.alt + '" /></a>';
		},
		after:   onAfter
	});  
	function onAfter(){ 
		$('#photoDescription').html(this.alt);            
	}
	$("#thumbs a").tooltip({
		track: true,
		delay: 0,
		showURL: false,
		fixPNG: true,
		showBody: " - ",
		extraClass: "pretty fancy",
		top: -15,
		left: 5
	});
	$('#realisationsContainer').accordion({ 
		active: true, 
		autoheight: false ,
		header: '.header', 
		navigation: true, 
		event: 'click', 
		fillSpace: false, 
		alwaysOpen: false,
		animated: 'easeslide'
	}).bind("change.ui-accordion", function(event, ui) { 
		$('a.readMore').show('fast');
		$('.selected a.readMore').hide('fast');
	});
	$("#recForm").validate({
		rules: {
			contactName: "required",
			contactSurname: "required",
			contactEmail:{
				required: true,
				email: true
			},
			contactPhone: "required",
			contactCity: "required",
			allow:{
				required: true
			}
		},
		messages: {
			contactName: " Proszę podać imię i nazwisko",
			contactEmail: " Proszę podać poprawny adres e-mail",
			contactPhone: " Proszę podać numer telefonu",
			contactCity: " Proszę podać miasto",
			allow:{ 
				required:"Proszę zaakceptować zgodę na przetwarzanie danych"
			}
		}
	});
	$("#newsletter").validate({
		errorLabelContainer: $("div.errorContainer"),
		rules: {
			'email':{
				required: true,
				email: true
			}
		},
		messages: {
			'email': " Proszę podać poprawny adres e-mail"
		}
	});
})
