$(function() {
	$("button").button();
	$("button").width(23);
	$("a[rel=galfotogroup]").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.length ? ' <br /> ' + title : '') + '</span>';
		}
	});
});

function load_prev(id) {
	var max = Math.ceil(id/10);
	/*var next = $("#next");
	var prev = $("#prev");*/
	for (i = 1; i <= max; i++) {
		if ($("#carousel"+i).is(':visible')) {
			var n = i;
			break;
		}
	}
	
	$("#carousel"+n).hide('slide', {direction: 'right'}, 500, function() {
		if (n == 1) { n = max; } else { n--; }
		$("#carousel"+n).show('slide', { direction: 'left' }, 500);
		
		/*if (n == 1) {
			prev.hide();
			next.css('margin-top', '40px');
		} else {
			prev.css('margin-top', '25px');
			prev.show();
			next.css('margin-top', '6pxpx');
		}
		next.show();*/
	});
}

function load_next(id) {
	var max = Math.ceil(id/10);
	/*var next = $("#next");
	var prev = $("#prev");*/
	for (i = 1; i <= max; i++) {
		if ($("#carousel"+i).is(':visible')) {
			var n = i;
			break;
		}
	}
	
	$("#carousel"+n).hide('slide', { direction: 'left' }, 500, function() {
		if (n == max) { n = 1; } else { n++; }
		$("#carousel"+n).show('slide', { direction: 'right' }, 500);
		
		/*if (max == n) {
			next.hide();
			prev.css('margin-top', '40px');
		} else {
			prev.css('margin-top', '25px');
			next.css('margin-top', '6px');
			next.show();
		}
		prev.show();*/
	});
}
