wl=window.wl||{}
wl.Edit=wl.Edit||{}

wl.Edit.Files = {
	//Extends: Swiff.Uploader,
	//p: {queued:1, limit:0},
	//objFStListArr:{},
	//objFLdListArr:{},
	Init : function (p) { // , pw, keyFV, field, pid, file
		if (p!=undefined || typeof(p)=='object') {
			this.flBlPref = ['st','ld'];
			//alert('p.pw= '+p.pw+', p.keyFV= '+p.keyFV+', p.field= '+p.field+', p.pid= '+p.pid+', p.file= '+p.file);
			this.pw = p.pw;
			//this.objFLdListArr:{};
			this.keyFV = p.keyFV;
			this.field = p.field;
			this.limit = p.limit;
			this.objFilesRead = $('filesread'+this.keyFV+this.field);
			this.objFLdList = $('fLdList'+this.keyFV+this.field);
			this.objFStList = $('fStList'+this.keyFV+this.field);
			//alert('this.objFStList= '+this.objFStList);
			//if (this.objFStListArr==undefined) this.objFStListArr = this._getIdTplArr('file_name',this.flBlPref[0],this.objFStList);
			this.objFStListArr = this._getIdTplArr('file_name',this.flBlPref[0],this.objFStList);
			//alert('this.objFStListArr= '+this.objFStListArr);
			this.filesSetted = (this.objFStListArr!=undefined && this.objFStListArr.length!=undefined) ? this.objFStListArr.length : 0 ;
			//alert('this.filesSetted= '+this.filesSetted);
			
			if (p.fileShowedId!=undefined) this.objFileShowed = $(p.fileShowedId);
			else if (p.file_name!=undefined) this.objFileShowed = $('st'+this.keyFV+this.field+p.file_name);
		} else {alert('[P]arams is\'t object');return false;}
	},
	Set : function (obj, p) {
		this.Init(p);
		//alert('this.objFilesRead= '+this.objFilesRead+', this.objFStList= '+this.objFStList+', this.keyFV= '+this.keyFV+', this.field= '+this.field);
		//if (this.objFileShowed!=undefined) {
			////while (id.firstChild) id.removeChild(id.firstChild);
			//this.objFileShowed.parentNode.removeChild(this.objFileShowed);
			//this.CheckLimit({});
		//}
		var fn = obj.getAttribute('file_name');
		//alert('obj.checked= '+obj.checked);
		if (obj.checked) {
			obj.parentNode.className += ' chkOn';
			var ajData = {'action':'load', 'pw':p.pw, 'keyFV':p.keyFV, 'field':p.field, 'fileSet':fn}; // , 'pid':p.pid
			ajData['isAdmin'] = /adm\//.test(location.href);
			var ajParams = {callback:'wl.Edit.Files.SetCallback',include:'call/wlFiles.php'}; // ,caching:false
			wlAjax(ajData,ajParams);
		} else {
			obj.parentNode.className = obj.parentNode.className.replace(' chkOn','');
			this._removeObj({'fileShowedId':'st'+this.keyFV+this.field+fn,'pw':this.pw,'keyFV':this.keyFV,'field':this.field,'file_name':fn,'limit':this.limit});
			this.CheckLimit();
		}
	},
	SetCallback : function (result) {
		//alert('result[free]= '+result["free"]+', result[price]= '+result["price"]+', result[title]= '+result["title"]+', result[message]= '+result["message"]+', result[src]= '+result["src"]+', result[gammaArr]= '+result["gammaArr"]);
		//alert('this.objFilesRead= '+this.objFilesRead+', this.objFStList= '+this.objFStList+', this.keyFV= '+this.keyFV+', this.field= '+this.field);
		//this.objFile.value = '';
		//this.objFilesRead.className = '';
		//if (this.filesSetted<this.limit) {
			if (result["setted"]!=undefined && result["setted"]!='') {
				this.objFStList.innerHTML += result["setted"];
				this.CheckLimit();
				//this.CheckLd();
			}
		//} else {
			
		//}
	},
	ShowLib : function (p) {
		this.Init(p);
		if (/ open/.test(this.objFilesRead.className)) {
			this.objFilesRead.className = this.objFilesRead.className.replace(' open','');
			this.objFLdList.innerHTML = '';
		} else {
			this.objFilesRead.className += ' open';
			var ajData = {'action':'getList', 'pw':p.pw, 'keyFV':p.keyFV, 'field':p.field}; // , 'pid':p.pid
			ajData['isAdmin'] = /adm\//.test(location.href);
			var ajParams = {callback:'wl.Edit.Files.ShowLibCallback',include:'call/wlFiles.php',caching:false}; // ,caching:false
			wlAjax(ajData,ajParams);
		}
	},
	ShowLibCallback : function (result) {
		//alert('result[free]= '+result["free"]+', result[price]= '+result["price"]+', result[title]= '+result["title"]+', result[message]= '+result["message"]+', result[src]= '+result["src"]+', result[gammaArr]= '+result["gammaArr"]);
		//alert('this.objFilesRead= '+this.objFilesRead+', this.objFStList= '+this.objFStList+', this.keyFV= '+this.keyFV+', this.field= '+this.field);
		//this.objFile.value = '';
		//this.objFilesRead.className = '';
		if (result["loaded"]!=undefined && result["loaded"]!='') {
			//if (result["libCount"]!=undefined && result["libCount"]!='') {
				//$('fLdCount'+this.keyFV+this.field).innerHTML += result["libCount"];
			//}
			//alert('result["loaded"]= `'+result["loaded"]+'`, this.objFStListArr= '+this.objFStListArr+', this.objFStListArr.length= '+this.objFStListArr.length);
			//this.filesSetted = (this.objFStListArr!=undefined && this.objFStListArr.length!=undefined) ? this.objFStListArr.length : 0 ;
			//this.objFLdList.innerHTML = result["loaded"] + this.objFLdList.innerHTML;
			this.objFLdList.innerHTML = result["loaded"];
			//this.CheckLimit({});
			//this.CheckLd();
			this.CheckLimit();
		} else this.objFLdList.innerHTML = '... Библиотека пустая ...';
	},
	Load : function (p) {
		this.Init(p);
		//this.objFilesRead.className = 'onupd';
		this.objFilesRead.className += ' onupd';
		//var ajData = {'action':'load', 'pw':p.pw, 'keyFV':p.keyFV, 'field':p.field, 'pid':p.pid, 'file':p.file};
		//var ajData = {'action':(this.filesSetted<this.limit)?'load':'loadToList', 'pw':p.pw, 'keyFV':p.keyFV, 'field':p.field, 'pid':p.pid, 'file':p.file};
		var ajData = {'action':'load', 'loadToList':(/ open/.test(this.objFilesRead.className)||this.filesSetted>=this.limit)?true:false, 'pw':p.pw, 'keyFV':p.keyFV, 'field':p.field, 'file':p.file}; // 'pid':p.pid, 
		//alert('/adm\//.test(location.href)= '+/adm\//.test(location.href));
		ajData['isAdmin'] = /adm\//.test(location.href);
		var ajParams = {callback:'wl.Edit.Files.LoadCallback',include:'call/wlFiles.php'}; // ,caching:false
		wlAjax(ajData,ajParams);
	},
	LoadCallback : function (result) {
		//alert('result[free]= '+result["free"]+', result[price]= '+result["price"]+', result[title]= '+result["title"]+', result[message]= '+result["message"]+', result[src]= '+result["src"]+', result[gammaArr]= '+result["gammaArr"]);
		//alert('this.objFilesRead= '+this.objFilesRead+', this.objFStList= '+this.objFStList+', this.keyFV= '+this.keyFV+', this.field= '+this.field);
		//this.objFile.value = '';
		//this.objFilesRead.className = '';
		this.objFilesRead.className = this.objFilesRead.className.replace(' onupd','');
		//if (result["md5_fn"]!=undefined && result["md5_fn"]!='') {
			//this._removeObj({'fileShowedId':'st'+this.keyFV+this.field+result["md5_fn"],'pw':this.pw,'keyFV':this.keyFV,'field':this.field,'md5_fn':result["md5_fn"],'limit':this.limit});
			//if (/ open/.test(this.objFilesRead.className)&&this.filesSetted>=this.limit) this._removeObj({'fileShowedId':'ld'+this.keyFV+this.field+result["md5_fn"],'pw':this.pw,'keyFV':this.keyFV,'field':this.field,'md5_fn':result["md5_fn"],'limit':this.limit});
		//}
		//alert('this.filesSetted= '+this.filesSetted+', this.limit= '+this.limit);
		//alert('this.objFStListArr= '+this.objFStListArr);
		//alert('$(this.objFStListArr[0])= '+$(this.objFStListArr[0]));
		//alert('$(this.objFStListArr[0]).id= '+$(this.objFStListArr[0]).id);
		//alert('$(this.objFStListArr[0]).style.float= '+$(this.objFStListArr[0]).style.float);
		//alert('getElementComputedStyle(this.objFStListArr[0],float)= '+getElementComputedStyle(this.objFStListArr[0],'float'));
		//alert('this.filesSetted= '+this.filesSetted+', this.limit= '+this.limit);
		//alert('result["file_name"]= '+result["file_name"]);
		if (result["file_name"]!=undefined) this._removeObj({'fileShowedId':'st'+this.keyFV+this.field+result["file_name"],'pw':this.pw,'keyFV':this.keyFV,'field':this.field,'file_name':result["file_name"],'limit':this.limit});
		if (this.filesSetted<this.limit) {
			if (result["setted"]!=undefined && result["setted"]!='') {
				//alert('this.objFStListArr= '+this.objFStListArr+', this.objFStListArr.length= '+this.objFStListArr.length);
				//this.filesSetted = (this.objFStListArr!=undefined && this.objFStListArr.length!=undefined) ? this.objFStListArr.length : 0 ;
				this.objFStList.innerHTML += result["setted"];
				this.CheckLimit();
			}
		} else if (this.objFLdList.innerHTML==undefined || this.objFLdList.innerHTML=='') {
			this.ShowLib({'pw':this.pw, 'keyFV':this.keyFV, 'field':this.field, 'pid':this.pid, 'limit':this.limit});
			//alert('this.filesSetted= '+this.filesSetted+', this.limit= '+this.limit);
		}
		if (/ open/.test(this.objFilesRead.className) && this.filesSetted>=this.limit) {
			if (result["file_name"]!=undefined) this._removeObj({'fileShowedId':'ld'+this.keyFV+this.field+result["file_name"],'pw':this.pw,'keyFV':this.keyFV,'field':this.field,'file_name':result["file_name"],'limit':this.limit});
			if (result["loaded"]!=undefined && result["loaded"]!='') {
				this.objFLdList.innerHTML = result["loaded"] + this.objFLdList.innerHTML;
				this.CheckLimit();
			}
		}
	},
	Delete : function (p) {
		//var is_confirmed = window.confirm(confirmText);
		//if (is_confirmed) {
		if (window.confirm('Вы уверены, что хотите удалить файл из библиотеки?')) {
			this.Init(p);
			var ajData = {'pw':p.pw, 'keyFV':p.keyFV, 'field':p.field, 'fileDel':p.file_name}; // 'pid':p.pid, 
			ajData['isAdmin'] = /adm\//.test(location.href);
			var ajParams = {callback:'wl.Edit.Files.DeleteCallback',include:'call/wlFiles.php'}; // ,caching:false
			wlAjax(ajData,ajParams);
		}
	},
	DeleteCallback : function (result) {
		if (result["file_name"]!=undefined) {
			//alert('Удаляем `'+result["file_name"]+'` (st)');
			this._removeObj({'fileShowedId':'st'+this.keyFV+this.field+result["file_name"],'pw':this.pw,'keyFV':this.keyFV,'field':this.field,'file_name':result["file_name"],'limit':this.limit});
			//alert('Удаляем `'+result["file_name"]+'` (ld)');
			this._removeObj({'fileShowedId':'ld'+this.keyFV+this.field+result["file_name"],'pw':this.pw,'keyFV':this.keyFV,'field':this.field,'file_name':result["file_name"],'limit':this.limit});
			this.CheckLimit();
		}
	},
	//CheckLimit : function (p) {
	CheckLimit : function () {
		//alert('this._getIdTplArr(`file_name`,'+this.flBlPref[0]+',this.objFStList)= '+this._getIdTplArr('file_name',this.flBlPref[0],this.objFStList));
		this.filesSetted = this._getIdTplArr('file_name',this.flBlPref[0],this.objFStList).length;
		//alert('this.filesSetted= '+this.filesSetted);
		$('filesLimit'+this.keyFV+this.field).innerHTML = this.limit;
		$('filesSetted'+this.keyFV+this.field).innerHTML = this.filesSetted;
		if (this.objFLdList.innerHTML!=undefined && this.objFLdList.innerHTML!='') {
			var flsLd = document.getElementsByName('inp'+this.keyFV+this.field);
			//alert('flsLd= '+flsLd+', flsLd.length= '+flsLd.length);
			if (flsLd!=undefined && flsLd.length!=undefined) {
				var ls,ld,file_name = '';
				//if (this.objFLdListArr==undefined) this.objFLdListArr = this._getIdTplArr('file_name',this.flBlPref[1],this.objFLdList);
				//this.objFLdListArr = this._getIdTplArr('file_name',this.flBlPref[1],this.objFLdList);
				//alert('this.objFLdListArr= '+this.objFLdListArr);
				for (var q=0; q<flsLd.length; q++) {
					file_name = flsLd[q].getAttribute('file_name');
					ls = $(this.flBlPref[0]+this.keyFV+this.field+file_name);
					//alert('file_name= `'+file_name+'`, ls= '+ls);
					$(this.flBlPref[1]+this.keyFV+this.field+file_name).className = $(this.flBlPref[1]+this.keyFV+this.field+file_name).className.replace(' setted','');
					$(this.flBlPref[1]+this.keyFV+this.field+file_name).className = $(this.flBlPref[1]+this.keyFV+this.field+file_name).className.replace(' disabled','');
					if (ls!=undefined) {
						//alert('file_name= '+file_name+', ls= '+ls);
						//alert('file_name= `'+file_name+'`, ls= '+ls+', ls.id= '+ls.id);
						flsLd[q].checked = true;
						flsLd[q].parentNode.className += ' chkOn';
						//alert('this.flBlPref[1]= '+this.flBlPref[1]+', this.keyFV= '+this.keyFV+', this.field= '+this.field);
						$(this.flBlPref[1]+this.keyFV+this.field+file_name).className += ' setted';
						//alert(2);
					} else {
						flsLd[q].checked = false;
						flsLd[q].parentNode.className = flsLd[q].parentNode.className.replace(' chkOn','');
						//$(this.flBlPref[1]+this.keyFV+this.field+file_name).className = $(this.flBlPref[1]+this.keyFV+this.field+file_name).className.replace(' setted','');
						flsLd[q].disabled = (this.filesSetted<this.limit) ? false : true ;
						//$(this.flBlPref[1]+this.keyFV+this.field+file_name).className = $(this.flBlPref[1]+this.keyFV+this.field+file_name).className.replace(' setted','');
						if (this.filesSetted>=this.limit) $(this.flBlPref[1]+this.keyFV+this.field+file_name).className += ' disabled';
					}
				}
			}
		}
	},
	_removeObj : function (p) {
		//alert('p.fileShowedId= '+p.fileShowedId);
		this.Init(p);
		if (this.objFileShowed!=undefined) {
			//alert('p.fileShowedId= '+p.fileShowedId+', this.objFileShowed= '+this.objFileShowed+', this.objFileShowed.id= '+this.objFileShowed.id);
			//alert('this.objFileShowed= '+this.objFileShowed+', $(this.objFileShowed).id= '+$(this.objFileShowed).id);
			//alert('this.objFileShowed= '+this.objFileShowed);
			//while (id.firstChild) id.removeChild(id.firstChild);
			this.objFileShowed.parentNode.removeChild(this.objFileShowed);
			this.CheckLimit();
		}
	},
	//_getIdTplArr : function (searchTpl, node, tag) {
	_getIdTplArr : function (attrTpl, pref, node, tag) {
		var attr = '';
		if (node==undefined || node==null || node=='') node = document;
		if (tag==undefined || tag==null || tag=='') tag = '*';
		var tagsArr = node.getElementsByTagName(tag);
		//alert('attrTpl= '+attrTpl+', tagsArr= '+tagsArr+', tagsArr.length= '+tagsArr.length);
		if (tagsArr!=undefined && tagsArr.length!=undefined) {
			var arr = [];
			//for (var i=0; i<tagsArr.length; i++) {if (new RegExp(searchTpl,'i').test(tagsArr[i].id)) arr.push(tagsArr[i].id);}
			for (var i=0; i<tagsArr.length; i++) {
				/*
				attr = tagsArr[i].getAttribute(attrTpl);
				if (attr!=undefined) {
					//alert('attr= '+attr+', tagsArr[i]= '+tagsArr[i]+', tagsArr[i].id= '+tagsArr[i].id);
					if (tagsArr[i].id==undefined || tagsArr[i].id=='') tagsArr[i].id = pref + this.keyFV + this.field + attr;
					arr.push(tagsArr[i].id);
				}
				*/
				if (new RegExp(pref+this.keyFV+this.field,'i').test(tagsArr[i].id)) arr.push(tagsArr[i].id);
			}
			//alert('arr= '+arr);
		}
		return arr;
	}
}


