/*
	With the following code, Slimbox will activate itself automatically on all links pointing to images,
	or more specifically all links having URLs ending with: ".jpg" or ".png" or ".gif".
	As a result, you will not need to set the rel="lightbox" attribute on any link to activate Slimbox.
	Furthermore, all image links contained in the same block or paragraph (having the same parent element)
	will automatically be grouped together in a gallery, so you will not need to specify groups either.
	Images that are alone in their block or paragraph will be displayed individually.

	Replace the default autoload code block with this one.
*/

jQuery(function($) {

	//normal mode
	$("a[href]").filter(function() {
		return /\.(bmp|jpg|jpeg|png|gif)$/i.test(this.href);
	}).slimbox({
		loop: false,				// Allows to navigate between first and last images
		overlayOpacity: 0.8,			// 1 is opaque, 0 is completely transparent (change the color in the CSS file)
		overlayFadeDuration: 400,		// Duration of the overlay fade-in and fade-out animations (in milliseconds)
		resizeDuration: 400,			// Duration of each of the box resize animations (in milliseconds)
		resizeEasing: "swing",			// "swing" is jQuery's default easing
		initialWidth: 250,			// Initial width of the box (in pixels)
		initialHeight: 250,			// Initial height of the box (in pixels)
		imageFadeDuration: 400,			// Duration of the image fade-in animation (in milliseconds)
		captionAnimationDuration: 400,		// Duration of the caption animation (in milliseconds)
		counterText: "Immagine {x} di {y}"	// Translate or change as you wish, or set it to false to disable counter text for image groups
		}, 
		function(el) { //linkmapper
	        return [el.href, el.title];
		}, 
		function(el) { //linkfilter
		return (this == el) || (this.parentNode && (this.parentNode == el.parentNode));
	});


	//gallery mode
	$("a.lightbox").filter(function() {
		return /\.(bmp|jpg|jpeg|png|gif)$/i.test(this.href);
	}).slimbox({
		loop: false,				// Allows to navigate between first and last images
		overlayOpacity: 0.8,			// 1 is opaque, 0 is completely transparent (change the color in the CSS file)
		overlayFadeDuration: 400,		// Duration of the overlay fade-in and fade-out animations (in milliseconds)
		resizeDuration: 400,			// Duration of each of the box resize animations (in milliseconds)
		resizeEasing: "swing",			// "swing" is jQuery's default easing
		initialWidth: 250,			// Initial width of the box (in pixels)
		initialHeight: 250,			// Initial height of the box (in pixels)
		imageFadeDuration: 400,			// Duration of the image fade-in animation (in milliseconds)
		captionAnimationDuration: 400,		// Duration of the caption animation (in milliseconds)
		counterText: "Immagine {x} di {y}"	// Translate or change as you wish, or set it to false to disable counter text for image groups
		}, 
		function(el) { //linkmapper
	        return [el.href, el.title];
		}, 
		function(el) { //linkfilter
		return true;
	});
	
});