/**
 *	Class to submit a form according to a specific action.
 *
 *	@author		Unknown
 *	@version	1.0
 *	@copyright	Katana Productions Pty Ltd 2002
 *
 *	@param	form    The form object to be submitted.
*/
function LookUpAction(form)
{
  this.base = Action;
  this.base(form)
}

LookUpAction.prototype = new Action

/**
 *	Causes a general action submit of the form.
 *
 *	@param fieldId An integer representing the id field value to update.
 *	@param fieldValue A string representing the value field value to update.
 *	@param refresh A boolean on whether to refresh the page after the lookup has occurred
*/
LookUpAction.prototype.doLookUpAction = function(fieldId, fieldValue,refresh)
{  
  // check to see whether we are opening it through a modal dialog or through
  // a standard browser window
  if(!opener)
  {
    this.fieldId = fieldId;
	  this.fieldValue = fieldValue;
	  var dlg = top.dialogArguments.device.doAction(fieldId, fieldValue);
  }
  else
  {
	  var formname = document.forms.main_form.formname.value;
	  var form = eval('opener.document.forms.' + formname);
	  var idfieldname = document.forms.main_form.idfieldname.value;
	  eval('form.' + idfieldname + '.value = fieldId');
	  var displayfieldname = document.forms.main_form.displayfieldname.value;
	  eval('form.' + displayfieldname + '.value = unescape(fieldValue)');
  
    // Refresh the page if required.
    if(refresh)
    {
      new Action(form).doAction(Action.ACTION_VIEWCONTEXT)
    }
  }
	window.close();
  return false;
}