// viewDetails
// 18-sep-2008: fix image zoom bug
var ORef;
var OH, OW;
var ZTI, ZTO;
window.onload = initVars;
var MAXHEIGHT = 600; // 600
var MAXWIDTH = 800; // 800

function initVars()
{
  ORef = getRef("mainimage");
  if (ORef)
  {
    OH = parseInt(ORef.height);
    OW = parseInt(ORef.width);
    ORef.onmousedown = zoomImage;
    ORef.onmouseup = stopZoom;
    ORef.onmouseover = zoomCursor;
    ORef.onmouseout = autoCursor;
  }
}

function stopZoom()
{
  clearTimeout(ZTI);
  clearTimeout(ZTO);
}

function zoomImage(E)
{
  var B;
  if (navigator.userAgent.indexOf("Opera") != -1) { alert('Sorry, zoom not available in Opera.'); return false; } // right mouse has no event so ugnore them all

  if (E && E.which) { B = E.which;  }
  else if (window.event) { B = window.event.button; }
  else { return false; }

  if (B == 1) zoomIn();
  else zoomOut();
  return false;
}

function zoomIn()
{
//alert('h1='+ORef.height+'; w1='+ORef.width + '; OW='+OW + '; OH='+OH);
  if (ORef.height < MAXHEIGHT && ORef.width < MAXWIDTH) { ORef.height *= 1.25; ORef.width *= 1.25; }
  //ZTI = setTimeout("zoomIn()",500);

}

function zoomOut()
{
//var I = getRef("mainimage");

  if (ORef.height > OH && ORef.width > OW) { ORef.height /= 1.25; ORef.width /= 1.25;  }
  //ZTO = setTimeout("zoomOut()",500);
}

function zoomCursor()
{
  ORef.style.cursor = "w-resize";
  return false;
}

function autoCursor()
{
  ORef.style.cursor = "auto";
  return false;
}