wl.Edit.Select = {
	Chk : function (objCheker, p) {
		if (p!=undefined || typeof(p)=='object') {
			var objPotiPress = $('potiPress['+p.keyFV+']');
			var objPotiSep = $('potiSep['+p.keyFV+']');
			var objPotiOpt = $('potiOpt['+p.keyFV+']');
			var objPotiPressOther = $('potiPressOther['+p.keyFV+']');
			if (objCheker!=undefined) {
				if (objCheker.checked) {
					objPotiOpt.disabled = true;
					if (objPotiPress!=undefined) objPotiPress.disabled = true;
					if (objPotiSep!=undefined) objPotiSep.disabled = true;
					objPotiPressOther.disabled = false;
					objPotiPressOther.style.display = 'inline';
				} else {
					objPotiOpt.disabled = false;
					if (objPotiPress!=undefined) objPotiPress.disabled = false;
					if (objPotiSep!=undefined) objPotiSep.disabled = false;
					objPotiPressOther.disabled = true;
					objPotiPressOther.style.display = 'none';
				}
				this.Ed(p);
			}
		} else {alert('[P]arams is\'t object');return false;}
	},
	Ed : function (p) {
		if (p!=undefined || typeof(p)=='object') {
			var objPotiPress = $('potiPress['+p.keyFV+']');
			var objPotiSep = $('potiSep['+p.keyFV+']');
			var objPotiOpt = $('potiOpt['+p.keyFV+']');
			var objInput = $(p.id);
			var objCheker = $('potiChecker['+p.keyFV+']');
			if (objCheker!=undefined && objCheker.checked) objInput.value = $('potiPressOther['+p.keyFV+']').value;
			else {
				objInput.value = '';
				if (objPotiPress!=undefined) objInput.value += $(objPotiPress).value;
				if (objPotiSep!=undefined) objInput.value += p.separator;
				if ($(objPotiOpt).multiple) {
					if (objPotiOpt!=undefined && objPotiOpt.length!=undefined && objPotiOpt.length!=0) {
						var tArr = new Array();
						for (var i=0; i<objPotiOpt.length; i++) {
							var t = '';
							if (objPotiOpt[i].selected) {
								//alert('objPotiOpt['+i+'].innerHTML= '+objPotiOpt[i].innerHTML+', objPotiOpt['+i+'].value= '+objPotiOpt[i].value);
								if (objPotiPress!=undefined) t += $(objPotiPress).value;
								if (objPotiSep!=undefined) t += p.separator;
								t += objPotiOpt[i].value;
								tArr.push(t);
							}
						}
						objInput.value = tArr;
					}
				} else objInput.value += $(objPotiOpt).value;
			}
		} else {alert('[P]arams is\'t object');return false;}
	}
}


