$(function(){
	$.fn.exists = function(){return $(this).length>0;}



//galeria

	if ($('.gallery').exists()) {
		$("head").append('<link rel="stylesheet" type="text/css" href="css/prettyPhoto.css" media="screen" />');
		$.getScript('js/jquery.prettyPhoto.js', function(){
			$("a[rel^='prettyPhoto[pp_gal]']").prettyPhoto({
				theme: 'light_rounded'
			});
		});
	}

	if ($('form').exists()) {
		$("head").append('<link rel="stylesheet" type="text/css" href="css/prettyPhoto.css" media="screen" />');
		$.getScript('js/jquery.prettyPhoto.js', function(){
			$("a[rel^='prettyPhoto']").prettyPhoto({
				theme: 'light_rounded'
			});
		});
	}



//walidacja formularza

	$('form').bind('submit', function(){
		var valid = true;

		$('.required').click(function(){
			$(this).removeClass('error-input');
		});
		$('.required').each(function(){
			if(($(this).val()=='') || ($(this).val()=="Imię i nazwisko *") || ($(this).val()=="E-mail *") || ($(this).val()=="Wiadomość *")){
				$(this).addClass('error-input');
				valid = false;
			} else{
				$(this).removeClass('error-input');
			}
		});
		if(!valid){
			return false;
		}
	});

	$('.required').blur(function(){
		if($(this).val() == ""){
			$(this).addClass('error-input');
		} else {
			$(this).removeClass('error-input');
		}
	});

	$('input, textarea').click(function(){
		$(this).val("");
	});


//tabele
	$('table tr:first-child').addClass('firstrow');
	$('table tr:even').addClass('even');



//ostatni element listy
	$('ul li:last-child').addClass('last');



//pokaz slajdów

	if ($('#slideshow').exists()) {
		$.getScript('js/jquery.cycle.all.min.js', function(){
			$("#slideshow").cycle({
				sync:		1,
				timeout:	4000,
				speed:		1500
			});
		});
	}



}); // ready end
