/*utilities.js
 * updated 04/19/02 by Chris Frazier
 * added optional width and height params to openChildWindow
 *
 *updated 04/23/02
 *added functionality for getClick() to not blow up.
 */

function finalize()
{
    if (typeof(hndWindow) != 'undefined')
    {
        if (hndWindow != null)
        {
            if (!hndWindow.closed)  hndWindow.close();
        }
    }
    if (windowOpenerExists())
    {
        window.opener.focus();
    }
}


// Validate data for 'Save' and 'Update'
function Command_onclick() {
  return IsValid();
}

var hndWindow = null;


function openChildWindow(strURL, strName, iWid, iHt)
{
	var iWidth = 650;
	var iHeight = 650;
	
	if(arguments.length >= 3)
	{
		iWidth = iWid;	
	}
	
	if(arguments.length == 4)
	{
		iHeight = iHt;	
	}

  hndWindow = window.open(
    strURL, 
    strName, 
    "WIDTH=" + iWidth + ",HEIGHT=" + iHeight + ",toolbar=no,scrollbars=yes,location=no,directories=no,menubar=no,resizable=yes,status=yes");

  //window.document.onclick = getClick();
  if(windowOpenerExists() == true){
	window.opener.document.body.onfocus = getClick();
  }
  
  hndWindow.focus()
}


function getClick()
{
    if (!hndWindow || hndWindow.closed)
    {
        window.document.onclick = null;
        window.self.focus();
    }
    else
    {
        window.blur();
        hndWindow.focus();
    }
}



function windowOpenerExists()
{
    if (typeof(window.opener) == 'undefined')
    {
        return false;
    }
    else
    {
        return true;
    }
}