wl.Edit.Checkbox = {
	Chk : function (objCheker, p) {
		if (p!=undefined || typeof(p)=='object') {
			var objInput = $(p.id);
			if (objCheker!=undefined && objInput!=undefined) {
				//alert('objCheker= '+objCheker+', objCheker.checked= '+objCheker.checked);
				if (objCheker.checked) {
					objInput.value += ','+objCheker.value;
				} else {
					objInput.value = objInput.value.replace(objCheker.value,'');
				}
				objInput.value = objInput.value.replace(/[,]+/g,','); // Убираем повторяющиеся запятые
				objInput.value = wl.trim(objInput.value,',');
			}
		} else {alert('[P]arams is\'t object');return false;}
	}
}


wl.Edit.Radiobox = {
	Chk : function (objCheker, p) {
		if (p!=undefined || typeof(p)=='object') {
			var objInput = $(p.id);
			if (objCheker!=undefined && objInput!=undefined) {
				//alert('objCheker= '+objCheker+', objCheker.checked= '+objCheker.checked);
				if (objCheker.checked) {
					objInput.value += ','+objCheker.value;
				} else {
					objInput.value = objInput.value.replace(objCheker.value,'');
				}
				objInput.value = objInput.value.replace(/[,]+/g,','); // Убираем повторяющиеся запятые
				objInput.value = wl.trim(objInput.value,',');
			}
		} else {alert('[P]arams is\'t object');return false;}
	}
}


