// movebg by Michael Ball
// www.beyondthenorthwind.co.uk

function movebg($direction) {
if (document.getElementById) {
 // check whether we are moving right or left
if ($direction == '-') movebg.firstimg--;
  else movebg.firstimg++;

// if the value of the first image is less than 1 or greater than the total no of images, correct it.

if (movebg.firstimg > movebg.totalimg) { movebg.firstimg = movebg.firstimg - movebg.totalimg }
if (movebg.firstimg < 1) { movebg.firstimg = movebg.totalimg + movebg.firstimg }	
//movebg.firstimg++

  iv = document.getElementById('imageviewer')
  iv.style.backgroundPosition = movebg.firstimg * movebg.step + 10 +'px 0px';
  
  //alert ('firstimg: ' + movebg.firstimg + '\nOffset: ' + movebg.firstimg * movebg.step + '\n');
}
}

function imgvwr_magnifier(ths_img) {
if (document.getElementById) {
ths_img =  movebg.firstimg - ths_img
if  (ths_img < 1) {ths_img = movebg.totalimg + ths_img}
//alert ('firstimg: ' + movebg.firstimg + '\nths_img:' + ths_img + '\n');
im = document.getElementById('imagemagnifier')
im.style.backgroundPosition = ths_img * imgvwr_magnifier.step + 'px 0px';
}
}

// state the total number of items shown in the background image.
movebg.totalimg = 16;

// Initialize the value of the counter.
movebg.firstimg = movebg.totalimg;

// state the step size in pixels.
movebg.step = 120;

// initialise the script
movebg.btnw = 1;

// calculate the width of the background image
movebg.totalwidth = movebg.totalimg * movebg.step;

// number of items visible at any time
movebg.visitems = 4;

// state the step size for the detail image in pixels.
imgvwr_magnifier.step = 80;

var im = document.getElementById('imagemagnifier');

