
//if (typeof(V1_GenericIncluded) == "undefined")
//	alert("WINDOW.JS \ngeneric.js must be included first");

function V1_Window_OpenAboutBox (url)
{
	var height = 275;
	var width = 550;
	window.open(url, "about",
		"resizable," + _V1_Window_Size(height, width) + "," + _V1_Window_Center(height, width)
	).focus();
}

function V1_Window_OpenDialog (url, e)
{
	if (!window.dialog || window.dialog.closed)
	{
		var height = 675;
		var width = 555;
		window.dialog = window.open(url, "_blank",
			"resizable,scrollbars," + _V1_Window_Size(height, width) + "," + _V1_Window_Center(height, width)
		);
		_V1_Window_StartRedirectingFocus();
	}
	window.dialog.focus();
	
	if (e) V1_StandardEvent(e).preventDefault();
	return false;
}

function _V1_Window_StartRedirectingFocus ()
{
	V1_HookEvent(window, "unload", _V1_Window_CloseDialog);
	V1_HookEvent(window, "focus", _V1_Window_RedirectFocus);
	V1_HookEvent(document.body, "mousedown", _V1_Window_RedirectFocus);
	V1_HookEvent(document.body, "click", _V1_Window_RedirectFocus);
}
function _V1_Window_StopRedirectingFocus ()
{
	V1_UnhookEvent(window, "unload", _V1_Window_CloseDialog);
	V1_UnhookEvent(window, "focus", _V1_Window_RedirectFocus);
	V1_UnhookEvent(document.body, "mousedown", _V1_Window_RedirectFocus);
	V1_UnhookEvent(document.body, "click", _V1_Window_RedirectFocus);
}
function _V1_Window_RedirectFocus (e)
{
	if (window.dialog && !window.dialog.closed)
	{
		window.dialog.focus();
		V1_StandardEvent(e).preventDefault();
	}
	else
	{
		window.dialog = null;
		_V1_Window_StopRedirectingFocus();
	}
}
function _V1_Window_CloseDialog (e)
{
	if (window.dialog && !window.dialog.closed)
		window.dialog.close();
	window.dialog = null;
	_V1_Window_StopRedirectingFocus();
}

function V1_Window_Refresh ()
{
	if (typeof(__doPostBack) != "undefined")
		__doPostBack('','');
	else if (document.forms && document.forms[0] && document.forms[0].submit)
		document.forms[0].submit();
	else if (document.location)
	{
		if (document.location.reload)
			document.location.reload();
		else
			document.location.href = document.location.href;
	}
}

function _V1_Window_Size (height, width)
{
	return "height="+height+",width="+width+",innerHeight="+height+",innerWidth="+width;
}

function _V1_Window_Center (height, width)
{
	if (!window.screen) return "";
	var ah = screen.availHeight - 30;
	var aw = screen.availWidth - 10;
	var xc = (aw - width) / 2;
	var yc = (ah - height) / 2;
	return "left=" + xc + ",screenX=" + xc + ",top=" + yc + ",screenY=" + yc;	
}
