


function popup( name, url, width, height, args )
	{
	var options = null;
		if( arguments.length == 4 ) options = {
										left:	window.screenLeft + Math.round((document.body.offsetWidth - width)/2),
										top:	window.screenTop + Math.round((document.body.offsetHeight - height)/2),
										resizable:	'yes',
										scrollbars:	'no'
										};
		else if( arguments.length == 5 && typeof(arguments[4]) == 'object' )
		{
		options = arguments[4];
			if( options.layout != null )
			{
			var lt = options.layout;
			var x = options.x;
			var y = options.y;
			options.layout = null;
			options.x = null;
			options.y = null;
				if( lt.indexOf('window') != -1 ) (new Popup_WindowLayout(lt, x, y)).addOptions(options);
				else if( ps.indexOf('document') != -1 ) (new Popup_DocumentLayout(lt, x, y)).addOptions(options);
				else (new Popup_ScreenLayout(lt, x, y)).addOptions(options);
			}
		}
		else if( arguments.length == 6 ) options = {
										left:	arguments[4],
										top:	arguments[5],
										resizable:	'yes',
										scrollbars:	'no'
										};
		else
		{
		alert('Illegal usage of "popup" function');
		return false;
		}
	
		if( window.windows == null ) window.windows = {};
//		if( window.windows[name] != null && !window.windows[name].closed ) window.windows[name].close();
	
	var op_str = 'width=' + width + ',height=' + height;
		for( p in options )
			if( options[p] != null ) op_str += ',' + p + '=' + options[p];
	window.windows[name] = window.open(url, name, op_str);
	window.windows[name].focus();
	
	return false;
	}



function Popup_ScreenLayout( layout, x, y )
	{
	
	this.addOptions = function ( options )
		{
		}
	}

function Popup_WindowLayout( layout, x, y )
	{
	
	this.addOptions = function ( options )
		{
		}
	}

function Popup_DocumentLayout( layout, x, y )
	{
	var alignX;
	var alignY;
	
		if( layout.indexof('left') != -1 ) alignX = 'left';
		else if( layout.indexof('right') != -1 ) alignX = 'right';
		else if( layout.indexof('center') != -1 ) alignX = 'center';
	
	this.addOptions = function ( options )
		{
		}
	}
