
function StructPopupData(strGet, strReceiver)
{
	// constructor logic ==>
	this.strGet = strGet;
	this.strIdReceiver = strReceiver;
	// <== constructor logic
	
	this.GetStr = function()
	{
		return this.strGet;
	}
	this.SetStr = function(strGet)
	{
		this.strGet = strGet;
	}
	this.GetReceiverStr = function()
	{
		return this.strIdReceiver;
	}
	this.GetObjReceiver = function()
	{
		return document.getElementById( this.strIdReceiver );
	}
	this.SetReceiverStr = function(strRec)
	{
		this.strIdReceiver = strRec;
	}
	
	this.Clone = function()
	{
		objNewData = new StructPopupData(this.strGet, this.strIdReceiver);
		return objNewData;
	}
	
	this.RemoveFromDocumentBody = function()
	{
		objRemoved = document.body.removeChild( this.GetObjReceiver() );
		if (objRemoved != null)
		{
			this.SetReceiverStr(null);
			this.SetStr(null);
		}
	}
	
	this.DestroyWindow = function(strId)
	{
		if (strId != null)
		{
			obj = this.GetObjReceiver();
			objParent = obj.parentNode;
			objRemoved = objParent.removeChild(obj);
			if (objRemoved != null)
			{
				// objParent.onmouseout();
				this.SetReceiverStr(null);
				this.SetStr(null);
			}
		}
	}
	
	this.GetCloseObject = function()
	{
		return '';
		//return '<p style="text-align: right; padding: 0; margin: 0;"><span onclick="g_popupData.DestroyWindow(\'' + this.GetReceiverStr() + '\');" style="cursor: pointer;">[x]</span></p>';
	}
	
	this.OutputToReceiver = function(xmlString)
	{
		if (this.GetReceiverStr() != null)
		{
			strCloseObject = this.GetCloseObject();
			strHtml = strCloseObject + xmlString;
			this.GetObjReceiver().innerHTML = strHtml;
		}
	}
}

var ajaxPopupData = new AjaxMgr("GET", true);
var g_popupData = new StructPopupData("", null);

function popupData_handleServerResponse(){ajaxPopupData.handleServerResponse();}
function popupData_OnComplete(){}
function popupData_OnBusy(){setTimeout(popupDataGet, 200)}

function popupData_ProcessXmlCallback(xmlDoc)
{
	alert("error: popupData_ProcessXmlCallback called");
}

function popupData_ProcessXmlStringCallback(xmlStr)
{
	g_popupData.OutputToReceiver(xmlStr);
	return true;
}
	
ajaxPopupData.SetCallbacks
	(	popupData_handleServerResponse, 
		popupData_ProcessXmlCallback, 
		null, 
		popupData_OnComplete, 
		popupData_OnBusy
	);

function popupDataGet()
{
	ajaxPopupData.m_FnProcessXmlString = popupData_ProcessXmlStringCallback;
	ajaxPopupData.m_GetString = g_popupData.GetStr();
	ajaxPopupData.m_bAsync = true;
	ajaxPopupData.SendRequest();
}

function createShadowDiv(objMaster)
{
	x = FromPx(objMaster.style.left) + 5;
	y = FromPx(objMaster.style.top) + 5;
	// this is not working ...
	w = objMaster.clientWidth;
	h = objMaster.clientHeight;
	
	var newDiv = document.createElement('div');
	newDiv.className = "divShadow";
	newDiv.style.left = Px(x);
	newDiv.style.top = Px(y);
	newDiv.style.width = w;
	newDic.style.height = h;
	return newDiv;
}

// this is the main method - add this to the onclick event
function popupDataCreate(strGet, strClass, objAnchor)
{
	var strId = objAnchor.id + "_childPopup";
	
	var newDiv = document.createElement('div');
	newDiv.id = strId;
	
	// set style
	// newDiv.className = strClass;
	
	// set position
	var nx = getAbsX(objAnchor);
	var ny = getAbsY(objAnchor);
	
	newDiv.style.left = Px(nx + objAnchor.clientWidth);
	newDiv.style.top = Px(ny + objAnchor.clientHeight);
	newDiv.style.position = "absolute";
	newDiv.style.display = "block";
	newDiv.style.backgroundColor = "white";
	newDiv.style.border = "thin dashed gray";
	newDiv.style.padding = "5px";
	
	var internalDiv = document.createElement('div');
	internalDiv.onclick = function () 
		{
			objRemoved = document.body.removeChild( document.getElementById(strId) );
		}
	newDiv.appendChild(internalDiv);
	// << new code
	
	//newDiv.setAttribute("onclick", "g_popupData.DestroyWindow('" + strId + "');");
	newDiv.onclick = function () 
		{
			objRemoved = document.body.removeChild( document.getElementById(strId) );
		}
	
	g_popupData.SetStr(strGet);
	g_popupData.SetReceiverStr(strId);

	popupDataGet();
		
	document.body.appendChild(newDiv);		
}

