// The OpenWindow script
// ---------------------
// This code is made by Silvester Erdeg (slipszi@yunord.net)
// Use it freely :)
// Note: this code depends on browser_sniffer.js
image_window=null;
function OpenWindow(image,width,height)
{
	// Determine the features
	var features="channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,personalbar=0,status=1,toolbar=0,"
	// Close the image window if it was previously opened
	if(is_ie4up||is_nav3up)
	{
		if(image_window!=null)
		{
			if(!image_window.closed)
				image_window.close();
			image_window=null;
		}
	}
	// Add the margins
	var hmargin=8;
	var vmargin=8;
	if(is_ie4up)
	{
		hmargin=10;
		vmargin=15;
	}
	width+=2*hmargin;
	height+=2*vmargin;
	// Determine the parent window size
	var window_width,window_height,scrollbar_size;
	if(is_nav5up||is_ie4up)
	{
		window_width=document.body.offsetWidth;
		window_height=document.body.offsetHeight;
		scrollbar_size=20;
	}
	else if(is_nav4up)
	{
		window_width=window.innerWidth;
		window_height=window.innerHeight;
		scrollbar_size=16;
	}
	// Clip the child window size
	var resizeable=1,scrollbars=1;
	if(width>window_width&&height>window_height)
	{
		width=window_width;
		height=window_height;
	}
	else if(width>window_width)
	{
		width=window_width;
		height+=scrollbar_size;
	}
	else if(width>window_width||height>window_height)
	{
		width+=scrollbar_size;
		height=window_height;
	}
	else
		resizeable=0,scrollbars=0;
	features+=",width="+width+",height="+height;
	features+=",resizable="+resizeable+",scrollbars="+scrollbars;
	// Open the window
	if(image_window!=null)
		image_window.open(image,"",features);
	else
		image_window=window.open(image,"",features);
	return(false);
}
window.onUnload=WindowClose;
function WindowClose()
{
	if(image_window!=null&&!image_window.closed)
		image_window.close();
	return(true);
}