var isIE=document.all;
var isNN=!document.all&&document.getElementById;
var isN4=document.layers;
var isHot=false;

function openWindow(aTarget, aWidth, aHeight, isScroll, isStatus, isMenu, isTool, isResize) {
	var allParam = '';
	allParam = allParam + 'width=' + aWidth + ',';
	allParam = allParam + 'height=' + aHeight + ',';
	allParam = allParam + 'scrollbars=' + isScroll + ',';
	allParam = allParam + 'status=' + isStatus + ',';
	allParam = allParam + 'menubar=' + isMenu + ',';
	allParam = allParam + 'toolbar=' + isTool + ',';
	allParam = allParam + 'resizable=' + isResize;
	var newWin = window.open(aTarget, '', allParam);
	return newWin;
}

function openWindowCentered(aTarget, aWidth, aHeight, isScroll, isStatus, isMenu, isTool, isResize) {
	var newWin = openWindow(aTarget, aWidth, aHeight, isScroll, isStatus, isMenu, isTool, isResize);
	centerWindow(newWin, aWidth, aHeight);
	return newWin;
}

function centerWindow(aWindow, aWidth, aHeight) {
	placeWindow(aWindow, 'center', aWidth, aHeight);
}

function placeWindow(aWindow, aPosition, aWidth, aHeight) {

	// horizontale Positionen
	var hMin = 0;
	var hAvg = Math.floor( (screen.width - aWidth) / 2);
	var hMax = Math.floor( screen.width - aWidth );

	// vertikale Positionen
	var vMin = 0;
	var vAvg = Math.floor( (screen.height - aHeight) / 2);
	var vMax = Math.floor( screen.height - aHeight );

	// Position bestimmen und setzen
	switch(aPosition) {
		case 'center':
			aWindow.moveTo(hAvg, vAvg);
			break;
		case 'left_top':
			aWindow.moveTo(hMin, vMin);
			break;
		case 'top':
			aWindow.moveTo(hAvg, vMin);
			break;
		case 'right_top':
			aWindow.moveTo(hMax, vMin);
			break;
		case 'right':
			aWindow.moveTo(hMax, vAvg);
			break;
		case 'right_bottom':
			aWindow.moveTo(hMax, vMax);
			break;
		case 'bottom':
			aWindow.moveTo(hAvg, vMax);
			break;
		case 'left_bottom':
			aWindow.moveTo(hMin, vMax);
			break;
		case 'left':
			aWindow.moveTo(hMin, vAvg);
			break;
	}
}

function getWindowLeft(aWindow) {
	if (isIE) {
		return aWindow.screenLeft;
	} else {
		return aWindow.screenX;
	}
}

function getWindowTop(aWindow) {
	if (isIE) {
		return aWindow.screenTop;
	} else {
		return aWindow.screenY;
	}
}
