$(document).ready(function () {
	$('#info .title').html($('#work .box img:visible').attr('alt'));
	$('#nav ul li').not('.active').hover(
		function () {
			$(this).stop().animate({ backgroundPosition:'(0 0)' }, 300, 'swing');
		}, 
		function () {
			$(this).stop().animate({ backgroundPosition:'(12px -30px)' }, 300, 'swing');
		}
	);
	
	$('#bottom li').not('.active').css('opacity', 0.5);
	
	$('#bottom li').not('.active').hover(
		function () {
			$(this).animate({ opacity:'1' }, 500, 'swing');
		}, 
		function () {
			$(this).animate({ opacity:'0.5' }, 500, 'swing');
		}
	);
	
	$('.infonav li a').click(function () {
		var cindex = parseInt($(this).text());
		//alert(cindex);
		if($(this).parent().hasClass('prev'))
		{
			if($('#work .box img:visible').prev().length > 0)
			{
				$('.infonav li').removeClass('active');
				$('#work .box img:visible').fadeOut('fast', function () {
					$('#info .title').html($(this).prev().attr('alt'));
					$(this).prev().fadeIn('fast');
					$('.infonav li:eq('+(cindex)+')').addClass('active');
					$('.infonav .next a').text(cindex+1);
					$('.infonav .prev a').text(cindex-1);
				});

			}
		}
		else if($(this).parent().hasClass('next'))
		{
			if($('#work .box img:visible').next().length > 0)
			{
				$('.infonav li').removeClass('active');
				$('#work .box img:visible').fadeOut('fast', function () {
					$('#info .title').html($(this).next().attr('alt'));
					$(this).next().fadeIn('fast');
					$('.infonav li:eq('+(cindex)+')').addClass('active');
					$('.infonav .next a').text(cindex+1);
					$('.infonav .prev a').text(cindex-1);
				});
			}
		}
		else
		{
			var windex = $(this).text();
			$('.infonav li').removeClass('active');
			$('#work .box img:visible').removeClass('active').fadeOut('fast', function () {
				$('#info .title').html($('#work .box img:eq('+(windex-1)+')').attr('alt'));
				$('#work .box img:eq('+(windex-1)+')').fadeIn('fast');
				$('.infonav .next a').text(cindex+1);
				$('.infonav .prev a').text(cindex-1);
			});
			$(this).parent().addClass('active');
		}
		return false;
	});
});