var popUp;

function OpenWindow(wndName, id, params, postBack, width, height, left, top)
{
	popUp = window.open(wndName + '?frm=' + document.forms[0].name + '&id=' + id + '&' +
		params + 'pb=' + postBack, 'popupwnd', 'width=' + width + ',height=' + height + 
		',left=' + left + ',top=' + top);
}

function OpenWindowNId(wndName, params, postBack, width, height, left, top)
{
	popUp = window.open(wndName + '?frm=' + document.forms[0].name + '&' + params + 
		'pb=' + postBack, 'popupwnd', 'width=' + width + ',height=' + height + 
		',left=' + left + ',top=' + top);
}

function OpenWindowNIdS(wndName, params, postBack, width, height, left, top)
{
	popUp = window.open(wndName + '?frm=' + document.forms[0].name + '&' + params + 
		'pb=' + postBack, 'popupwnd', 'width=' + width + ',height=' + height + 
		',left=' + left + ',top=' + top + ',scrollbars=yes');
}

function OpenWindowWS(wndName, id, params, postBack, width, height, left, top)
{
	popUp = window.open(wndName + '?frm=' + document.forms[0].name + '&id=' + id + '&' +
		params + 'pb=' + postBack, 'popupwnd', 'width=' + width + ',height=' + height + 
		',left=' + left + ',top=' + top + ',scrollbars=yes');
}

function JS_OpenWindowSP(pageUrl, name, id, params, postBack, width, height, left, top, centered, settings)
{
	if (centered)
	{
		left = (screen.width)? (screen.width - width) / 2: left;
		top = (screen.height)? (screen.height - height) / 2: top;
	}
	settings = 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',' + settings;
	pageUrl += 'frm=' + document.forms[0].name + '&id=' + id + '&' + params + 'pb=' + postBack; 
	popUp = window.open(pageUrl, name, settings);
}

function JS_OpenWindow(pageUrl, name, width, height, left, top, centered, settings)
{
	if (centered)
	{
		left = (screen.width)? (screen.width - width) / 2: left;
		top = (screen.height)? (screen.height - height) / 2: top;
	}
	settings = 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',' + settings;
	window.open(pageUrl, name, settings);
}

function ReturnToParent(formName, id, value, postBack)
{
	eval('var theElement = document.' + formName + '.' + id + ';');
	popUp.close();
	theElement.value = value;
	if (postBack == 'true')
		document.forms[0].submit();
}

function ReturnToParentPB(formName, id, value, postBack)
{
	eval('var theElement = document.' + formName + '.' + id + ';');
	popUp.close();
	theElement.value = value;
	if (postBack)
		__postBack(id, '');
}

function ReturnToParentS(postBack)
{
	popUp.close();
	if (postBack)
		document.forms[0].submit();
}

function ReturnToParentSPB(id, postBack)
{
	if (postBack)
		__postBack(id, '');
}

function CloseMe()
{
	popUp.close();
}

function CompactParams(params, values)
{
	var result = '';
	for(var i = 0; i < params.length; i++)
		result += params[i] + '=' + values[i] + ';';
	return result;	
}
