$(document).ready(function() {



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



	// Flash animation

			//$('#kleks').flash({
		    //	src: 'flash/kleks.swf',
		   	// 	width: 139,
		    //	height: 150,
		    //	wmode: 'transparent',
		    //	expressInstall: true
		    //});




	// Focus border remove

			$("a").focus(function() {
				$(this).blur();
			});





	// Fancybox

			$(".fancy, #gallery a").fancybox({
				'titlePosition'	:	'over',
				'padding'			: 0,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'              : 'image',
				'changeFade'        : 0,
				'onComplete'	:	function() {
					$("#fancybox-wrap").hover(function() {
						$("#fancybox-title").show();
					}, function() {
						$("#fancybox-title").hide();
					});
				}
			});






	// Clear input

			clearInput = function (arg) {
				var $nam = $(arg).val();

				$(arg).focus(function() {
					if(	$(this).val() == $nam) {
						$(this).val('');
					}
				})

				$(arg).blur(function() {
					if(	$(this).val() == '') {
						$(this).val($nam);
					}
				});
			}

			clearInput("#name");
			clearInput("#email");






	// Opacity

			$.fn.opacity = function() {
				$(this).hover(
				  function () {
					$(this).css({ opacity: ".9" });
				  },
				  function () {
					$(this).css({ opacity: "1" });
				  }
				);
			}

			$(".flags a").opacity();
			$("#foot #fb img").opacity();
			$("#foot #nasi img").opacity();

			$("#gallery a").opacity();
			$("#gallery .item .printer").opacity();





	// Remove margin in last element







	// _blank

			$(function() {
				$('.blank').click( function() {
					window.open(this.href);
					return false;
				});
			});






	// Drop down horiz menu

			$("ul.topnav li a").mouseover(function() {
				$(this).parent().find("ul.subnav").show();
				$(this).addClass("hov");

				$(this).parent().hover(function() {
				}, function(){
					$(this).find(".hov").removeClass("hov");
					$(this).parent().find("ul.subnav").hide();
				});
			});






	// Add arrows

			if($(".start").exists()) {
				$("#aktualnosci .item p").append("<img src='img/arrow-green.png' alt='' class='arrow' />");
				$("#dlarodzica .item p").append("<img src='img/arrow-orange.png' alt='' class='arrow' />");
				$("#cogdziekiedy .item p").append("<img src='img/arrow-green-dark.png' alt='' class='arrow' />");
				$("#promocje .item p").append("<img src='img/arrow-yellow.png' alt='' class='arrow' />");
			}




	// Slider
			$('#slider').css({ display: "block" })
			if( $("body").hasClass("static") ) {
				$('#slider').easyAccordion({

					autoStart: false,
					slideInterval: 5000,
					slideNum:false
				});
			} else {
				$('#slider').easyAccordion({
					autoStart: true,
					slideInterval: 5000,
					slideNum:false
				});

			}






	// If only one column

			if($("#right").exists()) { } else {
				$("#left").css({ width: "890px" });
			}






	// Bajery z naglowkiem

			if(	$(".hgroup h2").exists()) {
				var str = $("h1").text();

				if ( $(".hgroup h2").width() > 300 ) {
					$(".hgroup h1, .hgroup h2").css({ display: "block" });
				} else {
					if ( $("h2").width() > 0 ) {
						$(".hgroup h1").text(" / " + str);
					}
				}
			}







	// Collection

			if(	$(".collection").exists()) {

				$(".collection").css({ display: "block" });

			 	$(function() {
		            var zoomFunc = function(dimension) {
						return dimension * 2;
		            }
		            var shrinkFunc = function(dimension) {
						return dimension * 0.5;
		            }

		            $('div.collection img').slidingGallery({
		            	container: $('.collection'),
		            	useCaptions: true,

		            	captionUpPath: 'img/measure2.png',
		            	captionUpWidth: '50',
		            	captionUpHeight: '35',

		            	captionDownPath: 'img/measure.png',
		            	captionDownWidth: '80',
		            	captionDownHeight: '68',
		            	captionTextAttribute: 'alt',
		            	captionStyle: 'margin-top: 15px; text-align: center; background-color: white; font-weight: bold; opacity: 0.6; filter: alpha(opacity = 60);',

		            	'slideSpeed':'slow',
		            	'Lzoom':zoomFunc,
		            	'Pzoom':zoomFunc,
		            	'Lshrink':shrinkFunc,
		            	'Pshrink':shrinkFunc,
		            	'Lwidth': 300,
		            	'Lheight': 282

		            });
		        });

	        }



	// Round menu

		$("#horiz .subnav").append('<li class="round-bottom"></li>');
		$("#horiz .subnav").prepend('<li class="round-top"></li>');


	// Add round after page

		if($(".start").exists()) { } else {
			$("#center").append('<div class="page-footer"></div>');
		}



	// Add class to first page section

		$(".page:first").addClass("top");
		//$(".page:eq(1)").addClass("white");



});

