function NewWindow(mypage,myname,w,h,scroll) {
	if ((screen.height-h)<=150)
		TopPosition = 0;
	else
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings)
}


function NewWindowFullScreen(mypage) {
	NewWindow(mypage, "myname", (screen.w-20), (screen.h-20), 'yes');
}

function NewWindowMaxWidth(mypage, maxWidth) {
	NewWindow(mypage, "myname", maxWidth, (screen.height-30), 'yes');
}





function NewFullWindow(targetFolder, targetFile, myname, scroll){
// 800x600, 1024x768, 1280x1024, 1600x1200, 1920x1200 ONLY!
TopPosition = 0;
LeftPosition = 0;
widthSupported = (screen.width == 800 || screen.width == 1024 || screen.width == 1280 || screen.width == 1600 || screen.width == 1920); 
heightSupported = (screen.height == 600 || screen.height == 768 || screen.height == 1024 || screen.height == 1200); 

if (widthSupported && heightSupported)
	targetFolder += screen.width + 'x' + screen.height + '/';
else {
	if (screen.width < 1024)
		targetFolder += '800x600/';
	else {
		if (screen.width < 1280)
			targetFolder += '1024x768/';
		else
			targetFolder += '1280x1024/';
	}
}
target = targetFolder + targetFile;
settings ='height='+(screen.height-20)+',width='+(screen.width-20)+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(target,myname,settings)
}