/**
 * Supports these field types: "Currency" | "Timezone" | "FKey" | "FKeySet"
 * @constructor
 * @extends LoginPanelAgent
 * @param {String} id This Agent's field reference
 */
function DDAgent(id) {

	this.init(id);

	// procedure callbacks implemented in modRec, filter & collection
	this.update = AgentPCB.update;
	this.onLogin = AgentPCB.onLogin;

	this.submitValue = function(obj) {

		var ov = obj.options[obj.selectedIndex].value;

		if (ov=='newRecord') { // new record for FKey or FKeySet
			var oButton = $('popup_'+this.fieldRef);
			Manager.openPopup(oButton,oButton.longDesc);
			return}

		var xmlValue = '<NullValue/>';
		if (ov && ov!='') switch (this.fieldType) {
			case 'FKey' : xmlValue = '<FKey recId="'+ov+'"/>'; break;
			case 'FKeySet' :
				if (this.recId || this.mmrId) {
					Manager.getAgent('link_'+this.fieldRef).addFKey(ov);
					$(this.id).selectedIndex = 0;
					return}
				else xmlValue = '<FKey recId="'+ov+'"/>';
				break;
			default : xmlValue = '<'+this.fieldType+' code="'+ov+'"/>'} // Currency or Timezone

		var xeValue = new ParsedXMLElement(xmlValue);

		var xeCommand;
		if (this.recId) xeCommand = this.xeSetFieldValue(xeValue);
		else if (this.mmrId) xeCommand = this.xeSetMMRFieldValue(xeValue);
		else xeCommand = this.xeGetPSValueLabel(xeValue);

		var xeWidgetResult = this.xeWidgetResult(xeCommand);
        this.update(xeWidgetResult)}

	this.toString = function() {
		return 'DDAgent: {agentPrefix: ' + this.agentPrefix + '; fieldRef: ' + this.fieldRef + '}'}
}

DDAgent.prototype = new LoginPanelAgent();
