$(document).ready(function() {

	/* navigation animation */
	$("#navigation").find("a").each(function() {
		var cont = $(this).html();
		$(this).append("<span>"+cont+"</span>");
	});
	$("#navigation").find("a").hover(function() {
		$(this).animate({top:'-16px'}, { queue: false, duration: 100 });
	}, function() {
		$(this).animate({top:'0px'}, { queue: false, duration: 100 });
	})
	
	/* launch button animation */
	$(".launch").find("a").hover(function() {
		if ($.browser.msie) {
			$(this).animate({
				backgroundPositionX: '36px',
				paddingLeft: '0px',
				paddingRight: '16px'
			}, { queue: false, duration: 100 });
		} else {
			$(this).animate({
				backgroundPosition: '36px 0px',
				paddingLeft: '0px',
				paddingRight: '16px'
			}, { queue: false, duration: 100 });
		}
		$(this).parent().parent().css({
			backgroundImage: "url('images/hover.png')",
			backgroundPosition: 'top left',
			backgroundRepeat: 'repeat-y'
		});
	}, function() {
		if ($.browser.msie) {
			$(this).animate({
				backgroundPositionX: '0px',
				paddingLeft: '16px',
				paddingRight: '0px'
			}, { queue: false, duration: 100 });
		} else {
			$(this).animate({
				backgroundPosition: '0px 0px',
				paddingLeft: '16px',
				paddingRight: '0px'
			}, { queue: false, duration: 100 });
		}
		$(this).parent().parent().css({
			backgroundImage: 'none'
		});
	});
	
	/* details button animation */
	$(".details").find("a").hover(function() {
		if ($.browser.msie) {
			$(this).animate({
				backgroundPositionX: '6px',
				paddingLeft: '16px',
				paddingRight: '0px'
			}, { queue: false, duration: 100 });
		} else {
			$(this).animate({
				backgroundPosition: '6px 0px',
				paddingLeft: '16px',
				paddingRight: '0px'
			}, { queue: false, duration: 100 });
		}
		$(this).parent().parent().css({
			backgroundImage: "url('images/hover.png')",
			backgroundPosition: 'top right',
			backgroundRepeat: 'repeat-y'
		});
	}, function() {
		if ($.browser.msie) {
			$(this).animate({
				backgroundPositionX: '41px',
				paddingLeft: '0px',
				paddingRight: '15px'
			}, { queue: false, duration: 100 });
		} else {
			$(this).animate({
				backgroundPosition: '41px 0px',
				paddingLeft: '0px',
				paddingRight: '15px'
			}, { queue: false, duration: 100 });
		}
		$(this).parent().parent().css({
			backgroundImage: 'none'
		});
	});
	
	/* disable details when no description */
	$(".details").find("a").each(function() {
		if ($(this).parents(".work").find(".description").length <= 0) {
			$(this).parent().css({ opacity: '0.4' });
		}
	});
	
	/* thumbnail animation */
	$(".thumbnail a").hover(function() {
		$(this).find("img").animate({
			marginTop: '-10px'
		}, { queue: false, duration: 120, complete: function() { $(this).animate({
			marginTop: '0px',
		}, { queue: false, duration: 160 }); }});
		$(this).find("small").animate({
			fontSize: '0.7em',
			opacity: 1,
			bottom: '2px'
		}, { queue: false, duration: 120 });
	}, function() {
		$(this).find("small").animate({
			fontSize: '0.4em',
			opacity: 0,
			bottom: '-22px'
		}, { queue: false, duration: 120 });
	});
	
	/* launch button action */
	$(".launch").find("a").click(function() {
		var url = $(this).parents(".work").find(".thumbnail a").attr("href");
		$(this).attr({
			href: url,
			target: '_blank'
		});
	});
	
	/* details button action */
	$(".details").find("a").click(function() {
		$(this).parents(".work").find(".description").stop().fadeIn("fast").hover(null, function() {
			$(this).fadeOut("slow");
		});
		$(this).parents(".work").find(".description").find("u").hover(function() {
			$(this).parent().siblings("p").stop().animate({
				height: "14px"
			});
			$(this).parent().stop().animate({
				height: "76px"
			});
		});
		return false;
	});

});
