var mouse = 0;
var circle = 1;
var direction = 0;
var count = 0;
var max_margin = 381;
window.addEvent('domready', function() {

	if($('products')==null) return false;
	
	$('products').addEvent('mouseover',function(){
		
		mouse = 1;
	
	});
	
	$('products').addEvent('mouseout',function(){
		
		mouse = 0;
	
	});
	
	$$('div.product_widget').each(function(){
		count++;
		max_margin= max_margin - 381;
	});
	
	leftmargin = $('move1').getStyle('margin-left');
	
	
	
	
	if(count>0) setInterval("slide()",5000);
});

function slide() 
{
	if(count==0) return;
	
	if(direction == 0)
	{
		
		if(mouse==1) return;
		
		leftmargin = $('move1').getStyle('margin-left');
			

	        wyrreg = new String(leftmargin);
	        leftmargin = wyrreg.replace(/px/,"");
	        leftmargin = parseInt(leftmargin);
			var fx = new Fx.Tween('move1');
			
			fx.start('margin-left', leftmargin - 381);
			circle++;
			
			
			
			if(circle>=count)
			{
				direction = 1;
			}
			
	}
	else
	{
		if(mouse==1) return;
		
			leftmargin = $('move1').getStyle('margin-left');
			

	        wyrreg = new String(leftmargin);
	        leftmargin = wyrreg.replace(/px/,"");
	        
			var fx = new Fx.Tween('move1');
			
			leftmargin = parseInt(leftmargin);
			
			
			fx.start('margin-left', leftmargin+381);
			
			circle--;
			
			if(circle==1)
			{
				direction = 0;
			}
			
	}
	
	
	
	
}