var active = 1;
var activebigimg = 1;
showbigimage();
showimages();

function scrollleftClick()
{
	active=active-1;
	showimages();
}
function scrollrightClick()
{
	active=active+1;
	showimages();
}
function buttonleftClick()
{
	activebigimg=activebigimg-1;
	showbigimage();
}
function buttonrightClick()
{
	activebigimg=activebigimg+1;
	showbigimage();
}

function showbigimage()
{
	var t = document.getElementById("imgtd"+activebigimg);

	var im = document.getElementById("bigimage");
	var bn = document.getElementById("bnadpis");
	var a = t.getAttribute("name");
	var ar = a.split(";");
	im.src=ar[0];
	if(ar[1]=="" || ar[1]=="NoDescr") bn.innerHTML="&nbsp;";
	else bn.innerText=ar[1];
	if(ar[1]=="" || ar[1]=="NoDescr") im.title="";
	else im.title=ar[1];
	var totalcount = 1;
	var existimg = true;
	while(existimg)
	{
	var b = document.getElementById("imgtd"+totalcount);
	if(b)totalcount++;
	else existimg=false;
	
	}
	totalcount=totalcount-1;
	var buttonright = document.getElementById("rightbutton");
	var buttonleft = document.getElementById("leftbutton");

	if(activebigimg>=totalcount)
	{
		buttonright.style.visibility="hidden";
	}
	else
	{
		buttonright.style.visibility="visible";
	}

	if(activebigimg<=1)
	{
		buttonleft.style.visibility="hidden";
	}
	else
	{
		buttonleft.style.visibility="visible";
	}
	
}
function showimages()
{
	var totalcount = 1;
	var existimg = true;
	while(existimg)
	{
	var b = document.getElementById("imgtd"+totalcount);
	if(b)totalcount++;
	else existimg=false;
	
	}
	totalcount=totalcount-1;
	var scrollright = document.getElementById("scrollright");
	var scrollleft = document.getElementById("scrollleft");
	if(active+3>=totalcount)
	{
		scrollright.style.visibility="hidden";
	}
	else
	{
		scrollright.style.visibility="visible";
	}
	if(active<=1)
	{
		scrollleft.style.visibility="hidden";
	}
	else
	{
		scrollleft.style.visibility="visible";
	}
	for(i=1;i<=totalcount;i++)
	{
	var a = document.getElementById("imgtd"+i);
	if(a) a.style.display="none";
	}
	for(i=active;i<active+5;i++)
	{
	var a = document.getElementById("imgtd"+i);
	if(a) a.style.display="inline";
	}
}
