var newWindow;

function openWindow(url, name) {
	newWindow = window.open(url, name, "width=" + screen.availWidth + ",height=" + (screen.availHeight - 30));
	newWindow.focus();
}

function openLoginWindow() {
	loginWindow = window.open(BASE + "/app/login.php","loginWindow", "width=" + screen.availWidth + ",height=" + (screen.availHeight - 30) + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,screenX=0,screenY=0,left=0,top=0");
	loginWindow.focus();
}

function newWindow(url, width, height, windowName) {
	var left = (screen.availWidth / 2) - (width / 2);
	var top = (screen.availHeight / 2) - (height / 2);
	var newWindow;
	if(!windowName) {
		var windowName = 'newWindow' + Math.floor(Math.random() * 100);
	}
	newWindow = window.open(url, windowName, 'top=' + top + 'px,left=' + left + 'px,screenX=' + left + 'px,screenY=' + top + 'px,width=' + width + 'px,height=' + height + 'px,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no');
	newWindow.focus();
}

function newPrintWindow(url, windowName) {
	var width = 780;
	var height = 580;
	var left = (screen.availWidth / 2) - (width / 2);
	var top = (screen.availHeight / 2) - (height / 2);
	var newWindow;
	if(!windowName) {
		var windowName = 'newWindow' + Math.floor(Math.random() * 100);
	}
	newWindow = window.open(url, windowName, 'top=' + top + 'px,left=' + left + 'px,screenX=' + left + 'px,screenY=' + top + 'px,width=' + width + 'px,height=' + height + 'px,menubar=yes,resizable=yes,scrollbars=yes,status=no,toolbar=no');
	newWindow.focus();
}

function newUserPageWindow(url, windowName) {
	var width = 780;
	var height = 580;
	var left = (screen.availWidth / 2) - (width / 2);
	var top = (screen.availHeight / 2) - (height / 2);
	var newWindow;
	if(!windowName) {
		var windowName = 'newWindow' + Math.floor(Math.random() * 100);
	}
	newWindow = window.open(url, windowName, 'top=' + top + 'px,left=' + left + 'px,screenX=' + left + 'px,screenY=' + top + 'px,width=' + width + 'px,height=' + height + 'px,menubar=yes,resizable=yes,scrollbars=yes,status=no,toolbar=no');
	newWindow.focus();
}

function newMailWindow(url, width, height) {
	url = BASE + url;
	newWindow(url, width, height);
}