var Timer   = new Array();
function slider_move(cnt,objid,direct,slow,mshift,auto,pause)
{
	if(obj = document.getElementById(objid))
	{
		mshift = parseInt(mshift);
		auto = parseInt(auto);
		slow = parseInt(slow);
		if(!slow) slow = 4;
		pause = parseInt(pause);
		if(!pause) pause = 4;

		var startauto = (auto && !cnt && !Timer[objid]) ? 1 : 0;
		
		// уже движемся
		if(Timer[objid])
		{
			// вошли по клику
			if(cnt == 0)
			{
				// не автомат - игнорируем
				if(!auto)
					return;
				// автомат - перезапускаемся
				else
				{
					clearTimeout(Timer[objid]);
					Timer[objid] = null;
				}
			}
			// не автомат - пора останавливаться
			if(!auto && cnt >= mshift)
			{
				clearTimeout(Timer[objid]);
				Timer[objid] = null;
				return;
			}
		}
		sblocks = obj.childNodes;
		allblocks = sblocks.length;
		sliderDim = mshift * allblocks;
		cshift = (auto) ? auto : parseInt((mshift - cnt)/slow);
		if(cshift <= 0) cshift = 1;
		cnt = parseInt(cnt) + parseInt(cshift);
		if(!auto && cnt > mshift)
			cshift = mshift - cnt + cshift;
		var firstpos = 0;
		for(j=0;j < allblocks; ++j)
		{
			if(!sblocks[j].style) continue;
			curPos = (direct=='left' || direct=='right') ? parseInt(sblocks[j].style.left) : parseInt(sblocks[j].style.top);
			curPos = (direct=='left' || direct=='top') ? curPos + cshift : curPos - cshift;
			if(curPos + mshift >= sliderDim)
				curPos -= sliderDim;
			if(curPos <= -mshift)
				curPos += sliderDim;
			if(!startauto)
			{
				if(direct == 'left' || direct == 'right')
					sblocks[j].style.left = curPos + 'px';
				else
					sblocks[j].style.top  = curPos + 'px';
			}
			if(curPos==0)
				firstpos = 1;
		}
		var tm = (auto && (firstpos || startauto)) ? pause*1000 : 30;
		
		Timer[objid] = setTimeout("slider_move('" + cnt + "','" + objid + "','" + direct + "','" + slow +"','" + mshift + "','" + auto + "','" + pause + "')",tm);
	}
}

