/***************************************************************************
	Dialog event handler functions for non IE Browsers
	Allows only one dialog per session
***************************************************************************/

var winModalWindow
 
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 OpenPDF(sStart, sName)
{
  //Get screen resolution variables  
  var iWidth = window.screen.width - 10;
  var iHeight = window.screen.height - 70;
 
	if (window.showModalDialog)
	{
		// Microsoft Internet Explorer
		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);
		window.parent.location.reload();
	}
	else
	{
	    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 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:635px;dialogwidth:800px;dialogHide:yes;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);
}

function wopen(url, name, w, h)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  //w += 32;
  //h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=no, resizable=no');
    
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}
/***************************************************************************
	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);
}