var closing = false;
var arrWindows = new Array();
var nextWindowIndex = 0;
var dialogResultInputName = null;

function isValidWin(win)
{
	return (win != null && !win.closed);
}

function openWin(url, winname, width, height)
{
	openWinEx(url, winname, width, height, 100, 100, 'resizable=no,status=no,scrollbars=yes');
}

function openWinEx(url, winname, width, height, left, top, features)
{
	openWinDialog(url, winname, width, height, left, top, features, null);
}


function openWinDialog(url, winname, width, height, left, top, features, inputName)
{
	dialogResultInputName = inputName;
	var fullFeatures = 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',' + features;
	arrWindows[nextWindowIndex] = window.open(url, winname, fullFeatures);
	var w = arrWindows[nextWindowIndex];
	nextWindowIndex++;
	
	if (isValidWin(w))
	{
		w.focus();
	}
}

//so that dialog window doesn't try to reload parent window
function doOnUnLoad()
{
	for (i = 0; i < nextWindowIndex; i++)
	{
		var w = arrWindows[i];
		if (isValidWin(w))
		{
			w.close();
		}
	}
}
onunload = doOnUnLoad;

function callBackFuncW(dialogResult) 
{ 
	
	if (dialogResultInputName != null && dialogResultInputName != '')
	{		
		var obj = this.document.getElementById(dialogResultInputName.id);						
		obj.value = dialogResult;
	}		
	__doPostBack('', 'dialogResultOK');	
}


function callBackFuncCallW(controlName, dialogResult) {
	__doPostBack(controlName, dialogResult);
}





