
// LightBox galéria
if ($('#gallery').length > 0) $('#gallery').find('a').lightbox();

// Képváltó
if ($('#image-rotator').length > 0)
{
	var imageRotator = new Object();
	imageRotator.nextIndex = 2;
	imageRotator.imageCount = $('#image-rotator').data('image-count');
	imageRotator.frontImageDIV = $('#frontImage');
	imageRotator.backImageDIV = $('#backImage');
	imageRotator.frontImage = $('#frontImage img');
	imageRotator.backImage = $('#backImage img');
	
	setTimeout(changeImage, 2000);
}

function changeImage()
{
	imageRotator.frontImageDIV.fadeOut(1000, function(){
		imageRotator.frontImage.attr('src', imageRotator.backImage.attr('src'));
		setTimeout(function(){
			imageRotator.frontImageDIV.show();
	
			setTimeout(function(){
				imageRotator.nextIndex++;
				if (imageRotator.nextIndex > imageRotator.imageCount) imageRotator.nextIndex = 1;
				imageRotator.backImage.attr('src', config.rotatorImagesURL + imageRotator.nextIndex);
	    	setTimeout(changeImage, 2000);
			}, 1000);
		}, 1000);
	});
}

// Túl nagyméretű képek átméretezése 960 szélesre
$('#content img').each(function(){
	if ($(this).width() > config.maxImageWidth) $(this).css('width', config.maxImageWidth);
});

