jQuery.noConflict();
jQuery(document).ready(function($){

	$('#slideshowbox img').css('max-width', '100%');
	
	$('#slideshowbox').bind('mouseenter', function(){
		$('#pilvenstre').fadeIn('500');
		$('#pilhoyre').fadeIn('500');
		$('#captions .caption').slideDown();
	}).bind('mouseleave', function(){
		$('#pilvenstre').fadeOut('500');
		$('#pilhoyre').fadeOut('500');
		$('#captions .caption').slideUp();
	});
	
	
	
	$('#pilvenstre').bind('click', function(){
		currentcap = $('#captions').find('.caption');
		prevcap = $(currentcap).prev();

		currentimg = $('#slideshow').find('.active');
		previmg = $(currentimg).prev();

		if(!$('#slideshow').find('.active').is(':first-child')) {
		$(currentimg).removeClass('active');
		$(previmg).addClass('active');

		$(currentcap).removeClass('caption');
		$(currentcap).css('display', 'none');
		$(prevcap).addClass('caption');
		$(prevcap).css('display', 'block');
		}
	});


	$('#pilhoyre').bind('click', function(){
		currentimg = $('#slideshow').find('.active');
		nextimg = $(currentimg).next();

		if(!$('#slideshow').find('.active').is(':last-child')){
		currentcap = $('#captions').find('.caption');
		nextcap = $(currentcap).next();

		$(currentimg).removeClass('active');
		$(nextimg).addClass('active');

		$(currentcap).removeClass('caption');
		$(currentcap).css('display', 'none');
		$(nextcap).addClass('caption');
		$(nextcap).css('display', 'block');
		}
	});
	
});

