﻿function fnEnlarge(img)
{
  var imgPath = "/media/Pics/" + img;
  
  var imgWin = fnOpenWindow("", 640, 480, "yes", "yes");
  imgWin.document.write("<html>\n");
  imgWin.document.write("<head>\n");
  imgWin.document.write("<title>PYWA Pic Preview</title>\n");
  imgWin.document.write("<style type=\"text/css\">\n");
  imgWin.document.write("body { background-color: black; margin: 0px; }\n");
  imgWin.document.write("</style>\n");
  imgWin.document.write("</head>\n");
  imgWin.document.write("<body>\n");
  imgWin.document.write("<img src=\"" + imgPath + "\" />\n");
  imgWin.document.write("</body>\n");
  imgWin.document.write("</html>\n");
}

function fnOpenWindow(url, w, h, sb, r, mb, tb, s, loc, dir)
{
  var screenWidth = window.screen.availWidth;
  var screenHeight = window.screen.availHeight;

  var offsetXWinXP = 5;
  var offsetYWinXP = 18;

  var halfScreenWidth = Number(window.screen.availWidth / 2);
  var halfScreenHeight = Number(window.screen.availHeight / 2);

  var halfWindowWidth = Number(w / 2);
  var halfWindowHeight = Number(h / 2);

  var diffWidth = Number(halfScreenWidth-halfWindowWidth);
  var diffHeight = Number(halfScreenHeight-halfWindowHeight);

  diffWidth -= offsetXWinXP;
  diffHeight -= offsetYWinXP;
  
  //The windowName is a zero-based integer corresponding to the number of milliseconds
  //since January 1, 1970, to the date specified by the instance of the Date object;
  //therefore, the windowName will almost always be unique.
  var dtm = new Date();
  var windowName = dtm.getTime();
  
  //if (url == null) { url = "" };
  if (w == null) { w = 640 };
  if (h == null) { h = 480 };
  if (sb == null) { sb = "no" };
  if (r == null) { r = "no" };
  if (mb == null) { mb = "no" };
  if (tb == null) { tb = "no" };
  if (s == null) { s = "no" };
  if (loc == null) { loc = "no" };
  if (dir == null) { dir = "no" };

  var features = "directories=" + dir + ",";
  features += "location=" + loc + ",";
  features += "menubar=" + mb + ",";
  features += "resizable=" + r + ",";
  features += "scrollbars=" + sb + ",";
  features += "status=" + s + ",";
  features += "toolbar=" + tb +",";
  features += "width=" + w + ",";
  features += "height=" + h + ",";
  features += "top=" + diffHeight + ",";
  features += "left=" + diffWidth;
  
  return window.open(url, windowName, features);
}
