var fadeSpeed= 400;
var currentImage= 1;
var imagesCount= 0;
	
function nextImage()
{
	$('#topCaseImageWrapper img:nth-child('+currentImage+')').animate({'opacity': 0}, fadeSpeed);
	if(currentImage==imagesCount)
		currentImage= 1;
	else
		currentImage++;
	$('#topCaseImageWrapper img:nth-child('+currentImage+')').animate({'opacity': 1}, fadeSpeed);
	$('#topCaseNaviPager').html(currentImage+'/'+imagesCount);
}

function prevImage()
{
	$('#topCaseImageWrapper img:nth-child('+currentImage+')').animate({'opacity': 0}, fadeSpeed);
	if(currentImage==1)
		currentImage= imagesCount;
	else
		currentImage--;
	$('#topCaseImageWrapper img:nth-child('+currentImage+')').animate({'opacity': 1}, fadeSpeed);
	$('#topCaseNaviPager').html(currentImage+'/'+imagesCount);
}

$(document).ready(function () 
{
	$('#topCaseImageWrapper img').css('opacity', 0);
	$('#topCaseImageWrapper img').each(function ()
	{
		$(this).css('opacity', 1);
		return false;
	});
	imagesCount= $('#topCaseImageWrapper img').length;
	if(imagesCount<2)
	{
		$('#topCaseNaviPager').css('display', 'none');
		
		$('#topCaseNaviRight').css('display', 'none');
		$('#topCaseNaviLeft').css('display', 'none');
	}
	else
	{
		$('#topCaseNaviPager').html(currentImage+'/'+imagesCount);
		
		$('#topCaseNaviRight').bind('click', nextImage);
		$('#topCaseNaviLeft').bind('click', prevImage);
	}
});

$(document).ready(function () 
{
	if($('#topCaseNaviTitle').text().length> 45)
	{
		$('#topCaseNaviTitle').css({'line-height': '24px', 'margin-top': '10px'});
		$('#topCaseNaviSubtitle').css({'margin-top': '58px'});
	}
});
