if (document.getElementById('main-container').className.indexOf('carousel-page') !== -1) {
	
	function replaceDetails(thisEl) {
        var thisDetails = $(thisEl).parent().parent().clone();
        $('#images-info').children().fadeOut('slow', function () {
            $('#images-info').children().replaceWith(thisDetails).css('display', 'none').css('opacity', '1').fadeIn('slow');
            $('#images-info a.nyroModal').replaceWith($('#images-info a.nyroModal img'));
        });		
	};

	var setRotationSpeed = 2;
	if ($('ul#images li:has(img)').length < 3) {
		setRotationSpeed = 0;
		if ($('ul#images li:has(img)').length === 2) {
			$('ul#images li:first-child').before('<li>&nbsp;</li>').after('<li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li>');
			$('ul#images li:last-child').before('<li>&nbsp;</li>');
		}
		
	}
    
    $(function () {
        
        $('ul#images').Carousel({
            itemWidth : 160,
            itemHeight : 162,
            itemMinWidth : 50,
            items : 'li',
            reflections : 0.5,
            rotationSpeed : setRotationSpeed
        }).fadeIn('slow');
		
		
		
		if (setRotationSpeed === 0) {
			$('ul#images').trigger('mousemove');
			if ($('ul#images li:has(img)').length === 2) {
				replaceDetails($('#images li:nth-child(2) img'));
			} else {
				replaceDetails($('#images li:first-child img'));
			}
		} else {
			replaceDetails($('#images li:first-child img'));
		}
		
		// set dir position
		$('.rotdir').css({
			top : ($('ul#images').position().top + $('ul#images').height() - 80)
		});
            
    });
    
    $('#images-info').html('<p>&nbsp;</p>');
    $('ul#images img').mouseover(function () {
		replaceDetails(this);
    });
    
}
