<!-- open non-html output, e.g. a PDF, in a new window -->
function openWindow(url) {
  var newWindow=window.open(url);
  newWindow.focus();
}

<!-- open a page in a new window; standard size, centered, no bars --> 
function openFrame(myurl, myname, w, h, features) {
  var x = 0, y = 0; // default values
  if (document.all) {
    x = window.screenTop + 50;
    y = window.screenLeft + 20;
  } else if (document.layers) {
    x = window.screenX + 50;
    y = window.screenY + 20;
  }
  if (w == undefined) {
    w = 500;
  }
  if (h == undefined) {
    h = 600;
  }
  if (features == undefined) {
    features = "width=" + w + ",height=" + h + ",left=" + x + ",top=" + y;
    features += ",scrollbars=1,resizable=1,location=0";
    features += ",menubar=0,toolbar=0,status=0";
  } else {
    features += ",width=" + w + ",height=" + h;
  }
  window.open(myurl, myname, features);
}

<!-- set a hidden input object and submit 'main' form -->
function submitForm(myvalue, myid) {
  if (document.main.action != null) {
    document.main.action.value = myvalue;
  }
  if (document.main.actionid != null) {
    document.main.actionid.value = myid;
  }
  document.main.submit();
}

<!-- set a hidden input object and submit 'main' form to new form target mywindow -->
function submitFormWithTarget(myvalue, myid, mywindow, width, height, features) {
  if (document.main.action != null) {
    document.main.action.value = myvalue;
  }
  if (document.main.actionid != null) {
    document.main.actionid.value = myid;
  }
  finalFeatures = openFrame("", mywindow, width, height, features);
  document.main.target = mywindow;
  document.main.submit();
  <!-- reset target to avoid displaying in wrong window -->
  document.main.target = "_self";
}

<!-- set a hidden input object and submit 'main' form to existing target mywindow -->
function submitFormWithExistingTarget(myvalue, myid, mywindow) {
  if (document.main.action != null) {
    document.main.action.value = myvalue;
  }
  if (document.main.actionid != null) {
    document.main.actionid.value = myid;
  }
  document.main.target = mywindow;
  document.main.submit();
  <!-- reset target to avoid displaying in wrong window -->
  document.main.target = "_self";
}

<!-- set a hidden input object and submit a form -->
function submitOtherForm(myformname, myvalue, myid) {
  var myform;
  for (var elems=0; elems < document.forms.length; elems++) {
    if (document.forms[elems].name == myformname) {
      myform = document.forms[elems];
      if (myform.action != null) {
        myform.action.value = myvalue;
      }
      if (myform.id != null) {
        myform.id.value = myid;
      }
      myform.submit();
    }
  }
}

<!-- set the focus to the first enabled, visible control in the main form -->
function setMainFocus() {
  for (var elems=0; elems < document.main.length; elems++) {
    if ((document.main.elements[elems].type!='hidden') &&
        (document.main.elements[elems].type=='enabled')) {
      document.main.elements[elems].focus();
      return true;
    }
  }
}

<!-- display or hide a debug section -->
function toggleDebug() {
  var debugDiv = document.getElementById('debug');
  if (debugDiv != undefined) {
    debugDiv.style.display = (debugDiv.style.display == 'none') ? 'block' : 'none';
  }
}

<!-- a popup reminder to print recipes -->
function popupReminder() {
  var w = 300, h = 180;
  var x = 0, y = 0;

  if (document.all) {
    x=window.screenLeft + ((document.body.offsetWidth-w)/2);
    y=window.screenTop + ((document.body.offsetHeight-h)/2);
  } else {
    x=window.screenX + ((window.innerWidth-w)/2);
    y=window.screenY + ((window.innerHeight-h)/2);
  }

  var features="status=no,menubar=no,resizable=no,width="+w+",height="+h+",left="+x+",top="+y;

  popup = window.open("reminder.html","reminder",features);
  window.onunload = function(){popup.close();}
}
