$(function(){
    
    
    $.fn.initGallery = function()
    {
    	var gallery = $(this);
    	if (!gallery.length) {
    		return;
    	}
	    $('div.gallery div.thumbnails', gallery).dxSlider();
    	
    	var image = $('div.image', gallery);
	    $('div.gallery div.thumbnails li a', gallery).click(function(e){
	    	e.preventDefault();
	    	var fn = $(this);
	    	
	    	fn.parent().addClass('active').siblings('.active').removeClass('active');
	    	
	    	image.fadeOut('fast', function(){
	    		image.html(fn.html());
	    		image.fadeIn('fast');
	    	});
	    });
	    
	    //
	    gallery.find('p.light a').fancybox({
			'padding'		: 0,
			'autoScale'		: true,
			'autoDimensions': false,
			'centerOnScroll': true,
			'margin'		: 0,
			'padding'		: 1,
			'titleShow'		: false,
			'showNavArrows' : false,
			'overlayOpacity': 0.8,
			'overlayColor'	: '#000',
			'width'			: 550,
			'height'		: 680,
			'href'			: '',
			'titleShow'		: true,
			'titlePosition'  : 'outside'
			
	    });
    }
    $('#slidegallery').initGallery();
    
});

	$("a#example5").fancybox({
		'titlePosition'  : 'inside'
	});
	
	$("a#example6").fancybox({
		'titlePosition'  : 'over'
	});
	
	$("a[rel=example_group]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
		}
	});
