var Ver4=parseInt(navigator.appVersion.charAt(0))>=4
var IE=navigator.appName.indexOf("Microsoft")!=-1
var a1, a2, a3 ,a4 ,ex=-40, ey=-40, x0=-40, y0=-40
  
function Muovi()
{
  if ((Math.abs(ex-x0)>20)||(Math.abs(ey-y0)>20)) {
    if (Math.abs(ex-x0)>=10)
    { x0+=Math.floor((ex-x0)*0.1)/5 }
    else
      if (ex!=x0)
      { x0+=Math.abs(ex-x0)/(ex-x0) }
    if (Math.abs(ey-y0)>=10)
    { y0+=Math.floor((ey-y0)*0.1)/5 }
    else
      if (ey!=y0)
      { y0+=Math.abs(ey-y0)/(ey-y0) }
  }
  
  if ((Math.abs(ex-x0)<40)&&(Math.abs(ey-y0)<40)) {
    if (ex>x0) {
      a1.left=-40
      a1.top=-40
      a2.left=-40
      a2.top=-40
      a3.left=x0-20
      a3.top=y0
      a4.left=-40
      a4.top=-40
    }
    else
    if (ex<x0) {
      a1.left=-40
      a1.top=-40
      a2.left=-40
      a2.top=-40
      a3.left=-40
      a3.top=-40
      a4.left=x0-20
      a4.top=y0
    }
  }
  else {
    if (ex>x0) {
      a1.left=x0-20
      a1.top=y0
      a2.left=-40
      a2.top=-40
      a3.left=-40
      a3.top=-40
      a4.left=-40
      a4.top=-40
    }
    else
    if (ex<x0) {
      a1.left=-40
      a1.top=-40
      a2.left=x0-20
      a2.top=y0
      a3.left=-40
      a3.top=-40
      a4.left=-40
      a4.top=-40
    }
  }

  setTimeout("Muovi();",100)
}

function EventoMouse(e)
{
  if (Ver4)
  { if (!IE)
    { ex=e.pageX
      ey=e.pageY }
    else
    { ex=event.clientX+document.body.scrollLeft
      ey=event.clientY+document.body.scrollTop }
  }
}

function ScriptSetup()
{
  if (Ver4)
  { if (!IE)
    { a1=document.Foglio1
      a2=document.Foglio2
      a3=document.Foglio3
      a4=document.Foglio4
      document.captureEvents(Event.MOUSEMOVE)
    }
    else
    { a1=document.all.Foglio1.style
      a2=document.all.Foglio2.style
      a3=document.all.Foglio3.style
      a4=document.all.Foglio4.style }
    document.onmousemove = EventoMouse
    Muovi()
  }
}

function Principale()
{ 
  if(Ver4)
  { s ='<DIV STYLE="visibility:hidden"></DIV>'
    s+='<DIV ID="Foglio1" STYLE="position:absolute;'
    s+='top:-40; left:-40; width:40; height:40">'
    s+='<IMG NAME="Oggetto1" SRC="../pics/lumaca_r.gif" border=0></DIV>'
    s+='<DIV ID="Foglio2" STYLE="position:absolute;'
    s+='top:-40; left:-40; width:40; height:40">'
    s+='<IMG NAME="Oggetto2" SRC="../pics/lumaca_l.gif" border=0></DIV>'
    s+='<DIV ID="Foglio3" STYLE="position:absolute;'
    s+='top:-40; left:-40; width:40; height:40">'
    s+='<IMG NAME="Oggetto3" SRC="../pics/lumaca_pr.gif" border=0></DIV>'
    s+='<DIV ID="Foglio4" STYLE="position:absolute;'
    s+='top:-40; left:-40; width:40; height:40">'
    s+='<IMG NAME="Oggetto4" SRC="../pics/lumaca_pl.gif" border=0></DIV>'

    document.writeln(s)
  }
}

window.onload = ScriptSetup
Principale()
