﻿
function OpenInNewWindow( PageToOpen, WindowName, WindowWidth, WindowHeight, ScrollAbility, WindowStartPosition) {
    if(WindowStartPosition == "random") {
		LeftPosition = (screen.width) ? Math.floor(Math.random()*(screen.width - WindowWidth)) : 100;
		TopPosition = (screen.height) ? Math.floor(Math.random()*((screen.height - WindowHeight) - 75)) : 100;
	}
	
	if(WindowStartPosition == "center") {
		LeftPosition = (screen.width) ? (screen.width - WindowWidth) / 2 : 100;
		TopPosition = (screen.height) ? (screen.height - WindowHeight) / 2 : 100;
	} else if((WindowStartPosition != "center" && WindowStartPosition != "random") || WindowStartPosition == null) {
		LeftPosition = 0;
		TopPosition = 20;
	}
	
	WindowSettings = 'width=' + WindowWidth + ',height=' + WindowHeight + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + ScrollAbility + ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win = window.open(PageToOpen, WindowName, WindowSettings);
}
