var BeltTimer
var BeltOffset = 1000
var BeltMovingOffset = 10
var ImageWidth = 660
var BlockWidth = 110
var Urls = new Array(
'затычка',
'/products/autonorms',
'/products/autobearings',
'/products/manufacture',
'/develop/portfolio/denisschool',
'/products/valute',
'/products/autolist'
)

function BeltMouseMove(e)
{
  var mousePosition = getBeltMousePosition(e.clientX)
  document.getElementById('Belt').style.cursor = getBeltImageId(mousePosition) ? 'pointer' : 'default'
}


function BeltClick(e)
{
  var mousePosition = getBeltMousePosition(e.clientX)
  var imageId = getBeltImageId(mousePosition)
  if( imageId )
  {
    document.location.href=Urls[imageId];
  }
}


function BeltRollLeftStart()
{
  beltRoll( -10 )
  BeltTimer = setTimeout(BeltRollLeftStart, 25)
}

function BeltRollRightStart()
{
  beltRoll( 10 )
  BeltTimer = setTimeout(BeltRollRightStart, 25)
}

function BeltRollStop()
{
  clearTimeout(BeltTimer)
}

function beltRoll(offset)
{
  var bgWidth = 1000
  if ((offset>0)&&(BeltOffset<2000))
  {
    BeltOffset += offset
    document.getElementById('Belt').style.backgroundPosition = '-' + BeltOffset + 'px 0px'
  }
  if ((BeltOffset>0)&&(offset<0)){
    BeltOffset += offset
    document.getElementById('Belt').style.backgroundPosition = '-' + BeltOffset + 'px 0px'
  }
}

function getBeltMousePosition(clientX)
{
  return ( clientX)
}

function getBeltImageId( mousePosition )
{  
  i =  BeltOffset +  mousePosition - 497
  k =  Math.floor(i/ImageWidth)
  i = i - k * ImageWidth  
  var n = Math.floor(i/BlockWidth)+1
  while (i>0) i=i-BlockWidth
  if ((i==-2)||(i==-1)) n = 0
  return n
}