var count_min=1;
var count_main=0;

image1 = new Image();
image2 = new Image();
image3 = new Image();
image4 = new Image();
image5 = new Image();

image1.src = "/images/1.gif";
image2.src = "/images/2.gif";
image3.src = "/images/3.gif";
image4.src = "/images/4.gif";
image5.src = "/images/5.gif";

function open_win(id) {
	window.open("/images/" + id, "photo_big","width=400,height=500,resizable=no,scrollbars=no,menubar=no");
}

function show_img(id) {
var elemBI = document.getElementById(id)

image = elemBI.src.split('/');

image[(image.length-1)] == 'but_min_activ.gif' ? elemBI.src = '/images/but_min_one.gif' : elemBI.src = '/images/but_min_activ.gif';
}

function movelayer_min(div, start, curx, deltax, areawidth, end, stop){
	if ((count_min > 1 && start==1) || count_main==1001)
		return false;
	else if (count_main==2000)
		{
		count_min++;
		start=2;
		}
	else
		{
		count_min++;
		start=2;
		}

	curx+=deltax;
	curx<0 ? curx=0 : '';
	
	document.getElementById(div).style.width=curx;
	
	if(curx>areawidth) {
		if (stop!=0) {
			deltax=-deltax;
			setTimeout('movelayer_min("hand", ' + start + ', ' + curx + ', ' + deltax + ', ' + areawidth + ', ' + end + ', ' + stop + ')',50);
			}
		else
			{	
			count_min=1;
			count_main++;
			}
		}
	else if (curx > end)	
		{
		setTimeout('movelayer_min("hand", ' + start + ', ' + curx + ', ' + deltax + ', ' + areawidth + ', ' + end + ', ' + stop + ')',0);
		}
/*	else
		{
		if (count_main==2000 && curx==0)
			{			document.getElementById("hand").style.background='url(/images/4.gif)';
			setTimeout('movelayer_min("hand", 1, 0, 3, 110, 0, 0)',100);
			}
		else if (count_main==3000 && curx==0)
			{			document.getElementById("hand").style.background='url(/images/5.gif)';
			setTimeout('movelayer_min("hand", 1, 0, 3, 250, 0, 0)',100);
			}	
		count_min=1;
		} 
	if (count_main == 2000 && curx >248)
		setTimeout('movelayer_min("hand", 1, 250, 3, 250, 0, 1)',100); */
}

function movelayer(div, start, curx, deltax, areawidth, end){
	var div='hand';
	if (count_main==3001)
		return false;
	else if ((count_min > 1 && start==1) || count_main>=1001)
		{
		display_dop_img();
		return;
		}
	else
		{
		count_min++;
		start=2;
		}
	curx+=deltax;
	curx<0 ? curx=0 : '';
	document.getElementById('hand').style.width=curx;
	
	if(curx>areawidth) {
		deltax=-deltax;
		document.getElementById("butl").style.visibility="hidden";
		document.getElementById('but_min').style.display="block";
		
		document.getElementById("hand").style.background='url(/images/2.gif)';
		document.getElementById("but_min").style.right=175;
		document.getElementById("but_min").style.top=151;
		document.getElementById("but_min").width=80;
		document.getElementById("but_min").height=190;
		//right:172; margin-top:20; top:145;
		setTimeout('min_max_butl(' + document.getElementById('but_min').width + ', ' + document.getElementById('but_min').height + ')', 500);

		setTimeout('movelayer("hand", ' + start + ', ' + curx + ', ' + deltax + ', ' + areawidth + ', ' + end + ')',50);
		}
	else if (curx > end)
		{
		setTimeout('movelayer("hand", ' + start + ', ' + curx + ', ' + deltax + ', ' + areawidth + ', ' + end + ')',0);
		}
	else
		{
		count_min=1;
		if (count_main<=2)
			document.getElementById("hand").style.background='url(/images/1.gif)';
			setTimeout('movelayer_min("hand", 1, 0, 3, 110, 0, 0)',500);

		if (count_main>=2)
			{
			document.getElementById("hand").style.background='url(/images/3.gif)';
			count_main=1000;
			}

		//document.getElementById("butl").style.right=165;
		}
}

function min_max_butl(x,y)	{
	var a = document.getElementById('but_min');
	if (x<94)	{
		a.style.top=parseInt(a.style.top, 10) + 'px';
		a.style.right=parseInt(a.style.right, 10)-0.5 + 'px';
		a.width=x+1;
		a.height=y+1;
		setTimeout('min_max_butl(' + a.width + ', ' + a.height + ')', 5);
		}
}

function display_dop_img()
{
if (count_main<1500)
	count_main=2000;
else if (count_main<2500)
	count_main=3000;

setTimeout('movelayer_min("hand", 1, 110, 3, 110, 0, 1)',0);
}