wl.Edit.SkinNameGamma = {
	/*init : function (p) {
		if (p!=undefined || typeof(p)=='object') {
			//this.separator = p.separator;
			this.keyFV = p.keyFV;
			this.objSkinInput = $(p.id);
			if (p.gammaTagId!=undefined && p.gammaTagId!='') this.objGammaInput = $(p.gammaTagId);
			this.objOpt = $('skinOpt['+p.keyFV+']');
			this.objImg = $('skinImg['+p.keyFV+']');
			this.objOpt2 = $('skinOpt['+p.keyFV+']');
		} else {
			alert('p is\'t object');
			return false;
		}
	},*/
	GetInfo : function (p) {
		if (p!=undefined || typeof(p)=='object') {
			//alert('p.tagNameId= '+p.tagNameId+', p.gammaTagId= '+p.gammaTagId+', p.keyFV= '+p.keyFV)
			this.pw = p.pw;
			this.tagNameId = p.tagNameId;
			this.keyFV = p.keyFV;
			//this.objOpt = $('skinNmGmOpt['+this.keyFV+']');
			this.objOpt = $(p.tagNameId);
			this.objPrice = $('skinNmGmPrice['+this.keyFV+']');
			this.objTitle = $('skinNmGmTitle['+this.keyFV+']');
			this.objMessage = $('skinNmGmMessage['+this.keyFV+']');
			this.objImg = $('skinNmGmImg['+this.keyFV+']');
			this.objGamma = $('skinNmGmGamma['+this.keyFV+']');
			if (this.objOpt!=undefined) {
				if (p.gammaTagId!=undefined && p.gammaTagId!='') {
					this.gammaTagId = p.gammaTagId;
					this.objGammaGroup = $(p.gammaTagId);
				}
				if (this.objOpt.value!='') {
					var ajData = {
						'pw':p.pw,
						'keyFV':p.keyFV,
						'skin_name':this.objOpt.value
					};
					if (this.tagNameId!=undefined) {
						ajData.tagNameId = this.tagNameId;
					}
					if (p.gamma!=undefined) {
						ajData.gamma = p.gamma;
					}
					var ajParams = {callback:'wl.Edit.SkinNameGamma.GetInfoCallback',include:'call/wlSkins.php'}; // ,caching:false
					wlAjax(ajData,ajParams);
				} else {
					this.objPrice.innerHTML = this.objTitle.innerHTML = this.objMessage.innerHTML = '';
					this.objImg.src = '/themes/.public/images/s.gif';
					if (this.objGamma!=undefined) this.objGamma.innerHTML = '';
				}
			}
		} else {alert('[P]arams is\'t object');return false;}
	},
	/*
	Как узнать значение группы input radio (input type radio value)?
	function getRadioGroupValue(radioGroupObj) {
	  for (var i=0; i < radioGroupObj.length; i++)
	    if (radioGroupObj[i].checked) return radioGroupObj[i].value;
	  return null;
	}
	*/
	GetInfoCallback : function (result) {
		//alert('result[free]= '+result["free"]+', result[price]= '+result["price"]+', result[title]= '+result["title"]+', result[message]= '+result["message"]+', result[src]= '+result["src"]+', result[gammaArr]= '+result["gammaArr"]);
		//alert('result[imgUpdate]= '+result["imgUpdate"]);
		//if (result['keyFV']!=undefined) { // result['inputId']!=undefined && 
			//var objSkinInput = $(p.tagNameId);
			/*
			radio=document.createElement('input');
			radio.setAttribute("type", "radio");
			radio.setAttribute("name", temp);
			document.body.appendChild(radio);  
			*/
			if (result["imgUpdate"]==undefined || result["imgUpdate"]==false) {
				if (this.objPrice!=undefined) this.objPrice.innerHTML = '';
				if (this.objTitle!=undefined) this.objTitle.innerHTML = '';
				if (this.objMessage!=undefined) this.objMessage.innerHTML = '';
				if (this.objGamma!=undefined) this.objGamma.innerHTML = '';
			}
			if (result["price"]!=undefined && result["price"]!='') {
				if (this.objPrice!=undefined) this.objPrice.innerHTML = result["price"];
			}
			if (result["title"]!=undefined && result["title"]!='') {
				if (this.objTitle!=undefined) this.objTitle.innerHTML = result["title"];
			}
			if (result["message"]!=undefined && result["message"]!='') {
				if (this.objMessage!=undefined) this.objMessage.innerHTML = result["message"];
			}
			if (result["src"]!=undefined && result["src"]!='') {
				//alert('result["src"]= '+result["src"]);
				//var objImg = $('skinNmGmImg['+p.keyFV+']');
				if (this.objImg!=undefined) this.objImg.src = result["src"];
			}
			if (result["gammaArr"]!=undefined && result["gammaArr"].length) {
				if (this.objGamma!=undefined && this.gammaTagId!=undefined) {
					//this.objGamma.innerHTML = '<label for="'+this.gammaTagId+'[0]">&nbsp;<input type="radio" checked="checked" id="'+this.gammaTagId+'[0]" name="'+this.gammaTagId+'" value="" onclick="wl.Edit.SkinNameGamma.GetInfo({pw:\''+this.pw+'\',tagNameId:\''+this.tagNameId+'\',gammaTagId:\''+this.gammaTagId+'\',keyFV:\''+this.keyFV+'\',gamma:this.value})"/>&nbsp;Basic</label>';
					this.objGamma.innerHTML = '<label for="'+this.gammaTagId+'[0]">&nbsp;<input type="radio" checked="checked" id="'+this.gammaTagId+'[0]" name="'+this.gammaTagId+'" value="0" onclick="wl.Edit.SkinNameGamma.GetInfo({pw:\''+this.pw+'\',tagNameId:\''+this.tagNameId+'\',keyFV:\''+this.keyFV+'\',gamma:this.value})"/>&nbsp;Basic</label>';
					var quo = ', ';
					for (i=0; i<result["gammaArr"].length; i++) {
						//this.objGamma.innerHTML += quo+'<label for="'+this.gammaTagId+'['+(i+1)+']">&nbsp;<input type="radio" id="'+this.gammaTagId+'['+(i+1)+']" name="'+this.gammaTagId+'" value="'+result["gammaArr"][i]+'" onclick="wl.Edit.SkinNameGamma.GetInfo({pw:\''+this.pw+'\',tagNameId:\''+this.tagNameId+'\',gammaTagId:\''+this.gammaTagId+'\',keyFV:\''+this.keyFV+'\',gamma:this.value})"/>&nbsp;'+result["gammaArr"][i]+'</label>';
						this.objGamma.innerHTML += quo+'<label for="'+this.gammaTagId+'['+(i+1)+']">&nbsp;<input type="radio" id="'+this.gammaTagId+'['+(i+1)+']" name="'+this.gammaTagId+'" value="'+result["gammaArr"][i]+'" onclick="wl.Edit.SkinNameGamma.GetInfo({pw:\''+this.pw+'\',tagNameId:\''+this.tagNameId+'\',keyFV:\''+this.keyFV+'\',gamma:this.value})"/>&nbsp;'+result["gammaArr"][i]+'</label>';
					}
				}
			}
		//}
		/*if (result["ident"]!=undefined && result["ident"]!='') {
			var objChkajax = $('isCheckAjax'+result["ident"]);
			var objChkajaxParent = $('layer'+result["ident"]);
			if (objChkajax!=undefined && objChkajaxParent!=undefined) {
				objChkajaxParent.className = objChkajaxParent.className.replace(' chAjWait','');
				if (result["errors"]!=undefined && result["errors"].length) {
					objChkajax.innerHTML = result["errors"];
					objChkajax.className = 'isCheckAjax err';
					objChkajaxParent.className += ' chAjErr';
				} else {
					objChkajax.innerHTML = '';
					objChkajax.className = 'isCheckAjax ok';
					objChkajaxParent.className += ' chAjOk';
					if (result['inputId']!=undefined && result['keyFV']!=undefined) {
						//alert('result[inputId]= '+result['inputId']+', result[keyFV]= '+result['keyFV']+'\n$('+result['inputId']+').value= '+$(result['inputId']).value+', $('+result['keyFV']+'InputTemp).value= '+$(result['keyFV']+'InputTemp').value);
						if (result['setLinkDone']!=undefined) $(result['inputId']).setAttribute('setLinkDone',true);
						this.SetClassName({'keyFV':result['keyFV'],'className':''}); // Установка класса для отображения конвертированной ссылки
						//$(result['keyFV']+'LinkTemp1').innerHTML = $(result['inputId']).value = $(result['keyFV']+'InputTemp').value;
						$(result['inputId']).value = $(result['keyFV']+'InputTemp').value;
						this.LinkShowCuting({'keyFV':result['keyFV'],'inputId':result['inputId']});
					}
				}
			}
		}*/
	}
}


