﻿$(document).ready(function() {


	jQuery.fn.exists = function() { return jQuery(this).length>0; }


	// Greyscale Hover Effect:

		smoothFade = function (arg) {
			$(arg).hover(function() { //On hover...
				var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
			
				//Set a background image(thumbOver) on the &lt;a&gt; tag 
				$(this).css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
				
				//Fade the image to 0 
				$(this).find("span").stop().fadeTo('slow', 0 , function() {
					$(this).hide() //Hide the image after fade
				});
	
				}, function() { //on hover out...
					//Fade the image to 1 
					$(this).find("span").stop().fadeTo('slow', 1).show();
			});
		}

		smoothFade("footer dd");
		smoothFade("#submit");

		if ($(".start").exists()) {
			smoothFade("#zobacz-portfolio");
		}




	// Focus border remove

			$("a").focus(function() {
				$(this).blur();
			});





	// Contact - clear inputs
	
			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");



	// Fancybox
	
			$(".external").fancybox({
				'width'				: '100%',
				'height'			: '100%',
				'autoScale'			: true,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});


});


