var PopupParams = 
[
  // default:
  {
  id:'',
  width:640,
  height:480,
  winid:null
  }
];

function getPopupParamsIndex(id)
{
  var ix;
  var params = null;
  for (ix = 0; ix<PopupParams.length; ix++)
  {
    params = PopupParams[ix];
    if (id == params.id) return ix;
    if (!params.id) return ix; // default
  }
  return -1;
}

function popupWindowOpen(id,source,title,wide)
{
  var ix = getPopupParamsIndex(id);
  if (ix < 0) return;
  var width= PopupParams[ix].width;
  var height =  PopupParams[ix].height;
  PopupParams[ix].winid =
    dhtmlwindow.open(id, 'iframe', source, title, 
      'width='+width+'px,height='+height+'px,center=1,resize=1,scrolling=1');
}

function popupWindowClose(id)
{
  var ix = getPopupParamsIndex(id);
  if (ix < 0) return;
  winid = parent.PopupParams[ix].winid; // yup, it is parent object!
  if (winid == null) return;
  winid.style.display="none";
}

function popupOrderWindow(product_id)
{
  popupWindowOpen('order', '/order.php?product_id=' + product_id, "Order Print");
}

function closeOrderWindow()
{
  // don't know why close() method won't work, but this does...
  popupWindowClose('order');
}

