var func=false;
function recheck(ss)
{


        	 x2s=document.getElementById('x2');
             if(parseInt(x2s.offsetLeft)>0)
		 	document.getElementById('widthx').value=parseInt(x2s.offsetLeft)-10;

   x1height=document.getElementById('block1height');
//alert(x1height.offsetTop);
x2height=document.getElementById('block2height');
//alert(x2height.offsetTop);
x3height=document.getElementById('block3height');
//alert(x3height.offsetTop);

heights=parseInt(x1height.offsetTop);
if(parseInt(x2height.offsetTop)>heights)heights=parseInt(x2height.offsetTop);
if(parseInt(x3height.offsetTop)>heights)heights=parseInt(x3height.offsetTop);
  //             alert(heights);

              if(heights>0)
document.getElementById('common_div').style.height=heights+'px';

curval = document.getElementById('cur').value;



totalWidth=parseInt(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(totalWidth)-parseInt((minWidth*(i)))+'px';

				blockA.style.width=totalWidth+"px";
			   	blockA.style.height=heights+'px';

				if(whiteA){ whiteA.style.left=parseInt(totalWidth-20-(totalBlocks*25))+'px';}

				if(i<curval)
				{
					blockA.style.left=parseInt(totalWidth)-parseInt(i*minWidth)+"px";

				}
				else
				{
					blockA.style.left=parseInt(minWidth*(totalBlocks-i))+"px";
				}

			}
	}
if(ss && ss>1)recheck();
}

function change_size(id)
 {
        tabs=new Array('live','kat','tag');
setCookie('slider',id,365);

	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(i==curval)
	{

	   	document.getElementById('arrow_images'+i+'a').style.display ="";

	   	document.getElementById('arrow_images'+i).style.display ="none";

	}
	else
	{

	   	document.getElementById('arrow_images'+i).style.display ="";
       	document.getElementById('arrow_images'+i+'a').style.display ="none";
	}

	}
    
}