var dragsort = junkdrawer = '';
var editorTName = new Array(); // for editor - DON'T DELETE
var editorTDefId = new Array(); // for editor - DON'T DELETE
//function tabs (keyFV, tab) { // thisis, classLayer, tagLayer, classOnLayer, classTab, tagTab, classOnTag
function tabs (p) { // thisis, classLayer, tagLayer, classOnLayer, classTab, tagTab, classOnTag
	if (p!=undefined || typeof(p)=='object') {
		if (p.keyFV==undefined) p.keyFV = 0;
		if (p.tab==undefined) alert('Не задано `tab`');
		p.selectLayersSteps = (p.selectLayersSteps!=undefined) ? true : false ;
		//alert('p.keyFV= '+p.keyFV+', p.tab= '+p.tab);
		if (p.tab!=undefined) {
			var selected = ' a';
			// активируем данную табу
			var objTabLis = $('tabs'+p.keyFV).getElementsByTagName('li');
			if (objTabLis!=undefined && objTabLis.length) {
				for (i=0; i<objTabLis.length; i++) {
					var tabName = objTabLis[i].getAttribute('tabName');
					objTabLis[i].className = objTabLis[i].className.replace(selected,'');
					if (tabName==p.tab) {
						////objTabLis[i].className = objTD.className.replace(/listRowBgOff/i,'');
						objTabLis[i].className += selected;
					}
				}
			}
			if (p.selectLayersSteps) { // показываем только нужные ОСНОВНЫЕ слои
				var layerArr = getElementsByClass('steps','div');
				if (layerArr!=undefined && layerArr.length>0) {
					for (i=0; i<layerArr.length; i++) {
						//alert('p.tab= '+p.tab+', layerArr[i].id= '+layerArr[i].id);
						if (layerArr[i].id=='step'+p.tab) {
							layerArr[i].style.display = 'block';
						} else {
							layerArr[i].style.display = 'none';
						}
					}
				}
			} else {
				var objLayers = $('layers'+p.keyFV).getElementsByTagName('li');
				if (objLayers!=undefined && objLayers.length) {
					for (i=0; i<objLayers.length; i++) {
						if (objLayers[i].id!=undefined && objLayers[i].id.match('layer'+p.keyFV)!=null) {
							var tabsTypes = objLayers[i].getAttribute('tabsTypes');
							if (tabsTypes!=undefined && tabsTypes!='') {
								objLayers[i].style.display = (p.tab=='TabAll' || tabsTypes.match(p.tab)!=null) ? 'block' : 'none' ;
							} else alert('Error tabsTypes..');
						}
					}
				}
			}
		}
	}
	return false;
}


/*
 * Displays an confirmation box beforme to submit a "DROP/DELETE/ALTER" query.
 * This function is called while clicking links
 * @param   object   the link
 * @param   object   the sql query to submit
 * @return  boolean  whether to run the query or not
 */
function confirmLink (thisis, question, query, id) {
	if (thisis!=undefined && question!=undefined && question!='') {
		//if (question == '' || typeof(window.opera) != 'undefined') {
			//return true;
		//}
		//var is_confirmed = confirm(question + ':\n`' + query + '`');
		if (query!=undefined && query!='') question += ':\n`'+query+'`';
		if (id!=undefined && id!='' && id!=0) question += '\n(id:'+id+')';
		var is_confirmed = window.confirm(question);
		if (is_confirmed) {
			thisis.href += '&confirm=1';
		}
		return is_confirmed;
	} else return true;
}


