
var _i = 1;
var _j = 1;
var _x = 0;
var _iPhotoW = 0;
var _iPhotoH = 0;
var _imgPhoto = new Image();
var firstLoop = 0, itemName = "", previousItem = "", firstY = 0, firstX = 0;
var offSety = 10, offSetx = 10;

function zoomIt(item) {
  path = "photos/" + item + ".jpg";
  if (item == "photo4b") { offSety = 200; offSetx = 100; }
  else { offSety = 10; offSetx = 10; }
  if (itemName == "" || (item != itemName && item != undefined)) { firstLoop = 0; }

//  alert(path + " - " + item + " - " + itemName + " - " + firstLoop);
//  alert(firstLoop + " - " + previousItem + " - " + item);
// Remove Previous Product
  if (firstLoop == 0 && previousItem != "" && previousItem != item) {
	var divPhoto = (document.getElementById) ? document.getElementById(previousItem) : (document.all) ? document.all[previousItem] : null;
	divPhoto.style.display = "none";
	previousItem = item;
  }
  else if (previousItem == "") { previousItem = item; }

// Prevent Variables From Being Replaced; Save Info Needed Later
  if (firstLoop == 0) { _imgPhoto = new Image(); itemName = item; firstLoop = 1; var xe = window.event; firstY = xe.clientY - offSety; firstX = xe.clientX - offSetx; }

  if (!_imgPhoto.src) {
	_imgPhoto.src = path;
	setTimeout("zoomIt()",100);
  }
  else if ((_imgPhoto.complete) && (_imgPhoto.width > 25)) { zoomIn(); }
  else {
	if (_x > 50000) { return; }
	else { _x += 1; }
	setTimeout("zoomIt()",100);
  }
}

function zoomIn() {
//  alert(itemName + " - " + firstY + " - " + firstX);
  var imgPhoto = document.images[itemName];	
  var divPhoto = (document.getElementById) ? document.getElementById(itemName) : (document.all) ? document.all[itemName] : null;	
  var e = window.event;
  if (e != null) {
	divPhoto.style.top = e.clientY - offSety;
	divPhoto.style.left = e.clientX - offSetx;
  }
  else if (firstY != 0 && firstX != 0) {
	divPhoto.style.top = firstY;
	divPhoto.style.left = firstX;
	firstY = 0; firstX = 0;
  }
  divPhoto.style.display = "";
  _iPhotoW = _imgPhoto.width;
  _iPhotoH = _imgPhoto.height;
  imgPhoto.src = _imgPhoto.src;	
  imgPhoto.width = 1;
  imgPhoto.height = 1;
  _j = 1;
  zoomInLoop();
}

function zoomInLoop() {
  var imgPhoto = document.images[itemName];
  if (imgPhoto.width < _iPhotoW) {
	imgPhoto.width += _j;
	if (imgPhoto.width > _iPhotoW) { imgPhoto.width = _iPhotoW; }
	imgPhoto.height = Math.round(imgPhoto.width * ((_iPhotoH)/(_iPhotoW)));
	setTimeout("zoomInLoop()",10);
	_j += 1;
//	if (itemName == "photo4b") { photo4b.style.top = 50; }
  }
}

function zoomOut() {
  var imgPhoto = document.images[itemName];
  var divPhoto = (document.getElementById) ? document.getElementById(itemName) : (document.all) ? document.all[itemName] : null;
  if (imgPhoto.width > 0) {
	imgPhoto.width -= _i;
	imgPhoto.height = Math.round(imgPhoto.width * ((_iPhotoH)/(_iPhotoW)));
	setTimeout("zoomOut()",10);
	_i += 1;
  }
  else {
	divPhoto.style.display = "none";
	imgPhoto.width = _iPhotoW;
	imgPhoto.height = _iPhotoH;	
	_i = 1;
  }
}


function createWindow(target,width,height,scroll,resize) {
  targetName = target;
  targetName = target.substring(0, target.lastIndexOf('.'));
  if (target.indexOf('/') != -1) { targetName = targetName.substring(targetName.lastIndexOf('/')+1, length.targetName); }
  scrollbars = "no"; if (scroll == "scroll") { scrollbars = "yes"; }
  resizable = "yes"; if (resize == "noresize") { resizable = "no"; }
  if (targetName == "form1") { height -= 1; }
//  params = "toolbar=no,width=" + width + ",height=" + height + ",directories=no,location=no,status=no,scrollbars=" + scrollbars + ",resizable=" + resizable + ",menubar=no";
//  alert("x" + targetName + "x");

  window.open(target, targetName, "toolbar=no,width=" + width + ",height=" + height + ",directories=no,location=no,status=no,scrollbars=" + scrollbars + ",resizable=" + resizable + ",menubar=no");
//var popupWin = 
//  if (popupWin) { popupWin.focus(); }
}


function message(txt) { window.status = txt; }
function remove_message() { window.status = ""; }

