function view(image, current)
{
	var big_image = document.getElementById('big_image');
	big_image.src = "http://" + top.location.host + "/uploads/tx_kalendarium/" + image + ".jpg";
	var images = document.getElementById('gallery_thumbs').childNodes.length;
	for (i = 1; i <= images; i++)
	{
		document.getElementById('image' + i).className = '';
	}
	document.getElementById('image' + current).className = 'active';
}

function viewIM(image, current)
{
	var big_image = document.getElementById('big_image');
	big_image.src = "/" + image;
	var images = document.getElementById('gallery_thumbs').childNodes.length;
	for (i = 1; i <= images; i++)
	{
		document.getElementById('image' + i).className = '';
	}
	document.getElementById('image' + current).className = 'active';
}

var current_position = 0;

function scroll(mode, increment)
{
	var gallery_thumbs = document.getElementById('gallery_thumbs');
	document.getElementById('gallery_thumbs').style.height = 'auto';
	var gallery_height = parseInt(document.getElementById('gallery_thumbs').offsetHeight);
	if (increment == undefined)
	{
		increment = 30;
	}
	if (mode == 'up')
	{
		increment = -increment;
	}
	if (gallery_thumbs.style.top)
	{
		current_position = parseInt(gallery_thumbs.style.top, 10);
	}
	var new_position = current_position + increment;
	if (new_position > 0)
	{
		gallery_thumbs.style.top = '0px';
	}
	else if (new_position < -(gallery_height - 376))
	{
		gallery_thumbs.style.top = Math.min(0, -(gallery_height - 376)) + 'px';
	}
	else
	{
		gallery_thumbs.style.top = new_position + 'px';
	}
	current_position = parseInt(gallery_thumbs.style.top, 10);
}

var nonStopScrollId;

function nonStopScroll(mode)
{
	stopNonStopScroll();
	nonStopScrollId = setInterval('scroll("' + mode + '", 10)', 50);
}

function stopNonStopScroll()
{
	if (nonStopScrollId != undefined)
	{
		clearInterval(nonStopScrollId);
	}
	nonStopScrollId = undefined;
}