// ставится на событие отправки данных
function submitForm (formObject, btnSubmitFieldId, btnSubmitText) {
	// Если на странице есть редактор, то заполняем нужные скрытые поля из редактора
	if (editorTName!=undefined && editorTName.length && editorTDefId!=undefined && editorTDefId.length) { //  && editorTName!=null
		for (var eDefKey in editorTDefId) {
			//alert('eDefKey= '+eDefKey+', typeof(eDefKey)= '+typeof(eDefKey)+', editorTDefId['+eDefKey+']= '+editorTDefId[eDefKey]);
			if (editorTDefId[eDefKey]!=undefined) { //  && editorTDefId[eDefKey].length
				for (var eDefKey2 in editorTDefId[eDefKey]) {
					//alert('eDefKey= '+eDefKey+', eDefKey2= '+eDefKey2);
					//alert('eDefKey2= '+eDefKey2+', typeof(eDefKey2)= '+typeof(eDefKey2)+', editorTDefId['+eDefKey+']['+eDefKey2+']= '+editorTDefId[eDefKey][eDefKey2]);
					//alert('editorTDefId= '+editorTDefId);
					if (editorTName[eDefKey][eDefKey2]!=undefined && editorTName[eDefKey][eDefKey2]!='' && editorTDefId[eDefKey][eDefKey2]!=undefined && editorTDefId[eDefKey][eDefKey2]!='') {
						var eName = editorTName[eDefKey][eDefKey2];
						var eDefNameObject = $(editorTDefId[eDefKey][eDefKey2]);
						//alert('eName= '+eName+', eDefNameObject= '+eDefNameObject);
						//alert('eName= '+eName+', eDefNameObject= '+eDefNameObject+', eDefNameObject.value= '+eDefNameObject.value);
						if (editorTDefId!=undefined) {
							//alert('Добавляем запись...');
							eDefNameObject.value = getEditorValue (eName);
						}
					}
				}
			}
		}
	}
	if (formObject[btnSubmitFieldId]!=undefined) {
		formObject[btnSubmitFieldId].blur();
		formObject[btnSubmitFieldId].disabled = true;
	}
}


// Если присутствует - включает поле "Пример".
// Если textarea - проверяет на длинну символом и вытягивает по высоте.
// Если включено - проверяет поле через AJAX.
function checkField (obj, p) {
	if (p!=undefined || typeof(p)=='object') {
		
		if (p.autohight==undefined) p.autohight = false; // Временно не включаю. Надо проверить свойство -  wrap="virtual" - действительно ли оно уничтожает все переносы строк???
		if (p.isCheckAjax==undefined) p.isCheckAjax = false; // Проверять или нет поле через AJAX
		
		//if (p.example_show==undefined) p.example_show = false;
		//alert('obj= '+obj+', p= '+p+', p.pw= '+p.pw+', p.example_show= '+p.example_show+', p.isCheckAjax= '+p.isCheckAjax);
		//alert('p.length= '+p.length+', p.ident= '+p.ident);
		if (obj!=undefined) {
			if (p.ident!=undefined && p.ident!='') {
				
				if (p.example_show!=undefined) {
					var objExam = $('exmpl'+p.ident);
					if (objExam!=undefined) objExam.style.display = (p.example_show) ? 'block' : 'none' ;
				}
				
				if (p.isCheckAjax && p.pw!=undefined && p.pw!='') {
					var objChkajax = $('isCheckAjax'+p.ident);
					//var objChkajaxParent = objChkajax.parentNode.parentNode;
					var objChkajaxParent = $('layer'+p.ident);
					if (objChkajax!=undefined && objChkajaxParent!=undefined) {
						//alert('objChkajax= '+objChkajax+', objChkajax.innerHTML= '+objChkajax.innerHTML+', objChkajax.className= '+objChkajax.className);
						objChkajaxParent.className = objChkajaxParent.className.replace(' chAjOk','');
						objChkajaxParent.className = objChkajaxParent.className.replace(' chAjErr','');
						objChkajaxParent.className += ' chAjWait';
					}
					//alert('p.isCheckAjax= '+p.isCheckAjax+', p.pw= '+p.pw+', p.field= '+p.field+', obj.value= '+obj.value);
					////var fv = {};
					////fv[p.field] = obj.value;
					////var ajData = {'pw':p.pw,'field':p.field,'value':obj.value,'fv':[fv]};
					var ajData = {'pw':p.pw,'id':[p.id],'ident':p.ident,'field':p.field,'value':obj.value};
					if (p.action!=undefined) ajData['action'] = p.action;
					if (p.mltLang!=undefined) ajData['mltLang'] = p.mltLang;
					var ajParams = {callback:'ajCheckFieldCallback',include:'call/wlCheckField.php'}; // ,caching:false
					wlAjax(ajData,ajParams);
				}
				
				//var viewObj = $('view'+p.ident+(p.mltLang!=undefined?p.mltLang:''));
				var viewObj = $('view'+p.ident);
				//alert('p.ident= '+p.ident+', viewObj= '+viewObj);
				//alert('p.ident= '+p.ident+', viewObj= '+viewObj+', viewObj.innerHTML= '+viewObj.innerHTML);
				if (viewObj!=undefined) {
					//alert('p.ident= '+p.ident+', viewObj= '+viewObj+', viewObj.innerHTML= '+viewObj.innerHTML);
					/*var maxlen=0;
					if (obj && obj.maxLength) {
						maxlen=obj.maxLength;
					} else if (obj && obj.maxlength) {
						maxlen=obj.maxlength;
					} else if (p.length>0) {
						maxlen=p.length;
					}*/
					//alert('obj.maxLength= '+obj.maxLength+', obj.maxlength= '+obj.maxlength);
					if (obj && p.length==undefined) {
						p.length = obj.getAttribute('maxlength'); // .toLowerCase()
					}
					//alert('p.length= '+p.length+', obj.value.length= '+obj.value.length+', viewObj.value= '+viewObj.value+', viewObj.innerHTML= '+viewObj.innerHTML);
					if (p.length>0) {
						if (p.length >= obj.value.length) {
							viewObj.innerHTML = p.length - obj.value.length;
						} else {
							obj.value = obj.value.substring(0,p.length);
						}
						//alert('p.length= '+p.length+', obj.value.length= '+obj.value.length+', (('+(p.length-obj.value.length)+')<=5)= '+((p.length-obj.value.length)<=5));
						viewObj.className = viewObj.className.replace('over','');
						if ((p.length-obj.value.length)<=5) viewObj.className = viewObj.className+' over';
						//alert('viewObj.className= '+viewObj.className);
					}
				}
				
				if (obj.type.toLowerCase()=='textarea') { // Проверка длинны, если textarea
					//alert('p.autohight= '+p.autohight);
					if (p.autohight) {
						//if ((navigator.userAgent.toLowerCase().indexOf("firefox") == -1) && (navigator.userAgent.toLowerCase().indexOf("opera") == -1)) return true;
						//if ((navigator.userAgent.toLowerCase().indexOf("firefox") != -1) && (navigator.userAgent.toLowerCase().indexOf("opera") != -1)) {
						if ((navigator.userAgent.toLowerCase().indexOf("firefox") == -1) && (navigator.userAgent.toLowerCase().indexOf("opera") == -1)) {
							var substrings = obj.value.split("\n");
							var objHeight = obj.offsetHeight;
							var heightDefault = 60;
							var heightLimit = 1000;
							var addHeight = 19;
							var startOn = Math.round(heightDefault / addHeight);
							var charsOnLine = 38;
							var add = 0;
							//alert('substrings.length= '+substrings.length);
							for(i = 0; i < substrings.length; i ++){
								add = add + Math.round(substrings[i].length / charsOnLine) + 1;
							}
							if(add > startOn && objHeight <= heightLimit){
								obj.style.height = add * addHeight;
							} else if(add <= startOn) obj.style.height = heightDefault;
							if(obj.value == "") obj.style.height = heightDefault;
						}
					}
				}
				
			}
		} else alert('Не указан идентификатор объекта проверки');
	} else alert('Не указаны дополнительные параметры поля');
}
function ajCheckFieldCallback (result) {
	//alert('ajActiveUpdate= '+ajActiveUpdate+', ajActiveUpdate.length= '+ajActiveUpdate.length);
	//alert('result= '+result+', result.length= '+result.length+', result["errors"]= '+result["errors"]+', result["errors"].length= '+result["errors"].length);
	//alert('result= '+result+', result["errors"]= '+result["errors"]+', result["ident"]= '+result["ident"]);
	if (result["ident"]!=undefined && result["ident"]!='') {
		var objChkajax = $('isCheckAjax'+result["ident"]);
		//var objChkajaxParent = objChkajax.parentNode.parentNode;
		var objChkajaxParent = $('layer'+result["ident"]);
		if (objChkajax!=undefined && objChkajaxParent!=undefined) {
			////alert('objChkajax= '+objChkajax+', objChkajax.innerHTML= '+objChkajax.innerHTML+', objChkajax.className= '+objChkajax.className);
			//objChkajaxParent.className = objChkajaxParent.className.replace(' chAjOk','');
			//objChkajaxParent.className = objChkajaxParent.className.replace(' chAjErr','');
			objChkajaxParent.className = objChkajaxParent.className.replace(' chAjWait','');
			if (result["errors"]!=undefined && result["errors"].length) {
				objChkajax.innerHTML = result["errors"];
				objChkajax.className = 'isCheckAjax err';
				objChkajaxParent.className += ' chAjErr';
			} else {
				objChkajax.innerHTML = '';
				objChkajax.className = 'isCheckAjax ok';
				objChkajaxParent.className += ' chAjOk';
			}
			////alert('objChkajaxParent.className= '+objChkajaxParent.className);
		}
	} //else objChkajaxParent.className = objChkajaxParent.className.replace(' chAjWait','');
}








