	jQuery(function() {
		// show a simple loading indicator
		var loader = jQuery('<div id="loader"><img src="images/loading.gif" alt="loading..." /></div>')
			.css({position: "relative", top: "1em", left: "25em"})
			.appendTo("body")
			.hide();
		jQuery().ajaxStart(function() {
			loader.show();
		}).ajaxStop(function() {
			loader.hide();
		}).ajaxError(function(a, b, e) {
			throw e;
		});
		
		var v = jQuery("#form").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#resultmail"
				});
			}
		});
		
		jQuery("#reset").click(function() {
			v.resetForm();
		});
		

		$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 7000, true);
		
		$(".tv-player").fancybox({
			'width'				: '50%',
			'height'			: '50%',
			'overlayOpacity'	: '0.7',
			'titleShow'			: false,
			'overlayColor'		: '#000000',
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe'
		});
	

		$("a[rel=random_gallery]").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'overlayOpacity'	: '0.7',
			'overlayColor'		: '#000000',		
			'titlePosition' 	: 'over',
			'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Zdjęcie ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
			}
		});
		
	});

