
//--------------------------------------------------------
//Open a new window in center of screen
//--------------------------------------------------------
function F_OpenNewWindow(_url, _width, _height, _top, _left, _windowName, _booMenubar, _booReturnObject){
	var _availHeight = parseInt(screen.availHeight)-60;
	var _availWidth = parseInt(screen.availWidth)-60;
	var txtParam = "scrollbars=yes, resizable=yes";
	
	//Fenstername generieren => unterschiedliche Fenster möglich
    if(_windowName == undefined || _windowName == "") _windowName = "windowName" + Math.round(Math.random()*1000000);

    if (isNaN(_width)==true || _width < 100) _width=750;
    if (isNaN(_height)==true || _height < 100) _height=600;

	//Check with monitor-resolution
	//Prevent out of screen
	if(_height > _availHeight) _height = _availHeight;
	if(_width > _availWidth) _width = _availWidth;

	
	//Get width and height of screen
	//Center windows
	if (_top == undefined || _top==""){
		if (_availHeight > 0) _top = parseInt((_availHeight - _height)/2);
		if (_top > 20) _top = _top-20	//Just personal taste
	}

	if (_left == undefined || _left==""){
		if (_availWidth > 0) _left = parseInt((_availWidth - _width)/2);
	}
	
	//Dont allow spaces in window name, js would crash
	if (_windowName != undefined){
		_windowName = _windowName.replace(/ /g, "");
	}

	if (_width != undefined) txtParam += ", width=" + _width;
	if (_height != undefined) txtParam += ", height=" + _height;
	if (_top != undefined) txtParam += ", top=" + _top;
	if (_left != undefined) txtParam += ",left=" + _left;
	if (_booMenubar) txtParam += ", menubar=yes ";

	Fenster = window.open(_url, _windowName, txtParam);
	Fenster.focus();

	//Return object only in special cases
	//Workaround to keep old versions without void() working
	if(_booReturnObject) return Fenster
}


