// PicturesScript.js for small pictures and help files 

var newWindow = null

function makeNewWindow(template,width,height,sb) 
{
	var scroll = 'no'
	var top=1;
	var left=1;
	var screenX=0;
	var screenY=0;
	var availWidth=window.screen.availWidth;
	var availHeight=window.screen.availHeight;

	if (newWindow != null) newWindow.close();
	
	if (width == null) width = 320;
	if (width < 121) width = 121;
	if (height == null) height = 320;
	if ((typeof event != "undefined") && (event != null))
	{	screenX=event.screenX; screenY=event.screenY; left = event.screenX; top = event.screenY + 12;}
	if (top + height + 32 > availHeight) top=screenY - height - 48;
	if (left + width + 16 > availWidth) left=availWidth - width - 16;
	if (top < 1 || left < 1) {top=1;left=1;}
	if (sb != null) {scroll = 'yes'; top=1; left=1}
	if (template.indexOf("?") == -1)
	{	template = template + '?availWidth=' + availWidth + '&availHeight=' + availHeight + '&screenX=' + screenX + '&screenY=' + screenY; }
	else
	{	template = template + '&availWidth=' + availWidth + '&availHeight=' + availHeight + '&screenX=' + screenX + '&screenY=' + screenY; }
	
//	alert( top + ' ' + left + ' ' + screenX + ' ' + screenY + ' ' + availWidth + ' ' + availHeight + ' ' + template); 
	
	
	
	newWindow = window.open(template,'Test','resizable,scrollbars=' + scroll + ',width=' + width + ',height=' + height + ',top=' + top + ',left=' + left);
	
	newWindow.focus()
}

function closeNewWindow() 
{
	if (newWindow != null) newWindow.close();
}

