var mediaList = new Array();
var srcList = new Array();
$(document).ready(function() {
	$('#groupwrapper .thumbs li a span').each(function() {
		mediaList.push(parseInt($(this).text(),10));
	});
	$('#groupwrapper .thumbs li a').each(function() {
		srcList.push($(this).attr('href'));
	});
	var startIndex = 0;
	if ( /[#\/]\d{5,}$/.test(document.location.href) ) {
		startIndex = $.inArray(parseInt(/(\d+)$/.exec(document.location.href)[0],10),mediaList);
		if (startIndex == -1)
			startIndex = 0;
	}
	Galleria.loadTheme('/include/galleria_theme.js');
	$('#galleryFull').galleria({
		show: startIndex,
		thumbnails:  true,
		thumb_quaity: true,
		carousel: true, 
		image_crop:false,
	                max_scale_ratio: 1,
		thumb_crop:true,
	    data_source: 'ul.thumbs',
	    transition: 'fade',
            data_config: function(img) {
                return {
                    description: null
                }
            },
	    keep_source: false	});
	$('#viewFull').click(function(e){
		e.preventDefault();
		var viewFullIndex = parseInt(document.location.hash.replace(/^[^\d]+/,''),10);
		document.location.href = srcList[viewFullIndex];
		return false;
	});
        $('#sidebarHeader a.hires-button').click(function(){
                document.location.href = document.URL.replace('/screenshots','/screenshots/full');
        });
});