// Scripts used on Allied Supply site
// Standard height and width of windows if none specified
var STANDARD_WIN_WIDTH = 900;
var STANDARD_WIN_HEIGHT = 600;
// Window spacing margin
var STANDARD_WIN_MARGIN = 40;


function PictureWindowOpener(sImageURL, nWidth, nHeight)
{
	// Scroll less options
	var sOptions = ",directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,statusbar=no,toolbar=no";
	var dToday = new Date();
	var sWindowName = "PictureWindow" + dToday.getTime();
	
	if((nWidth == null) || (nWidth == ""))
	{
		nWidth = STANDARD_WIN_WIDTH;
	}
	if((nHeight == null) || (nHeight == ""))
	{
		nHeight = STANDARD_WIN_HEIGHT;
	}
	
	if(nWidth >= screen.availWidth)
	{
		nWidth = screen.availWidth - STANDARD_WIN_MARGIN;
		sOptions = ",directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,statusbar=no,toolbar=no";
	}
	if (nHeight >= (screen.availHeight - 20))
	{
		nHeight = screen.availHeight - STANDARD_WIN_MARGIN;
		sOptions = ",directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,statusbar=no,toolbar=no";
	}

	var nLeft = (screen.availWidth/2) - (nWidth/2);
	var nTop = (screen.availHeight/2) - (nHeight/2);
	
	if(nLeft < 1)
	{ 
		nLeft = 1;
	}
	
	if(nTop < 1) 
	{
		nTop = 1
	}
	
	var sRider = "width=" + nWidth + ",height=" + nHeight + ",top=" + nTop +",left=" + nLeft + sOptions;
	var sLocation = "picturewindow.html?" + sImageURL;
	window.open(sLocation, sWindowName, sRider);
}