PageSourceSearch

https://vademec.ru/bitrix/js/main/utils.js

js vademec.ru collected 2026-09-24 18:27:31 UTC 29,279 bytes, 1,302 lines download raw bytes

1var phpVars;
2if(!phpVars)
3{
4	phpVars = {
5		ADMIN_THEME_ID: '.default',
6		LANGUAGE_ID: 'en',
7		FORMAT_DATE: 'DD.MM.YYYY',
8		FORMAT_DATETIME: 'DD.MM.YYYY HH:MI:SS',
9		opt_context_ctrl: false,
10		cookiePrefix: 'BITRIX_SM',
11		titlePrefix: '',
12		bitrix_sessid: '',
13		messHideMenu: '',
14		messShowMenu: '',
15		messHideButtons: '',
16		messShowButtons: '',
17		messFilterInactive: '',
18		messFilterActive: '',
19		messFilterLess: '',
20		messLoading: 'Loading...',
21		messMenuLoading: '',
22		messMenuLoadingTitle: '',
23		messNoData: '',
24		messExpandTabs: '',
25		messCollapseTabs: '',
26		messPanelFixOn: '',
27		messPanelFixOff: '',
28		messPanelCollapse: '',
29		messPanelExpand: ''
30	};
31}
32
33var jsUtils =
34{
35	arEvents: Array(),
36
37	addEvent: function(el, evname, func, capture)
38	{
39		if(el.attachEvent) // IE
40			el.attachEvent("on" + evname, func);
41		else if(el.addEventListener) // Gecko / W3C
42			el.addEventListener(evname, func, false);
43		else
44			el["on" + evname] = func;
45		this.arEvents[this.arEvents.length] = {'element': el, 'event': evname, 'fn': func};
46	},
47
48	removeEvent: function(el, evname, func)
49	{
50		if(el.detachEvent) // IE
51			el.detachEvent("on" + evname, func);
52		else if(el.removeEventListener) // Gecko / W3C
53			el.removeEventListener(evname, func, false);
54		else
55			el["on" + evname] = null;
56	},
57
58	removeAllEvents: function(el)
59	{
60		var i;
61		for(i=0; i<this.arEvents.length; i++)
62		{
63			if(this.arEvents[i] && (el==false || el==this.arEvents[i].element))
64			{
65				jsUtils.removeEvent(this.arEvents[i].element, this.arEvents[i].event, this.arEvents[i].fn);
66				this.arEvents[i] = null;
67			}
68		}
69		if(el==false)
70			this.arEvents.length = 0;
71	},
72
73	IsDoctype: function()
74	{
75		if (document.compatMode)
76			return (document.compatMode == "CSS1Compat");
77
78		if (document.documentElement && document.documentElement.clientHeight)
79			return true;
80
81		return false;
82	},
83
84	GetRealPos: function(el)
85	{
86		if(window.BX)
87			return BX.pos(el);
88
89		if(!el || !el.offsetParent)
90			return false;
91
92		var res = Array();
93		res["left"] = el.offsetLeft;
94		res["top"] = el.offsetTop;
95		var objParent = el.offsetParent;
96
97		while(objParent && objParent.tagName != "BODY")
98		{
99			res["left"] += objParent.offsetLeft;
100			res["top"] += objParent.offsetTop;
101			objParent = objParent.offsetParent;
102		}
103		res["right"] = res["left"] + el.offsetWidth;
104		res["bottom"] = res["top"] + el.offsetHeight;
105
106		return res;
107	},
108
109	FindChildObject: function(obj, tag_name, class_name, recursive)
110	{
111		if(!obj)
112			return null;
113		var tag = tag_name.toUpperCase();
114		var cl = (class_name? class_name.toLowerCase() : null);
115		var n = obj.childNodes.length;
116		for(var j=0; j<n; j++)
117		{
118			var child = obj.childNodes[j];
119			if(child.tagName && child.tagName.toUpperCase() == tag)
120				if(!class_name || child.className.toLowerCase() == cl)
121					return child;
122			if(recursive == true)
123			{
124				var deepChild;
125				if((deepChild = jsUtils.FindChildObject(child, tag_name, class_name, true)))
126					return deepChild;
127			}
128		}
129		return null;
130	},
131
132	FindParentObject: function(obj, tag_name, class_name)
133	{
134		if(!obj)
135			return null;
136		var o = obj;
137		var tag = tag_name.toUpperCase();
138		var cl = (class_name? class_name.toLowerCase() : null);
139		while(o.parentNode)
140		{
141			var parent = o.parentNode;
142			if(parent.tagName && parent.tagName.toUpperCase() == tag)
143				if(!class_name || parent.className.toLowerCase() == cl)
144					return parent;
145			o = parent;
146		}
147		return null;
148	},
149
150	FindNextSibling: function(obj, tag_name)
151	{
152		if(!obj)
153			return null;
154		var o = obj;
155		var tag = tag_name.toUpperCase();
156		while(o.nextSibling)
157		{
158			var sibling = o.nextSibling;
159			if(sibling.tagName && sibling.tagName.toUpperCase() == tag)
160				return sibling;
161			o = sibling;
162		}
163		return null;
164	},
165
166	FindPreviousSibling: function(obj, tag_name)
167	{
168		if(!obj)
169			return null;
170		var o = obj;
171		var tag = tag_name.toUpperCase();
172		while(o.previousSibling)
173		{
174			var sibling = o.previousSibling;
175			if(sibling.tagName && sibling.tagName.toUpperCase() == tag)
176				return sibling;
177			o = sibling;
178		}
179		return null;
180	},
181
182	bOpera : navigator.userAgent.toLowerCase().indexOf('opera') != -1,
183	bIsIE : document.attachEvent && navigator.userAgent.toLowerCase().indexOf('opera') == -1,
184
185	IsIE: function()
186	{
187		return this.bIsIE;
188	},
189
190	IsOpera: function()
191	{
192		return this.bOpera;
193	},
194
195	IsSafari: function()
196	{
197		var userAgent = navigator.userAgent.toLowerCase();
198		return (/webkit/.test(userAgent));
199	},
200
201	IsEditor: function()
202	{
203		var userAgent = navigator.userAgent.toLowerCase();
204		var version = (userAgent.match( /.+(msie)[\/: ]([\d.]+)/ ) || [])[2];
205		var safari = /webkit/.test(userAgent);
206
207		if (this.IsOpera() || (document.all && !document.compatMode && version < 6) || safari)
208			return false;
209
210		return true;
211	},
212
213	ToggleDiv: function(div)
214	{
215		var style = document.getElementById(div).style;
216		if(style.display!="none")
217			style.display = "none";
218		else
219			style.display = "block";
220		return (style.display != "none");
221	},
222
223	urlencode: function(s)
224	{
225		return escape(s).replace(new RegExp('\\+','g'), '%2B');
226	},
227
228	OpenWindow: function(url, width, height)
229	{
230		var w = screen.width, h = screen.height;
231		if(this.IsOpera())
232		{
233			w = document.body.offsetWidth;
234			h = document.body.offsetHeight;
235		}
236		window.open(url, '', 'status=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+',top='+Math.floor((h - height)/2-14)+',left='+Math.floor((w - width)/2-5));
237	},
238
239	SetPageTitle: function(s)
240	{
241		document.title = phpVars.titlePrefix+s;
242		var h1 = document.getElementsByTagName("H1");
243		if(h1)
244			h1[0].innerHTML = s;
245	},
246
247	LoadPageToDiv: function(url, div_id)
248	{
249		var div = document.getElementById(div_id);
250		if(!div)
251			return;
252		CHttpRequest.Action = function(result)
253		{
254			CloseWaitWindow();
255			document.getElementById(div_id).innerHTML = result;
256		}
257		ShowWaitWindow();
258		CHttpRequest.Send(url);
259	},
260
261	trim: function(s)
262	{
263		if (typeof s == 'string' || typeof s == 'object' && s.constructor == String)
264		{
265			var r, re;
266
267			re = /^[\s\r\n]+/g;
268			r = s.replace(re, "");
269			re = /[\s\r\n]+$/g;
270			r = r.replace(re, "");
271			return r;
272		}
273		else
274			return s;
275	},
276
277	Redirect: function(args, url)
278	{
279		var e = null, bShift = false;
280		if(args && args.length > 0)
281			e = args[0];
282		if(!e)
283			e = window.event;
284		if(e)
285			bShift = e.shiftKey;
286
287		if(bShift)
288			window.open(url);
289		else
290		{
291			window.location.href=url;
292		}
293	},
294
295	False: function(){return false;},
296
297	AlignToPos: function(pos, w, h)
298	{
299		var x = pos["left"], y = pos["bottom"];
300
301		var scroll = jsUtils.GetWindowScrollPos();
302		var size = jsUtils.GetWindowInnerSize();
303
304		if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0)
305		{
306			if(pos["right"] - w >= 0 )
307				x = pos["right"] - w;
308			else
309				x = scroll.scrollLeft;
310		}
311
312		if((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0)
313		{
314			if(pos["top"] - h >= 0)
315				y = pos["top"] - h;
316			else
317				y = scroll.scrollTop;
318		}
319
320		return {'left':x, 'top':y};
321	},
322
323	// evaluate js string in window scope
324	EvalGlobal: function(script)
325	{
326		try {
327		if (window.execScript)
328			window.execScript(script, 'javascript');
329		else if (jsUtils.IsSafari())
330			window.setTimeout(script, 0);
331		else
332			window.eval(script);
333		} catch (e) {/*alert("Error! jsUtils.EvalGlobal");*/}
334	},
335
336	GetStyleValue: function(el, styleProp)
337	{
338		var res;
339		if(el.currentStyle)
340			res = el.currentStyle[styleProp];
341		else if(window.getComputedStyle)
342			res = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
343		if(!res)
344			res = '';
345		return res;
346	},
347
348	GetWindowInnerSize: function(pDoc)
349	{
350		var width, height;
351		if (!pDoc)
352			pDoc = document;
353
354		if (self.innerHeight) // all except Explorer
355		{
356			width = self.innerWidth;
357			height = self.innerHeight;
358		}
359		else if (pDoc.documentElement && (pDoc.documentElement.clientHeight || pDoc.documentElement.clientWidth)) // Explorer 6 Strict Mode
360		{
361			width = pDoc.documentElement.clientWidth;
362			height = pDoc.documentElement.clientHeight;
363		}
364		else if (pDoc.body) // other Explorers
365		{
366			width = pDoc.body.clientWidth;
367			height = pDoc.body.clientHeight;
368		}
369		return {innerWidth : width, innerHeight : height};
370	},
371
372	GetWindowScrollPos: function(pDoc)
373	{
374		var left, top;
375		if (!pDoc)
376			pDoc = document;
377
378		if (self.pageYOffset) // all except Explorer
379		{
380			left = self.pageXOffset;
381			top = self.pageYOffset;
382		}
383		else if (pDoc.documentElement && (pDoc.documentElement.scrollTop || pDoc.documentElement.scrollLeft)) // Explorer 6 Strict
384		{
385			left = document.documentElement.scrollLeft;
386			top = document.documentElement.scrollTop;
387		}
388		else if (pDoc.body) // all other Explorers
389		{
390			left = pDoc.body.scrollLeft;
391			top = pDoc.body.scrollTop;
392		}
393		return {scrollLeft : left, scrollTop : top};
394	},
395
396	GetWindowScrollSize: function(pDoc)
397	{
398		var width, height;
399		if (!pDoc)
400			pDoc = document;
401
402		if ( (pDoc.compatMode && pDoc.compatMode == "CSS1Compat"))
403		{
404			width = pDoc.documentElement.scrollWidth;
405			height = pDoc.documentElement.scrollHeight;
406		}
407		else
408		{
409			if (pDoc.body.scrollHeight > pDoc.body.offsetHeight)
410				height = pDoc.body.scrollHeight;
411			else
412				height = pDoc.body.offsetHeight;
413
414			if (pDoc.body.scrollWidth > pDoc.body.offsetWidth ||
415				(pDoc.compatMode && pDoc.compatMode == "BackCompat") ||
416				(pDoc.documentElement && !pDoc.documentElement.clientWidth)
417			)
418				width = pDoc.body.scrollWidth;
419			else
420				width = pDoc.body.offsetWidth;
421		}
422		return {scrollWidth : width, scrollHeight : height};
423	},
424
425	GetWindowSize: function()
426	{
427		var innerSize = jsUtils.GetWindowInnerSize();
428		var scrollPos = jsUtils.GetWindowScrollPos();
429		var scrollSize = jsUtils.GetWindowScrollSize();
430
431		return  {
432			innerWidth : innerSize.innerWidth, innerHeight : innerSize.innerHeight,
433			scrollLeft : scrollPos.scrollLeft, scrollTop : scrollPos.scrollTop,
434			scrollWidth : scrollSize.scrollWidth, scrollHeight : scrollSize.scrollHeight
435		};
436	},
437
438
439	arCustomEvents: {},
440
441	addCustomEvent: function(eventName, eventHandler, arParams, handlerContextObject)
442	{
443		if (!this.arCustomEvents[eventName])
444			this.arCustomEvents[eventName] = [];
445
446		if (!arParams)
447			arParams = [];
448		if (!handlerContextObject)
449			handlerContextObject = false;
450
451		this.arCustomEvents[eventName].push(
452			{
453				handler: eventHandler,
454				arParams: arParams,
455				obj: handlerContextObject
456			}
457		);
458	},
459
460	removeCustomEvent: function(eventName, eventHandler)
461	{
462		if (!this.arCustomEvents[eventName])
463			return;
464
465		var l = this.arCustomEvents[eventName].length;
466		if (l == 1)
467		{
468			delete this.arCustomEvents[eventName];
469			return;
470		}
471
472		for (var i = 0; i < l; i++)
473		{
474			if (!this.arCustomEvents[eventName][i])
475				continue;
476			if (this.arCustomEvents[eventName][i].handler == eventHandler)
477			{
478				delete this.arCustomEvents[eventName][i];
479				return;
480			}
481		}
482	},
483
484	onCustomEvent: function(eventName, arEventParams)
485	{
486		if (!this.arCustomEvents[eventName])
487			return;
488
489		if (!arEventParams)
490			arEventParams = [];
491
492		var h;
493		for (var i = 0, l = this.arCustomEvents[eventName].length; i < l; i++)
494		{
495			h = this.arCustomEvents[eventName][i];
496			if (!h || !h.handler)
497				continue;
498
499			if (h.obj)
500				h.handler.call(h.obj, h.arParams, arEventParams);
501			else
502				h.handler(h.arParams, arEventParams);
503		}
504	},
505
506	loadJSFile: function(arJs, oCallBack, pDoc)
507	{
508		if (!pDoc)
509			pDoc = document;
510		if (typeof arJs == 'string')
511			arJs = [arJs];
512		var callback = function()
513		{
514			if (!oCallBack)
515				return;
516			if (typeof oCallBack == 'function')
517				return oCallBack();
518			if (typeof oCallBack != 'object' || !oCallBack.func)
519				return;
520			var p = oCallBack.params || {};
521			if (oCallBack.obj)
522				oCallBack.func.apply(oCallBack.obj, p);
523			else
524				oCallBack.func(p);
525		};
526		var load_js = function(ind)
527		{
528			if (ind >= arJs.length)
529				return callback();
530			var oSript = pDoc.body.appendChild(pDoc.createElement('script'));
531			oSript.src = arJs[ind];
532			var bLoaded = false;
533			oSript.onload = oSript.onreadystatechange = function()
534			{
535				if (!bLoaded && (!oSript.readyState || oSript.readyState == "loaded" || oSript.readyState == "complete"))
536				{
537					bLoaded = true;
538					setTimeout(function (){load_js(++ind);}, 50);
539				}
540			};
541		};
542		load_js(0);
543	},
544
545	loadCSSFile: function(arCSS, pDoc, pWin)
546	{
547		if (typeof arCSS == 'string')
548		{
549			var bSingle = true;
550			arCSS = [arCSS];
551		}
552		var i, l = arCSS.length, pLnk = [];
553		if (l == 0)
554			return;
555		if (!pDoc)
556			pDoc = document;
557		if (!pWin)
558			pWin = window;
559		if (!pWin.bxhead)
560		{
561			var heads = pDoc.getElementsByTagName('HEAD');
562			pWin.bxhead = heads[0];
563		}
564		if (!pWin.bxhead)
565			return;
566		for (i = 0; i < l; i++)
567		{
568			var lnk = document.createElement('LINK');
569			lnk.href = arCSS[i];
570			lnk.rel = 'stylesheet';
571			lnk.type = 'text/css';
572			pWin.bxhead.appendChild(lnk);
573			pLnk.push(lnk);
574		}
575		if (bSingle)
576			return lnk;
577		return pLnk;
578	},
579
580	appendBXHint : function(node, html)
581	{
582		if (!node || !node.parentNode || !html)
583			return;
584		var oBXHint = new BXHint(html);
585		node.parentNode.insertBefore(oBXHint.oIcon, node);
586		node.parentNode.removeChild(node);
587		oBXHint.oIcon.style.marginLeft = "5px";
588	},
589
590	PreventDefault : function(e)
591	{
592		if(!e) e = window.event;
593		if(e.stopPropagation)
594		{
595			e.preventDefault();
596			e.stopPropagation();
597		}
598		else
599		{
600			e.cancelBubble = true;
601			e.returnValue = false;
602		}
603		return false;
604	},
605
606	CreateElement: function(tag, arAttr, arStyles, pDoc)
607	{
608		if (!pDoc)
609			pDoc = document;
610		var pEl = pDoc.createElement(tag), p;
611		if(arAttr)
612		{
613			for(p in arAttr)
614			{
615				if(p == 'className' || p == 'class')
616				{
617					pEl.setAttribute('class', arAttr[p]);
618					if (jsUtils.IsIE())
619						pEl.setAttribute('className', arAttr[p]);
620					continue;
621				}
622
623				if (arAttr[p] != undefined && arAttr[p] != null)
624					pEl.setAttribute(p, arAttr[p]);
625			}
626		}
627		if(arStyles)
628		{
629			for(p in arStyles)
630				pEl.style[p] = arStyles[p];
631		}
632		return pEl;
633	},
634
635	in_array: function(needle, haystack)
636	{
637		for(var i=0; i<haystack.length; i++)
638		{
639			if(haystack[i] == needle)
640				return true;
641		}
642		return false;
643	},
644
645	htmlspecialchars: function(str)
646	{
647		if(!str.replace)
648			return str;
649
650		return str.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
651	}
652}
653
654/************************************************/
655
656function JCFloatDiv()
657{
658	var _this = this;
659	this.floatDiv = null;
660	this.x = this.y = 0;
661
662	this.Create = function(arParams)
663	{
664		var div = document.body.appendChild(document.createElement("DIV"));
665		div.id = arParams.id;
666		div.style.position = 'absolute';
667		div.style.left = '-10000px';
668		div.style.top = '-10000px';
669		if(arParams.className)
670			div.className = arParams.className;
671		if(arParams.zIndex)
672			div.style.zIndex = arParams.zIndex;
673		if(arParams.width)
674			div.style.width = arParams.width+'px';
675		if(arParams.height)
676			div.style.height = arParams.height+'px';
677		return div;
678	}
679
680	this.Show = function(div, left, top, dxShadow, restrictDrag)
681	{
682		var component = BX.ZIndexManager.getComponent(div);
683		if (!component)
684		{
685			BX.ZIndexManager.register(div);
686		}
687
688		BX.ZIndexManager.bringToFront(div);
689
690		if (left < 0)
691			left = 0;
692
693		if (top < 0)
694			top = 0;
695
696		div.style.left = parseInt(left) + "px";
697		div.style.top = parseInt(top) + "px";
698
699		/*Restrict drag*/
700		div.restrictDrag = restrictDrag || false;
701
702		/*shadow*/
703		if(isNaN(dxShadow))
704			dxShadow = 5;
705
706		div.dxShadow = dxShadow;
707	}
708
709	this.Close = function(div)
710	{
711		if(!div)
712			return;
713		var sh = document.getElementById(div.id+"_shadow");
714		if(sh)
715			sh.style.visibility = 'hidden';
716
717		var frame = document.getElementById(div.id+"_frame");
718		if(frame)
719			frame.style.visibility = 'hidden';
720	}
721
722	this.Move = function(div, x, y)
723	{
724		if(!div)
725			return;
726
727		var dxShadow = div.dxShadow;
728		var left = parseInt(div.style.left)+x;
729		var top = parseInt(div.style.top)+y;
730
731		if (div.restrictDrag)
732		{
733			//Left side
734			if (left < 0)
735				left = 0;
736
737			//Right side
738			if ( (document.compatMode && document.compatMode == "CSS1Compat"))
739				windowWidth = document.documentElement.scrollWidth;
740			else
741			{
742				if (document.body.scrollWidth > document.body.offsetWidth ||
743					(document.compatMode && document.compatMode == "BackCompat") ||
744					(document.documentElement && !document.documentElement.clientWidth)
745				)
746					windowWidth = document.body.scrollWidth;
747				else
748					windowWidth = document.body.offsetWidth;
749			}
750
751			var floatWidth = div.offsetWidth;
752			if (left > (windowWidth - floatWidth - dxShadow))
753				left = windowWidth - floatWidth - dxShadow;
754
755			//Top side
756			if (top < 0)
757				top = 0;
758		}
759
760		div.style.left = left+'px';
761		div.style.top = top+'px';
762
763		this.AdjustShadow(div);
764	}
765
766	this.HideShadow = function(div)
767	{
768		var sh = document.getElementById(div.id + "_shadow");
769		sh.style.visibility = 'hidden';
770	}
771
772	this.UnhideShadow = function(div)
773	{
774		var sh = document.getElementById(div.id + "_shadow");
775		sh.style.visibility = 'visible';
776	}
777
778	this.AdjustShadow = function(div)
779	{
780		var sh = document.getElementById(div.id + "_shadow");
781		if(sh && sh.style.visibility != 'hidden')
782		{
783			var dxShadow = div.dxShadow;
784
785			sh.style.width = div.offsetWidth+'px';
786			sh.style.height = div.offsetHeight+'px';
787			sh.style.left = parseInt(div.style.left)+dxShadow+'px';
788			sh.style.top = parseInt(div.style.top)+dxShadow+'px';
789		}
790
791		var frame = document.getElementById(div.id+"_frame");
792		if(frame)
793		{
794			frame.style.width = div.offsetWidth + "px";
795			frame.style.height = div.offsetHeight + "px";
796			frame.style.left = div.style.left;
797			frame.style.top = div.style.top;
798		}
799	}
800
801	this.StartDrag = function(e, div)
802	{
803		if(!e)
804			e = window.event;
805		this.x = e.clientX + document.body.scrollLeft;
806		this.y = e.clientY + document.body.scrollTop;
807		this.floatDiv = div;
808
809		jsUtils.addEvent(document, "mousemove", this.MoveDrag);
810		document.onmouseup = this.StopDrag;
811		if(document.body.setCapture)
812			document.body.setCapture();
813
814		document.onmousedown = jsUtils.False;
815		var b = document.body;
816		b.ondrag = jsUtils.False;
817		b.onselectstart = jsUtils.False;
818		b.style.MozUserSelect = _this.floatDiv.style.MozUserSelect = 'none';
819		b.style.cursor = 'move';
820	}
821
822	this.StopDrag = function(e)
823	{
824		if(document.body.releaseCapture)
825			document.body.releaseCapture();
826
827		jsUtils.removeEvent(document, "mousemove", _this.MoveDrag);
828		document.onmouseup = null;
829
830		this.floatDiv = null;
831
832		document.onmousedown = null;
833		var b = document.body;
834		b.ondrag = null;
835		b.onselectstart = null;
836		b.style.MozUserSelect = _this.floatDiv.style.MozUserSelect = '';
837		b.style.cursor = '';
838	}
839
840	this.MoveDrag = function(e)
841	{
842		var x = e.clientX + document.body.scrollLeft;
843		var y = e.clientY + document.body.scrollTop;
844
845		if(_this.x == x && _this.y == y)
846			return;
847
848		_this.Move(_this.floatDiv, (x - _this.x), (y - _this.y));
849		_this.x = x;
850		_this.y = y;
851	}
852}
853var jsFloatDiv = new JCFloatDiv();
854
855/************************************************/
856
857var BXHint = function(innerHTML, element, addParams)
858{
859	this.oDivOver = false;
860	this.timeOutID = null;
861	this.oIcon = null;
862	this.freeze = false;
863	this.x = 0;
864	this.y = 0;
865	this.time = 700;
866
867	if (!innerHTML)
868		innerHTML = "";
869	this.Create(innerHTML, element, addParams);
870}
871
872BXHint.prototype.Create = function(innerHTML, element, addParams)
873{
874	var
875		_this = this,
876		width = 0,
877		height = 0,
878		className = null,
879		type = "icon";
880	this.bWidth = true;
881
882	if (addParams)
883	{
884		if (addParams.width === false)
885			this.bWidth = false;
886		else if (addParams.width)
887			width = addParams.width;
888
889		if (addParams.height)
890			height = addParams.height;
891
892		if (addParams.className)
893			className = addParams.className;
894
895		if (addParams.type && (addParams.type == "link" || addParams.type == "icon"))
896			type = addParams.type;
897		if (addParams.time > 0)
898			this.time = addParams.time;
899	}
900
901	if (element)
902		type = "element";
903
904	if (type == "icon")
905	{
906		var element = document.createElement("IMG");
907		element.src = (addParams && addParams.iconSrc) ? addParams.iconSrc : "/bitrix/themes/"+phpVars.ADMIN_THEME_ID+"/public/popup/hint.gif";
908		element.ondrag = jsUtils.False;
909	}
910	else if (type == "link")
911	{
912		var element = document.createElement("A");
913		element.href = "";
914		element.onclick = function(e){return false;}
915		element.innerHTML = "[?]";
916	}
917
918	this.element = element;
919	if (type == "element")
920	{
921		if(addParams && addParams.show_on_click)
922		{
923			jsUtils.addEvent(
924				element,
925				"click",
926				function (event)
927				{
928					if (!event)
929						event = window.event;
930					_this.GetMouseXY(event);
931					_this.timeOutID = setTimeout(function () {_this.Show(innerHTML,width,height,className) }, 10);
932				}
933			);
934		}
935		else
936		{
937			jsUtils.addEvent(
938				element,
939				"mouseover",
940				function (event)
941				{
942					if (!event)
943						event = window.event;
944					_this.GetMouseXY(event);
945					_this.timeOutID = setTimeout(function () {_this.Show(innerHTML,width,height,className) }, 750);
946				}
947			);
948		}
949
950		jsUtils.addEvent(
951			element,
952			"mouseout",
953			function(event)
954			{
955				if (_this.timeOutID)
956					clearTimeout(_this.timeOutID);
957				_this.SmartHide(_this);
958			}
959		);
960	}
961	else
962	{
963		this.oIcon = element;
964		element.onmouseover = function(event) {if (!event) event = window.event; _this.GetMouseXY(event); _this.Show(innerHTML,width,height,className)};
965		element.onmouseout = function() {_this.SmartHide(_this);};
966	}
967}
968
969BXHint.prototype.IsFrozen = function()
970{
971	return this.freeze;
972}
973
974BXHint.prototype.Freeze = function()
975{
976	this.freeze = true;
977	this.Hide();
978}
979
980BXHint.prototype.UnFreeze = function()
981{
982	this.freeze = false;
983}
984
985BXHint.prototype.GetMouseXY = function(event)
986{
987	if (event.pageX || event.pageY)
988	{
989		this.x = event.pageX;
990		this.y = event.pageY;
991	}
992	else if (event.clientX || event.clientY)
993	{
994		this.x = event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
995		this.y = event.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
996	}
997}
998
999BXHint.prototype.Show = function(innerHTML, width, height, className)
1000{
1001	//Delete previous hint
1002	var old = document.getElementById("__BXHint_div");
1003	if (old)
1004		this.Hide();
1005
1006	if (this.freeze)
1007		return;
1008
1009	var _this = this;
1010	var oDiv = document.body.appendChild(document.createElement("DIV"));
1011	oDiv.onmouseover = function(){_this.oDivOver = true};
1012	oDiv.onmouseout = function(){_this.oDivOver = false; _this.SmartHide(_this);}
1013	oDiv.id = "__BXHint_div";
1014	oDiv.className = (className) ? className : "bxhint";
1015	oDiv.style.position = 'absolute';
1016	if (width && this.bWidth)
1017		oDiv.style.width = width + "px";
1018
1019	if (height)
1020		oDiv.style.height = height + "px";
1021	oDiv.innerHTML = innerHTML;
1022
1023	var w = oDiv.offsetWidth;
1024	var h = oDiv.offsetHeight;
1025	if (this.bWidth)
1026	{
1027		if (!width && w>200)
1028			w = Math.round(Math.sqrt(1.618*w*h));
1029		oDiv.style.width = w + "px";
1030		h = oDiv.offsetHeight;
1031	}
1032
1033	var pos = {left : this.x + 10, right : this.x + w, top : this.y, bottom : this.y + h};
1034
1035	pos = this.AlignToPos(pos, w, h);
1036
1037	jsFloatDiv.Show(oDiv, pos.left, pos.top,3);
1038
1039//	oDiv.ondrag = jsUtils.False;
1040//	oDiv.onselectstart = jsUtils.False;
1041//	oDiv.style.MozUserSelect = 'none';
1042	oDiv = null;
1043}
1044
1045BXHint.prototype.AlignToPos = function(pos, w, h)
1046{
1047	var body = document.body;
1048	if((body.clientWidth + body.scrollLeft) < (pos.left + w))
1049		pos.left = (pos.left - w >= 0) ? (pos.left - w) : body.scrollLeft;
1050
1051	if((body.clientHeight + body.scrollTop) - (pos["bottom"]) < 0)
1052		pos.top = (pos.top - h >= 0) ? (pos.top - h) : body.scrollTop;
1053
1054	return pos;
1055}
1056
1057BXHint.prototype.Hide = function()
1058{
1059	var oDiv = document.getElementById("__BXHint_div");
1060
1061	if (!oDiv)
1062		return;
1063
1064	BX.ZIndexManager.unregister(oDiv);
1065
1066	jsFloatDiv.Close(oDiv);
1067	oDiv.parentNode.removeChild(oDiv);
1068	oDiv = null;
1069}
1070
1071BXHint.prototype.SmartHide = function(_this)
1072{
1073	setTimeout(function ()
1074		{
1075			if (!_this.oDivOver)
1076				_this.Hide();
1077		}, 100
1078	);
1079}
1080
1081/************************************************/
1082
1083function WaitOnKeyPress(e)
1084{
1085	if(!e) e = window.event
1086	if(!e) return;
1087	if(e.keyCode == 27)
1088		CloseWaitWindow();
1089}
1090
1091function ShowWaitWindow()
1092{
1093	CloseWaitWindow();
1094
1095	var obWndSize = jsUtils.GetWindowSize();
1096
1097	var div = document.body.appendChild(document.createElement("DIV"));
1098	div.id = "wait_window_div";
1099	div.innerHTML = phpVars.messLoading;
1100	div.className = "waitwindow";
1101	//div.style.left = obWndSize.scrollLeft + (obWndSize.innerWidth - div.offsetWidth) - (jsUtils.IsIE() ? 5 : 20) + "px";
1102	div.style.right = (5 - obWndSize.scrollLeft) + 'px';
1103	div.style.top = obWndSize.scrollTop + 5 + "px";
1104
1105	if(jsUtils.IsIE())
1106	{
1107		var frame = document.createElement("IFRAME");
1108		frame.src = "javascript:''";
1109		frame.id = "wait_window_frame";
1110		frame.className = "waitwindow";
1111		frame.style.width = div.offsetWidth + "px";
1112		frame.style.height = div.offsetHeight + "px";
1113		frame.style.right = div.style.right;
1114		frame.style.top = div.style.top;
1115		document.body.appendChild(frame);
1116	}
1117	jsUtils.addEvent(document, "keypress", WaitOnKeyPress);
1118}
1119
1120function CloseWaitWindow()
1121{
1122	jsUtils.removeEvent(document, "keypress", WaitOnKeyPress);
1123
1124	var frame = document.getElementById("wait_window_frame");
1125	if(frame)
1126		frame.parentNode.removeChild(frame);
1127
1128	var div = document.getElementById("wait_window_div");
1129	if(div)
1130		div.parentNode.removeChild(div);
1131}
1132
1133/************************************************/
1134
1135var jsSelectUtils =
1136{
1137	addNewOption: function(select_id, opt_value, opt_name, do_sort, check_unique)
1138	{
1139		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
1140		if(oSelect)
1141		{
1142			var n = oSelect.length;
1143			if(check_unique !== false)
1144			{
1145				for(var i=0;i<n;i++)
1146					if(oSelect[i].value==opt_value)
1147						return;
1148			}
1149			var newoption = new Option(opt_name, opt_value, false, false);
1150			oSelect.options[n]=newoption;
1151		}
1152		if(do_sort === true)
1153			this.sortSelect(select_id);
1154	},
1155
1156	deleteOption: function(select_id, opt_value)
1157	{
1158		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
1159		if(oSelect)
1160		{
1161			for(var i=0;i<oSelect.length;i++)
1162				if(oSelect[i].value==opt_value)
1163				{
1164					oSelect.remove(i);
1165					break;
1166				}
1167		}
1168	},
1169
1170	deleteSelectedOptions: function(select_id)
1171	{
1172		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
1173		if(oSelect)
1174		{
1175			var i=0;
1176			while(i<oSelect.length)
1177				if(oSelect[i].selected)
1178				{
1179					oSelect[i].selected=false;
1180					oSelect.remove(i);
1181				}
1182				else
1183					i++;
1184		}
1185	},
1186
1187	deleteAllOptions: function(oSelect)
1188	{
1189		if(oSelect)
1190		{
1191			for(var i=oSelect.length-1; i>=0; i--)
1192				oSelect.remove(i);
1193		}
1194	},
1195
1196	optionCompare: function(record1, record2)
1197	{
1198		var value1 = record1.optText.toLowerCase();
1199		var value2 = record2.optText.toLowerCase();
1200		if (value1 > value2) return(1);
1201		if (value1 < value2) return(-1);
1202		return(0);
1203	},
1204
1205	sortSelect: function(select_id)
1206	{
1207		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
1208		if(oSelect)
1209		{
1210			var myOptions = [];
1211			var n = oSelect.options.length;
1212			for (var i=0;i<n;i++)
1213			{
1214				myOptions[i] = {
1215					optText:oSelect[i].text,
1216					optValue:oSelect[i].value
1217				};
1218			}
1219			myOptions.sort(this.optionCompare);
1220			oSelect.length=0;
1221			n = myOptions.length;
1222			for(var i=0;i<n;i++)
1223			{
1224				var newoption = new Option(myOptions[i].optText, myOptions[i].optValue, false, false);
1225				oSelect[i]=newoption;
1226			}
1227		}
1228	},
1229
1230	selectAllOptions: function(select_id)
1231	{
1232		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
1233		if(oSelect)
1234		{
1235			var n = oSelect.length;
1236			for(var i=0;i<n;i++)
1237				oSelect[i].selected=true;
1238		}
1239	},
1240
1241	selectOption: function(select_id, opt_value)
1242	{
1243		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
1244		if(oSelect)
1245		{
1246			var n = oSelect.length;
1247			for(var i=0;i<n;i++)
1248				oSelect[i].selected = (oSelect[i].value == opt_value);
1249		}
1250	},
1251
1252	addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort)
1253	{
1254		if(!oSelect)
1255			return;
1256		var n = oSelect.length;
1257		for(var i=0; i<n; i++)
1258			if(oSelect[i].selected)
1259				this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique);
1260	},
1261
1262	moveOptionsUp: function(oSelect)
1263	{
1264		if(!oSelect)
1265			return;
1266		var n = oSelect.length;
1267		for(var i=0; i<n; i++)
1268		{
1269			if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false)
1270			{
1271				var option1 = new Option(oSelect[i].text, oSelect[i].value);
1272				var option2 = new Option(oSelect[i-1].text, oSelect[i-1].value);
1273				oSelect[i] = option2;
1274				oSelect[i].selected = false;
1275				oSelect[i-1] = option1;
1276				oSelect[i-1].selected = true;
1277			}
1278		}
1279	},
1280
1281	moveOptionsDown: function(oSelect)
1282	{
1283		if(!oSelect)
1284			return;
1285		var n = oSelect.length;
1286		for(var i=n-1; i>=0; i--)
1287		{
1288			if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false)
1289			{
1290				var option1 = new Option(oSelect[i].text, oSelect[i].value);
1291				var option2 = new Option(oSelect[i+1].text, oSelect[i+1].value);
1292				oSelect[i] = option2;
1293				oSelect[i].selected = false;
1294				oSelect[i+1] = option1;
1295				oSelect[i+1].selected = true;
1296			}
1297		}
1298	}
1299
1300}
1301
1302/************************************************/

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.