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

//galeria

	if ($('.gallery').exists()) {

		$.getScript('js/jquery.prettyPhoto.js', function(){
			$("a[rel^='prettyPhoto[pp_gal]']").prettyPhoto({
				theme: 'light_rounded'
			});
		});
	}


// slideshow

	$.getScript('js/jquery.cycle.all.min.js', function(){
		$("#slideshow").cycle({
			fx:			"fade",
			speed:		800,
			timeout:	3000
		});
	});



//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').click(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
