var dy;
var inter;
var nImage = 1;


function showNextImg()
{
	if (++nImage > nImages)
		nImage = 1;
	
	showLargeImg(nImage-1,0);
}


function showPrevImg()
{
	if (--nImage < 1)
		nImage = nImages;
	
	showLargeImg(nImage-1,0);
}


scrollUp = function()
{	
	if (document.documentElement.scrollTop > 260 - dy)
		window.scrollTo(0,document.documentElement.scrollTop - dy);
	else
		window.clearInterval(inter);
}


function showLargeImg(intNum, intPhoto)
{
	document.getElementById('mainImg').src = document.getElementById('img' + intNum).src.replace("-t","-m");
	document.getElementById('mainImg').title = document.getElementById('img' + intNum).title;
	document.getElementById('mainImg').width = document.getElementById('img' + intNum).getAttribute('fx');
	document.getElementById('mainImg').height = document.getElementById('img' + intNum).getAttribute('fy');
	document.getElementById('capt').style.width = document.getElementById('mainImg').width + "px";
	document.getElementById('textmain').innerHTML = document.getElementById('img' + intNum).title;
	
	for (i=0;i<nImages;i++)
		document.getElementById('imganc' + i).className='';
	
	document.getElementById('imganc' + intNum).className='selected';
	document.getElementById('nums').innerHTML = (intNum+1) + ' of ' + nImages;
	nImage = intNum+1;
	
	//alert(document.documentElement.scrollTop);
	
	if (document.documentElement.scrollTop>370)
	{
		dy = (document.documentElement.scrollTop-260)/25;
		inter = setInterval(scrollUp,15);
	}
	
	return false;
}


document.getElementById('imganc0').className='selected';
