﻿// Open a new window ///////////////////////////////////////////////////////////////////////////////

var openWindows = 0;

function openNewWindow(url, showBars, height, width)
{
  var windowWidth = 800;
  var windowHeight = 600;

  if (height)
  {
    windowHeight = height
  }

  if (width)
  {
    windowWidth = width;
  }

  openWindows++;

  if (showBars)
  {
    newWindow = window.open(url, ('NewWindow' + openWindows), 'status=1,toolbar=1,location=1,menubar=1,directories=1,resizable=1,scrollbars=1,height=' + windowHeight + ',width=' + windowWidth);
  }
  else
  {
    newWindow = window.open(url, ('NewWindow' + openWindows), 'status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=' + windowHeight + ',width=' + windowWidth);
  }

  newWindow.focus();

  return false;
}

// Post values to a new window /////////////////////////////////////////////////////////////////////

function postValues(url, values, target)
{
  form = document.createElement('form');
  form.setAttribute('method', 'post');
  form.setAttribute('action', url);

  if (! target)
  {
    target = '_self';
  }

  form.setAttribute('target', target);

  for (var counter = 0; (counter < values.length); counter++)
  {
    input = document.createElement('input');
    input.setAttribute('type', 'hidden');
    input.setAttribute('name', values[counter][0]);
    input.setAttribute('value', values[counter][1]);
    form.appendChild(input);
  }

  document.body.appendChild(form);

  form.submit();
}

