
function scroll_left(id,start_point,distance)
{
	var o = document.getElementById(id);
	var i=start_point;


	o.style.left = i+'px';
	if(o!=null)
	{
		function change()
		{
			if(i<=distance)
			{
				i=distance;				
			}
			else
			{
				delta=(i-distance)/6;
				if(delta<0.5)
					delta=0.5;
				i-=delta;
				o.style.left = i+'px' ;    
			}
		}
	}

	if(i>distance)
		window.setInterval(change,1);

	
}

function scroll_right(id,start_point,distance)
{
	var o = document.getElementById(id);
	var i=start_point;

	o.style.left = parseInt(i)+'px';
	if(o!=null)
	{
		function change()
		{
			if(i>=distance)
			{
				i=distance;
			}
			else
			{
				delta=(distance-i)/6;
				if(delta<0.5)
					delta=0.5;
				i+=delta;
				o.style.left = i+'px' ;    
			}
		}
	}

	if(i<distance)
		window.setInterval(change,1);
}

function index_show_next(gg)
{
	var mm=parseInt(document.getElementById('demo_current').value);
	
	demo_old='demo'+mm;
			
	if(mm==gg)
		NO=1;
	else
		NO=mm+1;

	document.getElementById('demo_current').value=NO;
	
	demo_new='demo'+NO;
	document.getElementById(demo_new).style.display='block';
	//alert(mm);
	scroll_left(demo_old,0,'-900');
	scroll_left(demo_new,900,0);

}

function index_show_prev(gg)
{
	var mm=parseInt(document.getElementById('demo_current').value);
	
	demo_old='demo'+mm;
			
	if(mm==1)
		NO=gg;
	else
		NO=mm-1;

	document.getElementById('demo_current').value=NO;
	
	demo_new='demo'+NO;
	document.getElementById(demo_new).style.display='block';
	//alert(mm);
	scroll_right(demo_old, 0 ,900);
	scroll_right(demo_new, -900 ,0);
}

var STOP; 

function show_demo()
{
	var mm=parseInt(document.getElementById('demo_current').value);
	
	index_show_next(5);

	STOP=setTimeout("show_demo()",3000);

}
function show_demo_stop()
{
	clearTimeout(STOP);
}
function changeAgin()
{
	show_demo();
}
