function popupManager ()
{
	this.popupOBJ = null;
	
	this.close = function ()
	{
		var thisOBJ = this;
		if ( this.popupOBJ ) thisOBJ.popupOBJ.parentNode.removeChild(this.popupOBJ);
		this.popupOBJ = null;
	}
	
	this.show = function ( paramsOBJ )
	{
		thisOBJ = this;
		if ( this.popupOBJ ) return ( false );
		ajax.send ( 'popup.php', 'post', paramsOBJ.query + '&event=' + paramsOBJ.popupName, this.fetch, thisOBJ );
	}
	
	this.fetch = function ( XML, popupOBJ )
	{
		var response = XML.getElementsByTagName('response')[0];
		var errors = response.getElementsByTagName('error');
		if ( errors.length > 0 )
		{
			errorStr = '';
			for ( var i = 0; i < errors.length; i++ )
			{
				errorStr += '<div>' + errors[i].childNodes[0].nodeValue + '</div>';
			}
			popupOBJ.display ( errorStr );
		}
		else
		{
			var html = response.getElementsByTagName('html')[0].childNodes[0].nodeValue;
			popupOBJ.display ( html );
		}
	}
	
	this.display = function ( html )
	{
		var thisOBJ = this;
		this.popupOBJ = document.createElement('DIV');
		this.popupOBJ.innerHTML = html;
		this.popupOBJ.style.position = 'absolute';
		this.popupOBJ.style.top = document.documentElement.scrollTop + 50 + 'px';
		this.popupOBJ.style.visibility = 'hidden';
		document.getElementsByTagName('BODY')[0].appendChild(this.popupOBJ);
		this.popupOBJ.style.left = parseInt(document.getElementsByTagName('BODY')[0].offsetWidth)/2 - parseInt(this.popupOBJ.offsetWidth/2) + 'px'
		this.popupOBJ.style.visibility = 'visible';
		//dndMgr.registerDraggable( new Rico.Draggable(this.popupOBJ,this.popupOBJ) );
	}
}

var popupManager = new popupManager ();