var milisec=100;
var t=0, tmax;
var Y=0,ystart;
var V;
var page;

function InitElevator(fl)
{
	var _y;
	oElevator = document.getElementById("lift");
	if(oElevator)
	{
		_y=100+100*(5-fl);
		oElevator.style.top;
		oElevator.style.top=_y;
	}
}

function changepictures(index)
{
	for (i=0; i<5; i++)
	{
document.images[i+2].src = 'http://www.belsnablift.ru/images/'+(i+1)+'.gif';

	}
	document.images[index+1].src = 'http://www.belsnablift.ru/images/'+(index)+'a.gif';

	
}

function MoveElevator(targetFloor){

	changepictures(targetFloor);

	var yend;
	
	//V=(yend-ystart)/tmax;
	
	page=targetFloor;
	
	oElevator = document.getElementById("lift");
	if(oElevator){
		tmp=oElevator.style.top;
	}
	ystart=parseInt(tmp.substring(0,tmp.length-2));
	yend = 100+100*(5-targetFloor);
	
	if ((yend-ystart)<0){V=-200}else{V=200;}
	
	tmax=(yend-ystart)/V;
	t=0;
	
	timer();
}



function timer(){ 

	if(milisec<=0){
		t=t+0.01;
		milisec=100
	}
	if(t>=tmax){
		milisec=0;t-=0.01;
		switch (page) {
			case 1: window.location.href = "http://www.belsnablift.ru/"; break;
			case 2: window.location.href = "http://www.belsnablift.ru/products/"; break;
			case 3: window.location.href = "http://www.belsnablift.ru/docs/"; break;
			case 4: window.location.href = "http://www.belsnablift.ru/about/"; break;
			case 5: window.location.href = "http://www.belsnablift.ru/contacts/"; break;
		}
	}else{ 
		milisec-=100; 
		Y=Math.ceil(ystart+V*t);
		document.getElementById("lift").style.top=Y+'px'
		setTimeout("timer()",1); 
	}
}



