stop = false;
var cpic = 0;
var lastPic = 0;
var current4link = 0;
function find_lastPic() {
	lastPic = currentPic - 1;
	if (lastPic == -1)
	
		lastPic = maxPic;
	return lastPic;
}
function startIMG(ignorestop, findlast, lng) {
	if (stop && !ignorestop)
		stop = false;
	else {
		if (findlast)
			find_lastPic();
		if (currentPic == -1) {
			currentPic = 0;
			cpic = currentPic;
			current4link = cpic;
			document.getElementById('s'+photos[cpic]).style.background='url(\'/img/main/slideshow_number_on.gif\') no-repeat top left';
			document.getElementById('s'+photos[cpic]).style.color='#fff';
			document.getElementById(photos[currentPic]).style.display='block';
			//url(\'/img/slideshow/'+photos[currentPic]+'.png\')
			document.getElementById("slideshow_img").style.background='url(\'/img/slideshow/'+photos[currentPic]+'_en.png\') no-repeat center center';
			$("#slideshow_img").fadeIn(2000, function none() {});
		}
		else {

			cpic = currentPic;
			current4link = cpic;
			$("#slideshow_img").fadeOut(1000, function callback() {
					
					for (i = 0; i <= maxPic; ++i) {
						document.getElementById(photos[i]).style.display='none';
						document.getElementById('s'+photos[i]).style.background='url(\'/img/main/slideshow_number.gif\') no-repeat top left';
						document.getElementById('s'+photos[i]).style.color='#670000';
					}
					document.getElementById('s'+photos[cpic]).style.background='url(\'/img/main/slideshow_number_on.gif\') no-repeat top left';
					document.getElementById('s'+photos[cpic]).style.color='#fff';
		
	
					document.getElementById(photos[cpic]).style.display='block';
					document.getElementById("slideshow_img").style.background='url(\'/img/slideshow/'+photos[cpic]+'_en.png\') no-repeat center center';
					$("#slideshow_img").fadeIn(1000, function none() {});
				});
		}
		
		//document.getElementById('lpic'+currentPic).style.background = 'url(\'/img/bg_pic_hover.png\') no-repeat';
		//document.getElementById('lapic'+currentPic).style.color = '#fff';
		
		currentPic++;
		if (currentPic > maxPic)
			currentPic = 0;

		
		document.getElementById('preloadi').innerHTML = '<img src="'+photos[currentPic]+'_en" alt="photo" style="width: 0; height: 0; visibility: hidden;" />';
		setTimeout("startIMG(false, true)", 5000);
	}

}
