	var docCharset = 'iso-8859-1';
// Note: Installer changes the first line & it should be charCode set.
//%name: arweb.js % %date_modified: Mon May 14 12:43:24 2001 % %version: 18 % 

	var ns      = false;
	var ie      = false;
	var show    = 'show';
	var hide    = 'hide';
	var inherit = 'inherit';
   var windows = navigator.userAgent.indexOf("Win")>-1;
	var win31   = navigator.userAgent.indexOf("Windows 3.1")>-1 || navigator.userAgent.indexOf("Win16")>-1;
	var fStr    = 'F';
	var onModifyWindow = 'false';
	if (navigator.userAgent.indexOf("MSIE") == -1)
	{
		ns = true;
	}
	else
	{
		ie = true;
		show = 'visible';
		hide = 'hidden';
	}

	var arWindows;
    var arWindowsLength = 0;

	function embeddedFrame()
	{
		return top  // top exists
			&& top!=window  // top does not refer back to this window
			&& (window.name=="main" || window.name=="arwebdoc"); 
				// name of this frame is "main" or "arwebdoc"
				// These are the only two names used by approval server
	}

	if (embeddedFrame() && top.arWindows)
	{
		// There is already an arWindows array existing in
		// top frame. Make the current arWindows point to that one
		arWindows = top.arWindows;
		arWindowsLength = arWindows.length;
	}
	else
	{
		// Create a new arWindows array
		arWindows = new Array();
		arWindowsLength = 0;
	}
	if (embeddedFrame() && !top.arWindows)
	{
		// Store a reference to this arWindows array in the top frame
		// So that it doesn't get garbage collected when this frame goes out of scope
		top.arWindows = arWindows;
	}
	var currentWin = null;

	var typeNone       = 0;
	var typeCharacter  = 1;
	var typeDiary      = 2;
	var typeSelection  = 3;
	var typeInteger    = 4;
	var typeReal       = 5;
	var typeTrim       = 6;
	var typeControl    = 7;
	var typeTimestamp  = 8;
	var typeTable      = 9;
	var typeColumn     = 10;
	var typeAttach     = 11;
	var typeGroupId    = 12;
	var typePage       = 13;
	var typePageHolder = 14;
	var typeDecimal    = 15;

	var submitForm     = 0;
	var queryForm      = 1;
	var modifyForm     = 2;
	var fireActiveLink = 3;

	var disabled       = 1;
	var readOnly       = 2;
	var readWrite      = 3;

	var picklistWin          = null;
	var PickListStr			 = '';
	var SelectedFromPickList = 0;
	var helpWin              = null;
	var tmpWinId             = 0;

	// vars to hold the ctrl and previous value so that onkeydown handler can
	// simluate readonly and disabled fields
	var fldOnKeyDown;
	var onKeyDownValue;

      // Used to measure performance times
	var prevDate = 0;
	var currDate = 0;
	var currCmd = '';
	
	// Don't init the 2 globals below in initGlobals. These
	// are meant to be set when arweb.js is loaded and do not need
	// to be initialized during login.
	var timeFlag = 0;
	var cacheFlag = 1;

    // initialize globals. Place ONLY those globals that need to be
	// initialized during login(i.e. for every session).
    function initGlobals()
    {
        arWindows  = new Array();
        arWindowsLength = 0;
	    currentWin = null;
		if (embeddedFrame())
			top.arWindows = arWindows; // Save a reference to top
    }
	function EncodeHtmlQuotedString(theString)
	{		
		var localString = theString;
		
		var regexp;


		// replace & with &amp;
		regexp = /&/gi;
		localString = localString.replace(regexp, "&amp;");

		// replace cr with &#13
		regexp = /\r/gi;
		localString = localString.replace(regexp, "&#13;");

		//replace lf with &#10
		regexp = /\n/gi;
		localString = localString.replace(regexp, "&#10;");

		// replace " with &quot; so it gets translated correctly via html
		regexp = /"/gi;
		localString = localString.replace(regexp,"&quot;");
		
		return localString;
	}

	function EncodeHtmlStringInternal(theString, bConvertCRLF)
	{
		var localString = theString;
		
		var regexp;

		// Replacing special characters in plain html text.

		regexp = /&/gi;
		localString = localString.replace(regexp, "&amp;");

		regexp = /</gi;
        	localString = localString.replace(regexp,"&lt;");

		regexp = />/gi;
        	localString = localString.replace(regexp,"&gt;");
		
		if (bConvertCRLF)
		{
			regexp = /\r\n/gi;
			localString = localString.replace(regexp,"<br>");

			regexp = /\n/gi;
			localString = localString.replace(regexp,"<br>");
		}

		return localString;
	}
	
	function EncodeHtmlString(theString)
	{
		return EncodeHtmlStringInternal(theString, true);
	}

	function EncodeHtmlStringTextArea(theString)
	{
		return EncodeHtmlStringInternal(theString, false);
	}
	
	function EncodeJavaScriptQuotedString(theString)
	{
		var localString = theString;
		var regexp;
		
		// replacing special chars for a js quotedstring

		regexp = /\\/gi;
		localString = localString.replace(regexp, "\\\\");

		regexp = /\r/gi;
		localString = localString.replace(regexp, "\\r");

		regexp = /\n/gi;
		localString = localString.replace(regexp, "\\n");

		regexp = /"/gi;
		localString = localString.replace(regexp, "\\\"");

		regexp = /'/gi;
		localString = localString.replace(regexp, "\\\'");


		return localString;
	}

	// -------------------------------------------------------------------
	// Handle 'Reset' button click on the schema form,
	// by calling 'reset()' method on each <form> of schema-form.
	// -------------------------------------------------------------------
	function resetHandler(requestingForm)
	{
		// dont reset if handling processing a request to the server
		if (ServerProcessingRequest(true))
			return true;

        if ( currentWin == null )
            return;

		for(var i=0; i<currentWin.fieldInstances.length; i++)
		{
			var fld = currentWin.fieldInstances[i];

			if	(
				fld.type == typeCharacter ||
				fld.type == typeGroupId   ||
				fld.type == typeDiary     ||
				fld.type == typeInteger   ||
				fld.type == typeReal      ||
				fld.type == typeDecimal   ||
				fld.type == typeTimestamp ||
				fld.type == typeSelection   
				)
			{
				if (requestingForm == queryForm)
                {
					fld.ctrl.form.reset();
                    fld.setCtrlValue("");
                }
				else if (requestingForm == modifyForm)
					fld.setCtrlValue(fld.originalValue);
			}
		}
		return true;
	}

	//
	// -----------------------------------------------------------------------
	// Called when user clicks on the ResetDefaults button on the submit Page.
	// Calls waserver because there may be active links associated with
	// SetDefaults action. Fills the form with new state from waserver.
	// -----------------------------------------------------------------------
	//
	function setDefaults()
	{
		doSubmit(-1, 'SetDefaults');
	}

	// ----------------------------------------------------------------------
	// Handle 'Submit'/'Save' or 'RunQuery' button click on the schema
	// form, by copying the value from each <form>'s element into hidden
	// variable of hiddenform generated in hidden_frame and calling 'submit()'
	// method of newly generated hidden form.
	// If the form was 'Query Form', also take the values of 'Qual' & 'Max'
	// from 'qualform'.
	// -----------------------------------------------------------------------
	function submitHandler(sForm, qForm)
	{
		var sText = '<form action="' + sForm.action + '" target="visual_frame" method="' + sForm.method + '">';
		var quotedName;
		var quotedValue;

        if ( currentWin == null )
            return;

		for (var i = 0; i < sForm.elements.length; i++)
		{
			sForm.WID.value = currentWin.winId;
			if (sForm.elements[i].name != "")
			{
				sText += '<input type="hidden" name="';
				quotedName = EncodeHtmlQuotedString(sForm.elements[i].name);
				sText += quotedName;
				sText += '" value="';
				quotedValue = EncodeHtmlQuotedString(sForm.elements[i].value);
				sText += quotedValue;
				sText += '" />';
			}
		}//for

		if (qForm != null)
		{
			for (var i = 0; i < qForm.elements.length; i++)
			{
				if (qForm.elements[i].name != "")
				{
					sText += '<input type="hidden" name="';
					quotedName = EncodeHtmlQuotedString(qForm.elements[i].name);
					sText += quotedName;
					sText += '" value="';
					quotedValue = EncodeHtmlQuotedString(qForm.elements[i].value);
					sText += quotedValue;
					sText += '" />';
				}
			}//for
		}

		doSubmit(sText, 'Submit');
	}

	function writeOutDirtyFields(hDoc)
	{
			var quotedVal;
			var quotedName;

			// Keep track of data fields and dirty field count.
			// Netscape won't submit a form that has no input fields so if there are no
			// dirty fields we have to send one anyway.  The first one is as good as any.
			var firstDataField = null;
			var numDirty = 0;

			for(var i=0; i<currentWin.fieldInstances.length; i++)
			{
				var fld = currentWin.fieldInstances[i];
				if (fld.type == typeCharacter ||
					fld.type == typeGroupId     ||
					fld.type == typeDiary     ||
					fld.type == typeInteger   ||
					fld.type == typeReal      ||
					fld.type == typeDecimal   ||
					fld.type == typeTimestamp ||
					fld.type == typeSelection   )
				{
					if (firstDataField == null)
						firstDataField = fld;

					quotedVal = fld.getCtrlValue();

					if (quotedVal == fld.value) // not dirty, ignore.
						continue;

					// if field R/O don't let the data pass
					// on IE autocomplete, in text fields will fill in the field, not caught by handleKeyDown(ecr73875)
					// on unix NN, keystoke trapping doesn't work when field R/O, so keystrokes entered into field(ecr73876)
					if (fld.access == readOnly)	// and ctrl value has changed
					{
						fld.setCtrlValue(fld.value);
						continue;
					}

					numDirty++;
					fld.value = quotedVal;
					quotedVal = EncodeHtmlQuotedString(quotedVal);
					quotedName = EncodeHtmlQuotedString(fld.name);
					hDoc.writeln('<input type="hidden" name="' + quotedName + '" value="' + quotedVal + '" />');					
				}
				else if (fld.type == typeTable)
				{
					// send the currently selected row index
					if ( fld.indexValue  == fld.originalIndexValue)
						continue;
					
					// set original to this value
					fld.originalIndexValue = fld.indexValue;
					quotedName = EncodeHtmlQuotedString(fld.name);
					// no need to encode the value, it' a number
					numDirty++
					hDoc.writeln('<input type="hidden" name="' + quotedName + '" value="' + fld.indexValue  + '" />');
				}
			}//for

         // If there are no dirty fields, write the first one anyway.  We need to do this
         // to force Netscape to submit a form that has no input fields!
         if ( (numDirty == 0) && (firstDataField != null) )
         {
    			hDoc.writeln('<input type="hidden" name="' + firstDataField.name + '" value="' + firstDataField.value + '" />');
         }

			return numDirty;
	}

	// -----------------------------------------------------------------------
	// Handles the 'submit operation' and 'active-link firing'.
	// It sends only the dirty state information by traversing through the list
	// of fields and generates the hidden <form> variable in hidden_frame.
	// Also handles the select-picklist operation.
	// -----------------------------------------------------------------------
	function doSubmit(idStr, typeStr)
	{
        if ( currentWin == null )
        {
            //alert("ASSERT: In doSubmit, currentWin is null");
            return;
        }

		// don't let the next request through until current one is finished

		// sql query, need reponse to continue processing previous request
		if (typeStr != 'SelectPickList' && ServerProcessingRequest(true))
			return;
		
		// it's already set don't set off a new timer
		if (typeStr !=	'SelectPickList')
		{
			SetServerProcessingRequest(true);
		}			

		var hDoc = hidden_frame.document;
		hDoc.open("text/html", "replace");
		if (typeStr == 'Submit')
			var formStr = idStr;
		else
			var formStr = 'Hidden Page for active links and menus\n' +
						  '<form action="actlink.jsp" method="post">\n' +
					      '<input type="hidden" name="WID" value="' + currentWin.winId + '" />\n' +
					      '<input type="hidden" name="O" value="1" />\n' +
					      '<input type="hidden" name="al_type" value="' + typeStr + '" />\n' +
					      '<input type="hidden" name="al_id" value="' + idStr + '" />\n';

		hDoc.write(formStr);
		// always send the scale parms
		hDoc.write('<input type="hidden" name="Scale" value="' + currentWin.scaleParams + '">\n');

		var numDirty = writeOutDirtyFields(hDoc);
		hDoc.writeln('</form>');
		hDoc.close();
		hDoc.charset = docCharset;
		hDoc.forms[0].submit();
	}

	function DataField(parent, id, type, access, label, append,
			onEnter, onMenuChange, isRadio, radioItems,
			value, menuName)
	{
		this.parent       = parent;
		this.id           = id;
		this.name         = fStr + id + fStr;
		this.type         = type;
		this.access       = access;
		this.label        = label;
		this.append       = append;
		this.onEnter      = onEnter;
		this.onMenuChange = onMenuChange;
		this.isRadio      = isRadio;
		this.radioItems	  = radioItems;
		this.value        = value;
		this.originalValue= this.value;
		this.menuName = menuName;
		// keep the current value of the radio string to support turning radio buttons on/off
		this.prevRadioValue = '';
		return this;
	}
	function MenuArray(menuName, menuStatic, menuWidth, menuHeight, menuString)
	{
		this.menuName = menuName;
		this.menuStatic = menuStatic;
		this.menuString = menuString;
		this.menuWidth  = menuWidth;
		this.menuHeight = menuHeight;
	}
	function ButtonField(parent, id, access, onClick)
	{
		this.parent       = parent;
		this.id           = id;
		this.name         = fStr + id + fStr;
		this.type         = typeControl;
		this.access       = access;
		this.onClick      = onClick;

		return this;
	}
	function TrimField(parent, id)
	{
		this.parent       = parent;
		this.id           = id;
		this.name         = fStr + id + fStr;
		this.type         = typeTrim;

		return this;
	}

	function AttachField(parent, id, value)
	{
		this.parent       = parent;
		this.id           = id;
		this.name         = fStr + id + fStr;
		this.type         = typeAttach;

		this.value			= value;
		// not saving the value as original value. The attachment shouldn't have to be sent to the server
		// for dosubmit functions, pointer to FxxFContent

		return this;
	}
	// ------------------------------------------------------------------------
	// Get the FieldInstanceObject from DataStructure based on the field-id.
	// ------------------------------------------------------------------------
	function getFieldInstanceByID(id)
	{
		return getFieldInstanceByName(fStr+id+fStr);
	}
	// ------------------------------------------------------------------------
	// Get the FieldInstanceObject from DataStructure based on the field-name.
	// ------------------------------------------------------------------------
	function getFieldInstanceByName(name)
	{
        if ( currentWin == null )
            return null;

		return currentWin.reverseLookup[name];
	}
	
	// ------------------------------------------------------------------------
	// Get the menuInstance object from data structure based on the menu name.
	// ------------------------------------------------------------------------
	function getMenuInstanceByName(name)
	{
        if ( currentWin == null )
            return null;

		for(var i=0; i<currentWin.menuInstances.length; i++)
			if (currentWin.menuInstances[i].menuName == name) return currentWin.menuInstances[i];
		return null;
	}
	// ------------------------------------------------------------------------
	// Get the WindowInstance for the given window-id.
	// ------------------------------------------------------------------------
	function getWindowInstance(wid)
	{
		for(var i=0; i<arWindowsLength; i++)
			if (arWindows[i].winId == wid) return arWindows[i];
		return null;
	}
	// ------------------------------------------------------------------------
	// Get the Parent names recursively to name the control, since Netscape
	// refers to a form and/or control with full reference in the DOM.
	// ------------------------------------------------------------------------
	function getParentName(fld)
	{
		var nm = '';
		if (fld.parent != null && fld.parent != 0)
		{
			var prnt = getFieldInstanceByID(fld.parent);
			nm += getParentName(prnt) + prnt.name + '.document.';
		}
		return nm;
	}

	// ------------------------------------------------------------------------
	// Name the form and/or controls so that we can use them to operate on.
	// Just eval() these 'Addr' strings to get the real controls.
	// Ex: eval(this.ctrl + '.value = ' + newValue);
	// ------------------------------------------------------------------------
	function nameTheFieldControl(fld)
	{
		var ctrlName, outerDiv;
		var fidf = fld.name;

		fld.setFocus     = setFocusToDataField;
		fld.setVisible   = setVisible;
		fld.changeColor  = changeLabelColor;
		fld.setCtrlIndex = null;
		
		if (ns)
		{
			ctrlName = 'visual_frame.document.formcontainer.document.' 
				+ getParentName(fld) + fidf;
		} else if (ie)
		{
			while (allDivs[allDivsIndex].id != fidf) allDivsIndex++;
			outerDiv = allDivs[allDivsIndex];
		}

		if (fld.type == typeCharacter || fld.type == typeDiary     ||
			fld.type == typeInteger   || fld.type == typeReal      ||
			fld.type == typeDecimal   || fld.type == typeTimestamp ||
			fld.type == typeSelection || fld.type == typeGroupId)
		{
			if (ns)
			{
				fld.layer       = eval(ctrlName);
				fld.labelAddr   = eval(ctrlName + '.document.'+ fidf +'Label');
				fld.ctrl        = eval(ctrlName + '.document.'+ fidf + 'Control.document.forms[0].elements[0]');
			} else if (ie)
			{
				
				fld.layer       = outerDiv.style;
				fld.labelAddr   = outerDiv.children[0];
				fld.ctrl        = outerDiv.children[1].children[0].elements[0];
			}
			if (fld.type == typeSelection && fld.isRadio == 1)
			{
				fld.setCtrlValue = setRadioValue;
                fld.setCtrlValueAppend = setRadioValue;
				fld.getCtrlValue = getRadioValue;
				fld.getCtrlIndex = getRadioIndex;
			}
			else if (fld.type == typeSelection)
			{
				fld.setCtrlValue = setSelectValue;
                fld.setCtrlValueAppend = setSelectValue;
				fld.getCtrlValue = getSelectValue;
				fld.getCtrlIndex = getSelectIndex;
			}
			else
			{
				fld.setCtrlValue = setCharValue;
		        fld.setCtrlValueAppend = setCharValueAppend;
				fld.getCtrlValue = getCharValue;
				fld.getCtrlIndex = null;
			}
		}
		else if (fld.type == typeControl)
		{
			if (ns)
			{
				fld.layer       = eval(ctrlName);
				fld.ctrl        = eval(ctrlName + '.document.forms[0].elements[0]');
			} else if (ie)
			{
				fld.layer       = outerDiv.style;
				fld.ctrl        = outerDiv.children[0].elements[0];
			}
			if (fld.access == disabled)	fld.ctrl.disabled = true;
			else fld.ctrl.disabled = false;
		}
		else if ( fld.type == typeTrim || fld.type == typePageHolder)
		{
			if (ns)
			{
				fld.layer		= eval(ctrlName);
			} else if (ie)
			{
				fld.layer		= outerDiv.style;
			}
		}
		else if (fld.type == typePage)
		{
			if (ns)
			{
				fld.layer		= eval(ctrlName);
				fld.tab			= eval(ctrlName + 'Tab');
				fld.tabLabel	= eval(ctrlName + 'Tab.document.' + fidf + 'TabLabel');
			} else if (ie)
			{
				fld.layer		= outerDiv.style;
				fld.tab			= allDivs[allDivsIndex - 2].style;
				fld.tabLabel	= allDivs[allDivsIndex - 1].style;
				fld.tab.pixelLeft = allDivs[allDivsIndex - 2].offsetLeft;   // for IE5
				fld.tab.pixelWidth = allDivs[allDivsIndex - 2].offsetWidth; // for IE5
			}
			fld.setVisible   = setPageFieldVisible;
			fld.changeColor  = changeTabColor;
			fld.setFocus     = setFocusToPageField;
		}
		else if (fld.type == typeTable)
		{
			// visual_frame.FxxFScroll
			fld.ctrl        = eval( 'visual_frame' + '.' + fidf + 'Scroll');

			if (ns)
			{
				fld.layer       = eval(ctrlName);
			} else if (ie)
			{
				fld.layer       = outerDiv.style;
			}
			fld.setVisible   = setTableFieldVisible;
			fld.setFocus     = setFocusToTable;
			fld.getCtrlIndex = getTableIndexInternal;
			fld.setCtrlIndex = setTableIndexInternal;
			fld.setCtrlValue = setTableValue;
		}
		else if (fld.type == typeAttach)
		{
			// visual_frame.FxxFScroll
			fld.ctrl        = eval( 'visual_frame' + '.' + fidf + 'Scroll');

			if (ns)
			{
				fld.layer       = eval(ctrlName);
			} else if (ie)
			{
				fld.layer       = outerDiv.style;
			}
			fld.setCtrlValue = setAttachValue;
		}
	}

	// -----------------------------------------------------------------
	// Create a new AR window datastructure in the buffer that holds all
	// the fields.
	// -----------------------------------------------------------------
	function createARWin(currentTime, winId, fields, server, schema, user, servers, entry, runProcess)
	{
		var ARWin = new Array();

		ARWin.winId          = winId;
		ARWin.createTime     = currentTime; // At what time was this window created?
		ARWin.fieldInstances = fields;
		ARWin.menuInstances  = null;
		ARWin.serverProcessingRequest = false;	// used so that al type requests to server are sequential
		ARWin.sprTimer = -1;
		ARWin.server         = server;
		ARWin.schema         = schema;
		ARWin.user           = user;
		ARWin.servers        = servers;
		ARWin.entry          = entry;
		
		// store pending runprocess Activelink 
		ARWin.runProcess     = runProcess;

		// Add the current window to the end of the list.
		arWindows[arWindowsLength++] = ARWin;

		currentWin = ARWin;

		currentWin.reverseLookup = new Array();

		for (var i=0; i<fields.length; i++)
			currentWin.reverseLookup[fields[i].name] = fields[i];
	}

    // This function is called to prune the window list when we go back to an
    // existing node, such as a query list or task list or table field drill-down.
    function cleanAfterTimestamp( parentTime )
    {
        // We want to throw away any existing windows that have been created
        // since the parent of the current window was created.
        var numItems = arWindowsLength;
        for ( var wIndex = 0; wIndex < numItems; wIndex++ )
        {
           // Check for running off the end of the array
           if ( arWindows[wIndex] == null )
           {
              break;
           }

           if ( arWindows[wIndex].createTime > parentTime )
           {
              delete arWindows[wIndex];
              arWindows[wIndex] = null;
              arWindowsLength--;
           }
        }
    }

	// this function is called whenever the submit/modify/query page is loaded. 
	// It can be called either directly or as a result of forward/back buttons
	function setupPage()
	{
		getTimeDiff(); getDate('Setting up fields in JS');
		if (retCurrentWinId() == -1 && currentWin)
		{
			nameTheFields();
			initializeFieldValues();
			setInitialPageVisibility();
			saveCurrentWinId();
			// initialize menus with values from server
			currentWin.menuInstances = visual_frame.initialMenuInstances;
			if (currentWin.runProcess != null)
			{
				// trigger pending runprocess Activelink 
				window.setTimeout(currentWin.runProcess, 1);
			}
		}
		else
		{
			//Document was visited again as a result of 'Back' or 'Forward' button click...

			currentWin = getWindowInstance(retCurrentWinId());

            if ( currentWin == null )
            {
               // Probably came back from outside the ARWeb set of pages!
               // This is not supported, so put out an error message.
               alert( NavigationErrStr );

               // OK, we need to fake a currentWin so that we don't get a pile of JavaScript errors
               // This is a hack and does NOT represent a real window object.  We just neeed to
               // set enough properties so that the form can show up without javascript errors.
               // We're going to overwrite the display anyway but there's no way to just stop
               // displaying the current form at this point!
               currentWin = new Array();
               currentWin.user = "";
               currentWin.servers = "";
               currentWin.entry = "";
               currentWin.scaleParams = "";

               // Set the document to the login screen.
               document.location = "arweb.jsp";
               return;
            }

			nameTheFields();
			resetVisibleAttributes();
		}
		getTimeDiff(); getDate('Loading rest of doc in HTML');
	}

	function nameTheFields()
	{
        if ( currentWin == null )
            return;

	    var fields = currentWin.fieldInstances;

		// ======== NAME THE CONTROLS ============
		var fld;
		var i;
		if (ie) 
		{
			allDivs = visual_frame.formcontainer.all.tags("DIV");
			allDivsIndex = 0;
		}
		for (i = 0; i < fields.length; i++)
		{
			fld = fields[i];

			nameTheFieldControl(fld);
		}
	}

	function initializeFieldValues()
           {
              if ( currentWin == null )
                 return;

              var fields = currentWin.fieldInstances;
              for (i = 0; i < fields.length; i++)
              {
                 var fld = fields[i];
                 if (fld.type == typeCharacter ||
                     fld.type == typeGroupId   ||
                     fld.type == typeDiary     ||
                     fld.type == typeInteger   ||
                     fld.type == typeReal      ||
                     fld.type == typeDecimal   ||
                     fld.type == typeTimestamp ||
                     fld.type == typeSelection   )
                 {
                    if (fld.value != "") 
                       fld.setCtrlValue(fld.value);
                    if (fld.access == disabled)	
                       fld.ctrl.disabled = true;
                 }
              }
           }


	// -----------------------------------------------------------------
	// Handle Button Click
	// -----------------------------------------------------------------
	function handleButtonClick(fld)
	{
		var field = getFieldInstanceByName(fld.name);
		if (field.onClick == false || field.access == disabled) return;
		doSubmit(fld.name, 'ControlFired');
	}

	// -----------------------------------------------------------------
	// Handle onEnter active-links for radio and selection
	// -----------------------------------------------------------------
	function handleOnEnterSelection(fld)
	{
		var field = getFieldInstanceByName(fld.name);

		// reset any selection values for readonly IE5 and nnUnix. ie4/nnPC handled in gainfocus
		// reset any selection values for disabled nnUnix. Disabled on IE5 grays out field
		if ((field.access == readOnly || field.access == disabled) && !field.isRadio)
		{
			field.setCtrlValue(field.value);
		}
		// check for readonly and disabled
		if (field.access == readOnly || field.access == disabled)
		{
			return false;
		}

		if (field.onEnter == false) return false;

		doSubmit(fld.name, 'ReturnKey');
		return false;
	}
	//------------------------------------------------------------------
	// Handle onEnter active-links on text fields
	//------------------------------------------------------------------
	function handleOnEnterText(fld)
	{
		// pc handled in keydown
		if (windows)
			return false;
			
		var field = getFieldInstanceByName(fld.name);
		if (field.onEnter)
			doSubmit(fld.name, 'ReturnKey');

		return false;
	}

	// -----------------------------------------------------------------
	// Handle onEnter active-links on the field, r/o
	// For arfields that are displayed as text/textarea
	// you must trap keydown and see if return was pressed
	// behavior is different from WUT. In WUT, shift alt F5 will trigger
	// OnReturn in multiple line edit field. WUT allows cr/lf to be entered into
	// multi-line edit field that has AL onReturn, we don't
	// -----------------------------------------------------------------
	function handleOnKeyDown(event, ctrl)
	{

		var retStat = true; // ok to process

		var fld;
		fld = getFieldInstanceByName(ctrl.name);

		var keycode;
		if (ie)
			keycode = event.keyCode;
		else
			keycode = event.which;

		if (ServerProcessingRequest(true))
		{
			fldOnKeyDown = fld; 
			if (!windows)
			{
				fldOnKeyDown.ctrl.blur();
				fldOnKeyDown.ctrl.focus();
			}
			window.setTimeout("fldOnKeyDown.setCtrlValue(onKeyDownValue);", 1);
			onKeyDownValue = fldOnKeyDown.ctrl.value;
			return true;			
		}

		if (fld.access == readOnly)
		{
			// no als or has onEnter and char != enter
			if ((fld.onEnter == false) || (fld.onEnter == true && keycode != 13))
			{
				// IE 4/5: Only IE5 allows keys to be cancelled. So use the timeout to prevent keys from being entered.
				//         Note: using readonly property allows focus to be set but you cant put a cursor in the field; that's why
				//         it's not used
				// NN pc: You can prevent chars from being entered
				//        via the return status if you set the handler via the doc object model.
				//        Use the the timer to prevent chars from being entered.
				// NN unix: only textarea fields come here. Handle text fields with autocomplete r/o support
				
				fldOnKeyDown = fld;
				if (!windows)
				{
					fldOnKeyDown.ctrl.blur();
					fldOnKeyDown.ctrl.focus();
				}
				window.setTimeout("fldOnKeyDown.setCtrlValue(onKeyDownValue);", 1);
				onKeyDownValue = fldOnKeyDown.value;
			}
			else
			{
				// read only with al, char == enter
				fldOnKeyDown = fld;
				// only needed for unix, this interferes with automated testing
				if (!windows)
				{
					fldOnKeyDown.ctrl.blur();
					fldOnKeyDown.ctrl.focus();
				}
				window.setTimeout("fldOnKeyDown.setCtrlValue(onKeyDownValue);doSubmit(fldOnKeyDown.name, 'ReturnKey');",
										200);
				onKeyDownValue = fldOnKeyDown.value;
			}
		}
		// not readonly
		else
		{
			if ((fld.onEnter == false) || (fld.onEnter == true && keycode != 13))
			{
				//let normal processing happen
			}
			else
			{
				// handle on enter, no cr allowed to be put into field, use expand window to enter cr
				fldOnKeyDown = fld;
				// only needed for unix, this interferes with automated testing
				if (!windows)
				{
					fldOnKeyDown.ctrl.blur();
					fldOnKeyDown.ctrl.focus();
				}
					window.setTimeout("fldOnKeyDown.setCtrlValue(onKeyDownValue);doSubmit(fldOnKeyDown.name, 'ReturnKey');",
										200);
				onKeyDownValue = fldOnKeyDown.ctrl.value;
			}
		}

		return retStat;
	}
	function openDiaryField(fldID)
	{
		var fld = getFieldInstanceByID(fldID);
		if (fld.access == disabled)
			return;

		// if readonly or editable open in a window
		getHistory(fldID);
	}
	function openCharField(fldID)
	{
		var fld = getFieldInstanceByID(fldID);
		if (fld.access == disabled)
			return;

		// if readonly or editable, open in a window
		visual_frame.openEditBox(fldID);
	}
	// -----------------------------------------------------------------
	// Handle onGainFocus active-links on the field if any defined.
	// -----------------------------------------------------------------
	function handleGainFocus(fldName)
	{
		// Sometimes focus is called before setupPage. Ignore it
		if (!currentWin || currentWin.winId != retCurrentWinId())
			return;

		var fld = getFieldInstanceByName(fldName);
		if (fld.access == disabled)
		{
			fld.ctrl.blur();
		}
		// text and textarea handled in onkeydown
		if (fld.access == readOnly && fld.type == typeSelection)
		{
			fld.ctrl.blur();
		}
	}
	// -----------------------------------------------------------------
	// Handle onMenuChange active-links on the field if any defined.
	// -----------------------------------------------------------------
	function handleMenuChange(fld)
	{
		var field = getFieldInstanceByName(fld.name);
		if (field.access == disabled || field.access == readOnly)
		{
			field.setCtrlValue(field.value);
			return;
		}
		if (field.onMenuChange == false) return;
		doSubmit(fld.name, 'MenuChoice');
	}

	function getEnumValue(field)
	{
		// get the index for radio/selection field
		var ienumRet = -1;
		if (field.type == typeSelection)
		{
			var fieldCtrl;
			if (field.isRadio == 1)
				fieldCtrl = eval('field.ctrl.form.elements.' + field.ctrl.name);
			else
				fieldCtrl = field.ctrl.options;

			var enumStr = field.getCtrlValue();
			// use the current ctrl string to find the enum value
			ienumRet = field.getCtrlIndex(fieldCtrl, field.radioItems, enumStr);
			if (field.isRadio != 1)
				ienumRet--;		// selections have clear

		}

		return ienumRet;

	}

	//
	// =================================================================
	// Definitions of 'ChangeField' ActiveLink Action Functions...
	// =================================================================
	//
	function changeFieldVisibility(fID, visibility)
	{
		var fld = getFieldInstanceByID(fID);
		if (fld)
		{
			if (fld.visibility == visibility) return;
			fld.setVisible(visibility);
		}
	}
	function setVisible(visibility)
	{
		if (this.layer.visibility == visibility) return;
		this.layer.visibility = visibility;
		this.visibility = visibility;
	}
	function changeFieldAccess(fID, access)
	{
		var fld = getFieldInstanceByID(fID);
		if (fld)
		{
			if (fld.type == typeTrim)
				return;
			if (access == disabled || access == readOnly)
				fld.ctrl.blur();
			if (access == disabled)
				fld.ctrl.disabled = true;
			else
				fld.ctrl.disabled = false;
			fld.access = access;
		}
	}
	function setFocus(fID)
	{
		var fld = getFieldInstanceByID(fID);
		if (fld)
		{
			fld.setFocus();
		}
	}
	function setFocusToDataField()
	{
		this.ctrl.focus();
	}
	function changeFieldLabelColor(fID, newColor)
	{
		var fld = getFieldInstanceByID(fID);
		if (fld)
		{
			if (fld.lColor == newColor) return;
			fld.lColor = newColor;
			fld.changeColor(newColor);
		}
	}
	function changeLabelColor(newColor)
	{
		if (ie)
			this.labelAddr.style.color = newColor;
		else
		{
			this.labelAddr.document.open();
			this.labelAddr.document.clear();
			this.labelAddr.document.write('<font color="' + newColor + '">' + this.label + ' </font>');
			this.labelAddr.document.close();
			this.labelAddr.document.charset = docCharset;
		}
	}
	function changeFieldMenu(fID,menuName)
	{
		var fld = getFieldInstanceByID(fID);
		if (fld)
		{
			fld.menuName = menuName;
		}
	}
	function displayMessage(msg)
	{
		alert(msg);
	}

	//
	// -----------------------------------------------------------------
	// SetField ActiveLink action definition for different field-types.
	// -----------------------------------------------------------------
	//
	function setValue(fID, val)
	{
		var fld = getFieldInstanceByID(fID);

		if (fld)
		{
			fld.setCtrlValue(val);
			fld.value = val;
		}
	}
	function setCharValue(val)
	{
		this.ctrl.value = val;
	}
	function setCharValueAppend(val)
	{
		if (this.append == true)
		{
			if (this.ctrl.value.length > 0)
			{
				this.ctrl.value += ' ' + val;
			}
			else
			{
				this.ctrl.value = val;
			}
		}
		else	
		{
			this.ctrl.value = val;
		}
	}
	function getCharValue()
	{
		   return this.ctrl.value;
        }	
	function handleOnChangeText(ctrl)
	{
		// onChange for text/textarea
		var fld = getFieldInstanceByName(ctrl.name);
		if (fld.access == readOnly)
		{
			// handle readonly for the following
			//  NN pc: continuously holding down a key does not trigger onkeydown
			//  NN unix TEXT: no event onkeydown, use this to restore r/o value
			//  NN unix TEXTAREA: fast typing, last char goes in. Use this it restore the r/o value

			fld.setCtrlValue(fld.value);
		}

	}
	function setSelectValue(val)
	{
		// radioItems NOP
		this.ctrl.selectedIndex = getSelectIndex(this.ctrl.options, this.radioItems, val);
	}
	function updateSelectedValue(ctrl)
 	{
	} 
	function getSelectValue()
        {
		return this.ctrl.options[this.ctrl.selectedIndex].value;
	}
	function setRadioValue(val)
	{
		var elmnt = eval('this.ctrl.form.elements.' + this.ctrl.name);
		var indx = getRadioIndex(elmnt, this.radioItems, val);
		if (indx > -1)
		{
			if (this.radioItems == 1)
				elmnt.checked = true;
			else
				elmnt[indx].checked = true;
		}
                else
                {
                    // If the value is not a selection value, then clear
                    // the radio button that is current set.
                    indx = getRadioIndex(elmnt, this.radioItems, this.prevRadioValue);
                    if ((indx > -1) && (this.radioItems > 1))
                    {
                        elmnt[indx].checked = false;
                    }
                    else
                    {
                        elmnt.checked = false;
                    }
                }
                // use prevRadioValue in ccsfieldinstance to save the last radio value string
		// to check/uncheck radio button
		// there is no automatic notification for settting/unsetting of radio buttons
		// we have to do it ourselves
		this.prevRadioValue = val;
	}
	function getRadioValue()
        {
		return getRadioSelection(this.ctrl, this.radioItems);
	}
	function getRadioSelection(radio, radioItems)
	{
		// radio with a single button has no enum list

		var elmnt = eval('radio.form.elements.' + radio.name);
		if (radioItems == 1)
		{
			if (elmnt.checked == true) return elmnt.value;
		}
		else
		{
			for (var i=0; i< elmnt.length; i++)
				if(elmnt[i].checked == true) return elmnt[i].value;
		}

		return '';   
	}
	function getRadioIndex(radio, radioItems, value)
	{
		// work around a bug when radio only has 1 item
		if (radioItems == 1)
		{
			if (radio.value == value)
				return 0;
		}
		else
		{
			for (var i=0; i< radio.length; i++)
				if(radio[i].value == value)	return i;
		}

		return -1;
	}
	function getSelectIndex(selection, radioItems, value)
	{
		// radioitems is not used for selections it's used for radio 
		// to work around a "feature" when there is only 1 radio button
		for (var i = 0; i < selection.length; i++)
			if (selection[i].value == value)
				return i;

		return -1;
	}

	function setAttachValue(val)
	{
		this.ctrl.load(val);
                // Need the nestref for DynLayer so that we don't have 57
                // level deep recursion.  nestref is the full document path
                // for this attachment.  Fixes bug 76200
                var nestref = 'formcontainer.document.' + getParentName(this) + this.name;
		this.ctrl.activate(null, nestref);
	}

	function SetServerProcessingRequest(newVal)
	{
		if (currentWin)
		{
			currentWin.serverProcessingRequest = newVal;
            if ( newVal == true )
               currentWin.sprTimer = setTimeout( "SetServerProcessingRequest(false)", 60000 );  // One minute timeout
            else if ( currentWin.sprTimer >= 0 )
            {
               clearTimeout( currentWin.sprTimer );
               currentWin.sprTimer = -1;
            }
		}

	}
	function ServerProcessingRequest(bDisplayMessage)
	{
		// display a status message if a request is already in progress
		if (currentWin)
		{
			if (currentWin.serverProcessingRequest == true && bDisplayMessage)
				window.status = TransactionMsgStr;
			return currentWin.serverProcessingRequest;
		}
		else
			return false;
	}
	//
	//----------------------------
	// ServerFinishedRequest
	// server calls this to inform us that the request has been processed
	// does not guarantee the success or failure of the request
	function ServerFinishedRequest()
	{
		// request to server is finished, clear the flag
		SetServerProcessingRequest(false);
	}
	function buildHidden()
	{
		hidden_frame.document.open("text/html", "replace");
		hidden_frame.document.writeln("<html><body>Initial Empty Hidden Page</body></html>");
		hidden_frame.document.close();
		hidden_frame.document.charset = docCharset;
	}
	function goBack()
	{
		if (ns)
			hidden_frame.back();
		else if(ie && !win31)
			history.back();
	}
	function loadPickList()
	{
		return PickListStr;
	}
	function showPickList(pick_list_str)
	{
		if(picklistWin != null && !picklistWin.closed)
		{
			picklistWin.focus();
			return;
		}
		SelectedFromPickList = 0;
		PickListStr = pick_list_str;
		picklistWin = window.open('javascript:opener.loadPickList();', 'win' + (++tmpWinId), 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=400');

		//window.clearTimeout(PAGES[CURRENT_PAGE].timeout_id);
		//setBusy(1);
	}
	function submitPicklist(indxVal)
	{
		if(SelectedFromPickList == 1)
			return;
		doSubmit(indxVal, 'SelectPickList');
	}
	function doHelp(url)
	{
		if(helpWin != null && !helpWin.closed)
			helpWin.close();
      
      // For submit/modify/query page the WID needs to be added
      if (currentWin && 
         (url.indexOf("Hmodify") > -1 || url.indexOf("Hqry") > -1 || url.indexOf("Hsubm") > -1)
         )
         url += "&WID=" + currentWin.winId;
		helpWin = window.open(url, 'win' + (++tmpWinId),'toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=600,height=400');
		helpWin.focus();
	}
	function makeObject() {};
	//
	// -------------------------------------------------------------------
	// This routine will uncheck the radio button if it was clicked again.
	// -------------------------------------------------------------------
	//
	function unCheckRadio(rd)
	{
		var fld = getFieldInstanceByName(rd.name);
		if (fld.access == disabled || fld.access == readOnly)
		{
			rd.checked = false;
			rd.blur();
			fld.setCtrlValue(fld.prevRadioValue);
			return false;
		}
		// emulate the setting/unsetting of the button
		// you don't get this for free
		if (fld.prevRadioValue == rd.value)
		{
			// unset the radio button
			rd.checked = false;
			fld.prevRadioValue = '';
		}
		else
        {
			// value is checked, save the radio string so that can check for uncheck of radio button
			fld.prevRadioValue = rd.value;
        }
		return true;
	}
	function showDoc(addr)
	{
		window.open(addr, 'win' + (++tmpWinId), 'toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes');
	}

	function resetVisibleAttributes()
	{
		if ( currentWin == null )
			return;

		var fields = currentWin.fieldInstances;

		// -----------------------------------
		// Set up the page field visibility structure
		// This gets lost on a back
		// ------------------------------------
		setInitialPageVisibility();
		for (var i = 0; i < fields.length; i++)
		{
			var fld = fields[i];
			if (fld.type == typePageHolder)
			{
				fixPageSelection(fld);
			}
		}
		
		// -----------------------------------
		// Change the visibility of the fields
		// -----------------------------------
		for (var i = 0; i < fields.length; i++)
		{
			var fld = fields[i];
			if (fld.type != typePage)
			{
				if (('' + fld.visibility) != 'undefined') fld.setVisible(fld.visibility);
			}
		}
		// --------------------------------------------------------------------
		// Change the labelColor of the fields.
		// This was kept in a seperate for() loop, since changing the LabelColor
		// of one field is causing the other JavaScript problems in running.(TODO)
		// --------------------------------------------------------------------
		for (var i = 0; i < fields.length; i++)
		{
			if (('' + fields[i].lColor) != 'undefined') fields[i].changeColor(fields[i].lColor);
		}
	}

    function setTimeFlag(flg)
	{
	    timeFlag = flg;
	}

    function setCacheFlag(cflg)
	{
	    cacheFlag = cflg;
	}

    function getDate(command)
	{
	    if (timeFlag == 1)
	        prevDate = new Date();
	    else
		    prevDate = 0;
		currCmd = command;
	}
	function getTimeDiff()
	{
	    if (prevDate != 0)
		{
	        currDate = new Date();
	        diff = currDate.getTime() - prevDate.getTime();
	        perf_frame.document.timing_form.timings.value += currCmd + " time is " + diff + " ms\n";
	        currCmd = '';
		    prevDate = 0;
		}
	}
	function getHistory(fID)
	{
        if ( currentWin == null )
            return;

		if(onModifyWindow=="false")
		{	
			// open just the diary editor. don't show the diary history, since there is none.
			openDiaryEdit(fID);
			return;
		}
		var hDoc = hidden_frame.document;
		hDoc.open("text/html", "replace");

		var formStr = 'Hidden page for getting diary history\n' +
					  '<form action="history.jsp" method="post">\n' +
					  '<input type="hidden" name="WID" value="' + currentWin.winId + '" />\n' +
					  '<input type="hidden" name="fid" value="' + fID + '" />\n';
		hDoc.write(formStr);
		hDoc.writeln('</form>');
		hDoc.close();
		hDoc.charset = docCharset;
		hDoc.forms[0].submit();
	}
	
	// Note all parameters to this function (e.g. server, schema, view, user) should
	// have been already URL encoded
	function openFormWindow(act, page, server, schema, view, user, scaleParams, back, replace, lct)
	{
       if ( currentWin == null )
          return;

	   var urlstr = "";
	   if (page != "")
	   {
	      urlstr = page + "?s=" + server + "&S=" + schema + "&U=" + user + "&V=" + view;
		  urlstr += "&Scale=" + scaleParams + "&O=1&C=" + cacheFlag + "&LChTime=" + lct;
	   }

       // The back parameter is set to false only while debugging scaling
		if (back) goBack();
		getDate('Generating Html on waserver for ' + act);

		if (replace)
			visual_frame.document.location.replace(urlstr);
        else
			visual_frame.document.location = urlstr;

	}

	function openFormErrorWindow(act, server, schema, errorString, directAccess)
	{
		var hDoc = hidden_frame.document;
		hDoc.open("text/html", "replace");
		var formStr = 'Hidden page for submitting form error\n' +
			'<form action="formerror.jsp" method="post" target="visual_frame">\n' +
			'<input type="hidden" name="O" value="1">\n' +
			'<input type="hidden" name="Act" value="' + act + '" />\n' +
			'<input type="hidden" name="s" value="' + server + '" />\n' +
			'<input type="hidden" name="S" value="' + schema + '" />\n' +
			'<input type="hidden" name="Error" value="' + errorString + '" />\n';
		if (!directAccess) goBack();
		hDoc.write(formStr);
		hDoc.writeln('</form>');
		hDoc.close();
		hDoc.charset = docCharset;
		hDoc.forms[0].submit();
	}

	function saveCurrentWinId()
	{
	   if (ns)
	     visual_frame.document.saveWid.document.fwid.currWId.value=currentWin.winId;
	   else
		 visual_frame.document.fwid.currWId.value=currentWin.winId;
	}

	function retCurrentWinId()
	{
	   if (ns)
	     return visual_frame.document.saveWid.document.fwid.currWId.value;
	   else
	     return visual_frame.document.fwid.currWId.value;
	}

	// Generate a random number to make the URL unique and thus preven caching.
	function noCache()
	{
		var dt = new Date();
		return "&Ts=" + dt.getTime();
	}
///////////////////////////////////////////////////////
//
//  User Customizable functions
//
///////////////////////////////////////////////////////

	function openSubmitForm(server_url, schema_url, timestamp, view)
	{
        cleanAfterTimestamp( timestamp );
		var urlStr = "scaling.jsp?Act=submit&O=1&s=" + server_url + "&S=" + schema_url;

		if (view != null)
		{
			urlStr = urlStr + "&V=" + view;
		}
		urlStr = urlStr  + noCache();

		getDate("Generating scaling page in waserver");

		if (DebugScaling)
			visual_frame.document.location = urlStr;
		else
			hidden_frame.document.location = urlStr;
	}

	function openQueryForm(server_url, schema_url, timestamp, view)
	{
        cleanAfterTimestamp( timestamp );
		var urlStr = "scaling.jsp?Act=qbe&O=1&s=" + server_url + "&S=" + schema_url;

		if (view != null)
		{
			urlStr = urlStr + "&V=" + view;
		}
		urlStr = urlStr  + noCache();

		getDate("Generating scaling page in waserver");

		if (DebugScaling)
			visual_frame.document.location = urlStr;
		else
			hidden_frame.document.location = urlStr;
	}

	function openModifyForm(server_url, schema_url, entry_url, timestamp, view)
	{
        cleanAfterTimestamp( timestamp );

		var urlStr = "scaling.jsp?Act=modify&O=1&s=" + server_url + "&S=" + schema_url + "&E=" + entry_url;

		if (view != null)
		{
			urlStr = urlStr + "&V=" + view;
		}
		urlStr = urlStr  + noCache();

		getDate("Generating scaling page in waserver");

		if (DebugScaling)
			visual_frame.document.location = urlStr;
		else
			hidden_frame.document.location = urlStr;
	}

	function openDisplayForm(server_url, schema_url, entry_url, timestamp, view)
	{
        cleanAfterTimestamp( timestamp );
		var urlStr = "entry.jsp?O=1&s=" + server_url + "&S=" + schema_url + "&E=" + entry_url;

		if (view != null)
		{
			urlStr = urlStr + "&V=" + view;
		}
		urlStr = urlStr  + noCache();

		visual_frame.document.location = urlStr;
	}

	function openModifyForTbl(server_url, schema_url, entry_url, tableFieldId, timestamp, view)
	{
		// Ignore the tableFieldId parameter
		// May be used in customized code
		openModifyForm(server_url, schema_url, entry_url, timestamp, view);
	}

	function openAttachment(wid, entry_url, attachFieldId)
	{
		var urlStr = "attach.jsp?O=1&WID=" + wid + "&E=" + entry_url + "&F=" + attachFieldId + noCache();
		hidden_frame.document.location = urlStr;
	}

	function refreshTable(tableField)
	{
		if ( currentWin == null )
			return;

		if (ServerProcessingRequest(true))
			return;

		SetServerProcessingRequest(true);

		var hDoc = hidden_frame.document;
		hDoc.open("text/html", "replace");
		var formStr = 'Hidden Page for refresh table\n' +
					  '<form action="refreshtbl.jsp" method="post">\n' +
					   '<input type="hidden" name="WID" value="' + currentWin.winId + '" />\n' +
					   '<input type="hidden" name="F" value="' + tableField + '" />\n' +
					   '<input type="hidden" name="Scale" value="' + currentWin.scaleParams + '" />\n';

		hDoc.write(formStr);
	
		var numDirty = writeOutDirtyFields(hDoc);

		hDoc.writeln('</form>');
		hDoc.close();
		hDoc.charset = docCharset;
		hDoc.forms[0].submit();
	}
