var IE = document.all;
var winPop = null;

function popPDFWindow(formName, recipeId) 
{
  //alert("popPDFWindow...recipeId=" + recipeId);         //JWC999
  var url = '';
  var templateId = '';
  var templateObj = document.forms[formName].elements['TemplateId'];
  for(var i = 0; i < templateObj.length; i++)
  {
    if(templateObj[i].checked) 
    {
      templateId = templateObj[i].value;
    }
  }
  var quantity = document.forms[formName].elements['Quantity'].value;
  url = '/gifttags/pdf/' + recipeId + '/' + templateId + '/' + quantity + '/CreateGiftTag.pdf';
  //alert("popPDFWindow...url=" + url);         //JWC999
  
  popChildWindow('pdf', url, 600, 600, ",resizable,scrollbars");  
  return false;
}

function popChildWindow(popname, url, w, h, options) 
{
  //alert('popChildWindow...popname=' + popname + '  url=' + url + '  options=' + options);      //JWC999
  if (options == '' || options == null || options.length == 0)
    winPop = window.open(url, popname);
  else
    winPop = window.open(url, popname, popWindowOptions(w, h, options));
  winPop.focus();
  //alert('popChildWindow...end');
  return false;
}

function popWindowOptions(w, h, options) 
{
  //alert('popWindowOptions...begin');
  var winTop = (IE)?window.screenTop:window.screenY;
  var winLeft = (IE)?window.screenLeft:window.screenX;
  var width = (w)?w:360;
  var height = (h)?h:360;
  //alert('popWindowOptions...end');
  return 'height=' + height + ',width=' + width + ',top=' + parseInt(winTop + 25) + ',left=' + parseInt(winLeft + 75) + options;      
}

function popHelpWindow(sHelpKey, w, h, scroll, queryString) {
//  var width = (w) ? w:320;
//  var height = (h) ? h:300;
  var width = (w) ? w:325;
  var height = (h) ? h:320;
  var v_scrollbar = '';
  var v_scroll = (scroll) ? scroll:'';
  if (v_scroll.length) {
    v_scrollbar = ',scrollbars';
  }
  var url = '';
  switch (sHelpKey) {
    case 'searchhints':
      url = '/searchhints.asp' + queryString;
      break;
    default:
      break;
  }
  if (url.length) {
    window.open(url, sHelpKey, 'WIDTH=' + width + ',HEIGHT=' + height + v_scrollbar);
  }
}
