function WDFW_Dialog_Selection (_dlgTitle, _message, _valueList, _multiple, _targetField, _refreshID, _setting, _showAlias, _allowValuesNotInList) {

	var _form = dojo.byId('WDFWDlgSelForm');
	if (_form != null) { dojo.destroy('WDFWDlgSelForm') }
	
	var _form = dojo.create('form', {id: 'WDFWDlgSelForm'});
	dojo.create('span', {innerHTML: _message}, _form);
	dojo.create('br', {}, _form);
	dojo.create('br', {}, _form);
	
	var _optionsArray = [];
	var _selValues = dojo.query('input[id$="'+_targetField+'"]')[0].value.split(',');
			
	dojo.forEach (_valueList, function (_value) {
		var _tmpValue = _value.split('|');
		if (_selValues.indexOf(_tmpValue[1]) == -1) { 
			var _selected = false 
		} else { 
			var _selected = true;
			_selValues.splice (_selValues.indexOf(_tmpValue[1]), 1);
		}

		var _label = _showAlias == true ? _tmpValue[1] + ' - ' +_tmpValue[0] : _tmpValue[0];
		
		var _newoption = {	value: _tmpValue[1], label: _label, selected: _selected};
		_optionsArray.push(_newoption);
	});
	
	var _select = dijit.byId('WDFWDlgSelValues');
	if (_select != null) { _select.destroy() }
	
	if (_allowValuesNotInList == true) {
		for (var _idx = 0; _idx < _selValues.length; _idx++) {
			if (_selValues[_idx] != '') {
				var _newoption = {	value	: _selValues[_idx],
									label	: _selValues[_idx],
									selected: true};
				_optionsArray.push(_newoption);
			}
		}	
	}
	
	_select = new dojox.form.CheckedMultiSelect ({	id		: "WDFWDlgSelValues",
													multiple: _multiple,
													style   : "width: 300px; height: 203px"});
														
	_select.addOption(_optionsArray);
	_form.appendChild (_select.domNode);
	
	if (_allowValuesNotInList == true) {
		var _input = dijit.byId('WDFWDlgSelInput');
		if (_input != null) { _input.destroy() }
		
		_input = new dijit.form.TextBox ({	id		: "WDFWDlgSelInput",
											value	: "",
											style	: "width:300px"});
		dojo.create('br', {}, _form);
		
		var _inputDiv = dojo.create('div', {}, _form)
		dojo.style(_inputDiv, 'margin', '15px 0 0 0');
		var _title = dojo.create('span', {innerHTML: 'Neuer Wert:'}, _inputDiv);
		dojo.create('br', {}, _inputDiv);		
		_inputDiv.appendChild (_input.domNode);
	}
		   	
    var _buttons = dojo.create ('div', {}, _form);
    dojo.style(_buttons, 'margin', '15px 0 0 0');
    
    var _okButton = dijit.byId('WDFWDlgSelOkBt');
    if (_okButton != null) {_okButton.destroyRecursive();} 
    
    _okButton = new dijit.form.Button({	id: "WDFWDlgSelOkBt",
    									label: "Ok",
    									onClick: function () {WDFW_Dialog_Selection_Transfer(_targetField, _refreshID, _setting, _multiple, _allowValuesNotInList)}
    								})
    								    
    _buttons.appendChild(_okButton.domNode);
    
    var _cancelButton = dijit.byId('WDFWDlgSelCancelBt');
    if (_cancelButton != null) {_cancelButton.destroyRecursive();} 
    
    _cancelButton = new dijit.form.Button({	id: "WDFWDlgSelCancelBt",
    									label: "Abbrechen",
    									onClick: function () {	var _dialog = dijit.byId("WDFWDlgSel");
																_dialog.hide();
    															_dialog.destroyRecursive(); 
    									 					} 
	    								});
    								    
    _buttons.appendChild(_cancelButton.domNode);
   
    var _dialog = dijit.byId("WDFWDlgSel");
    if (_dialog != null) {_dialog.destroyRecursive();}
    
    _dialog = new dijit.Dialog({id		: "WDFWDlgSel", 
    							title	: _dlgTitle}, _form);       
    _dialog.startup();
    _dialog.show();
    		
} // END: WDFW_Dialog_Selection