function ajFieldsManageSteps (objForm, p) {
//function ajFieldsManageSteps (step) {
	if (typeof(objForm)!='object') var objForm = $(objForm);
	if (objForm!=undefined) { //  && objImportType!=undefined
		if (p!=undefined || typeof(p)=='object') {
			//if (objForm.value.length>0) {
				if (p.importErase==undefined) p.importErase = false;
				if (p.importType==undefined) p.importType = '';
				
				//var ajData = {'pw':p.pw,'importType':p.importType,'importErase':p.importErase,'file':obj};
				var ajData = {'pw':p.pw,'fv':objForm};
				var ajParams = {callback:'ajFieldsManageStepsCallback',include:'call/wlFieldsManageSteps.php'}; // ,caching:false
				wlAjax(ajData,ajParams);
			//} else alert('You must specify a file first');
		} else alert('Не указаны дополнительные параметры поля');
	} else alert('Не указан идентификатор объекта проверки');
	return false;
}
function ajFieldsManageStepsCallback (result) {
	//alert('ajActiveUpdate= '+ajActiveUpdate+', ajActiveUpdate.length= '+ajActiveUpdate.length);
	//alert('result= '+result+', result.length= '+result.length+', result["errors"]= '+result["errors"]+', result["errors"].length= '+result["errors"].length);
	//alert('result= '+result+', result["ok"]= '+result["ok"]+', result["data"]= '+result["data"]);
	if (result["data"]!=undefined && result["data"]!='') {
		$('fieldsmanagesteps').innerHTML = result["data"];
		scrollToObj();
		//alert('Импорт прошел успешно!');
		//self.document.location.reload();
	}
}


function chkChecked (thisis) {
	return thisis.checked;
}


// Собираем все значения списка и записываем их в скрытое поле ввода
function pick_chckbx (obj, objInputName, sep) {
	//alert('objInputName= '+objInputName);
	var objInput = $(objInputName);
	var separator = (sep!=undefined && sep!='') ? sep : ',';
	if (objInput!=undefined) {
		var len = (objInput.value.length!=undefined) ? objInput.value.length : 0 ;
		var pos = (len && objInput.value.indexOf(obj.value)>-1) ? objInput.value.indexOf(obj.value) : false ;
		if (obj.checked) objInput.value += (len) ? separator+obj.value : obj.value ;
		else if (pos!==false) { // objInput.value = (pos>0) ? objInput.value.replace(separator+obj.value,'') : objInput.value.replace(obj.value,'') ;
			objInput.value = objInput.value.replace(obj.value+separator,'');
			objInput.value = objInput.value.replace(separator+obj.value,'');
			objInput.value = objInput.value.replace(obj.value,'');
		}
		//alert('objInput.value= '+objInput.value);
	}
}


function pictPreview (obj, imgfieldId, w, h) {
	var objImg = $(imgfieldId);
	objImg.src = obj.value;
	if (w != undefined) objImg.width = w;
	if (h != undefined) objImg.height = h;
}


