// Give the URL to go to, the width & height of the popup lesson
// for netscape, x,y of where on the screen you want it to appear,
// and 'y' or 'n' for each of the possible IE width/height fixes
function create_popup_lesson (url, width, height, xoff, yoff, wfix, hfix)
{
  var modwidth, modheight, modx, mody, options;

  // First give this window a name so that it can be referred to later
  window.name = 'original';
  
  // Figure out which is the smallest proportional available Dimension - using 4x3
  // IF it is the height
  if (window.screen) {
  	if ((screen.availHeight / 3) < (screen.availWidth / 4)) {
	  // Now assign the values based upon this
	  sheight = (screen.availHeight / 3) * 3;
	  swidth = (screen.availHeight / 3) * 4;
	}
	// ELSE we need to turn the case
	else {
	  // Assume width is smallest
	  sheight = (screen.availWidth / 4) * 3;
	  swidth = (screen.availWidth / 4) * 4;
	}
		
    // And make it even smaller.
	sheight = sheight * 0.75;
	swidth = swidth * 0.75;
  } else {
	sheight = 480;
	swidth = 640;
  }
  
  // If the width or height is not specfied, give it the screen.
  modwidth = width * 1;
  modheight = height * 1;
  if (!modwidth) modwidth = swidth;
  if (!modheight) modheight = sheight;

  // Allow for IE's vertical scrollbar & extra space
  modx = xoff * 1;
  mody = yoff * 1;

  if (navigator.appName == "Microsoft Internet Explorer")
  {
    // If we want to fix the width
    if (wfix == 'y')
      {
        modwidth += 20;
        modx = (modx < 10) ? 0 : modx - 10;
      }
   
    // If we want to fix the height
    if (hfix == 'y')
      {
        modheight += 10;
        mody = (mody < 5) ? 0 : mody - 5;
      }
  }
  
  // Create the options list
  options = "scrollbars,resizable";

  // Add width & height
  options += ",width="+parseInt(modwidth, 10);
  options += ",height="+parseInt(modheight, 10);

  // Add where to appear
  options += ",screenX="+modx+",left="+modx;
  options += ",screenY="+mody+",top="+mody;

  window.open(url, '_blank', options);
}