function WDFW_Dialog_Selection_Transfer (_targetField, _refreshID, _setting, _multiple, _allowValuesNotInList) {

	var _select = dijit.byId('WDFWDlgSelValues');
	var _options = _select.options;
	var _selValues = new Array ();
	
	dojo.forEach (_options, function (_option) {  if (_option.selected == true) { _selValues.push(_option.value) } });
	
	if (_allowValuesNotInList == true) {
		var _input = dijit.byId('WDFWDlgSelInput');
		if (_input.value != '') {
			if (_setting){
				dojo.xhrGet ({	url : "xpAJAX.xsp"+dojo.query('input[id$=WDFSessionID]')[0].value,
								content: {	CONTEXT	: "SETUP",
											ACTION	: "ADDSETTING",
											SETTING	: _setting,
											VALUE	: _input.value,
											LANGUAGE: "G",
											FORCE	: "1"},
								handleAs: 'xml',
								load: function(_response, _ioArgs) {
									_alias = WDFW_ScriptExt_XMLValueGet (_response, 'ALIAS'); 
									_selValues.push(_alias);
									WDFW_Dialog_Selection_Transfer_Step2 (_targetField, _selValues, _refreshID);
								}
							});		
				return;
			} else {
				if (_multiple) {
					_selValues.push(_input.value);
				} else {
					_selValues = new Array (_input.value);
				}
			}
		}
	}
	
	WDFW_Dialog_Selection_Transfer_Step2 (_targetField, _selValues, _refreshID)
    
} // END: WDFW_Dialog_Selection_Transfer

function WDFW_Dialog_Selection_Transfer_Step2 (_targetField, _selValues, _refreshID) {
	
	dojo.query('input[id$='+_targetField+']')[0].value = _selValues.join(',');
	
	var _dialog = dijit.byId("WDFWDlgSel");
	_dialog.hide();
    _dialog.destroyRecursive();
    
	if (_refreshID) {
  		if (_refreshID.indexOf('|') > -1) {
  			WDO_Tools_RefreshIDs (_refreshID.split('|'), true)
  		} else { 
  			XSP.partialRefreshPost(_refreshID)
  		}
  	}    

} // END: WDFW_Dialog_Selection_Transfer_Step2

function WDFW_Dialog_Confirm (_title, _text, _bt1Lable, _bt2Lable, _cbFuncBt1, _cbFuncBt2) {

	var _dialog = dijit.byId('confirmationDialog');
	if (_dialog) { _dialog.destroyRecursive() }

	_dialog = new dijit.Dialog({ id: 'confirmationDialog', title: _title });

	_cbFuncBt1Final = function(){_dialog.hide(); _dialog.destroyRecursive(); _cbFuncBt1();};
	_cbFuncBt2Final = function(){_dialog.hide(); _dialog.destroyRecursive(); _cbFuncBt2();};
								
	var _textDiv = dojo.create('div', { innerHTML: _text });
	var _bt1 = new dijit.form.Button({ label: _bt1Lable, id: 'cdBt1', onClick: _cbFuncBt1Final});
	var _bt2 = new dijit.form.Button({ label: _bt2Lable, id: 'cdBt2', onClick: _cbFuncBt2Final });

	_dialog.containerNode.appendChild(_textDiv);
	_dialog.containerNode.appendChild(dojo.create('br'));
	_dialog.containerNode.appendChild(_bt1.domNode);
	_dialog.containerNode.appendChild(_bt2.domNode);
	_dialog.show();
	
} // END: WDFW_Dialog_Confirm
