/***************************************************************************
	Dialog event handler functions for non IE Browsers
	Allows only one dialog per session
***************************************************************************/

var winModalWindow
 
function OpenPDF(sStart, sName)
{
  // sStart = 'OpenNMFormA.asp?RecordOperation=view&OperatorID=<%=p%>'
  // sName = 'OpenNMFormA'
  //Get screen resolution variables  
  var iWidth = window.screen.width - 10;
  var iHeight = window.screen.height - 70;

//  window.open(sStart, sName, 'modal=yes, menubar=no, titlebar=no, toolbar=no, resizable=yes, status=no, location=no, hotkeys=no, top=0, left=0, width=' + iWidth +', height=' + iHeight)
  
	if (window.showModalDialog)
	{
		// Microsoft Internet Explorer
		//winModalWindow = window.showModalDialog(sStart,sName,'dialogheight:500px;dialogwidth:700px;resizable:no;status:no;help:no;scroll:off');		
		winModalWindow = window.open(sStart,sName,'modal=yes, menubar=no, titlebar=no, toolbar=no, resizable=yes, status=no, location=no, hotkeys=no, top=0, left=0, width=' + iWidth +', height=' + iHeight);
	    //winModalWindow.focus();		    
		//winModalWindow.reload();	    
	    //alert(winModalWindow.opener.document.title);
	}
	else
	{
		//alert(window.parent.document.title);
	    window.top.captureEvents(Event.CLICK|Event.FOCUS);
	    window.top.onclick=IgnoreEvents;
	    window.top.onfocus=HandleFocus ;
	    winModalWindow = window.open(sStart,sName,'modal=yes, menubar=no, titlebar=no, toolbar=no, resizable=yes, status=no, location=no, hotkeys=no, top=0, left=0, width=' + iWidth +', height=' + iHeight);
	    winModalWindow.focus();
	}
	return(0);  
}


function HandleFocus()
{
	if (winModalWindow)
	{
		if(!winModalWindow.closed)
		{
			winModalWindow.focus();
		}
		else
		{
			window.top.releaseEvents(Event.CLICK|Event.FOCUS);
			window.top.onclick="";
		}
	}
	return(false);
}

function IgnoreEvents(e)
{
	return(false);
}

/***************************************************************************
	Opening and closing functions
***************************************************************************/

function LoginDialog(s)
{
	if (window.showModalDialog)
	{
		// Microsoft Internet Explorer
		r = window.showModalDialog('forms/Dialog_Edit.asp?location=' + s, window,'dialogheight:280px;dialogwidth:280px;resizable:no;status:no;help:no;scroll:off');
//		alert(window.parent.document.title);
		window.parent.location.reload();
	}
	else
	{
	    window.top.captureEvents(Event.CLICK|Event.FOCUS);
	    window.top.onclick=IgnoreEvents;
	    window.top.onfocus=HandleFocus ;
	    winModalWindow = window.open('forms/Dialog_Edit.asp?location=' + s,"ModalChild","dependent=yes,width=800,height=400");
	    winModalWindow.focus();
	}
	return(0);
}

function EditDialog(s)
{
	if (window.showModalDialog)
	{
		// Microsoft Internet Explorer
		r = window.showModalDialog('Dialog_Edit.asp?location=' + s, window,'dialogheight:600px;dialogwidth:800px;resizable:yes;status:no;help:no;scroll:off');
	}
	else
	{
	    window.top.captureEvents(Event.CLICK|Event.FOCUS);
	    window.top.onclick=IgnoreEvents;
	    window.top.onfocus=HandleFocus ;
	    winModalWindow = window.open('Dialog_Edit.asp?location=' + s,"ModalChild","dependent=yes,width=800,height=400");
	    winModalWindow.focus();
	}
	return(0);
}

function DeleteDialog(s)
{
	if (window.showModalDialog)
	{
		// Microsoft Internet Explorer
		r = window.showModalDialog('dialog_delete.asp?location=' + s, window,'dialogheight:300px;dialogwidth:300px;resizable:yes;status:no;help:no;scroll:off');
	}
	else
	{
	    window.top.captureEvents(Event.CLICK|Event.FOCUS);
	    window.top.onclick=IgnoreEvents;
	    window.top.onfocus=HandleFocus ;
	    winModalWindow = window.open('dialog_delete.asp?location=' + s,"ModalChild","dependent=yes,width=300,height=200");
	    winModalWindow.focus();
	}
	return(0);
}

function close_dialog()
{
	window.close();
	return(0);
}

/***************************************************************************
	Dialog field modification highlight
***************************************************************************/

function label_toggle(node)
{
    var n = node;

    n.style.color = "red";
}

/***************************************************************************
	Record functions
***************************************************************************/

function delete_record()
{
	document.forms[0].mode.value = 'delete';
	document.forms[0].submit();
	return(0);
}

function undo_record()
{
	return(document.forms[0].submit());
}

function save_record()
{
	if (document.forms[0].RecordOperation.value == 'append')
	{
		document.forms[0].RecordOperation.value = 'executeappend';
		document.forms[0].submit();
	}
	else if (document.forms[0].RecordOperation.value == 'update')
	{
		document.forms[0].RecordOperation.value = 'executeupdate';
		document.forms[0].submit();
	}
	else
	{
	}

	return(0);
}

function SummarySubmitData()
{
	document.forms[0].RecordOperation.value = 'Submit';
	document.forms[0].submit();
	return(0);
}