PageSourceSearch

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

js detclinica.ru collected 2026-09-28 22:57:40 UTC 30,973 bytes, 1,353 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, showSubFrame)
681	{
682		if (showSubFrame !== false)
683			showSubFrame = true;
684		var zIndex = parseInt(div.style.zIndex);
685		if(zIndex <= 0 || isNaN(zIndex))
686			zIndex = 100;
687
688		//document.title = 'zIndex = ' + zIndex;
689		div.style.zIndex = zIndex;
690
691		if (left < 0)
692			left = 0;
693
694		if (top < 0)
695			top = 0;
696
697		div.style.left = parseInt(left) + "px";
698		div.style.top = parseInt(top) + "px";
699
700		if(jsUtils.IsIE() && showSubFrame === true)
701		{
702			var frame = document.getElementById(div.id+"_frame");
703			if(!frame)
704			{
705				frame = document.createElement("IFRAME");
706				frame.src = "javascript:''";
707				frame.id = div.id+"_frame";
708				frame.style.position = 'absolute';
709				frame.style.borderWidth = '0px';
710				frame.style.zIndex = zIndex-1;
711				document.body.appendChild(frame);
712			}
713			frame.style.width = div.offsetWidth + "px";
714			frame.style.height = div.offsetHeight + "px";
715			frame.style.left = div.style.left;
716			frame.style.top = div.style.top;
717			frame.style.visibility = 'visible';
718		}
719
720		/*Restrict drag*/
721		div.restrictDrag = restrictDrag || false;
722
723		/*shadow*/
724		if(isNaN(dxShadow))
725			dxShadow = 5;
726
727		if(dxShadow > 0)
728		{
729			var img = document.getElementById(div.id+'_shadow');
730			if(!img)
731			{
732				if(jsUtils.IsIE())
733				{
734		 			img = document.createElement("DIV");
735		 			img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/bitrix/themes/"+phpVars.ADMIN_THEME_ID+"/images/shadow.png',sizingMethod='scale')";
736				}
737				else
738				{
739		 			img = document.createElement("IMG");
740					img.src = '/bitrix/themes/' + phpVars.ADMIN_THEME_ID+'/images/shadow.png';
741				}
742				img.id = div.id+'_shadow';
743				img.style.position = 'absolute';
744				img.style.zIndex = zIndex-2;
745				img.style.left = '-1000px';
746				img.style.top = '-1000px';
747				img.style.lineHeight = 'normal';
748				img.className = "bx-js-float-shadow";
749				document.body.appendChild(img);
750			}
751			img.style.width = div.offsetWidth+'px';
752			img.style.height = div.offsetHeight+'px';
753			img.style.left = parseInt(div.style.left)+dxShadow+'px';
754			img.style.top = parseInt(div.style.top)+dxShadow+'px';
755			img.style.visibility = 'visible';
756		}
757		div.dxShadow = dxShadow;
758	}
759
760	this.Close = function(div)
761	{
762		if(!div)
763			return;
764		var sh = document.getElementById(div.id+"_shadow");
765		if(sh)
766			sh.style.visibility = 'hidden';
767
768		var frame = document.getElementById(div.id+"_frame");
769		if(frame)
770			frame.style.visibility = 'hidden';
771	}
772
773	this.Move = function(div, x, y)
774	{
775		if(!div)
776			return;
777
778		var dxShadow = div.dxShadow;
779		var left = parseInt(div.style.left)+x;
780		var top = parseInt(div.style.top)+y;
781
782		if (div.restrictDrag)
783		{
784			//Left side
785			if (left < 0)
786				left = 0;
787
788			//Right side
789			if ( (document.compatMode && document.compatMode == "CSS1Compat"))
790				windowWidth = document.documentElement.scrollWidth;
791			else
792			{
793				if (document.body.scrollWidth > document.body.offsetWidth ||
794					(document.compatMode && document.compatMode == "BackCompat") ||
795					(document.documentElement && !document.documentElement.clientWidth)
796				)
797					windowWidth = document.body.scrollWidth;
798				else
799					windowWidth = document.body.offsetWidth;
800			}
801
802			var floatWidth = div.offsetWidth;
803			if (left > (windowWidth - floatWidth - dxShadow))
804				left = windowWidth - floatWidth - dxShadow;
805
806			//Top side
807			if (top < 0)
808				top = 0;
809		}
810
811		div.style.left = left+'px';
812		div.style.top = top+'px';
813
814		this.AdjustShadow(div);
815	}
816
817	this.HideShadow = function(div)
818	{
819		var sh = document.getElementById(div.id + "_shadow");
820		sh.style.visibility = 'hidden';
821	}
822
823	this.UnhideShadow = function(div)
824	{
825		var sh = document.getElementById(div.id + "_shadow");
826		sh.style.visibility = 'visible';
827	}
828
829	this.AdjustShadow = function(div)
830	{
831		var sh = document.getElementById(div.id + "_shadow");
832		if(sh && sh.style.visibility != 'hidden')
833		{
834			var dxShadow = div.dxShadow;
835
836			sh.style.width = div.offsetWidth+'px';
837			sh.style.height = div.offsetHeight+'px';
838			sh.style.left = parseInt(div.style.left)+dxShadow+'px';
839			sh.style.top = parseInt(div.style.top)+dxShadow+'px';
840		}
841
842		var frame = document.getElementById(div.id+"_frame");
843		if(frame)
844		{
845			frame.style.width = div.offsetWidth + "px";
846			frame.style.height = div.offsetHeight + "px";
847			frame.style.left = div.style.left;
848			frame.style.top = div.style.top;
849		}
850	}
851
852	this.StartDrag = function(e, div)
853	{
854		if(!e)
855			e = window.event;
856		this.x = e.clientX + document.body.scrollLeft;
857		this.y = e.clientY + document.body.scrollTop;
858		this.floatDiv = div;
859
860		jsUtils.addEvent(document, "mousemove", this.MoveDrag);
861		document.onmouseup = this.StopDrag;
862		if(document.body.setCapture)
863			document.body.setCapture();
864
865		document.onmousedown = jsUtils.False;
866		var b = document.body;
867		b.ondrag = jsUtils.False;
868		b.onselectstart = jsUtils.False;
869		b.style.MozUserSelect = _this.floatDiv.style.MozUserSelect = 'none';
870		b.style.cursor = 'move';
871	}
872
873	this.StopDrag = function(e)
874	{
875		if(document.body.releaseCapture)
876			document.body.releaseCapture();
877
878		jsUtils.removeEvent(document, "mousemove", _this.MoveDrag);
879		document.onmouseup = null;
880
881		this.floatDiv = null;
882
883		document.onmousedown = null;
884		var b = document.body;
885		b.ondrag = null;
886		b.onselectstart = null;
887		b.style.MozUserSelect = _this.floatDiv.style.MozUserSelect = '';
888		b.style.cursor = '';
889	}
890
891	this.MoveDrag = function(e)
892	{
893		var x = e.clientX + document.body.scrollLeft;
894		var y = e.clientY + document.body.scrollTop;
895
896		if(_this.x == x && _this.y == y)
897			return;
898
899		_this.Move(_this.floatDiv, (x - _this.x), (y - _this.y));
900		_this.x = x;
901		_this.y = y;
902	}
903}
904var jsFloatDiv = new JCFloatDiv();
905
906/************************************************/
907
908var BXHint = function(innerHTML, element, addParams)
909{
910	this.oDivOver = false;
911	this.timeOutID = null;
912	this.oIcon = null;
913	this.freeze = false;
914	this.x = 0;
915	this.y = 0;
916	this.time = 700;
917
918	if (!innerHTML)
919		innerHTML = "";
920	this.Create(innerHTML, element, addParams);
921}
922
923BXHint.prototype.Create = function(innerHTML, element, addParams)
924{
925	var
926		_this = this,
927		width = 0,
928		height = 0,
929		className = null,
930		type = "icon";
931	this.bWidth = true;
932
933	if (addParams)
934	{
935		if (addParams.width === false)
936			this.bWidth = false;
937		else if (addParams.width)
938			width = addParams.width;
939
940		if (addParams.height)
941			height = addParams.height;
942
943		if (addParams.className)
944			className = addParams.className;
945
946		if (addParams.type && (addParams.type == "link" || addParams.type == "icon"))
947			type = addParams.type;
948		if (addParams.time > 0)
949			this.time = addParams.time;
950	}
951
952	if (element)
953		type = "element";
954
955	if (type == "icon")
956	{
957		var element = document.createElement("IMG");
958		element.src = (addParams && addParams.iconSrc) ? addParams.iconSrc : "/bitrix/themes/"+phpVars.ADMIN_THEME_ID+"/public/popup/hint.gif";
959		element.ondrag = jsUtils.False;
960	}
961	else if (type == "link")
962	{
963		var element = document.createElement("A");
964		element.href = "";
965		element.onclick = function(e){return false;}
966		element.innerHTML = "[?]";
967	}
968
969	this.element = element;
970	if (type == "element")
971	{
972		if(addParams && addParams.show_on_click)
973		{
974			jsUtils.addEvent(
975				element,
976				"click",
977				function (event)
978				{
979					if (!event)
980						event = window.event;
981					_this.GetMouseXY(event);
982					_this.timeOutID = setTimeout(function () {_this.Show(innerHTML,width,height,className) }, 10);
983				}
984			);
985		}
986		else
987		{
988			jsUtils.addEvent(
989				element,
990				"mouseover",
991				function (event)
992				{
993					if (!event)
994						event = window.event;
995					_this.GetMouseXY(event);
996					_this.timeOutID = setTimeout(function () {_this.Show(innerHTML,width,height,className) }, 750);
997				}
998			);
999		}
1000
1001		jsUtils.addEvent(
1002			element,
1003			"mouseout",
1004			function(event)
1005			{
1006				if (_this.timeOutID)
1007					clearTimeout(_this.timeOutID);
1008				_this.SmartHide(_this);
1009			}
1010		);
1011	}
1012	else
1013	{
1014		this.oIcon = element;
1015		element.onmouseover = function(event) {if (!event) event = window.event; _this.GetMouseXY(event); _this.Show(innerHTML,width,height,className)};
1016		element.onmouseout = function() {_this.SmartHide(_this);};
1017	}
1018}
1019
1020BXHint.prototype.IsFrozen = function()
1021{
1022	return this.freeze;
1023}
1024
1025BXHint.prototype.Freeze = function()
1026{
1027	this.freeze = true;
1028	this.Hide();
1029}
1030
1031BXHint.prototype.UnFreeze = function()
1032{
1033	this.freeze = false;
1034}
1035
1036BXHint.prototype.GetMouseXY = function(event)
1037{
1038	if (event.pageX || event.pageY)
1039	{
1040		this.x = event.pageX;
1041		this.y = event.pageY;
1042	}
1043	else if (event.clientX || event.clientY)
1044	{
1045		this.x = event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
1046		this.y = event.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
1047	}
1048}
1049
1050BXHint.prototype.Show = function(innerHTML, width, height, className)
1051{
1052	//Delete previous hint
1053	var old = document.getElementById("__BXHint_div");
1054	if (old)
1055		this.Hide();
1056
1057	if (this.freeze)
1058		return;
1059
1060	var _this = this;
1061	var oDiv = document.body.appendChild(document.createElement("DIV"));
1062	oDiv.onmouseover = function(){_this.oDivOver = true};
1063	oDiv.onmouseout = function(){_this.oDivOver = false; _this.SmartHide(_this);}
1064	oDiv.id = "__BXHint_div";
1065	oDiv.className = (className) ? className : "bxhint";
1066	oDiv.style.position = 'absolute';
1067	if (width && this.bWidth)
1068		oDiv.style.width = width + "px";
1069
1070	if (height)
1071		oDiv.style.height = height + "px";
1072	oDiv.innerHTML = innerHTML;
1073
1074	var w = oDiv.offsetWidth;
1075	var h = oDiv.offsetHeight;
1076	if (this.bWidth)
1077	{
1078		if (!width && w>200)
1079			w = Math.round(Math.sqrt(1.618*w*h));
1080		oDiv.style.width = w + "px";
1081		h = oDiv.offsetHeight;
1082	}
1083
1084	var pos = {left : this.x + 10, right : this.x + w, top : this.y, bottom : this.y + h};
1085
1086	pos = this.AlignToPos(pos, w, h);
1087
1088	oDiv.style.zIndex = 2100;
1089
1090	jsFloatDiv.Show(oDiv, pos.left, pos.top,3);
1091
1092//	oDiv.ondrag = jsUtils.False;
1093//	oDiv.onselectstart = jsUtils.False;
1094//	oDiv.style.MozUserSelect = 'none';
1095	oDiv = null;
1096}
1097
1098BXHint.prototype.AlignToPos = function(pos, w, h)
1099{
1100	var body = document.body;
1101	if((body.clientWidth + body.scrollLeft) < (pos.left + w))
1102		pos.left = (pos.left - w >= 0) ? (pos.left - w) : body.scrollLeft;
1103
1104	if((body.clientHeight + body.scrollTop) - (pos["bottom"]) < 0)
1105		pos.top = (pos.top - h >= 0) ? (pos.top - h) : body.scrollTop;
1106
1107	return pos;
1108}
1109
1110BXHint.prototype.Hide = function()
1111{
1112	var oDiv = document.getElementById("__BXHint_div");
1113
1114	if (!oDiv)
1115		return;
1116
1117	jsFloatDiv.Close(oDiv);
1118	oDiv.parentNode.removeChild(oDiv);
1119	oDiv = null;
1120}
1121
1122BXHint.prototype.SmartHide = function(_this)
1123{
1124	setTimeout(function ()
1125		{
1126			if (!_this.oDivOver)
1127				_this.Hide();
1128		}, 100
1129	);
1130}
1131
1132/************************************************/
1133
1134function WaitOnKeyPress(e)
1135{
1136	if(!e) e = window.event
1137	if(!e) return;
1138	if(e.keyCode == 27)
1139		CloseWaitWindow();
1140}
1141
1142function ShowWaitWindow()
1143{
1144	CloseWaitWindow();
1145
1146	var obWndSize = jsUtils.GetWindowSize();
1147
1148	var div = document.body.appendChild(document.createElement("DIV"));
1149	div.id = "wait_window_div";
1150	div.innerHTML = phpVars.messLoading;
1151	div.className = "waitwindow";
1152	//div.style.left = obWndSize.scrollLeft + (obWndSize.innerWidth - div.offsetWidth) - (jsUtils.IsIE() ? 5 : 20) + "px";
1153	div.style.right = (5 - obWndSize.scrollLeft) + 'px';
1154	div.style.top = obWndSize.scrollTop + 5 + "px";
1155
1156	if(jsUtils.IsIE())
1157	{
1158		var frame = document.createElement("IFRAME");
1159		frame.src = "javascript:''";
1160		frame.id = "wait_window_frame";
1161		frame.className = "waitwindow";
1162		frame.style.width = div.offsetWidth + "px";
1163		frame.style.height = div.offsetHeight + "px";
1164		frame.style.right = div.style.right;
1165		frame.style.top = div.style.top;
1166		document.body.appendChild(frame);
1167	}
1168	jsUtils.addEvent(document, "keypress", WaitOnKeyPress);
1169}
1170
1171function CloseWaitWindow()
1172{
1173	jsUtils.removeEvent(document, "keypress", WaitOnKeyPress);
1174
1175	var frame = document.getElementById("wait_window_frame");
1176	if(frame)
1177		frame.parentNode.removeChild(frame);
1178
1179	var div = document.getElementById("wait_window_div");
1180	if(div)
1181		div.parentNode.removeChild(div);
1182}
1183
1184/************************************************/
1185
1186var jsSelectUtils =
1187{
1188	addNewOption: function(select_id, opt_value, opt_name, do_sort, check_unique)
1189	{
1190		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
1191		if(oSelect)
1192		{
1193			var n = oSelect.length;
1194			if(check_unique !== false)
1195			{
1196				for(var i=0;i<n;i++)
1197					if(oSelect[i].value==opt_value)
1198						return;
1199			}
1200			var newoption = new Option(opt_name, opt_value, false, false);
1201			oSelect.options[n]=newoption;
1202		}
1203		if(do_sort === true)
1204			this.sortSelect(select_id);
1205	},
1206
1207	deleteOption: function(select_id, opt_value)
1208	{
1209		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
1210		if(oSelect)
1211		{
1212			for(var i=0;i<oSelect.length;i++)
1213				if(oSelect[i].value==opt_value)
1214				{
1215					oSelect.remove(i);
1216					break;
1217				}
1218		}
1219	},
1220
1221	deleteSelectedOptions: function(select_id)
1222	{
1223		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
1224		if(oSelect)
1225		{
1226			var i=0;
1227			while(i<oSelect.length)
1228				if(oSelect[i].selected)
1229				{
1230					oSelect[i].selected=false;
1231					oSelect.remove(i);
1232				}
1233				else
1234					i++;
1235		}
1236	},
1237
1238	deleteAllOptions: function(oSelect)
1239	{
1240		if(oSelect)
1241		{
1242			for(var i=oSelect.length-1; i>=0; i--)
1243				oSelect.remove(i);
1244		}
1245	},
1246
1247	optionCompare: function(record1, record2)
1248	{
1249		var value1 = record1.optText.toLowerCase();
1250		var value2 = record2.optText.toLowerCase();
1251		if (value1 > value2) return(1);
1252		if (value1 < value2) return(-1);
1253		return(0);
1254	},
1255
1256	sortSelect: function(select_id)
1257	{
1258		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
1259		if(oSelect)
1260		{
1261			var myOptions = [];
1262			var n = oSelect.options.length;
1263			for (var i=0;i<n;i++)
1264			{
1265				myOptions[i] = {
1266					optText:oSelect[i].text,
1267					optValue:oSelect[i].value
1268				};
1269			}
1270			myOptions.sort(this.optionCompare);
1271			oSelect.length=0;
1272			n = myOptions.length;
1273			for(var i=0;i<n;i++)
1274			{
1275				var newoption = new Option(myOptions[i].optText, myOptions[i].optValue, false, false);
1276				oSelect[i]=newoption;
1277			}
1278		}
1279	},
1280
1281	selectAllOptions: function(select_id)
1282	{
1283		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
1284		if(oSelect)
1285		{
1286			var n = oSelect.length;
1287			for(var i=0;i<n;i++)
1288				oSelect[i].selected=true;
1289		}
1290	},
1291
1292	selectOption: function(select_id, opt_value)
1293	{
1294		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
1295		if(oSelect)
1296		{
1297			var n = oSelect.length;
1298			for(var i=0;i<n;i++)
1299				oSelect[i].selected = (oSelect[i].value == opt_value);
1300		}
1301	},
1302
1303	addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort)
1304	{
1305		if(!oSelect)
1306			return;
1307		var n = oSelect.length;
1308		for(var i=0; i<n; i++)
1309			if(oSelect[i].selected)
1310				this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique);
1311	},
1312
1313	moveOptionsUp: function(oSelect)
1314	{
1315		if(!oSelect)
1316			return;
1317		var n = oSelect.length;
1318		for(var i=0; i<n; i++)
1319		{
1320			if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false)
1321			{
1322				var option1 = new Option(oSelect[i].text, oSelect[i].value);
1323				var option2 = new Option(oSelect[i-1].text, oSelect[i-1].value);
1324				oSelect[i] = option2;
1325				oSelect[i].selected = false;
1326				oSelect[i-1] = option1;
1327				oSelect[i-1].selected = true;
1328			}
1329		}
1330	},
1331
1332	moveOptionsDown: function(oSelect)
1333	{
1334		if(!oSelect)
1335			return;
1336		var n = oSelect.length;
1337		for(var i=n-1; i>=0; i--)
1338		{
1339			if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false)
1340			{
1341				var option1 = new Option(oSelect[i].text, oSelect[i].value);
1342				var option2 = new Option(oSelect[i+1].text, oSelect[i+1].value);
1343				oSelect[i] = option2;
1344				oSelect[i].selected = false;
1345				oSelect[i+1] = option1;
1346				oSelect[i+1].selected = true;
1347			}
1348		}
1349	}
1350
1351}
1352
1353/************************************************/

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.