/* CONTACT FORM */

jQuery(function() {
	// show a simple loading indicator
	var loader = jQuery('<div id="loader">Wysyłanie... <img src="/gfx/ajax-loader.gif" /></div>')
		.appendTo("#result")
		.hide();
	jQuery().ajaxStart(function() {
		loader.show();
	}).ajaxStop(function() {
		loader.hide();
		v.resetForm();
	}).ajaxError(function(a, b, e) {
		throw e;
	});
	
	var v = jQuery("form").validate({
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				target: "#result"
			});
		}
	});	
});

// Fancybox

$(document).ready(function() {


	$("a[rel=group]").fancybox({
    'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over"><span style="display: block; font-size:10px; margin-bottom: 5px;">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' </span><b> ' + title : '') + '</b></span>';
		}
	});
});


// images min galerry

$(function() {
			$('ul.hover_block li').hover(function(){
				$(this).find('img').animate({top:'0px'},{queue:false,duration:200});
			}, function(){
				$(this).find('img').animate({top:'50px'},{queue:false,duration:200});
			});
		});


// navigation

$(function(){
		 
		   $('#navigation li a').append('<span class="hover"></span>')
		   
		   $('#navigation li a').hover(function() {
	        
		// Stuff that happens when you hover on + the stop()
		$('.hover', this).stop().animate({
			'opacity': 1
			}, 300,'easeOutSine')
	
	},function() {
	
		// Stuff that happens when you unhover + the stop()
		$('.hover', this).stop().animate({
			'opacity': 0
			}, 500, 'easeOutQuad')
	
	})
		   });
		   

var images = 5;

$(document).ready(function() {
  var index = $('#myImage').attr('alt');

         function rotator() {
           if (index == images)
             {
               index = 1;
             }
           else
             {
               index++;
             }

           $('#myImage').fadeOut( 800, function() {
             $(this).attr('src', '/gfx/banner' + index + '.jpg');
             $(this).fadeIn( 800, function() {

             });
           });
         }

         setInterval (rotator, 4000);
       });
   

