var image;

function setup()
{
  image = document.getElementById("image");
  centerImage();
}

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;

var imagex = 3624;
var width = 0;
var piece = 0;
var newX = 0;

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE + screen width
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
    width = document.body.offsetWidth;
    
  } else {  // grab the x-y pos.s if browser is NS + screen width
    tempX = e.pageX
    tempY = e.pageY
    width = window.innerWidth;
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}
  
  // calculate target location
  total = 0 - imagex + width;
  piece = total / width;
  
  newX = piece * tempX;

  // adjust backgroud
  movePic(newX);
  return true
}

function centerImage()
{
  width = window.innerWidth;
  movePic(-(imagex - width) / 2);
}

function movePic(x)
{
  image.style.left = x+'px';
}

