$(document).ready(function(){
	jQuery('#ajax').append('<span class="loader" style="display:none"></span>');
	var delay = 200;
	
	$('a.step-btn, .submit, #sidebar a').bind('mousedown mouseup', function() {
		$(this).toggleClass('click');
	});	
	$('#nikos').mouseenter(function(){
		$('#nikos-wrapper').show();
	});
	$('#nikos').mouseleave(function(){
		$('#nikos-wrapper').hide()
	});
	$('#olga').mouseenter(function(){
		$('#olga-wrapper').show();
	});
	$('#olga').mouseleave(function(){
		$('#olga-wrapper').hide()
	});
	$('#kostas').mouseenter(function(){
		$('#kostas-wrapper').show();
	});
	$('#kostas').mouseleave(function(){
		$('#kostas-wrapper').hide()
	});
	
	var scrollValue;
	var animating = false;
	$(window).scroll(function(){
		scrollValue = $(window).scrollTop();
		$('#sidebar').wait({
			msec:1000,
			onEnd:function(){
				if(scrollValue == $(window).scrollTop() && !animating){
					var elementpos = scrollValue+130;
					animating =true;
					$('#sidebar').animate({'top':elementpos+'px'},1000,'easeOutCirc',function(){
						animating = false;
					});
				}
			}
		});
	});
});

function callstep(page){
	$('#steps').fadeOut(300,function(){
		$('.loader').show();
		$('#steps').html('');
		class = (page=='index')?'step1':page;
		$.ajax({
			url: page+'.php',		
			complete: function( res, status ) {
				$('.pagination a.active').removeClass('active');
				$('#steps').html($('<div/>').append(res.responseText).find('#steps'));
				height = $('#steps').height()+100;
				$('.loader').hide();
				$('#steps').fadeIn(200,function(){
					$('#ajax').animate({'height':height, 'min-height': height},600,'easeOutCirc');
				});
				$('#'+class).addClass('active');
			}
		});
	});
	return false;
};
