var sizeW;
var sizeH;
var screen_sizeW;
var screen_sizeH;
var scroll;
var filename;
var leftX;
var topY;
function openPic(sizeW, sizeH, filename){
scroll = 0;

if (sizeW > (window.screen.width - 15))
{
	screen_sizeW = window.screen.width - 15;
	scroll = 1;
}
 else
{
	screen_sizeW = sizeW;
}

if (sizeH > (window.screen.height - 60))
{
	screen_sizeH = window.screen.height - 60;
	scroll = 1;
}
 else
{
	screen_sizeH = sizeH;
}

leftX = ((window.screen.width - sizeW) / 2);
leftX = leftX < 0 ? 0 : leftX; // if position negative then set it to 0
topY = ((window.screen.height - sizeH) / 2);
topY = topY < 0 ? 0 : topY;

var OpenWindow = window.open("","Pic",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=' + scroll + ',resizable=0,width=' + screen_sizeW + ',height=' + screen_sizeH + ',left=' + leftX + ',top=' + topY);
OpenWindow.document.write( "<html>" );
OpenWindow.document.write( "<head>" );
OpenWindow.document.write( "<title>Red Dot Photo Gallery</title>" );
OpenWindow.document.write( "</head>" );
OpenWindow.document.write( "<body bgcolor=black topMargin=0 leftMargin=0 rightMargin=0 bottomMargin=0><center>" );
OpenWindow.document.write( "<img src=" + filename + " width=" + sizeW + " height=" + sizeH + " border=0>" );
OpenWindow.document.write( "</center></body></html>" );
}