/* Window Popup
 * 
 * Displays content in a new browser window. If the window has already been created, but been
 * ocluded or minimized it will bring it back to the top.
 *
 *
 * Dependancies: requires the use of global veriable "windowObjectReference" which must
 * be initialized to null. 
 */

			

// Get the given key value from the URL query.
function gup( key )
{
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+key+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( unescape(window.location.href) );
  if( results == null )
    return "";
  else
    return results[1];
}

			// var windowObjectReference = null; // global variable

			function windowPopup(targetURL,width,height)
			{
			

				if (!width) width=400;
				if (!height) height=200;
				var options = "width=" + width + ",height=" + height + ",resizable,menubar=no,status=no,toolbar=no,location=no";
			    var w = window.open(targetURL,"ImageUploadWindow",options );
				try {
				w.focus();
				}
				catch(err) {}
				//return false;
			}
 


			function windowPopup1(targetURL,width,height)
			{
			

			if (!width) width=400;
			if (!height) height=200;
			
 
			  //alert("in imageUploadPopup: windowObjectReference = " + windowObjectReference);

			  if (windowObjectReference != null)
			  {
			  	alert("Window Already Open: windowObjectReference.closed = " + windowObjectReference.closed);
			  } 
			  
			  if(windowObjectReference == null || windowObjectReference.closed)
			  /* if the pointer to the window object in memory does not exist
			     or if such pointer exists but the window was closed */
			
			  {
				//alert("opening new window");
				var options = "width=" + width + ",height=" + height + ",resizable,menubar=no,status=no,toolbar=no,location=no";
			    windowObjectReference = window.open(targetURL,"ImageUploadWindow",options );
			    /* then create it. The new window will be created and
			       will be brought on top of any other window. */
			  }
			  else
			  {
				alert("window already open - setting focus");

			    windowObjectReference.focus();
				/* else the window reference must exist and the window
			       is not closed; therefore, we can bring it back on top of any other
			       window with the focus() method. There would be no need to re-create
			       the window or to reload the referenced resource. */
			  }
			}

