  var G_thisRH = 40;  // reserve for window frame and scrollbars
  var G_thisRW = 40;  // reserve for window frame and scrollbars

// *************************************************************
// creates the largest (non full screen window possible to accomodate image
function GetWinOpts(picHeight,picWidth,minWidth,minHeight) {
  var iLeft = 2;
  var iTop = 2;
  var iH = window.screen.availHeight - 64; // leave room for taskbar
  var iW = window.screen.availWidth - 68; // less than full width
  var i = 0;
  var pH = picHeight;
  var pW = picWidth;
  var info = new Array(7);

  // set window size to pic (if pic smaller than max window)
  if ( (pH > 0) && (pW > 0) ) {
  	if ( (pH + G_thisRH) < iH ) {
	    iH = pH + G_thisRH;
		iW = pW + G_thisRW;
	}
    if ( (pW + G_thisRW) < iW ) {
	    iH = pH + G_thisRH;
		iW = pW + G_thisRW;
    }
  }

  if (iW < minWidth) { iW = minWidth; }
  if (iH < minHeight) { iH = minHeight; }

  iH = Math.round(iH);
  iW = Math.round(iW);
  info[0] = "Height="+iH+",Width="+iW+",screenX="+iLeft+",screenY="+iTop+",toolbar=no,scrollbars=yes,resizable=yes";
  info[1] = iH;
  info[2] = iW;
  info[3] = iLeft;
  info[4] = iTop;
  info[5] = pH;
  info[6] = pW;
  return info;
}

// *************************************************************
// 'X' rate - adds a contact us for pricing line at end
function doFullAuto(fname,picHeight,picWidth,rate) {
  var info;
  var newWin; 
  var iHeight = 0;
  var iWidth = 0;
  var iLeft = 0;
  var iTop = 0;
  var i = 0;
  var minWidth = 0;
  var item = '';
  var val = '';
  var lastline = '';
  var title = 'Full View - ';
  var wintitle = 'FullView_';
 
  minWidth = 310;
  minHeight = picHeight+80;

  info = GetWinOpts(picHeight,picWidth,minWidth,minHeight);  
  iHeight = info[1];
  iWidth = info[2];
  iLeft = info[3];
  iTop = info[4];
  pH = info[5];
  pW = info[6];
  
  // extract item name from file name
  i = fname.lastIndexOf("/");
  item = fname.substring(i+1,fname.length);
  i = item.indexOf(".");
  item = item.substring(0,i);

  val = 'mailto:contact@alanblaustein.com?subject=Print ' + item; 
  if (rate == 'X') {
    lastline = "<p align='center'><font size=4><a href='" + val + "'>Contact Us</a> for pricing and availability</font></p>";
	title = 'Ordering Information - ';
    wintitle = 'OrderInfo_';
  }
  
  title = title+item;
  wintitle = wintitle+item;	

  newWin = window.open("",wintitle,info[0]);   
 
  newWin.document.write("<HTML><HEAD><TITLE>"+title+"</TITLE></HEAD>");
  newWin.document.write("<BODY bgcolor='#000000' text='#C0C0C0' link='#00FF00' vlink='#00FFFF'>");
  newWin.document.write(lastline);
  newWin.document.write("<p align='center'><img src='http://www.alanblaustein.com/"+fname+"' border='0' ");
  newWin.document.write("></p>");
  newWin.document.write("</BODY></HTML>");
  newWin.document.close;
  return false;
}

// *************************************************************
function doOrder(fname,picHeight,picWidth,price,line1,line2,line3) {
  var info;
  var newWin; 
  var iHeight = 0;
  var iWidth = 0;
  var iLeft = 0;
  var iTop = 0;
  var i = 0;
  var minWidth = 0;
  var item = '';
  var val = '';
  var lastline = '';
  var title = 'Full View - ';
  var wintitle = 'FullView_';
 
  minWidth = 310;
  minHeight = 600;
  
  info = GetWinOpts(picHeight,picWidth,minWidth,minHeight);  
  iHeight = info[1];
  iWidth = info[2];
  iLeft = info[3];
  iTop = info[4];
  pH = info[5];
  pW = info[6];
  
  // extract item name from file name
  i = fname.lastIndexOf("/");
  item = fname.substring(i+1,fname.length);
  i = item.indexOf(".");
  item = item.substring(0,i);

  title = 'Ordering Information - '+item;
  wintitle = 'OrderInfo_'+item;	
  
  js = '<script language="JavaScript"> function addCart() { url = "http://www.alanblaustein.com/Cart.php?item='+
       item+'&desc='+line1+' '+line2+'&price='+price+'"; window.location=url; } </script>';

  newWin = window.open("",wintitle,info[0]);   
  newWin.document.write("<HTML><HEAD><TITLE>"+title+"</TITLE>");
  newWin.document.write(js);
  newWin.document.write("</HEAD>");
  newWin.document.write("<BODY bgcolor='#000000' text='#C0C0C0' link='#00FF00' vlink='#00FFFF'>");
  newWin.document.write("<p align='center'>"+line1+" "+line2+"<br>"+line3+"</p>");
  newWin.document.write("<p align='center'><input type='button' value='Add to Cart' onClick='addCart();'></p>");
  newWin.document.write("<p align='center'><img src='http://www.alanblaustein.com/"+fname+"' border='0' ");
  newWin.document.write("></p>");
  newWin.document.write("</BODY></HTML>");
  newWin.document.close;
  return false;
}

