/******************************************************************************************************************/
//	MENU FX
/******************************************************************************************************************/

function menufxHandle(){
	$('#menu A').css({backgroundPosition: "0px 0px"});
	
	$('#menu A').hover(function(){
		$(this).stop().animate({ backgroundPosition:"(0px -50px)" }, { duration: 200 })
	}, function(){
		$(this).stop().animate({ backgroundPosition:"(0px 0px)"}, { duration: 250 })
	});
}

/******************************************************************************************************************/
//	PROGETTI FX
/******************************************************************************************************************/

function projectfxHandle(){
	$('#progetti .info, #gallery .info').css('opacity','0');
	$('#progetti .info, #gallery .info').hide();
	
	$('#progetti LI, #gallery LI').hover(function(){
		offset = $(this).offset();
		myleft = offset.left - 60;
		mytop = offset.top - $(this).find('.info').height() + 15;
		
		$(this).find('.info').show();
		$(this).find('.info').animate({ opacity: '0.95', top: mytop, left: myleft }, 300);
	}, function(){
		offset = $(this).offset();
		$(this).find('.info').animate({ opacity: '0', top: offset.top, left: offset.left }, 300);
		$(this).find('.info').hide();
	});
}

/******************************************************************************************************************/
//	SERVICES FX
/******************************************************************************************************************/

function photoSlide(i) {
	num = $('#services .photo LI').size();
	
	offset = i * 245;
	offset = '-'+offset;
	
	$('#services .photo UL').animate({top: offset}, 500, 'easeOutCirc');
	
	i++;
	if (i >= num) i = 0;
	
	window.setTimeout('photoSlide('+ i +')', 3500);
}

function listSlide(i) {
	num = $('#services .list LI').size();
	
	offset = 85 + (i * 30);
	offset = offset;
	
	$('#services .cursor').animate({top: offset}, 100, 'easeOutCirc');
	
	$('#services .list LI').removeClass('sel');
	$('#services .list LI:eq('+ i +')').addClass('sel');
	
	i++;
	if (i >= num) i = 0;
	
	window.setTimeout('listSlide('+ i +')', 3500);
}

function servicesfxHandle(){
	$('#services').prepend('<div class="cursor"><!-- services cursor --></div>');
	listSlide(0);
	photoSlide(0);
}

/******************************************************************************************************************/
// On document load...
/******************************************************************************************************************/

$(function(){
	menufxHandle();
	servicesfxHandle();
	projectfxHandle();
	
	$('A[@rel*=prettyphoto]').prettyPhoto();
});
