// Opens a window for previewing images
// Compatibility: IE4+, NS4+
// Call in document head or following the body tag

var windowID = "";

function PopupWindow() {

	if (arguments.length > 0)
	{
		// Argument default values
		resourceURL = arguments[0];
		
		if (arguments.length < 2) width			= 400; 		else width			= arguments[1];
		if (arguments.length < 3) height		= 450;		else height			= arguments[2];
		if (arguments.length < 4) scrollbar		= false;	else scrollbar		= arguments[3];
		if (arguments.length < 5) centerWindow	= true;		else centerWindow	= arguments[4];
		if (arguments.length < 6) reuseWindow	= true;		else reuseWindow	= arguments[5];
		
		var popW = width, popH = height;
		
		if (scrollbar) 
			{ var enableScrolling = "yes"; }
		else 
			{ var enableScrolling = "no"; }
			
		if (centerWindow) 
			{ var xPos = (self.screen.availWidth-popW)/2; var yPos = (self.screen.availHeight-popH)/2; }
		else 
			{ var xPos = 10; var yPos = 10; }
				
		if (reuseWindow) 
			var frameName = "csPopup";
		else 
			var frameName = "_blank";
				
		if(windowID && !windowID.closed) windowID.close();
		windowID = window.open("/global/contentserver/includes/common/cspopup.cfm?res=" + resourceURL, 
			frameName, 
			"width="		+ popW + 
			",height="		+ popH + 
			",screenX="		+ xPos + 
			",screenY="		+ yPos + 
			",left="		+ xPos + 
			",top="			+ yPos + 
			",scrollbars="	+ enableScrolling);
		
	}
	
	else
		alert("ERROR: No resource URL was passed to the PopupWindow() function.");

}
