/**
 * @author jacky.lau
 */
$(document).ready(function() {

	//cufon
	Cufon.replace(".cufon");
	Cufon.replace(".cufonhover", { hover: true });

	//position gradient behind logo
	var LogoPosition = $(".header-navigation").position();
	var LogoGradientPositionLeft = LogoPosition.left - 127;
	$(".header").css("background-position", LogoGradientPositionLeft + "px 0px");
	$(window).resize(function() {
		var LogoPosition = $(".header-navigation").position();
		var LogoGradientPositionLeft = LogoPosition.left - 127;
		$(".header").css("background-position", LogoGradientPositionLeft + "px 0px");
	});

	//promo tiles hover animation binding
	$(".promo-tile-container").hover(
		function() {
			if ($(this).find("p.description").length > 0){
				var textHeight = Number($(this).find(".promo-tile-title-description").css("top").replace("px", "")) - $(this).find("p.description").height();
				textHeight -= 6;
				$(this).find(".promo-tile-title-description").stop(true, true).animate({
					top: textHeight + 'px'
				}, 250);
			}
		},
		function() {
			if ($(this).find("p.description").length > 0){
				$(this).find(".promo-tile-title-description").stop(true, true).animate({
					top: '125px'
				}, 200);
			}
		}
	);

	//Animate opacity hovering promo tiles / image gallery
	$(".promo-tile-container").hover(function() {
		$(this).find(".promo-tile-image").stop().animate({ "opacity": 0.6 });
	}, function() {
		$(this).find(".promo-tile-image").stop().animate({ "opacity": 1 });
	});
	$(".media-container").hover(function() {
		$(this).find(".media-image").stop().animate({ "opacity": 0.6 });
	}, function() {
		$(this).find(".media-image").stop().animate({ "opacity": 1 });
	});

});
