$(function(){
	$.fn.exists = function(){return $(this).length>0;}

	if($('#path ul li:eq(1) a').attr('href') == 'Aktualnosci.html'){
		$('.zajawka').hide();
	}

// wielokropek dla newsów zajawek

	if($('.news .more').length > 0){
		$('.news p').append(' ...');
	}


// długość newsów uzależniona od długości sekcji

	$('aside').css('minHeight', $('article').height());



//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'
			});
		});

		$('.gallery a').prepend('<div class="mask"></div>');
	}

	if ($('#polec_strone').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'
			});
		});
	}





//pokazy slajdów

	if ($('#slideshow1').exists()) {
		$.getScript('js/jquery.cycle.all.min.js', function(){
			$("#slideshow1").cycle({
				fx:			"scrollHorz",
				sync:		1,
				timeout:	3333,
				speed:		1200
			});
		});
	}

	if ($('.slideshow').exists()) {
		$.getScript('js/jquery.cycle.all.min.js', function(){
			$(".slideshow").cycle({
				fx:			"scrollHorz",
				sync:		1,
				timeout:	3000,
				speed:		1500
			});
		});
	}



//walidacja formularza

	$('#error').hide();
	$('form').bind('submit', function(){
		var valid = true;
		$('.required').change(function(){
			$(this).removeClass('error-input');
		});
		$('.required').each(function(){
			if($(this).val()==''){
				$(this).addClass('error-input');
				 valid = false;
			} else{
				$(this).removeClass('error-input');
			}
		});
		if(!valid){
			$('#error').fadeIn();
			return false;
		}
	});

	$('.required').blur(function(){
		if($(this).val() == ""){
			$(this).addClass('error-input');
		} else {
			$(this).removeClass('error-input');
		}
	});



// wartość pól formularzy

	if($("#login_form input, #search_form input").val() != ""){

		$('#login_form input, #search_form input').click(function(){
			$(this).val("");
		});

	}

}); // ready end
