  var G_defaultRH = 16;    // spacing around image
  var G_defaultRW = 16;
  var G_thisRH = 52;
  var G_thisRW = 32;
  var G_viewSize = 100;    // default window size is 100% of available

// *************************************************************
function GetWinOpts(picHeight,picWidth,minWidth,size,fittosize) {
  var iLeft = 2;
  var iTop = 2;
  var aname = navigator.appName;
  var aplat = navigator.platform;
  var iH = window.screen.availHeight - 32;
  var iW = window.screen.availWidth - 8;
  var i = 0;
  var pH = picHeight;
  var pW = picWidth;
  var info = new Array(7);

  iH = iH - (2 * iTop);
  iW = iW- (2 * iLeft);

  if ( (size > 0) && (size < 100) ) {
    iH = (iH / 100) * size;
    iW = (iW / 100) * size;
  }

  // IE (Mac and Win) - seems to need a height adjust from maximum
  // IE/Win shows vert scrollbars
  if (aname.search("Internet Explorer") != -1) {
    if (aplat.search("Win32") != -1)  {
      G_thisRH = G_thisRH + 16;
      G_thisRW = G_thisRW + 26;
    }
	else {
      G_thisRH = G_thisRH + 48;
	  G_thisRW = G_thisRW - 6;
	}
  }

// auto mode, create the smallest window that will accomodate the given image size
// and resize image if necessary to fit
  if (fittosize > 0) {
    if ( (pH > 0) && (pW > 0) ) {
	  if ( (pH + G_thisRH) > iH ) {
		pW = ((iH - G_thisRH) / pH) * pW;
	    pH = iH - G_thisRH;
	  }
	  if ( (pW + G_thisRW) > iW ) {
		pH = ((iW - G_thisRW) / pW) * pH;
	    pW = iW - G_thisRW;
	  }

      iH = pH + G_thisRH;
      iW = pW + G_thisRW;
	}
  }

  if (iW < minWidth) { iW = minWidth; }
  iH = Math.round(iH);
  iW = Math.round(iW);
  pH = Math.round(pH);
  pW = Math.round(pW);
  info[0] = "Height="+iH+",Width="+iW+",screenX="+iLeft+",screenY="+iTop+",scrollbars=yes,resizable=yes";
  info[1] = iH;
  info[2] = iW;
  info[3] = iLeft;
  info[4] = iTop;
  info[5] = pH;
  info[6] = pW;
  return info;
}

// *************************************************************
function doFull(fname,picHeight,picWidth,price,title,desc,shipcatg) {
  var info;
  var target = 'http://www.randychavez.com/cgi-bin/OrderItem.cgi';
  var newWin;
  var iHeight = 0;
  var iWidth = 0;
  var iLeft = 0;
  var iTop = 0;
  var i = 0;
  var pH = 0;
  var pW = 0;
  var minWidth = 400;
  var item = '';
  var val = '';
  var lastline = '';

// if price is included, generate 2 column custom page from cgi script, else single column
  G_thisRW = 32;
  G_thisRH = 52;
  if (price) { G_thisRW = 256; }
  else {
    if (desc) { G_thisRH = 144; }
	else {
      if (title) { G_thisRH = 10; }
	}
  }

  info = GetWinOpts(picHeight,picWidth,minWidth,100,1);
  iHeight = info[1];
  iWidth = info[2];
  iLeft = info[3];
  iTop = info[4];
  pH = info[5];
  pW = info[6];
  newWin = window.open("","",info[0]);

  if (price) {
    newWin.document.write("<HTML><HEAD><TITLE>Loading...</TITLE></HEAD>");
    newWin.document.write("<BODY bgcolor='#000000'><font size='6' color='silver'>Loading ...</font>");
    newWin.document.write("</BODY></HTML>");
    newWin.document.close;

    target += '?fname=' + fname + '&price=' + price + '&title=' + title + '&desc=' + desc
	+ '&shipcatg=' + shipcatg + '&picHeight=' + pH + '&picWidth=' + pW;
    i = iHeight - G_thisRH;
    target += "&maxheight="+ i;
    i = iWidth - G_thisRW;
    target += "&maxwidth="+ i;
    newWin.location = target;
	return true;
  }
  else {
    if (title) { item = title; }
    else {
      // extract item name from file name
      i = fname.lastIndexOf("/");
      item = fname.substring(i+1,fname.length);
      i = item.indexOf(".");
	  item = item.substring(0,i);
    }

    newWin.document.write("<HTML><HEAD><TITLE>"+item+"</TITLE>");
    newWin.document.write("<LINK REL='stylesheet' TYPE='text/css' HREF='base.css'>");
    newWin.document.write("</HEAD><BODY>");
    val = 'mailto:randy@randychavez.com?subject=' + item;
    lastline = "<p align='center'><a href='" + val + "'>Contact Us</a>&nbsp;&nbsp;<span class='HLITE'>for pricing and availability</span></p>";
	newWin.document.write("<p align='center'><img src='"+fname+"' border='0' ");
	newWin.document.write("height='"+pH+"' width='"+pW+"'></p>");
    if (title) { newWin.document.write("<p align='center'>"+title+"</p>"+lastline); }
    newWin.document.write("</BODY></HTML>");
    newWin.document.close;
    return true;
  }
}