Your IP : 172.28.240.42


Current Path : /var/www/html/clients/old.e-nkama.ru/e-nkama_bitrix/bitrix/js/form/
Upload File :
Current File : /var/www/html/clients/old.e-nkama.ru/e-nkama_bitrix/bitrix/js/form/form_taskbar.js

function BXFormElementsTaskbar()
{
	var pDataCell;
	var oTaskbar = this;
	
	BXFormElementsTaskbar.prototype.OnTaskbarCreate = function ()
	{
		pDataCell = oTaskbar.CreateScrollableArea(oTaskbar.pDataCell);
		
		oBXEditorUtils.addPropertyBarHandler('form_question', this.ShowProperties);
		oBXEditorUtils.addPropertyBarHandler('form_question_new', this.ShowProperties);
		oBXEditorUtils.addPropertyBarHandler('form_api', this.ShowAPIProperties);
		
		this.DisplayTree();
	}
	
	BXFormElementsTaskbar.prototype.DisplayTree = function ()
	{
		var arElements = [];
		
		var _arElement = [];
		_arElement['name'] = 'cformelements';
		_arElement['title'] = __arr_messages['FORM_TASKBAR_CFORM'];
		_arElement['tagname'] = 'cformelements';
		_arElement['icon'] = '';
		_arElement['isGroup'] = true;
		_arElement['params'] = [];		
		_arElement['childElements'] = [];

		for (var i=0; i<__arr_input_types.length; i++)
		{
			var __arPar = [];
			
			__arPar[0] = {name:'element_type', value:__arr_input_types[i]}
		
			var __arElement = [];
			__arElement['group'] = 'cformelements';
			__arElement['tagname'] = 'form_question_new';
			__arElement['name'] = __arr_input_types[i];
			__arElement['title'] = __arr_input_types_titles[i];
			__arElement['icon'] = '/bitrix/images/form/visual/form_' + __arr_input_types[i] + '.gif';
			__arElement['isGroup'] = false;
			__arElement['params'] = __arPar;
			_arElement['childElements'].push(__arElement); 
		}
		
		arElements.push(_arElement);
		
		if (oForm.arQuestions.length > 0)
		{
			var _arElement = [];
			_arElement['name'] = 'cformoutputelements';
			_arElement['title'] = __arr_messages['FORM_TASKBAR_CFORMOUTPUT'];
			_arElement['tagname'] = 'cformoutputelements';
			_arElement['icon'] = '';
			_arElement['isGroup'] = true;
			_arElement['params'] = [];		
			_arElement['childElements'] = [];
			
			for (var i=0; i<oForm.arQuestions.length; i++)
			{
				if (!oForm.arQuestions[i].isNew)
				{
					var __arPar = [];
					__arPar[0] = {name:'element_index', value:i}
					
					var __arElement = [];
					__arElement['group'] = 'cformoutputelements';
					__arElement['tagname'] = 'form_question';
					__arElement['name'] = oForm.arQuestions[i].FIELD_SID;
					__arElement['title'] = oForm.arQuestions[i].CAPTION;
					__arElement['icon'] = '/bitrix/images/form/visual/form_' + oForm.arQuestions[i].type + '.gif';
					__arElement['isGroup'] = false;
					__arElement['params'] = __arPar;
					_arElement['childElements'].push(__arElement); 
				}
			}
			
			if (_arElement['childElements'].length > 0)
				arElements.push(_arElement);
		}
		
		var _arElement = [];
		_arElement['name'] = 'cformoutputapimethods';
		_arElement['title'] = __arr_messages['FORM_TASKBAR_API'];
		_arElement['tagname'] = 'cformoutputapimethods';
		_arElement['icon'] = '';
		_arElement['isGroup'] = true;
		_arElement['params'] = [];		
		_arElement['childElements'] = [];

		for (var i=0; i<__arr_api_methods.length; i++)
		{
			var __arPar = [];
			  __arPar[0] = {name:'METHOD', value:__arr_api_methods[i]}
			
			var __arElement = [];
			__arElement['group'] = 'cformoutputapimethods';
			__arElement['tagname'] = 'form_api';
			__arElement['name'] = __arr_api_methods[i];
			__arElement['title'] = __arr_api_methods_title[i];
			__arElement['icon'] = '/bitrix/images/form/visual/form_api_' + __arr_api_methods[i].toLowerCase() + '.gif';
			__arElement['isGroup'] = false;
			__arElement['params'] = __arPar;
			
			_arElement['childElements'].push(__arElement); 
		}
		arElements.push(_arElement);		

		oTaskbar.DisplayElementList(arElements,pDataCell);
	}
	
	BXFormElementsTaskbar.prototype.ShowAPIProperties = function(_bNew, _pTaskbar, _pElement)
	{
		var arParams = oBXEditorUtils.getCustomNodeParams(_pElement);
		var __APIMethodName = arParams[0].value;

		var __saveParams = function(e)
		{
			__element_index = arParams[1].value;
			
			if (__arr_api_methods_params[__APIMethodName].length > 0)
			{
				for (var __i = 0; __i<__arr_api_methods_params[__APIMethodName].length; __i++)
				{	
					__obj = document.getElementById('__param_' + __arr_api_methods_params[__APIMethodName][__i]);
					
					if (__obj.tagName == "INPUT" && __obj.type == "checkbox")
					{
						arParams[2].value[__i].value = __obj.checked ? "Y" : "N";
					}
					else if (__obj.tagName == "SELECT")
					{
						__obj_self = document.getElementById('__param_' + __arr_api_methods_params[__APIMethodName][__i] + '_self');
						
						arParams[2].value[__i].value = __obj_self && __obj_self.value != '' ? __obj_self.value : __obj.value;
					}
					else
					{
						arParams[2].value[__i].value = __obj.value;
					}
				}
			}
			
			oForm.arMethods[__element_index].params = arParams[2].value;
		}
	
		oBXEditorUtils.BXRemoveAllChild(_pTaskbar.pCellProps);
		
		var _div = document.createElement('DIV');
		_div.setAttribute("align", "center");
		
		if (arParams[1])
		{
			if (oForm.arMethods[arParams[1].value])
			{
				arParams[2] = {name:'PARAMS', value:oForm.arMethods[arParams[1].value].params}
			}
		}
		
		//_div.appendChild(document.createTextNode(returnProperties(arParams)))
		//_div.appendChild(document.createElement('BR'));

		var __tn = document.createElement('B');
		var __method_caption = arParams[0].value;
		for (var __i=0; __i<__arr_api_methods.length; __i++)
		{
			if (__arr_api_methods[__i] == __method_caption)
			{
				__method_caption = __arr_api_methods_title[__i] + ' (' + __method_caption + ')';
			}
		}
		
		__tn.appendChild(document.createTextNode(__method_caption));
		_div.appendChild(__tn);
		_div.appendChild(document.createElement('BR'));
		
		if (arParams.length < 3 || arParams[2].value.length <= 0)
		{
			_div.appendChild(document.createTextNode(__arr_messages['FORM_METHOD_HAS_NO_PARAMS']));
		}
		else 
		{
			_table = document.createElement('TABLE');
			_table.className = "bxtaskbarpropscomp";
			_table.setAttribute("width", "100%");

			for(var i=0; i<__arr_api_methods_params[__APIMethodName].length; i++)
			{
				param_name = __arr_api_methods_params[__APIMethodName][i];
				param_value = oForm.getMethodParamValue(arParams[1].value, param_name);

				_row = _table.insertRow(-1);
				_cell_title = _row.insertCell(-1);
				_cell_input = _row.insertCell(-1);

				_cell_title.setAttribute("align", "right");
				_cell_title.setAttribute("valign", "top");
				_cell_title.setAttribute("width", "40%");
				_cell_title.style.verticalAlign = "top";				

				_cell_input.setAttribute("align", "left");
				_cell_input.setAttribute("valign", "top");
				_cell_input.setAttribute("width", "60%");
				_cell_input.style.verticalAlign = "top";
		
				_cell_title.appendChild(document.createTextNode(__arr_api_methods_params_captions[param_name] + ': '));				
				
				switch (param_name)
				{
					case 'CSS_STYLE':
						if (__APIMethodName  == 'ShowApplyButton' || __APIMethodName  == 'ShowSubmitButton' || __APIMethodName  == 'ShowResetButton')
							__arStyles = GLOBAL_pMainObj['FORM_TEMPLATE'].oStyles.arStyles["INPUT"];
						else
							__arStyles = GLOBAL_pMainObj['FORM_TEMPLATE'].oStyles.arStyles["DEFAULT"];
						
						if (!__arStyles) __arStyles = [];
						/*
						var style_include = document.getElementsByTagName("STYLE")[0];
						if (!style_include) 
						{
							style_include = document.createElement("STYLE");
							_div.appendChild(style_include);
						}
						
						style_include.appendChild(document.createTextNode(GLOBAL_pMainObj['FORM_TEMPLATE'].oStyles.sStyles));
						*/
						
						//GLOBAL_pMainObj['FORM_TEMPLATE'].oStyles.SetToDocument(document);

						_input = document.createElement('SELECT');
						_input.id = "__param_" + param_name;
						
						_option = document.createElement('OPTION');
						_option.value = '';
						_input.appendChild(_option);					
						
						__selected = false;
						
						for (var __i=0; __i<__arStyles.length; __i++)
						{
							_option = document.createElement('OPTION');
							_option.value = __arStyles[__i].className;
							_option.selected = _option.value == param_value;
							//_option.className = _option.value;
							__selected |= _option.selected;
							
							__node_text = '[' + __arStyles[__i].className + '] ' + (GLOBAL_pMainObj['FORM_TEMPLATE'].arTemplateParams["STYLES_TITLE"][__arStyles[__i].className] ? GLOBAL_pMainObj['FORM_TEMPLATE'].arTemplateParams["STYLES_TITLE"][__arStyles[__i].className] : '');
							
							_option.appendChild(document.createTextNode(__node_text));
							_input.appendChild(_option);
						}
						
						_input.onchange = __saveParams;					
						
						_cell_input.appendChild(_input);
						_cell_input.appendChild(document.createElement('BR'));
						
						_input = document.createElement('INPUT');
						_input.type = "text";
						_input.id = "__param_" + param_name + '_self';
						_input.value = __selected ? '' : param_value;
						_input.onchange = __saveParams;
						
						_cell_input.appendChild(_input);
						
						break;
						
					case 'ALIGN':
						_input = document.createElement('SELECT');
						_input.id = "__param_" + param_name;
						
						_option = document.createElement('OPTION');
						_option.value = '';
						_input.appendChild(_option);
						
						__arOptions = ['LEFT', 'RIGHT', 'CENTER'];
						
						for (var __j=0; __j<__arOptions.length; __j++)
						{
							_option = document.createElement('OPTION');
							_option.value = __arOptions[__j];
							_option.selected = _option.value == param_value;
							_option.appendChild(document.createTextNode(_option.value));
							
							_input.appendChild(_option);
						}
						
						_cell_input.appendChild(_input);
						
						break;
						
					case 'FIELD_SID':
						_input = document.createElement("SELECT");
						_input.id = '__param_'+param_name;
						_input.style.width = '100px';

						var __arr_sid_list = oForm.getFSIDList();
						
						var __option = document.createElement("OPTION");
						__option.value = '';

						_input.appendChild(__option);
						
						for (var _i=0; _i<__arr_sid_list.length; _i++)
						{
							var __option = document.createElement("OPTION");
							__option.value = __arr_sid_list[_i];
							__option.selected = __arr_sid_list[_i] == param_value;
							__option.appendChild(document.createTextNode(__arr_sid_list[_i]));

							_input.appendChild(__option);
						}
						_input.onchange = __saveParams;
						
						_cell_input.appendChild(_input);
					
						break;
					case 'ENLARGE_SHOW':
					case 'NOT_SHOW_CSS':
						_input = document.createElement('INPUT');
						_input.type = 'checkbox';
						_input.id = "__param_" + param_name;
						_input.defaultChecked = param_value == "Y";
						_input.checked = param_value == "Y";
						
						_input.onchange = __saveParams;						
					
						_cell_input.appendChild(_input);
					
						break;
						
					default:
						_input = document.createElement('INPUT');
						_input.type = 'text';
						_input.id = "__param_" + param_name;
						_input.value = param_value;
						_input.onchange = __saveParams;						
					
						_cell_input.appendChild(_input);
						
						break;
				}
			
				//_div.appendChild(document.createElement('BR'));
			}
			
			_div.appendChild(_table);
		}
		

		_pTaskbar.pCellProps.appendChild(_div);
	}

	
	BXFormElementsTaskbar.prototype.ShowProperties = function(_bNew, _pTaskbar, _pElement)
	{
		// _pTaskbar.pCellProps - ïðîêðó÷èâàåìàÿ îáëàñòü ïàíåëè ñâîéñòâ	
		var arParams = oBXEditorUtils.getCustomNodeParams(_pElement);
		var element_index = arParams[0].value;

		var _input,_div;
		var __arr_structure_input_ids = [];
		var _q_type;
		
		var __saveParams = function(e)
		{
			for (var _i in oForm.arQuestions[element_index])
			{
				_input = document.getElementById('__param_'+_i);
				if (_input)
				{
					oForm.arQuestions[element_index][_i] = _input.type != "checkbox" ? _input.value : (_input.checked ? "Y" : "N");
				}
				else if (_i == "structure")
				{
					if (oForm.arQuestions[element_index][_i] == null) oForm.arQuestions[element_index][_i] = [];
					
					for (var _j=0; _j<__arr_structure_input_ids.length; _j++)
					{
						obj = document.getElementById(__arr_structure_input_ids[_j]);
						obj_params = obj.id.split('___');
						
						row_num = obj_params[obj_params.length-2];
						row_fld = obj_params[obj_params.length-1];
						
						var fld_value = obj.type != "checkbox" ? obj.value : (obj.checked ? "Y" : "N");
						
						if (oForm.arQuestions[element_index][_i][row_num] == null) 
							oForm.arQuestions[element_index][_i]['value'][row_num] = [];
						oForm.arQuestions[element_index][_i][row_num][row_fld] = fld_value;
					}
				}
			}
		}
		
		if (_bNew)
		{
			oBXEditorUtils.BXRemoveAllChild(_pTaskbar.pCellProps);
			var __pt = document.createElement('TABLE');
			__pt.className = "bxtaskbarpropscomp";
			__pt.setAttribute("width", "100%");
		}
		
		for (var _i in oForm.arQuestions[element_index])
		{	
			if (_bNew)
			{
				__pt_row = __pt.insertRow(-1);
			}
		
			if (_i == "structure")
			{
				_input = document.getElementById('_fld_structure');
				if (!_input)
				{
					_input = document.createElement('DIV');
					_input.setAttribute("align", "left");
					_input.id = "_fld_structure";
				}
				else
				{
					oBXEditorUtils.BXRemoveAllChild(_input);
				}

				var _tab = document.createElement('TABLE');
				_tab.id = 'fld_params_table';
				_tab.className = 'internal';
				_tab.style.width = '200px';
				
				var __tr_index = 0;
				_tab.setAttribute("width", "200");
				_tab.setAttribute("cellpadding", "0");
				_tab.setAttribute("cellspacing", "0");
				_tab.setAttribute("border", "0");
				
				_row = _tab.insertRow(-1);
				_row.className = 'heading';
				
				switch (_q_type)
				{
					case 'textarea':
						__arr_col_captions = [__arr_messages["FORM_FIELD_DEF_VAL"], __arr_messages["FORM_FIELD_WIDTH_VAL"], __arr_messages["FORM_FIELD_HEIGHT_VAL"]];
					break;
					
					case 'radio':
					case 'checkbox':
					case 'dropdown':
					case 'multiselect':
						__arr_col_captions = [__arr_messages["FORM_ANSWER_VAL"], __arr_messages["FORM_SORT_VAL"], __arr_messages["FORM_DEF_VAL"]];
					
					break;
					
					case 'hidden':
						__arr_col_captions = [__arr_messages["FORM_FIELD_DEF_VAL"]];
					break;
					
					default:
						__arr_col_captions = [__arr_messages["FORM_FIELD_DEF_VAL"], __arr_messages["FORM_FIELD_SIZE_VAL"]];
					break;
				}
				
				for (var __i=0; __i<__arr_col_captions.length; __i++)
				{
					_cell = _row.insertCell(-1);
					_cell.appendChild(document.createTextNode(__arr_col_captions[__i]));
				}
				
				switch (_q_type)
				{
					case 'textarea':
						_row = _tab.insertRow(-1);

						_cell = _row.insertCell(-1);
						
						__input = document.createElement("INPUT");
						__input.type = "text";
						__input.id = 'param___0___VALUE';
						__arr_structure_input_ids[__arr_structure_input_ids.length] = __input.id;						
						__input.value = oForm.arQuestions[element_index][_i][0]['VALUE']
						__input.style.width = '90px';
						__input.onchange = __saveParams;
							
						_cell.appendChild(__input);
						_cell = _row.insertCell(-1);
						
						__input = document.createElement("INPUT");
						__input.type = "text";
						__input.id = 'param___0___FIELD_WIDTH';
						__arr_structure_input_ids[__arr_structure_input_ids.length] = __input.id;						
						__input.value = oForm.arQuestions[element_index][_i][0]['FIELD_WIDTH']
						__input.style.width = '90px';
						__input.onchange = __saveParams;
							
						_cell.appendChild(__input);

						_cell = _row.insertCell(-1);
						__input = document.createElement("INPUT");
						__input.type = "text";
						__input.id = 'param___0___FIELD_HEIGHT';
						__arr_structure_input_ids[__arr_structure_input_ids.length] = __input.id;
						__input.value = oForm.arQuestions[element_index][_i][0]['FIELD_HEIGHT'];
						__input.style.width = '90px';
						__input.onchange = __saveParams;
								
						_cell.appendChild(__input);

						__input = document.createElement("INPUT");
						__input.type = "hidden";
						__input.id = 'param___0___ANS_NEW';
						__arr_structure_input_ids[__arr_structure_input_ids.length] = __input.id;
						__input.value = oForm.arQuestions[element_index][_i][0]['ANS_NEW'];

						_cell.appendChild(__input);
						
						
					break;
					
					case 'radio':
					case 'checkbox':
					case 'dropdown':
					case 'multiselect':
						for (var _j=0; _j<oForm.arQuestions[element_index][_i].length; _j++)
						{
							_row = _tab.insertRow(-1);
							
							_cell = _row.insertCell(-1);
							
							__input = document.createElement("INPUT");
							__input.type = "text";
							__input.id = 'param___' + _j + '___MESSAGE';
							__arr_structure_input_ids[__arr_structure_input_ids.length] = __input.id;
							__input.value = oForm.arQuestions[element_index][_i][_j]['MESSAGE']
							__input.style.width = '90px';
							__input.onchange = __saveParams;
									
							_cell.appendChild(__input);
							_cell = _row.insertCell(-1);
							
							__input = document.createElement("INPUT");
							__input.type = "text";
							__input.id = 'param___' + _j + '___C_SORT';
							__arr_structure_input_ids[__arr_structure_input_ids.length] = __input.id;
							__input.value = oForm.arQuestions[element_index][_i][_j]['C_SORT']
							__input.style.width = '90px';
							__input.onchange = __saveParams;
									
							_cell.appendChild(__input);
							
							_cell = _row.insertCell(-1);
							
							_cell.setAttribute("align", "center");
							
							__input = document.createElement("INPUT");
							__input.type = "checkbox";
							__input.id = 'param___' + _j + '___DEFAULT';
							__arr_structure_input_ids[__arr_structure_input_ids.length] = __input.id;

							var bChecked = oForm.arQuestions[element_index][_i][_j]['FIELD_PARAM'] == "CHECKED" || oForm.arQuestions[element_index][_i][_j]['FIELD_PARAM'] == "SELECTED";
							__input.checked = bChecked;
							__input.defaultChecked = bChecked;

							__input.onchange = __saveParams;
									
							_cell.appendChild(__input);
							
							__input = document.createElement("INPUT");
							__input.type = "hidden";
							__input.id = 'param___' + _j + '___ANS_NEW';
							__arr_structure_input_ids[__arr_structure_input_ids.length] = __input.id;
							__input.value = oForm.arQuestions[element_index][_i][_j]['ANS_NEW'];
									
							_cell.appendChild(__input);
							
						}
					
					break;
					
					// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
					case "multiple": 
						_tab = null;
						_tab = document.createElement('B');
						_tab.appendChild(document.createTextNode(__arr_messages['FORM_FIELD_MULTIPLE_WARNING']));
					break;
					
					case "hidden":
						_row = _tab.insertRow(-1);
						_cell = _row.insertCell(-1);
						__input = document.createElement("INPUT");
						__input.type = "text";
						__input.id = 'param___0___VALUE';
						__arr_structure_input_ids[__arr_structure_input_ids.length] = __input.id;
						__input.value = oForm.arQuestions[element_index][_i][0]['VALUE'];
						__input.style.width = '90px';
						__input.onchange = __saveParams;
						_cell.appendChild(__input);
						
						__input = document.createElement("INPUT");
						__input.type = "hidden";
						__input.id = 'param___0___ANS_NEW';
						__arr_structure_input_ids[__arr_structure_input_ids.length] = __input.id;
						__input.value = oForm.arQuestions[element_index][_i][0]['ANS_NEW'];
								
						_cell.appendChild(__input);						
						
					break;
					
					default:
						_row = _tab.insertRow(-1);
						_cell = _row.insertCell(-1);
						__input = document.createElement("INPUT");
						__input.type = "text";
						__input.id = 'param___0___VALUE';
						__arr_structure_input_ids[__arr_structure_input_ids.length] = __input.id;
						__input.value = oForm.arQuestions[element_index][_i][0]['VALUE'];
						__input.style.width = '90px';
						__input.onchange = __saveParams;
						_cell.appendChild(__input);
						
						_cell = _row.insertCell(-1);						
						__input = document.createElement("INPUT");
						__input.type = "text";
						__input.id = 'param___0___FIELD_WIDTH';
						__arr_structure_input_ids[__arr_structure_input_ids.length] = __input.id;
						__input.value = oForm.arQuestions[element_index][_i][0]['FIELD_WIDTH']
						__input.style.width = '90px';
						__input.onchange = __saveParams;
								
						_cell.appendChild(__input);

						__input = document.createElement("INPUT");
						__input.type = "hidden";
						__input.id = 'param___0___ANS_NEW';
						__arr_structure_input_ids[__arr_structure_input_ids.length] = __input.id;
						__input.value = oForm.arQuestions[element_index][_i][0]['ANS_NEW'];
								
						_cell.appendChild(__input);

					break;
				}
				
				_input.appendChild(_tab);
			}
			else
			{
				_input = document.createElement('INPUT');
				switch (_i)
				{
					case 'CAPTION_UNFORM':
						_input = null;
						_input = document.createElement('TEXTAREA');
						_input.style.width = '500px';
						_input.style.width = '400px';
						_input.value = oForm.arQuestions[element_index][_i];
					
						break;				
					case 'isHTMLCaption':
					case 'isRequired':
					case 'inResultsTable':
					case 'inExcelTable':
							_input.type = 'checkbox';
							_input.value = 'Y';
							_input.checked = oForm.arQuestions[element_index][_i] == 'Y';
							_input.defaultChecked = oForm.arQuestions[element_index][_i] == 'Y';
							
						break;
					case 'isNew':
					case 'CAPTION':
					case 'ID':
							_input.type = 'hidden';
							_input.value = oForm.arQuestions[element_index][_i];
						break;

					case 'type':
							_input.type = 'hidden';
							_input.disabled = true;
							_q_type = oForm.arQuestions[element_index][_i];
							_input.value =_q_type;
							_input.id = '__param_'+_i;
							
							__title = '';
							for (var __i = 0; __i < __arr_input_types.length; __i++)
							{
								if (_q_type == __arr_input_types[__i]) 
								{
									__title = __arr_input_types_titles[__i];
									break;
								}
							}
							
							__div = document.createElement("B");
							__div.style.lineHeight = "20px";
							__div.appendChild(_input);
							__div.appendChild(document.createTextNode('[' + _q_type + '] ' + __title));
							
							_input = __div;

					case 'FIELD_SID': 
					default: 
							_input.type = 'text';
							_input.value = oForm.arQuestions[element_index][_i];
						break;
				}
			
				if (_i != 'type')
				{
					_input.id = '__param_'+_i;
					_input.onchange = __saveParams;
				}
			}
			
			if (_bNew)
			{
				__pt_cell = __pt_row.insertCell(-1);
				__pt_cell.setAttribute("align", "right");
				__pt_cell.setAttribute("valign", "top");
				__pt_cell.style.verticalAlign = "top";
				
				if (__arr_field_titles[_i])
					__pt_cell.appendChild(document.createTextNode(__arr_field_titles[_i] + ': '));
				
				__pt_cell = __pt_row.insertCell(-1);
				__pt_cell.setAttribute("valign", "top");
				__pt_cell.style.verticalAlign = "top";
				__pt_cell.id = '__form_'+_i;
				__pt_cell.appendChild(_input);		
				
				if (_input.type)
				{
					if(_input.type == "hidden")
					{
						__pt_row.style.display = 'none';
					}
				}
			}
			else
			{
				__pt_cell = document.getElementById('__form_'+_i);
				if (__pt_cell)
				{
					oBXEditorUtils.BXRemoveAllChild(__pt_cell);
					__pt_cell.appendChild(_input);
				}
			}
		}
		
		if (_bNew)
		{
			_pTaskbar.pCellProps.appendChild(__pt);	
		}
	}

	
	BXFormElementsTaskbar.prototype.UnParseElement = function(node)
	{
		if (node.arAttributes["__bxtagname"] == 'form_question')
		{
			var __arNodeParams = oBXEditorUtils.getCustomNodeParams(node)
			var element_index = __arNodeParams[0].value;
			
			if (null != element_index && null != oForm.arQuestions[element_index].FIELD_SID)
			{
				return '<' + '?=$FORM->ShowInput(\'' + oForm.arQuestions[element_index].FIELD_SID + '\')?' + '>';
			}
			else
			{
				return '<' + '?=$FORM->ShowInput(\'\')?' + '>';
			}
		}
		
		if (node.arAttributes["__bxtagname"] == 'form_api')
		{
			var __arNodeParams = oBXEditorUtils.getCustomNodeParams(node);
			
			if (null != __arNodeParams[0]["value"])
			{
				var _param = '';			
				
				if (__arNodeParams[1] && __arNodeParams[1]["name"] == "INDEX" && oForm.arMethods[__arNodeParams[1]["value"]]) 
				{
					if (oForm.arMethods[__arNodeParams[1]["value"]].params)
					{
						__params = oForm.arMethods[__arNodeParams[1]["value"]].params;
						for (var __i = 0; __i < __params.length; __i++)
						{
							if (_param != '') _param += ',';
							_param += '"' + __params[__i]["value"].replace(/"/g, "&quot;") + '"';
						}
					}
				}
				else
				{
					_param = null != __arNodeParams[1] ? '"' + __arNodeParams[1]["value"] + '"' : '';
				}
				
				return '<' + '?=$FORM->' + __arNodeParams[0]["value"] + '(' + _param + ')?' + '>';
			}
			
			return false;
		}
	
		return false;
	}
	
	BXFormElementsTaskbar.prototype.OnElementDragEnd = function(oEl)
	{
		if (oEl.ownerDocument != oTaskbar.pMainObj.pEditorDocument)
		{
			return;
		}

		var __bxtagname = oEl.getAttribute('__bxtagname');
		var __arPar = oBXEditorUtils.getCustomNodeParams(oEl);
		
		if (__bxtagname == 'form_question')
		{
			var element_index = __arPar[0].value;
			var element_type = oForm.arQuestions[element_index].type;

			oEl.setAttribute('src', '/bitrix/images/form/visual/form_edit_' + element_type + '.gif');
			oEl.removeAttribute("height");
			oEl.removeAttribute("width");
			oEl.style.width = null;
			oEl.style.height = null;
			
			return;
		
		}
		else if (__bxtagname == 'form_question_new')
		{
			var element_type = __arPar[0].value;
			var __arStructure = [];
			var __csort = 0;
			var __imax = 1;
			
			oEl.setAttribute('__bxtagname', 'form_question');
			oEl.setAttribute('src', '/bitrix/images/form/visual/form_edit_' + element_type + '.gif');
			oEl.removeAttribute("height");
			oEl.removeAttribute("width");
			oEl.style.width = null;
			oEl.style.height = null;
			
			if (element_type == 'dropdown' || element_type == 'checkbox' || element_type == 'multiselect' || element_type == 'radio')
			{
				__imax = 10;
			}
			for (var i=0; i<__imax; i++)
			{
				__csort += 100;

				__arStructure[i] = {ID:++_global_newanswer_counter,FIELD_ID:_global_newinput_counter,QUESTION_ID:_global_newinput_counter,TIMESTAMP_X:'',MESSAGE:(i==0 ? ' ' : ''),VALUE:'',FIELD_TYPE:element_type,FIELD_WIDTH:'',FIELD_HEIGHT:'',FIELD_PARAM:'',C_SORT:__csort.toString(),ACTIVE:'Y',ANS_NEW:true}
			}

			while (true)
			{
				new_element_id = 'new_field_' + Math.floor(Math.random() * 100000);
				if (oForm.getQuestionIndexBySID(new_element_id) === false) break;
			}
		
			var element_index = oForm.addQuestion(new_element_id, '', 'N', '', 'N', element_type, __arStructure, 'Y');
			
			__arPar = null;
			__arPar = [{name:'element_index', value:element_index}];
			
			oBXEditorUtils.setCustomNodeParams(oEl, __arPar);
			
			return;
		}
		else if (__bxtagname == 'form_api')
		{
			var element_type = __arPar[0].value.toLowerCase();
			if (element_type == 'showsubmitbutton' || element_type == 'showapplybutton' || element_type == 'showresetbutton')
			{
				oEl.setAttribute('src', '/bitrix/images/form/visual/form_api_edit_' + element_type + '.gif');
				oEl.removeAttribute("height");
				oEl.removeAttribute("width");
				oEl.style.width = null;
				oEl.style.height = null;
			}

		
			__ar_params = [];
			for (var j = 0; j<__arr_api_methods_params[__arPar[0].value].length; j++)
			{
				var param = __arr_api_methods_params[__arPar[0].value][j];
				__ar_params[j] = {name:param, value: ''};
			}
			
			var _index = oForm.addMethodInstance(__arPar[0].value, __ar_params);
			
			__arPar[1] = {name:'INDEX', value:_index};
			

			oBXEditorUtils.setCustomNodeParams(oEl, __arPar);
		}

		return;
	}	
}