function recheck()
{
	

curval = document.getElementById('cur').value;

x2s=document.getElementById('x2');

document.getElementById('widthx').value=parseInt(x2s.offsetLeft)-30;

totalWidth=document.getElementById('widthx').value;

for( i= 0;i <= totalBlocks;i++)
	{
		
		blockA = document.getElementById('block'+i);
		whiteA = document.getElementById('white'+i);
		if(blockA)
			{	blockA.style.left=parseInt(x2s.offsetLeft)-parseInt((minWidth*(i)))-30+'px';
				blockA.style.width=totalWidth+"px";
				
				if(whiteA){ whiteA.style.left=parseInt(x2s.offsetLeft-20-(totalBlocks*30))+'px';}

				if(i<curval)
					blockA.style.left=parseInt(x2s.offsetLeft)-parseInt(i*minWidth)-30+"px";
				else
					blockA.style.left=parseInt(minWidth*(totalBlocks-i))+"px";
					
			}
	}
}

function change_size(id)
 {
 
	var totalWidth = parseInt(document.getElementById('widthx').value);
	curval = document.getElementById('cur').value;
	//alert(id+'-'+curval);
	old=curval;
	if(id==curval ) return;
	
	
	document.getElementById('cur').value = id;	
	stateA = document.getElementById('state'+id).value;	
 	var maxval = parseInt(totalWidth-(totalBlocks-1)* minWidth);


	leftx0 = minWidth*(id-1);
	leftx1 = minWidth*(id-1)+maxval;
		
	//alert(id);
	//Если блок находится в положении 1 переводим его в положение 0
	if(stateA == 1)
	{
		if(curval == totalBlocks) return;

		document.getElementById('state'+(id)).value = '0';	
		obj = document.getElementById('block'+(id-1));
		document.getElementById('cur').value=id;
		oTween = new Tween(obj, 'left',func1,0+(totalBlocks-id-1)*minWidth, totalWidth-(id-1)*minWidth, duration);
			//+ переводим в 0 все что перед ним те слева
			
		for(i = (id);i>0;i--)
		{
			//alert(i+'-'+id);
		if(i!=id){
			stateB = document.getElementById('state'+i).value;	
			document.getElementById('state'+i).value = '0';
			if(stateB == 1)
			 	{	
					obj = document.getElementById('block'+i);
					oTween = new Tween(obj, 'left', func1,0+(totalBlocks-id-1)*minWidth, totalWidth-(i)*minWidth, duration);
				}
			}else document.getElementById('state'+i).value = '1';
		}
		
	}
	else	
	{
	// если блок в положении 0 то переводим его в 1
		document.getElementById('state'+id).value = '1';	
		obj = document.getElementById('block'+id);
		//alert(obj.offsetLeft);
		
				//alert(totalWidth-id*minWidth);
		oTween=new Tween(obj, 'left', func2,totalWidth-id*minWidth,0+(totalBlocks-id)*minWidth , duration);
		// + все что справа от этого блока тоже переводим в 1
		for(i=(id+1);i<=totalBlocks;i++)
		{
		if(i!=totalBlocks){
			stateB=document.getElementById('state'+i).value;	
			document.getElementById('state'+i).value='1';
			if(stateB!=1){	
			obj=document.getElementById('block'+i);
			oTween=new Tween(obj, 'left', func2,totalWidth-id*minWidth, 0+(totalBlocks-i)*minWidth, duration);
			}
			}else document.getElementById('state'+i).value = '1';
		}
		
	}	
	curval = document.getElementById('cur').value;
	for(i = 1; i <= totalBlocks; i++ ) 
{
	stateB=document.getElementById('state'+i).value;	
	
	if(i==(curval)){ document.getElementById('block'+i).className='n-click';}else document.getElementById('block'+i).className='click';
	
	if(stateB==1)
	{
		document.getElementById('arrow_image'+i).className = 'arrow_glvisual_right'; 
		
	}
	else 
	{
		document.getElementById('arrow_image'+i).className = 'arrow_glvisual_left';
	}
	
	}
}
