
var elewidth_ = 210;
function initProductSlides ( )
{
	if ( document.getElementById ( 'ProductSlideContainer' ) )
	{
		var productSlideContent = document.getElementById ( 'ProductSlideContent' );
		
		var eles = productSlideContent.childNodes;
		var xc = 0;
		var i = 0;
		for ( var a = 0; a < eles.length; a++ )
		{
			if ( !eles[ a ].style ) continue;
			eles[ a ].style.position = 'absolute';
			eles[ a ].style.left = ( i++ * elewidth_ ) + 'px';
			eles[ a ].style.top = '0px';
		}
		
		var arRight = document.getElementById ( 'ProductSlideArrowRight' );
		var arLeft = document.getElementById ( 'ProductSlideArrowLeft' );
		
		arRight.obj = productSlideContent;
		arLeft.obj = productSlideContent;
		
		arRight.onselectstart = function ( ){ return false; }
		arLeft.onselectstart = function ( ){ return false; }
		arRight.onmousedown = function ( )
		{
			this.obj.scroll ( -elewidth_ );
			return false;
		}
		arLeft.onmousedown = function ( )
		{
			this.obj.scroll ( elewidth_ );
			return false;
		}
		
		document.body.scroller_ = productSlideContent;
		productSlideContent.i = i;
		productSlideContent.scroll = function ( vardir )
		{
			var cleft = parseInt ( this.offsetLeft );
			if ( !vardir ) vardir = 0;
			else
			{
				if ( this.interval ) clearInterval ( this.interval );
				var val = Math.round ( parseInt ( vardir ) / elewidth_ );
				this.target = ( Math.round ( cleft / elewidth_ ) + val ) * elewidth_;
				if ( this.target > 0 ) this.target = 0;
				else if ( Math.round ( this.target / elewidth_ ) <= -( this.i - 3 ) )
					this.target = elewidth_ * -( this.i - 3 );
				this.current = cleft;
			}
			var diff = ( this.current - this.target ) / 3;
			if ( Math.abs ( diff ) < 0.2 )
				this.style.left = this.target + 'px';
			else
			{
				this.current -= diff;
				this.style.left = Math.round ( this.current ) + 'px';
				this.interval = setTimeout ( 'document.body.scroller_.scroll ( )', 70 );
			}
		}
		return true;
	}
	setTimeout ( 'initProductSlides ( )', 50 );
}

initProductSlides ( );


