$(document).ready(function() {
	$('#frontSplashImage').cycle({
		before: mOnBefore,
		speed:  1500,
		timeout: 6500
	});
	
	$('#contentInside').masonry({});
	
	// $('#frontBigNav ul li a').click(function() {
	// 	$('#frontSplashImage').cycle({
	// 		before: mOnBefore,
	// 		timeout: 0
	// 	});
	// 	
	// 	return false;
	// });
});

function mOnBefore()
{
	var newText = this.alt;
	
	var className = $(this).attr('class');
	
	$('#frontSplashText').fadeOut(500, function() {
		$('#frontSplashTextInside').html(newText);
		$(this).fadeIn();
	});
	
	if ($('#frontSplashText a.readMoreLink').hasClass('fr')) {
		oldHref = '/fr/';
	}
	else {
		oldHref = '';
	}
	
	$('#frontSplashText a.readMoreLink').attr('href', oldHref + className + '/');
	
	animateArrow(className);
}

function animateArrow(className)
{
	var lang = $('#frontSplashImage').attr('class');
	var points = {
		'buy': 0,
		'prepare': 0,
		'enjoy': 0
	};
	
	if (lang == 'en') {
		points.buy = 66;
		points.prepare = 216;
		points.enjoy = 384;
	} else {
		points.buy = 66;
		points.prepare = 216;
		points.enjoy = 384;
	}
	
	$('#frontBigNavArrow').animate({
		left: points[className]
	});
}
