/**
* (co) 2006 Copyright: tn34.de
*
* @package    lib
* @name       $RCSfile: newWindow.js,v $
* @version    $Revision: 1.2 $
* @date       $Date: 2006/09/26 16:30:25 $
* @author     $Author: bohlig $
*/
var childWindows = new Array(); //Alle Kindfenster
/**
 *
 *	newWindow('http://www.neueSeite.de', 'w=400', 'h=500', 'resize', 'scroll' ,'name=NEU');
 *
 *
 */
function newWindow(url){
	var name = '';
	var top  = 0;
	var left = 0;
	var move = true;
	var activate = true;
	var autoclose = false;
	var options = new Array();
	if(arguments.length > 1){
		for(var x=1 ; x<arguments.length ; x++){
			var args = arguments[x].split(/\s*=\s*/);
			switch( args[0].toLowerCase() ){
				case 'width':
				case 'w':
					options[options.length] = 'width='+args[1];
					break;
				case 'height':
				case 'h':
					options[options.length] = 'height='+args[1];
					break;
				case 'name':
				case 'n':
					var name = args[1];
					break;
				case 'menu':
				case 'menü':
				case 'm':
					options[options.length] = 'toolbar';
					options[options.length] = 'menubar';
					break;
				case 'scroll':
				case 's':
					options[options.length] = 'scrollbars';
					break;
				case 'resize':
				case 'r':
					options[options.length] = 'resizable';
					break;
				case 'url':
				case 'u':
					options[options.length] = 'location';
					break;
				case 'top':
				case 'y':
					top = args[1];
					break;
				case 'left':
				case 'x':
					left = args[1];
					break;
				case 'nomove':
				case 'dontmove':
				case 'fix':
				case 'nm':
					move = false;
					break;
				case 'nofocus':
				case 'dontshow':
				case 'noshow':
				case 'nf':
				case 'ns':
					activate = false;
					break;
				case 'close':
					autoclose = true;
					break;
			}
		}
	}
	dummy = window.open(url,name,options.join(',') );
	if (dummy != null){
		try{
			if(move)		dummy.moveTo(left,top);
			if(activate)	dummy.focus();
			if(autoclose)	childWindows[childWindows.length] = dummy;
			if(name == 'preview')
							top.preview = dummy;
		}catch(e){/*Nothing to do*/}
	}
}