// если супер-редактор есть, то обрабатываем и его, иначе переключаем слои с текстом (textarea или input)
//function editorLayerChange (butThisObject,  keyFV,fieldName,contactKey,  butTagName,butPattern,butClass,butClassActive,  textObjectId,viewLength,viewIdNeedle,  eTName,eTDefNam) {
function editorLayerChange (butThisObject, fldData, textObjectId) {
	//alert('textObjectId= '+textObjectId+', fldData[3]= '+fldData[3]+', viewIdNeedle= '+viewIdNeedle');
	if (fldData!=undefined && fldData.length==4) { // Проверка
		
		var mltLng = '';
		var textObject = $(textObjectId);
		
		/*var btnArray = document.getElementsByTagName(butTagName);
		var button = butPattern+fldData[0]+fldData[1];
		if (btnArray!=undefined && btnArray.length && (butClass!=undefined && butClass!='') && (butClassActive!=undefined && butClassActive!='')) {
			for (var i=0; i<btnArray.length; i++) {
				if (btnArray.item(i).id == button) {
					btnArray.item(i).className = 'butLang';
				}
			}
			butThisObject.className = 'butLangA';
		}*/
		//if (btnArray!=undefined && btnArray.length) {
			var btnArray = $('mltLngBtn'+fldData[0]+fldData[1]).getElementsByTagName('input');
			//alert('btnArray= '+btnArray+', btnArray.length= '+btnArray.length);
			for (var i=0; i<btnArray.length; i++) {
				btnArray[i].className = btnArray[i].className.replace('mltLngOn','');
				if (btnArray[i].getAttribute('mltLng')==fldData[2]) btnArray[i].className += ' mltLngOn';
			}
			var fldObj = $('mltLngFld'+fldData[0]+fldData[1]);
			var fldArray = fldObj.getElementsByTagName('input');
			//alert('fldArray= '+fldArray+', fldArray.length= '+fldArray.length);
			if (fldArray==undefined || fldArray.length==undefined || !fldArray.length) fldArray = fldObj.getElementsByTagName('textarea');
			//alert('fldArray= '+fldArray+', fldArray.length= '+fldArray.length);
			for (var i=0; i<fldArray.length; i++) {
				fldArray[i].className = fldArray[i].className.replace('mltLngOn','');
				if (fldArray[i].getAttribute('mltLng')==fldData[2]) fldArray[i].className += ' mltLngOn';
			}
			/*var viewArray = $('mltLngView'+fldData[0]+fldData[1]).getElementsByTagName('span');
			//alert('viewArray= '+viewArray+', viewArray.length= '+viewArray.length);
			if (viewArray!=undefined && viewArray.length) {
				for (var i=0; i<viewArray.length; i++) {
					viewArray[i].className = viewArray[i].className.replace('mltLngOn','');
					if (viewArray[i].getAttribute('mltLng')==fldData[2]) viewArray[i].className += ' mltLngOn';
				}
			}*/
			//var viewObj = $('mltLngView'+fldData[0]+fldData[1]).getElementsByTagName('span');
			var viewObj = $('view'+fldData[0]+fldData[1]);
			//alert('viewObj= '+viewObj);
			if (viewObj!=undefined) {
				viewObj.innerHTML = fldData[3] - textObject.innerHTML.length;
				//alert('viewObj= '+viewObj+', viewObj.innerHTML= '+viewObj.innerHTML.length);
			}
		//}
		
		if (editorTName!=undefined && editorTName[fldData[0]]!=undefined && editorTName[fldData[0]][fldData[1]]!=undefined && editorTName[fldData[0]][fldData[1]]!='' && editorTDefId!=undefined && editorTDefId[fldData[0]]!=undefined && editorTDefId[fldData[0]][fldData[1]]!=undefined && editorTDefId[fldData[0]][fldData[1]]!='') {
			var eName = editorTName[fldData[0]][fldData[1]];
			//var eDefName = editorTDefId[fldData[0]][fldData[1]];
			var eDefNameObject = $(editorTDefId[fldData[0]][fldData[1]]);
		} else {
			var eName = undefined;
			var eDefNameObject = undefined;
		}
		
		if (eName!=undefined && eDefNameObject!=undefined && textObject!=undefined) {
			//alert('Имеем дело с редактором...');
			//alert('eName= '+eName+', eDefNameObject= '+eDefNameObject+', textObject= '+textObject);
			eDefNameObject.value = getEditorValue (eName);
			//oFCKeditorTextareaIdDefault = textObject.id;
			//eDefName = textObject.id;
			editorTDefId[fldData[0]][fldData[1]] = textObject.id;
			setEditorValue (eName,textObject.value);
		} else {
			//var mltLngFldArray = document.getElementsByTagName(textTagName);
			//var mltLngFldArray = document.getElementsByTagName($('mltLngFld'+fldData[0]+'|'+fldData[1]));
			//var mltLngFldObj = $('mltLngFld'+fldData[0]+fldData[1]);
			//alert('mltLngFldObj= '+mltLngFldObj+', mltLngFldObj.id= '+mltLngFldObj.id);
			/*
			var mltLngFldArray = $('mltLngFld'+fldData[0]+fldData[1]).getElementsByTagName('div');
			//alert('mltLngFldArray= '+mltLngFldArray+', mltLngFldArray.length= '+mltLngFldArray.length);
			//if (mltLngFldArray!=undefined && mltLngFldArray.length && (fldData[0]+'|'+fldData[1]!=undefined && fldData[0]+'|'+fldData[1]!='') && (fldData[0]+'|'+fldData[1]+'|'+fldData[2]!=undefined && fldData[0]+'|'+fldData[1]+'|'+fldData[2]!='')) {
			if (mltLngFldArray!=undefined && mltLngFldArray.length) {
				//re = fldData[0]+"\\|"+fldData[1]+"\\|\\d{1,}";
				//re = fldData[0]+fldData[1]+fldData[2];
				for (var i=0; i<mltLngFldArray.length; i++) {
					//alert('mltLngFldArray.item(i).id.match(`'+re+'`)= '+mltLngFldArray.item(i).id.match(re)+', mltLngFldArray.item('+i+').id= '+mltLngFldArray.item(i).id);
					////if (mltLngFldArray.item(i).id.match(re) != null) {
						////alert('fldData[0]= '+fldData[0]+', fldData[1]= '+fldData[1]+', fldData[2]= '+fldData[2]+', mltLngFldArray.item('+i+').id= '+mltLngFldArray.item(i).id);
						////if (mltLngFldArray.item(i).id == fldData[0]+'|'+fldData[1]+'|'+fldData[2]) {
						//if (mltLngFldArray.item(i).id == fldData[0]+fldData[1]+fldData[2]) {
							//mltLngFldArray.item(i).style.display = '';
						//} else {
							//mltLngFldArray.item(i).style.display = 'none';
							////mltLngFldArray.item(i).blur();
							////alert('mltLngFldArray.item('+i+').blur()');
						//}
					////}
					mltLngFldArray[i].className = mltLngFldArray[i].className.replace('on','');
					if (mltLngFldArray[i].id == fldData[0]+fldData[1]+fldData[2]) {
						mltLngFldArray[i].className += ' on';
					}
				}
			}
			*/
			//if (textObject!=undefined) checkMaxInput(textObject,fldData[3],viewIdNeedle+fldData[0]+fldData[1]+fldData[2]); // выставляем цифры и обрезаем лишние символы, в зависимости от заданого ограничения
		}
		
		// Установить курсор в конец поля ввода textarea или input
		if (textObject!=undefined) {
			if (textObject.createTextRange) { // IE4+
				var r = textObject.createTextRange();
				//r.collapse(true); // в начало
				r.collapse(false); // в конец
				r.select();
			} else if (textObject.selectionStart) { // Mozilla/Gecko
				//textObject.setSelectionRange(0,0); // в начало
				var end = textObject.value.length;       // в конец
				//alert('end= '+end);
				textObject.setSelectionRange(end,end);   // в конец
				textObject.focus();
			} else { // Остальные браузеры или если текст не выделен
				textObject.focus();
			}
		}
	}
}
