	// create a pop up window that displays the image-list page
  	// (and handles clicks on the A tags in the image list page)
	function createWindow(width, height) {

		// Add some pixels to the width and height:
		width = width + 10;
		height = height + 10;

		// If the window is already open,
		// resize it to the new dimensions:
		if (window.popup && !window.popup.closed) {
			window.popup.resizeTo(width, height);
		}

		// Set the window properties:
		var specs = "location=no,scrollbars=no,menubar=no,toolbar=no,resizable=yes,left=0,top=0,width=" + width + ",height=" + height;

		// Set the URL:
		var url = "image-list.php"; // this will be changed to a .php file

		// Create the pop-up window:
		popup = window.open(url, "ImageWindow", specs);
		popup.focus();

		// use event delegation to listen for clicks in the popup window
		popup.addEventListener("click", function(evt){

			if(evt.target.classList.contains("insertImg")){
				// if the target of the click event was one of our A tags,
				// then extract the data from our custom attributes
				var aTag = evt.target;
				var imgName = aTag.dataset.filename;
				var imgDesc = aTag.dataset.filedescription;
				
				insertImg(imgName, imgDesc);

				popup.close();
				
			}

		});
	}