PageSourceSearch

https://alcon.kz/bitrix/cache/js/s1/inner_1col/kernel/kernel.js?1737542328

js alcon.kz collected 2026-10-04 20:43:47 UTC 487,846 bytes, 19,731 lines download raw bytes

1
2; /* Start:/bitrix/js/main/core/core.js*/
3/**********************************************************************/
4/*********** Bitrix JS Core library ver 0.9.0 beta ********************/
5/**********************************************************************/
6
7;(function(window){
8
9if (!!window.BX && !!window.BX.extend)
10	return;
11
12var _bxtmp;
13if (!!window.BX)
14{
15	_bxtmp = window.BX;
16}
17
18window.BX = function(node, bCache)
19{
20	if (BX.type.isNotEmptyString(node))
21	{
22		var ob;
23
24		if (!!bCache && null != NODECACHE[node])
25			ob = NODECACHE[node];
26		ob = ob || document.getElementById(node);
27		if (!!bCache)
28			NODECACHE[node] = ob;
29
30		return ob;
31	}
32	else if (BX.type.isDomNode(node))
33		return node;
34	else if (BX.type.isFunction(node))
35		return BX.ready(node);
36
37	return null;
38};
39
40// language utility
41BX.message = function(mess)
42{
43	if (BX.type.isString(mess))
44	{
45		if (typeof BX.message[mess] == 'undefined')
46			BX.debug('message undefined: ' + mess);
47		return BX.message[mess];
48	}
49	else
50	{
51		for (var i in mess)
52		{
53			BX.message[i]=mess[i];
54		}
55		return true;
56	}
57};
58
59if(!!_bxtmp)
60{
61	for(var i in _bxtmp)
62	{
63		if(!BX[i])
64		{
65			BX[i]=_bxtmp[i];
66		}
67		else if(i=='message')
68		{
69			for(var j in _bxtmp[i])
70			{
71				BX.message[j]=_bxtmp[i][j];
72			}
73		}
74		_bxtmp = null;
75	}
76}
77
78var
79
80/* ready */
81__readyHandler = null,
82readyBound = false,
83readyList = [],
84
85/* list of registered proxy functions */
86proxySalt = Math.random(),
87proxyId = 1,
88proxyList = [],
89deferList = [],
90
91/* getElementById cache */
92NODECACHE = {},
93
94/* List of denied event handlers */
95deniedEvents = [],
96
97/* list of registered event handlers */
98eventsList = [],
99
100/* list of registered custom events */
101customEvents = {},
102
103/* list of external garbage collectors */
104garbageCollectors = [],
105
106/* list of loaded CSS files */
107cssList = [],
108
109/* list of loaded JS kernel files */
110arKernelJS = [],
111
112/* browser detection */
113bSafari = navigator.userAgent.toLowerCase().indexOf('webkit') != -1,
114bOpera = navigator.userAgent.toLowerCase().indexOf('opera') != -1,
115bFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') != -1,
116bChrome = navigator.userAgent.toLowerCase().indexOf('chrome') != -1,
117bIE = document.attachEvent && !bOpera,
118
119/* regexps */
120r = {
121	script: /<script([^>]*)>/i,
122	script_src: /src=["\']([^"\']+)["\']/i,
123	space: /\s+/,
124	ltrim: /^[\s\r\n]+/g,
125	rtrim: /[\s\r\n]+$/g,
126	style: /<link.*?(rel="stylesheet"|type="text\/css")[^>]*>/i,
127	style_href: /href=["\']([^"\']+)["\']/i
128},
129
130eventTypes = {
131	click: 'MouseEvent',
132	dblclick: 'MouseEvent',
133	mousedown: 'MouseEvent',
134	mousemove: 'MouseEvent',
135	mouseout: 'MouseEvent',
136	mouseover: 'MouseEvent',
137	mouseup: 'MouseEvent',
138	focus: 'MouseEvent',
139	blur: 'MouseEvent'
140},
141
142lastWait = [],
143
144CHECK_FORM_ELEMENTS = {tagName: /^INPUT|SELECT|TEXTAREA|BUTTON$/i};
145
146BX.MSLEFT = 1;
147BX.MSMIDDLE = 2;
148BX.MSRIGHT = 4;
149
150BX.ext = function(ob) {for (var i in ob) this[i] = ob[i];}
151
152/* OO emulation utility */
153BX.extend = function(child, parent)
154{
155	var f = function() {};
156	f.prototype = parent.prototype;
157
158	child.prototype = new f();
159	child.prototype.constructor = child;
160
161	child.superclass = parent.prototype;
162	if(parent.prototype.constructor == Object.prototype.constructor)
163	{
164		parent.prototype.constructor = parent;
165	}
166}
167
168BX.debug = function()
169{
170	if (window.BXDEBUG)
171	{
172		if (window.console && window.console.log)
173			console.log('BX.debug: ', arguments.length > 0 ? arguments : arguments[0]);
174	}
175}
176
177BX.is_subclass_of = function(ob, parent_class)
178{
179	if (ob instanceof parent_class)
180		return true;
181
182	if (parent_class.superclass)
183		return BX.is_subclass_of(ob, parent_class.superclass);
184
185	return false;
186}
187
188BX.bitrix_sessid = function() {return BX.message.bitrix_sessid;}
189
190/* DOM manipulation */
191BX.create = function(tag, data, context)
192{
193	context = context || document;
194
195	if (null == data && typeof tag == 'object' && tag.constructor !== String)
196	{
197		data = tag; tag = tag.tag;
198	}
199
200	var elem;
201	if (BX.browser.IsIE() && !BX.browser.IsIE9() && null != data && null != data.props && (data.props.name || data.props.id))
202	{
203		elem = context.createElement('<' + tag + (data.props.name ? ' name="' + data.props.name + '"' : '') + (data.props.id ? ' id="' + data.props.id + '"' : '') + '>');
204	}
205	else
206	{
207		elem = context.createElement(tag);
208	}
209
210	return data ? BX.adjust(elem, data) : elem;
211}
212
213BX.adjust = function(elem, data)
214{
215	var j,len;
216
217	if (!elem.nodeType)
218		return null;
219
220	if (elem.nodeType == 9)
221		elem = elem.body;
222
223	if (data.attrs)
224	{
225		for (j in data.attrs)
226		{
227			if (j == 'class' || j == 'className')
228				elem.className = data.attrs[j];
229			else if (j == 'for')
230				elem.htmlFor = data.attrs[j];
231			else if(data.attrs[j] == "")
232				elem.removeAttribute(j);
233			else
234				elem.setAttribute(j, data.attrs[j]);
235		}
236	}
237
238	if (data.style)
239	{
240		for (j in data.style)
241			elem.style[j] = data.style[j];
242	}
243
244	if (data.props)
245	{
246		for (j in data.props)
247			elem[j] = data.props[j];
248	}
249
250	if (data.events)
251	{
252		for (j in data.events)
253			BX.bind(elem, j, data.events[j]);
254	}
255
256	if (data.children && data.children.length > 0)
257	{
258		for (j=0,len=data.children.length; j<len; j++)
259		{
260			if (BX.type.isNotEmptyString(data.children[j]))
261				elem.innerHTML += data.children[j];
262			else if (BX.type.isElementNode(data.children[j]))
263				elem.appendChild(data.children[j]);
264		}
265	}
266	else if (data.text)
267	{
268		BX.cleanNode(elem);
269		elem.appendChild((elem.ownerDocument || document).createTextNode(data.text));
270	}
271	else if (data.html)
272	{
273		elem.innerHTML = data.html;
274	}
275
276	return elem;
277}
278
279BX.remove = function(ob)
280{
281	if (ob && null != ob.parentNode)
282		ob.parentNode.removeChild(ob);
283	ob = null;
284	return null;
285}
286
287BX.cleanNode = function(node, bSuicide)
288{
289	node = BX(node);
290	bSuicide = !!bSuicide;
291
292	if (node && node.childNodes)
293	{
294		while(node.childNodes.length > 0)
295			node.removeChild(node.firstChild);
296	}
297
298	if (node && bSuicide)
299	{
300		node = BX.remove(node);
301	}
302
303	return node;
304}
305
306BX.addClass = function(ob, value)
307{
308	var classNames;
309	ob = BX(ob)
310
311	value = BX.util.trim(value);
312	if (value == '')
313		return ob;
314
315	if (ob)
316	{
317		if (!ob.className)
318		{
319			ob.className = value
320		}
321		else if (!!ob.classList && value.indexOf(' ') < 0)
322		{
323			ob.classList.add(value);
324		}
325		else
326		{
327			classNames = (value || "").split(r.space);
328
329			var className = " " + ob.className + " ";
330			for (var j = 0, cl = classNames.length; j < cl; j++)
331			{
332				if (className.indexOf(" " + classNames[j] + " ") < 0)
333				{
334					ob.className += " " + classNames[j];
335				}
336			}
337		}
338	}
339
340	return ob;
341}
342
343BX.removeClass = function(ob, value)
344{
345	ob = BX(ob);
346	if (ob)
347	{
348		if (ob.className && !!value)
349		{
350			if (BX.type.isString(value))
351			{
352				if (!!ob.classList && value.indexOf(' ') < 0)
353				{
354					ob.classList.remove(value);
355				}
356				else
357				{
358					var classNames = value.split(r.space), className = " " + ob.className + " ";
359					for (var j = 0, cl = classNames.length; j < cl; j++)
360					{
361						className = className.replace(" " + classNames[j] + " ", " ");
362					}
363
364					ob.className = BX.util.trim(className);
365				}
366			}
367			else
368			{
369				ob.className = "";
370			}
371		}
372	}
373
374	return ob;
375}
376
377BX.toggleClass = function(ob, value)
378{
379	var className;
380	if (BX.type.isArray(value))
381	{
382		className = ' ' + ob.className + ' ';
383		for (var j = 0, len = value.length; j < len; j++)
384		{
385			if (BX.hasClass(ob, value[j]))
386			{
387				className = (' ' + className + ' ').replace(' ' + value[j] + ' ', ' ');
388				className += ' ' + value[j >= len-1 ? 0 : j+1];
389
390				j--;
391				break;
392			}
393		}
394
395		if (j == len)
396			ob.className += ' ' + value[0];
397		else
398			ob.className = className;
399
400		ob.className = BX.util.trim(ob.className);
401	}
402	else if (BX.type.isNotEmptyString(value))
403	{
404		if (!!ob.classList)
405		{
406			ob.classList.toggle(value);
407		}
408		else
409		{
410			className = ob.className;
411			if (BX.hasClass(ob, value))
412			{
413				className = (' ' + className + ' ').replace(' ' + value + ' ', ' ');
414			}
415			else
416			{
417				className += ' ' + value;
418			}
419
420			ob.className = BX.util.trim(className);
421		}
422	}
423
424	return ob;
425}
426
427BX.hasClass = function(el, className)
428{
429	if (!el || !BX.type.isDomNode(el))
430	{
431		BX.debug(el);
432		return false;
433	}
434
435	if (!el.className || !className)
436	{
437		return false;
438	}
439
440	if (!!el.classList && !!className && className.indexOf(' ') < 0)
441	{
442		return el.classList.contains(BX.util.trim(className));
443	}
444	else
445		return ((" " + el.className + " ").indexOf(" " + className + " ")) >= 0;
446}
447
448BX.hoverEvents = function(el)
449{
450	if (el)
451		return BX.adjust(el, {events: BX.hoverEvents()});
452	else
453		return {mouseover: BX.hoverEventsHover, mouseout: BX.hoverEventsHout};
454}
455
456BX.hoverEventsHover = function(){BX.addClass(this,'bx-hover');this.BXHOVER=true;}
457BX.hoverEventsHout = function(){BX.removeClass(this,'bx-hover');this.BXHOVER=false;}
458
459BX.focusEvents = function(el)
460{
461	if (el)
462		return BX.adjust(el, {events: BX.focusEvents()});
463	else
464		return {mouseover: BX.focusEventsFocus, mouseout: BX.focusEventsBlur};
465}
466
467BX.focusEventsFocus = function(){BX.addClass(this,'bx-focus');this.BXFOCUS=true;}
468BX.focusEventsBlur = function(){BX.removeClass(this,'bx-focus');this.BXFOCUS=false;}
469
470BX.setUnselectable = function(node)
471{
472	BX.addClass(node, 'bx-unselectable');
473	node.setAttribute('unSelectable', 'on');
474}
475
476BX.setSelectable = function(node)
477{
478	BX.removeClass(node, 'bx-unselectable');
479	node.removeAttribute('unSelectable');
480}
481
482BX.styleIEPropertyName = function(name)
483{
484	if (name == 'float')
485		name = BX.browser.IsIE() ? 'styleFloat' : 'cssFloat';
486	else
487	{
488		var res = BX.browser.isPropertySupported(name);
489		if (res)
490		{
491			name = res;
492		}
493		else
494		{
495			var reg = /(\-([a-z]){1})/g;
496			if (reg.test(name))
497			{
498				name = name.replace(reg, function () {return arguments[2].toUpperCase();});
499			}
500		}
501	}
502	return name;
503}
504
505/* CSS-notation should be used here */
506BX.style = function(el, property, value)
507{
508	if (!BX.type.isElementNode(el))
509		return null;
510
511	if (value == null)
512	{
513		var res;
514
515		if(el.currentStyle)
516			res = el.currentStyle[BX.styleIEPropertyName(property)];
517		else if(window.getComputedStyle)
518		{
519			var q = BX.browser.isPropertySupported(property, true);
520			if (!!q)
521				property = q;
522
523			res = BX.GetContext(el).getComputedStyle(el, null).getPropertyValue(property);
524		}
525
526		if(!res)
527			res = '';
528		return res;
529	}
530	else
531	{
532		el.style[BX.styleIEPropertyName(property)] = value;
533		return el;
534	}
535}
536
537BX.focus = function(el)
538{
539	try
540	{
541		el.focus();
542		return true;
543	}
544	catch (e)
545	{
546		return false;
547	}
548}
549
550BX.firstChild = function(el)
551{
552	var e = el.firstChild;
553	while (e && !BX.type.isElementNode(e))
554	{
555		e = e.nextSibling;
556	}
557
558	return e;
559}
560
561BX.lastChild = function(el)
562{
563	var e = el.lastChild;
564	while (e && !BX.type.isElementNode(e))
565	{
566		e = e.previousSibling;
567	}
568
569	return e;
570}
571
572BX.previousSibling = function(el)
573{
574	var e = el.previousSibling;
575	while (e && !BX.type.isElementNode(e))
576	{
577		var e = e.previousSibling;
578	}
579
580	return e;
581}
582
583BX.nextSibling = function(el)
584{
585	var e = el.nextSibling;
586	while (e && !BX.type.isElementNode(e))
587	{
588		var e = e.nextSibling;
589	}
590
591	return e;
592}
593
594/*
595	params: {
596		tagName|tag : 'tagName',
597		className|class : 'className',
598		attribute : {attribute : value, attribute : value} | attribute | [attribute, attribute....],
599		property : {prop: value, prop: value} | prop | [prop, prop]
600	}
601
602	all values can be RegExps or strings
603*/
604BX.findChildren = function(obj, params, recursive)
605{
606	return BX.findChild(obj, params, recursive, true);
607}
608
609BX.findChild = function(obj, params, recursive, get_all)
610{
611	if(!obj || !obj.childNodes) return null;
612
613	recursive = !!recursive; get_all = !!get_all;
614
615	var n = obj.childNodes.length, result = [];
616
617	for (var j=0; j<n; j++)
618	{
619		var child = obj.childNodes[j];
620
621		if (_checkNode(child, params))
622		{
623			if (get_all)
624				result.push(child)
625			else
626				return child;
627		}
628
629		if(recursive == true)
630		{
631			var res = BX.findChild(child, params, recursive, get_all);
632			if (res)
633			{
634				if (get_all)
635					result = BX.util.array_merge(result, res);
636				else
637					return res;
638			}
639		}
640	}
641
642	if (get_all || result.length > 0)
643		return result;
644	else
645		return null;
646}
647
648BX.findParent = function(obj, params, maxParent)
649{
650	if(!obj)
651		return null;
652
653	var o = obj;
654	while(o.parentNode)
655	{
656		var parent = o.parentNode;
657
658		if (_checkNode(parent, params))
659			return parent;
660
661		o = parent;
662
663		if (!!maxParent &&
664			(BX.type.isFunction(maxParent)
665				|| typeof maxParent == 'object'))
666		{
667			if (BX.type.isElementNode(maxParent))
668			{
669				if (o == maxParent)
670					break;
671			}
672			else
673			{
674				if (_checkNode(o, maxParent))
675					break;
676			}
677		}
678	}
679	return null;
680}
681
682BX.findNextSibling = function(obj, params)
683{
684	if(!obj)
685		return null;
686	var o = obj;
687	while(o.nextSibling)
688	{
689		var sibling = o.nextSibling;
690		if (_checkNode(sibling, params))
691			return sibling;
692		o = sibling;
693	}
694	return null;
695}
696
697BX.findPreviousSibling = function(obj, params)
698{
699	if(!obj)
700		return null;
701
702	var o = obj;
703	while(o.previousSibling)
704	{
705		var sibling = o.previousSibling;
706		if(_checkNode(sibling, params))
707			return sibling;
708		o = sibling;
709	}
710	return null;
711}
712
713BX.findFormElements = function(form)
714{
715	if (BX.type.isString(form))
716		form = document.forms[form]||BX(form);
717
718	var res = [];
719
720	if (BX.type.isElementNode(form))
721	{
722		if (form.tagName.toUpperCase() == 'FORM')
723		{
724			res = form.elements;
725		}
726		else
727		{
728			res = BX.findChildren(form, CHECK_FORM_ELEMENTS, true);
729		}
730	}
731
732	return res;
733}
734
735BX.clone = function(obj, bCopyObj)
736{
737	var _obj, i, l;
738	if (bCopyObj !== false)
739		bCopyObj = true;
740
741	if (obj === null)
742		return null;
743
744	if (BX.type.isDomNode(obj))
745	{
746		_obj = obj.cloneNode(bCopyObj);
747	}
748	else if (typeof obj == 'object')
749	{
750		if (BX.type.isArray(obj))
751		{
752			_obj = [];
753			for (i=0,l=obj.length;i<l;i++)
754			{
755				if (typeof obj[i] == "object" && bCopyObj)
756					_obj[i] = BX.clone(obj[i], bCopyObj);
757				else
758					_obj[i] = obj[i];
759			}
760		}
761		else
762		{
763			_obj =  {};
764			if (obj.constructor)
765			{
766				if (obj.constructor === Date)
767					_obj = new Date(obj);
768				else
769					_obj = new obj.constructor();
770			}
771
772			for (i in obj)
773			{
774				if (typeof obj[i] == "object" && bCopyObj)
775					_obj[i] = BX.clone(obj[i], bCopyObj);
776				else
777					_obj[i] = obj[i];
778			}
779		}
780
781	}
782	else
783	{
784		_obj = obj;
785	}
786
787	return _obj;
788}
789
790/* events */
791BX.bind = function(el, evname, func)
792{
793	if (!el)
794		return;
795
796	if (evname === 'mousewheel')
797		BX.bind(el, 'DOMMouseScroll', func);
798	else if (evname === 'transitionend')
799	{
800		BX.bind(el, 'webkitTransitionEnd', func);
801		BX.bind(el, 'msTransitionEnd', func);
802		BX.bind(el, 'oTransitionEnd', func);
803		// IE8-9 doesn't support this feature!
804	}
805
806	if (el.addEventListener)
807		el.addEventListener(evname, func, false);
808	else if(el.attachEvent) // IE
809		el.attachEvent("on" + evname, BX.proxy(func, el));
810	else
811		el["on" + evname] = func;
812
813	eventsList[eventsList.length] = {'element': el, 'event': evname, 'fn': func};
814}
815
816BX.unbind = function(el, evname, func)
817{
818	if (!el)
819		return;
820
821	if (evname === 'mousewheel')
822		BX.unbind(el, 'DOMMouseScroll', func);
823
824	if(el.removeEventListener) // Gecko / W3C
825		el.removeEventListener(evname, func, false);
826	else if(el.detachEvent) // IE
827		el.detachEvent("on" + evname, BX.proxy(func, el));
828	else
829		el["on" + evname] = null;
830}
831
832BX.getEventButton = function(e)
833{
834	e = e || window.event;
835
836	var flags = 0;
837
838	if (typeof e.which != 'undefined')
839	{
840		switch (e.which)
841		{
842			case 1: flags = flags|BX.MSLEFT; break;
843			case 2: flags = flags|BX.MSMIDDLE; break;
844			case 3: flags = flags|BX.MSRIGHT; break;
845		}
846	}
847	else if (typeof e.button != 'undefined')
848	{
849		flags = event.button;
850	}
851
852	return flags || BX.MSLEFT;
853}
854
855BX.unbindAll = function(el)
856{
857	if (!el)
858		return;
859
860	for (var i=0,len=eventsList.length; i<len; i++)
861	{
862		try
863		{
864			if (eventsList[i] && (null==el || el==eventsList[i].element))
865			{
866				BX.unbind(eventsList[i].element, eventsList[i].event, eventsList[i].fn);
867				eventsList[i] = null;
868			}
869		}
870		catch(e){}
871	}
872
873	if (null==el)
874	{
875		eventsList = [];
876	}
877}
878
879var captured_events = null, _bind = null;
880BX.CaptureEvents = function(el_c, evname_c)
881{
882	if (_bind)
883		return false;
884
885	_bind = BX.bind; captured_events = [];
886
887	BX.bind = function(el, evname, func)
888	{
889		if (el === el_c && evname === evname_c)
890			captured_events.push(func);
891
892		_bind.apply(this, arguments);
893	}
894}
895
896BX.CaptureEventsGet = function()
897{
898	if (_bind)
899	{
900		BX.bind = _bind;
901
902		var captured = captured_events;
903
904		_bind = null; captured_events = null;
905		return captured;
906	}
907}
908
909// Don't even try to use it for submit event!
910BX.fireEvent = function(ob,ev)
911{
912	var result = false;
913	if (BX.type.isDomNode(ob))
914	{
915		result = true;
916		if (document.createEventObject)
917		{
918			// IE
919			if (eventTypes[ev] != 'MouseEvent')
920			{
921				var e = document.createEventObject();
922				e.type = ev;
923				result = ob.fireEvent('on' + ev, e);
924			}
925
926			if (ob[ev])
927			{
928				ob[ev]();
929			}
930		}
931		else
932		{
933			// non-IE
934			var e = null;
935
936			switch (eventTypes[ev])
937			{
938				case 'MouseEvent':
939					e = document.createEvent('MouseEvent');
940					e.initMouseEvent(ev, true, true, top, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null);
941				break;
942				default:
943					e = document.createEvent('Event');
944					e.initEvent(ev, true, true);
945			}
946
947			result = ob.dispatchEvent(e);
948		}
949	}
950
951	return result;
952}
953
954BX.getWheelData = function(e)
955{
956	e = e || window.event;
957	return wheelData = e.detail ? e.detail * -1 : e.wheelDelta / 40;
958}
959
960BX.proxy_context = null;
961
962BX.delegate = function (func, thisObject)
963{
964	if (!func || !thisObject)
965		return func;
966
967	return function() {
968		var cur = BX.proxy_context;
969		BX.proxy_context = this;
970		var res = func.apply(thisObject, arguments);
971		BX.proxy_context = cur;
972		return res;
973	}
974}
975
976BX.delegateLater = function (func_name, thisObject, contextObject)
977{
978	return function()
979	{
980		if (thisObject[func_name])
981		{
982			var cur = BX.proxy_context;
983			BX.proxy_context = this;
984			var res = thisObject[func_name].apply(contextObject||thisObject, arguments);
985			BX.proxy_context = cur;
986			return res;
987		}
988	}
989}
990
991BX._initObjectProxy = function(thisObject)
992{
993	if (typeof thisObject['__proxy_id_' + proxySalt] == 'undefined')
994	{
995		thisObject['__proxy_id_' + proxySalt] = proxyList.length;
996		proxyList[thisObject['__proxy_id_' + proxySalt]] = {};
997	}
998}
999
1000BX.proxy = function(func, thisObject)
1001{
1002	if (!func || !thisObject)
1003		return func;
1004
1005	BX._initObjectProxy(thisObject)
1006
1007	if (typeof func['__proxy_id_' + proxySalt] == 'undefined')
1008		func['__proxy_id_' + proxySalt] = proxyId++;
1009
1010	if (!proxyList[thisObject['__proxy_id_' + proxySalt]][func['__proxy_id_' + proxySalt]])
1011		proxyList[thisObject['__proxy_id_' + proxySalt]][func['__proxy_id_' + proxySalt]] = BX.delegate(func, thisObject);
1012
1013	return proxyList[thisObject['__proxy_id_' + proxySalt]][func['__proxy_id_' + proxySalt]];
1014}
1015
1016BX.defer = function(func, thisObject)
1017{
1018	if (!!thisObject)
1019		return BX.defer_proxy(func, thisObject);
1020	else
1021		return function() {
1022			var arg = arguments;
1023			setTimeout(function(){func.apply(this,arg)}, 10);
1024		};
1025}
1026
1027BX.defer_proxy = function(func, thisObject)
1028{
1029	if (!func || !thisObject)
1030		return func;
1031
1032	var f = BX.proxy(func, thisObject);
1033
1034	this._initObjectProxy(thisObject);
1035
1036	if (typeof func['__defer_id_' + proxySalt] == 'undefined')
1037		func['__defer_id_' + proxySalt] = proxyId++;
1038
1039	if (!proxyList[thisObject['__proxy_id_' + proxySalt]][func['__defer_id_' + proxySalt]])
1040	{
1041		proxyList[thisObject['__proxy_id_' + proxySalt]][func['__defer_id_' + proxySalt]] = BX.defer(BX.delegate(func, thisObject));
1042	}
1043
1044	return proxyList[thisObject['__proxy_id_' + proxySalt]][func['__defer_id_' + proxySalt]];
1045}
1046
1047BX.bindDelegate = function (elem, eventName, isTarget, handler)
1048{
1049	var h = BX.delegateEvent(isTarget, handler);
1050	BX.bind(elem, eventName, h);
1051	return h;
1052}
1053
1054BX.delegateEvent = function(isTarget, handler)
1055{
1056	return function(e)
1057	{
1058		e = e || window.event;
1059		var target = e.target || e.srcElement;
1060
1061		while (target != this)
1062		{
1063			if (_checkNode(target, isTarget))
1064			{
1065				return handler.call(target, e);
1066			}
1067			if (target && target.parentNode)
1068				target = target.parentNode;
1069			else
1070				break;
1071		}
1072	}
1073}
1074
1075BX.False = function() {return false;}
1076BX.DoNothing = function() {}
1077
1078// TODO: also check event handlers set via BX.bind()
1079BX.denyEvent = function(el, ev)
1080{
1081	deniedEvents.push([el, ev, el['on' + ev]]);
1082	el['on' + ev] = BX.DoNothing;
1083}
1084
1085BX.allowEvent = function(el, ev)
1086{
1087	for(var i=0, len=deniedEvents.length; i<len; i++)
1088	{
1089		if (deniedEvents[i][0] == el && deniedEvents[i][1] == ev)
1090		{
1091			el['on' + ev] = deniedEvents[i][2];
1092			BX.util.deleteFromArray(deniedEvents, i);
1093			return;
1094		}
1095	}
1096}
1097
1098BX.fixEventPageXY = function(event)
1099{
1100	BX.fixEventPageX(event);
1101	BX.fixEventPageY(event);
1102	return event;
1103};
1104
1105BX.fixEventPageX = function(event)
1106{
1107	if (event.pageX == null && event.clientX != null)
1108	{
1109		event.pageX =
1110			event.clientX +
1111			(document.documentElement && document.documentElement.scrollLeft || document.body && document.body.scrollLeft || 0) -
1112			(document.documentElement.clientLeft || 0);
1113	}
1114
1115	return event;
1116};
1117
1118BX.fixEventPageY = function(event)
1119{
1120	if (event.pageY == null && event.clientY != null)
1121	{
1122		event.pageY =
1123			event.clientY +
1124			(document.documentElement && document.documentElement.scrollTop || document.body && document.body.scrollTop || 0) -
1125			(document.documentElement.clientTop || 0);
1126	}
1127
1128	return event;
1129};
1130
1131BX.PreventDefault = function(e)
1132{
1133	if(!e) e = window.event;
1134	if(e.stopPropagation)
1135	{
1136		e.preventDefault();
1137		e.stopPropagation();
1138	}
1139	else
1140	{
1141		e.cancelBubble = true;
1142		e.returnValue = false;
1143	}
1144	return false;
1145}
1146
1147BX.eventReturnFalse = function(e)
1148{
1149	e=e||window.event;
1150	if (e && e.preventDefault) e.preventDefault();
1151	else e.returnValue = false;
1152	return false;
1153}
1154
1155BX.eventCancelBubble = function(e)
1156{
1157	e=e||window.event;
1158	if(e && e.stopPropagation)
1159		e.stopPropagation();
1160	else
1161		e.cancelBubble = true;
1162}
1163
1164/* custom events */
1165/*
1166	BX.addCustomEvent(eventObject, eventName, eventHandler) - set custom event handler for particular object
1167	BX.addCustomEvent(eventName, eventHandler) - set custom event handler for all objects
1168*/
1169BX.addCustomEvent = function(eventObject, eventName, eventHandler)
1170{
1171	/* shift parameters for short version */
1172	if (BX.type.isString(eventObject))
1173	{
1174		eventHandler = eventName;
1175		eventName = eventObject;
1176		eventObject = window;
1177	}
1178
1179	eventName = eventName.toUpperCase();
1180
1181	if (!customEvents[eventName])
1182		customEvents[eventName] = [];
1183
1184	customEvents[eventName].push(
1185		{
1186			handler: eventHandler,
1187			obj: eventObject
1188		}
1189	);
1190}
1191
1192BX.removeCustomEvent = function(eventObject, eventName, eventHandler)
1193{
1194	/* shift parameters for short version */
1195	if (BX.type.isString(eventObject))
1196	{
1197		eventHandler = eventName;
1198		eventName = eventObject;
1199		eventObject = window;
1200	}
1201
1202	eventName = eventName.toUpperCase();
1203
1204	if (!customEvents[eventName])
1205		return;
1206
1207	for (var i = 0, l = customEvents[eventName].length; i < l; i++)
1208	{
1209		if (!customEvents[eventName][i])
1210			continue;
1211		if (customEvents[eventName][i].handler == eventHandler && customEvents[eventName][i].obj == eventObject)
1212		{
1213			delete customEvents[eventName][i];
1214			return;
1215		}
1216	}
1217}
1218
1219BX.onCustomEvent = function(eventObject, eventName, arEventParams)
1220{
1221	/* shift parameters for short version */
1222	if (BX.type.isString(eventObject))
1223	{
1224		arEventParams = eventName;
1225		eventName = eventObject;
1226		eventObject = window;
1227	}
1228
1229	eventName = eventName.toUpperCase();
1230
1231	if (!customEvents[eventName])
1232		return;
1233
1234	if (!arEventParams)
1235		arEventParams = [];
1236
1237	var h;
1238	for (var i = 0, l = customEvents[eventName].length; i < l; i++)
1239	{
1240		h = customEvents[eventName][i];
1241		if (!h || !h.handler)
1242			continue;
1243
1244		if (h.obj == window || /*eventObject == window || */h.obj == eventObject) //- only global event handlers will be called
1245		{
1246			h.handler.apply(eventObject, arEventParams);
1247		}
1248	}
1249}
1250
1251BX.parseJSON = function(data, context)
1252{
1253	var result = null;
1254	if (BX.type.isString(data))
1255	{
1256		try {
1257			if (data.indexOf("\n") >= 0)
1258				eval('result = ' + data);
1259			else
1260				result = (new Function("return " + data))();
1261		} catch(e) {
1262			BX.onCustomEvent(context, 'onParseJSONFailure', [data, context])
1263		}
1264	}
1265
1266	return result;
1267}
1268
1269/* ready */
1270BX.isReady = false;
1271BX.ready = function(handler)
1272{
1273	bindReady();
1274
1275	if (!BX.type.isFunction(handler))
1276	{
1277		BX.debug('READY: not a function! ', handler);
1278	}
1279	else
1280	{
1281		if (BX.isReady)
1282			handler.call(document);
1283		else if (readyList)
1284			readyList.push(handler);
1285	}
1286}
1287
1288BX.submit = function(obForm, action_name, action_value, onAfterSubmit)
1289{
1290	action_name = action_name || 'save';
1291	if (!obForm['BXFormSubmit_' + action_name])
1292	{
1293		obForm['BXFormSubmit_' + action_name] = obForm.appendChild(BX.create('INPUT', {
1294			'props': {
1295				'type': 'submit',
1296				'name': action_name,
1297				'value': action_value || 'Y'
1298			},
1299			'style': {
1300				'display': 'none'
1301			}
1302		}));
1303	}
1304
1305	if (obForm.sessid)
1306		obForm.sessid.value = BX.bitrix_sessid();
1307
1308	setTimeout(BX.delegate(function() {BX.fireEvent(this, 'click'); if (onAfterSubmit) onAfterSubmit();}, obForm['BXFormSubmit_' + action_name]), 10);
1309}
1310
1311
1312/* browser detection */
1313BX.browser = {
1314
1315	IsIE: function()
1316	{
1317		return bIE;
1318	},
1319
1320	IsIE6: function()
1321	{
1322		return (/MSIE 6/i.test(navigator.userAgent));
1323	},
1324
1325	IsIE9: function()
1326	{
1327		return !!document.documentMode && document.documentMode >= 9;
1328	},
1329
1330	IsIE10: function()
1331	{
1332		return !!document.documentMode && document.documentMode >= 10;
1333	},
1334
1335	IsOpera: function()
1336	{
1337		return bOpera;
1338	},
1339
1340	IsSafari: function()
1341	{
1342		return bSafari;
1343	},
1344
1345	IsFirefox: function()
1346	{
1347		return bFirefox;
1348	},
1349
1350	IsChrome: function()
1351	{
1352		return bChrome;
1353	},
1354
1355	IsMac: function()
1356	{
1357		return (/Macintosh/i.test(navigator.userAgent));
1358	},
1359
1360	IsAndroid: function()
1361	{
1362		return (/Android/i.test(navigator.userAgent));
1363	},
1364
1365	IsIOS: function()
1366	{
1367		return (/(iPad;)|(iPhone;)/i.test(navigator.userAgent));
1368	},
1369
1370	IsDoctype: function(pDoc)
1371	{
1372		pDoc = pDoc || document;
1373
1374		if (pDoc.compatMode)
1375			return (pDoc.compatMode == "CSS1Compat");
1376
1377		if (pDoc.documentElement && pDoc.documentElement.clientHeight)
1378			return true;
1379
1380		return false;
1381	},
1382
1383	SupportLocalStorage: function()
1384	{
1385		return !!BX.localStorage && !!BX.localStorage.checkBrowser()
1386	},
1387
1388	addGlobalClass: function() {
1389		if (BX.browser.IsIOS())
1390		{
1391			BX.addClass(document.documentElement, 'bx-ios');
1392		}
1393		else if (BX.browser.IsMac())
1394		{
1395			BX.addClass(document.documentElement, 'bx-mac');
1396		}
1397		else if (BX.browser.IsAndroid())
1398		{
1399			BX.addClass(document.documentElement, 'bx-android');
1400		}
1401
1402		if (BX.browser.IsIOS() || BX.browser.IsAndroid())
1403		{
1404			BX.addClass(document.documentElement, 'bx-touch');
1405		}
1406		else
1407		{
1408			BX.addClass(document.documentElement, 'bx-no-touch');
1409		}
1410
1411		if (/AppleWebKit/.test(navigator.userAgent))
1412		{
1413			BX.addClass(document.documentElement, 'bx-chrome');
1414		}
1415		else if (/MSIE 8/.test(navigator.userAgent))
1416		{
1417			BX.addClass(document.documentElement, 'bx-ie bx-ie8'
1418				 + (!BX.browser.IsDoctype() ? ' bx-quirks' : ''));
1419		}
1420		else if (/MSIE 9/.test(navigator.userAgent))
1421		{
1422			BX.addClass(document.documentElement, 'bx-ie bx-ie9'
1423				 + (!BX.browser.IsDoctype() ? ' bx-quirks' : ''));
1424		}
1425		else if (/MSIE 10/.test(navigator.userAgent))
1426		{
1427			// it seems IE10 doesn't have any specific bugs like others event in quirks mode
1428			BX.addClass(document.documentElement, 'bx-ie bx-ie10');
1429		}
1430		else if (/Opera/.test(navigator.userAgent))
1431		{
1432			BX.addClass(document.documentElement, 'bx-opera');
1433		}
1434		else if (/Gecko/.test(navigator.userAgent))
1435		{
1436			BX.addClass(document.documentElement, 'bx-firefox');
1437		}
1438
1439		BX.browser.addGlobalClass = BX.DoNothing;
1440	},
1441
1442	isPropertySupported: function(jsProperty, bReturnCSSName)
1443	{
1444		if (!BX.type.isNotEmptyString(jsProperty))
1445			return false;
1446
1447		var property = jsProperty.indexOf("-") > -1 ? getJsName(jsProperty) : jsProperty;
1448		bReturnCSSName = !!bReturnCSSName;
1449
1450		var ucProperty = property.charAt(0).toUpperCase() + property.slice(1);
1451		var properties = (property + ' ' + ["Webkit", "Moz", "O", "ms"].join(ucProperty + " ") + ucProperty).split(" ");
1452		var obj = document.body || document.documentElement;
1453
1454		for (var i = 0; i < properties.length; i++)
1455		{
1456			var prop = properties[i];
1457			if (obj.style[prop] !== undefined)
1458			{
1459				var prefix = prop == property
1460							? ""
1461							: "-" + prop.substr(0, prop.length - property.length).toLowerCase() + "-";
1462				return bReturnCSSName ? prefix + getCssName(property) : prop;
1463			}
1464		}
1465
1466		function getCssName(propertyName)
1467		{
1468			return propertyName.replace(/([A-Z])/g, function() { return "-" + arguments[1].toLowerCase(); } )
1469		}
1470
1471		function getJsName(cssName)
1472		{
1473			var reg = /(\-([a-z]){1})/g;
1474			if (reg.test(cssName))
1475				return cssName.replace(reg, function () {return arguments[2].toUpperCase();});
1476			else
1477				return cssName;
1478		}
1479
1480		return false;
1481	},
1482
1483	addGlobalFeatures : function(features, prefix)
1484	{
1485		if (!BX.type.isArray(features))
1486			return;
1487
1488		var classNames = [];
1489		for (var i = 0; i < features.length; i++)
1490		{
1491			var support = !!BX.browser.isPropertySupported(features[i]);
1492			classNames.push( "bx-" + (support ? "" : "no-") + features[i].toLowerCase());
1493		}
1494		BX.addClass(document.documentElement, classNames.join(" "));
1495	}
1496}
1497
1498/* low-level fx funcitons*/
1499BX.show = function(ob, displayType)
1500{
1501	if (ob.BXDISPLAY || !_checkDisplay(ob, displayType))
1502	{
1503		ob.style.display = ob.BXDISPLAY;
1504	}
1505}
1506
1507BX.hide = function(ob, displayType)
1508{
1509	if (!ob.BXDISPLAY)
1510		_checkDisplay(ob, displayType);
1511
1512	ob.style.display = 'none';
1513}
1514
1515BX.toggle = function(ob, values)
1516{
1517	if (!values && BX.type.isElementNode(ob))
1518	{
1519		var bShow = true;
1520		if (ob.BXDISPLAY)
1521			bShow = !_checkDisplay(ob);
1522		else
1523			bShow = ob.style.display == 'none';
1524
1525		if (bShow)
1526			BX.show(ob);
1527		else
1528			BX.hide(ob);
1529	}
1530	else if (BX.type.isArray(values))
1531	{
1532		for (var i=0,len=values.length; i<len; i++)
1533		{
1534			if (ob == values[i])
1535			{
1536				ob = values[i==len-1 ? 0 : i+1]
1537				break;
1538			}
1539		}
1540		if (i==len)
1541			ob = values[0];
1542	}
1543
1544	return ob;
1545}
1546
1547/* some useful util functions */
1548
1549BX.util = {
1550	array_values: function(ar)
1551	{
1552		if (!BX.type.isArray(ar))
1553			return BX.util._array_values_ob(ar);
1554		var arv = [];
1555		for(var i=0,l=ar.length;i<l;i++)
1556			if (ar[i] !== null && typeof ar[i] != 'undefined')
1557				arv.push(ar[i]);
1558		return arv;
1559	},
1560
1561	_array_values_ob: function(ar)
1562	{
1563		var arv = [];
1564		for(var i in ar)
1565			if (ar[i] !== null && typeof ar[i] != 'undefined')
1566				arv.push(ar[i]);
1567		return arv;
1568	},
1569
1570	array_keys: function(ar)
1571	{
1572		if (!BX.type.isArray(ar))
1573			return BX.util._array_keys_ob(ar);
1574		var arv = [];
1575		for(var i=0,l=ar.length;i<l;i++)
1576			if (ar[i] !== null && typeof ar[i] != 'undefined')
1577				arv.push(i);
1578		return arv;
1579	},
1580
1581	_array_keys_ob: function(ar)
1582	{
1583		var arv = [];
1584		for(var i in ar)
1585			if (ar[i] !== null && typeof ar[i] != 'undefined')
1586				arv.push(i);
1587		return arv;
1588	},
1589
1590	array_merge: function(first, second)
1591	{
1592		if (!BX.type.isArray(first)) first = [];
1593		if (!BX.type.isArray(second)) second = [];
1594
1595		var i = first.length, j = 0;
1596
1597		if (typeof second.length === "number")
1598		{
1599			for (var l = second.length; j < l; j++)
1600			{
1601				first[i++] = second[j];
1602			}
1603		}
1604		else
1605		{
1606			while (second[j] !== undefined)
1607			{
1608				first[i++] = second[j++];
1609			}
1610		}
1611
1612		first.length = i;
1613
1614		return first;
1615	},
1616
1617	array_unique: function(ar)
1618	{
1619		var i=0,j,len=ar.length;
1620		if(len<2) return ar;
1621
1622		for (; i<len-1;i++)
1623		{
1624			for (j=i+1; j<len;j++)
1625			{
1626				if (ar[i]==ar[j])
1627				{
1628					ar.splice(j--,1); len--;
1629				}
1630			}
1631		}
1632
1633		return ar;
1634	},
1635
1636	in_array: function(needle, haystack)
1637	{
1638		for(var i=0; i<haystack.length; i++)
1639		{
1640			if(haystack[i] == needle)
1641				return true;
1642		}
1643		return false;
1644	},
1645
1646	array_search: function(needle, haystack)
1647	{
1648		for(var i=0; i<haystack.length; i++)
1649		{
1650			if(haystack[i] == needle)
1651				return i;
1652		}
1653		return -1;
1654	},
1655
1656	object_search_key: function(needle, haystack)
1657	{
1658		if (haystack[needle])
1659			return haystack[needle];
1660
1661		for(var i in haystack)
1662		{
1663			if (typeof haystack[i] == "object")
1664			{
1665				var result = BX.util.object_search_key(needle, haystack[i]);
1666				if (result !== false)
1667					return result;
1668			}
1669		}
1670		return false;
1671	},
1672
1673	trim: function(s)
1674	{
1675		if (BX.type.isString(s))
1676			return s.replace(r.ltrim, '').replace(r.rtrim, '');
1677		else
1678			return s;
1679	},
1680
1681	urlencode: function(s){return encodeURIComponent(s);},
1682
1683	// it may also be useful. via sVD.
1684	deleteFromArray: function(ar, ind) {return ar.slice(0, ind).concat(ar.slice(ind + 1));},
1685	insertIntoArray: function(ar, ind, el) {return ar.slice(0, ind).concat([el]).concat(ar.slice(ind));},
1686
1687	htmlspecialchars: function(str)
1688	{
1689		if(!str.replace) return str;
1690
1691		return str.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
1692	},
1693
1694	htmlspecialcharsback: function(str)
1695	{
1696		if(!str.replace) return str;
1697
1698		return str.replace(/\&quot;/g, '"').replace(/&#39;/g, "'").replace(/\&lt;/g, '<').replace(/\&gt;/g, '>').replace(/\&amp;/g, '&');
1699	},
1700
1701	// Quote regular expression characters plus an optional character
1702	preg_quote: function(str, delimiter)
1703	{
1704		if(!str.replace)
1705			return str;
1706		return str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&');
1707	},
1708
1709	jsencode: function(str)
1710	{
1711		if (!str || !str.replace)
1712			return str;
1713
1714		var escapes =
1715		[
1716			{ c: "\\\\", r: "\\\\" }, // should be first
1717			{ c: "\\t", r: "\\t" },
1718			{ c: "\\n", r: "\\n" },
1719			{ c: "\\r", r: "\\r" },
1720			{ c: "\"", r: "\\\"" },
1721			{ c: "'", r: "\\'" },
1722			{ c: "<", r: "\\x3C" },
1723			{ c: ">", r: "\\x3E" },
1724			{ c: "\\u2028", r: "\\u2028" },
1725			{ c: "\\u2029", r: "\\u2029" }
1726		];
1727		for (var i = 0; i < escapes.length; i++)
1728			str = str.replace(new RegExp(escapes[i].c, 'g'), escapes[i].r);
1729		return str;
1730	},
1731
1732	str_pad: function(input, pad_length, pad_string, pad_type)
1733	{
1734		pad_string = pad_string || ' ';
1735		pad_type = pad_type || 'right';
1736		input = input.toString();
1737
1738		if (pad_type == 'left')
1739			return BX.util.str_pad_left(input, pad_length, pad_string);
1740		else
1741			return BX.util.str_pad_right(input, pad_length, pad_string);
1742
1743	},
1744
1745	str_pad_left: function(input, pad_length, pad_string)
1746	{
1747		var i = input.length, q=pad_string.length;
1748		if (i >= pad_length) return input;
1749
1750		for(;i<pad_length;i+=q)
1751			input = pad_string + input;
1752
1753		return input;
1754	},
1755
1756	str_pad_right: function(input, pad_length, pad_string)
1757	{
1758		var i = input.length, q=pad_string.length;
1759		if (i >= pad_length) return input;
1760
1761		for(;i<pad_length;i+=q)
1762			input += pad_string;
1763
1764		return input;
1765	},
1766
1767	strip_tags: function(str)
1768	{
1769		return str.split(/<[^>]+>/g).join('')
1770	},
1771
1772	popup: function(url, width, height)
1773	{
1774		var w, h;
1775		if(BX.browser.IsOpera())
1776		{
1777			w = document.body.offsetWidth;
1778			h = document.body.offsetHeight;
1779		}
1780		else
1781		{
1782			w = screen.width;
1783			h = screen.height;
1784		}
1785		return 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));
1786	},
1787
1788	// BX.util.objectSort(object, sortBy, sortDir) - Sort object by property
1789	// function params: 1 - object for sort, 2 - sort by property, 3 - sort direction (asc/desc)
1790	// return: sort array [[objectElement], [objectElement]] in sortDir direction
1791
1792	// example: BX.util.objectSortBy({'L1': {'name': 'Last'}, 'F1': {'name': 'First'}}, 'name', 'asc');
1793	// return: [{'name' : 'First'}, {'name' : 'Last'}]
1794	objectSort: function(object, sortBy, sortDir)
1795	{
1796		sortDir = sortDir == 'asc'? 'asc': 'desc';
1797
1798		var arItems = Array();
1799		for (var i in object)
1800			if (object[i][sortBy])
1801				arItems.push([i, object[i][sortBy]]);
1802
1803		if (sortDir == 'asc')
1804		{
1805			arItems.sort(function(i, ii) {
1806				if (!isNaN(i[1]) && !isNaN(ii[1]))
1807				{
1808					var s1 = parseInt(i[1]); var s2 = parseInt(ii[1]);
1809				}
1810				else
1811				{
1812					var s1 = i[1].toString().toLowerCase(); var s2 = ii[1].toString().toLowerCase();
1813				}
1814				if (s1 > s2) return 1; else if (s1 < s2) return -1; else return 0;
1815			});
1816		}
1817		else
1818		{
1819			arItems.sort(function(i, ii) {
1820				if (!isNaN(i[1]) && !isNaN(ii[1]))
1821				{
1822					var s1 = parseInt(i[1]);
1823					var s2 = parseInt(ii[1]);
1824				}
1825				else
1826				{
1827					var s1 = i[1].toString().toLowerCase();
1828					var s2 = ii[1].toString().toLowerCase();
1829				}
1830				if (s1 < s2) return 1; else if (s1 > s2) return -1; else return 0;
1831			});
1832		}
1833
1834		var arReturnArray = Array();
1835		for (var i = 0; i < arItems.length; i++)
1836			arReturnArray.push(object[arItems[i][0]]);
1837
1838		return arReturnArray;
1839	},
1840
1841	// #fdf9e5 => {r=253, g=249, b=229}
1842	hex2rgb: function(color)
1843	{
1844		var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g);
1845		for (var i=0;  i<3; i++)
1846		{
1847			rgb[i] = parseInt(rgb[i], 16);
1848		}
1849		return {'r':rgb[0],'g':rgb[1],'b':rgb[2]};
1850	},
1851
1852	remove_url_param: function(url, param)
1853	{
1854		if (BX.type.isArray(param))
1855		{
1856			for (var i=0; i<param.length; i++)
1857				url = BX.util.remove_url_param(url, param[i])
1858		}
1859		else
1860		{
1861			url = url.replace(new RegExp('([?&])'+param+'=[^&]*[&]*', 'i'), '$1');
1862		}
1863
1864		return url;
1865	},
1866
1867	even: function(digit)
1868	{
1869		return (parseInt(digit) % 2 == 0)? true: false;
1870	}
1871}
1872
1873BX.type = {
1874	isString: function(item) {
1875		return item === '' ? true : (item ? (typeof (item) == "string" || item instanceof String) : false);
1876	},
1877	isNotEmptyString: function(item) {
1878		return BX.type.isString(item) ? item.length > 0 : false;
1879	},
1880	isBoolean: function(item) {
1881		return item === true || item === false;
1882	},
1883	isNumber: function(item) {
1884		return item === 0 ? true : (item ? (typeof (item) == "number" || item instanceof Number) : false);
1885	},
1886	isFunction: function(item) {
1887		return item === null ? false : (typeof (item) == "function" || item instanceof Function);
1888	},
1889	isElementNode: function(item) {
1890		//document.body.ELEMENT_NODE;
1891		return item && typeof (item) == "object" && "nodeType" in item && item.nodeType == 1 && item.tagName && item.tagName.toUpperCase() != 'SCRIPT' && item.tagName.toUpperCase() != 'STYLE' && item.tagName.toUpperCase() != 'LINK';
1892	},
1893	isDomNode: function(item) {
1894		return item && typeof (item) == "object" && "nodeType" in item;
1895	},
1896	isArray: function(item) {
1897		return item && Object.prototype.toString.call(item) == "[object Array]";
1898	},
1899	isDate : function(item) {
1900		return item && Object.prototype.toString.call(item) == "[object Date]";
1901	}
1902}
1903
1904BX.isNodeInDom = function(node)
1905{
1906	return node === document ? true :
1907		(node.parentNode ? BX.isNodeInDom(node.parentNode) : false);
1908}
1909
1910BX.isNodeHidden = function(node)
1911{
1912	if (node === document)
1913		return false;
1914	else if (BX.style(node, 'display') == 'none')
1915		return true;
1916	else
1917		return (node.parentNode ? BX.isNodeHidden(node.parentNode) : true);
1918}
1919
1920BX.evalPack = function(code)
1921{
1922	while (code.length > 0)
1923	{
1924		var c = code.shift();
1925
1926		if (c.TYPE == 'SCRIPT_EXT' || c.TYPE == 'SCRIPT_SRC')
1927		{
1928			BX.loadScript(c.DATA, function() {BX.evalPack(code)});
1929		}
1930		else if (c.TYPE == 'SCRIPT')
1931			BX.evalGlobal(c.DATA);
1932	}
1933}
1934
1935BX.evalGlobal = function(data)
1936{
1937	if (data)
1938	{
1939		var head = document.getElementsByTagName("head")[0] || document.documentElement,
1940			script = document.createElement("script");
1941
1942		script.type = "text/javascript";
1943
1944		if (!BX.browser.IsIE())
1945		{
1946			script.appendChild(document.createTextNode(data));
1947		}
1948		else
1949		{
1950			script.text = data;
1951		}
1952
1953		head.insertBefore(script, head.firstChild);
1954		head.removeChild(script);
1955	}
1956}
1957
1958BX.processHTML = function(HTML, scriptsRunFirst)
1959{
1960	var matchScript, scripts = [], styles = [], data = HTML;
1961
1962	while ((matchScript = data.match(r.script)) !== null)
1963	{
1964		var end = data.search(/<\/script>/i);
1965		if (end == -1)
1966			break;
1967
1968		var bRunFirst = scriptsRunFirst || (matchScript[1].indexOf('bxrunfirst') != '-1');
1969
1970		var matchSrc;
1971		if ((matchSrc = matchScript[1].match(r.script_src)) !== null)
1972			scripts.push({"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]});
1973		else
1974		{
1975			var start = matchScript.index + matchScript[0].length;
1976			var js = data.substr(start, end-start);
1977
1978			scripts.push({"bRunFirst": bRunFirst, "isInternal": true, "JS": js});
1979		}
1980
1981		data = data.substr(0, matchScript.index) + data.substr(end+9);
1982	}
1983
1984	while ((matchStyle = data.match(r.style)) !== null)
1985	{
1986		var matchHref;
1987		if ((matchHref = matchStyle[0].match(r.style_href)) !== null && matchStyle[0].indexOf('media="') < 0)
1988		{
1989			styles.push(matchHref[1]);
1990		}
1991		data = data.replace(matchStyle[0], '');
1992	}
1993
1994	return {'HTML': data, 'SCRIPT': scripts, 'STYLE': styles};
1995}
1996
1997BX.garbage = function(call, thisObject)
1998{
1999	garbageCollectors.push({callback: call, context: thisObject});
2000}
2001
2002/* window pos functions */
2003
2004BX.GetDocElement = function (pDoc)
2005{
2006	pDoc = pDoc || document;
2007	return (BX.browser.IsDoctype(pDoc) ? pDoc.documentElement : pDoc.body);
2008}
2009
2010BX.GetContext = function(node)
2011{
2012	if (BX.type.isElementNode(node))
2013		return node.ownerDocument.parentWindow || node.ownerDocument.defaultView || window;
2014	else if (BX.type.isDomNode(node))
2015		return node.parentWindow || node.defaultView || window;
2016	else
2017		return window;
2018}
2019
2020BX.GetWindowInnerSize = function(pDoc)
2021{
2022	var width, height;
2023
2024	pDoc = pDoc || document;
2025
2026	if (self.innerHeight) // all except Explorer
2027	{
2028		width = BX.GetContext(pDoc).innerWidth;
2029		height = BX.GetContext(pDoc).innerHeight;
2030	}
2031	else if (pDoc.documentElement && (pDoc.documentElement.clientHeight || pDoc.documentElement.clientWidth)) // Explorer 6 Strict Mode
2032	{
2033		width = pDoc.documentElement.clientWidth;
2034		height = pDoc.documentElement.clientHeight;
2035	}
2036	else if (pDoc.body) // other Explorers
2037	{
2038		width = pDoc.body.clientWidth;
2039		height = pDoc.body.clientHeight;
2040	}
2041	return {innerWidth : width, innerHeight : height};
2042}
2043
2044BX.GetWindowScrollPos = function(pDoc)
2045{
2046	var left, top;
2047
2048	pDoc = pDoc || document;
2049
2050	if (self.pageYOffset) // all except Explorer
2051	{
2052		left = BX.GetContext(pDoc).pageXOffset;
2053		top = BX.GetContext(pDoc).pageYOffset;
2054	}
2055	else if (pDoc.documentElement && (pDoc.documentElement.scrollTop || pDoc.documentElement.scrollLeft)) // Explorer 6 Strict
2056	{
2057		left = pDoc.documentElement.scrollLeft;
2058		top = pDoc.documentElement.scrollTop;
2059	}
2060	else if (pDoc.body) // all other Explorers
2061	{
2062		left = pDoc.body.scrollLeft;
2063		top = pDoc.body.scrollTop;
2064	}
2065	return {scrollLeft : left, scrollTop : top};
2066}
2067
2068BX.GetWindowScrollSize = function(pDoc)
2069{
2070	var width, height;
2071	if (!pDoc)
2072		pDoc = document;
2073
2074	if ( (pDoc.compatMode && pDoc.compatMode == "CSS1Compat"))
2075	{
2076		width = pDoc.documentElement.scrollWidth;
2077		height = pDoc.documentElement.scrollHeight;
2078	}
2079	else
2080	{
2081		if (pDoc.body.scrollHeight > pDoc.body.offsetHeight)
2082			height = pDoc.body.scrollHeight;
2083		else
2084			height = pDoc.body.offsetHeight;
2085
2086		if (pDoc.body.scrollWidth > pDoc.body.offsetWidth ||
2087			(pDoc.compatMode && pDoc.compatMode == "BackCompat") ||
2088			(pDoc.documentElement && !pDoc.documentElement.clientWidth)
2089		)
2090			width = pDoc.body.scrollWidth;
2091		else
2092			width = pDoc.body.offsetWidth;
2093	}
2094	return {scrollWidth : width, scrollHeight : height};
2095}
2096
2097BX.GetWindowSize = function(pDoc)
2098{
2099	var innerSize = this.GetWindowInnerSize(pDoc);
2100	var scrollPos = this.GetWindowScrollPos(pDoc);
2101	var scrollSize = this.GetWindowScrollSize(pDoc);
2102
2103	return  {
2104		innerWidth : innerSize.innerWidth, innerHeight : innerSize.innerHeight,
2105		scrollLeft : scrollPos.scrollLeft, scrollTop : scrollPos.scrollTop,
2106		scrollWidth : scrollSize.scrollWidth, scrollHeight : scrollSize.scrollHeight
2107	};
2108}
2109
2110BX.hide_object = function(ob)
2111{
2112	ob = BX(ob);
2113	ob.style.position = 'absolute';
2114	ob.style.top = '-1000px';
2115	ob.style.left = '-1000px';
2116	ob.style.height = '10px';
2117	ob.style.width = '10px';
2118};
2119
2120BX.is_relative = function(el)
2121{
2122	var p = BX.style(el, 'position');
2123	return p == 'relative' || p == 'absolute';
2124}
2125
2126BX.is_float = function(el)
2127{
2128	var p = BX.style(el, 'float');
2129	return p == 'right' || p == 'left';
2130}
2131
2132BX.is_fixed = function(el)
2133{
2134	var p = BX.style(el, 'position');
2135	return p == 'fixed';
2136}
2137
2138BX.pos = function(el, bRelative)
2139{
2140	var r = { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
2141	bRelative = !!bRelative;
2142	if (!el)
2143		return r;
2144	if (typeof (el.getBoundingClientRect) != "undefined" && el.ownerDocument == document && !bRelative)
2145	{
2146		var clientRect = el.getBoundingClientRect();
2147		var root = document.documentElement;
2148		var body = document.body;
2149
2150		r.top = clientRect.top + (root.scrollTop || body.scrollTop);
2151		r.left = clientRect.left + (root.scrollLeft || body.scrollLeft);
2152		r.width = clientRect.right - clientRect.left;
2153		r.height = clientRect.bottom - clientRect.top;
2154		r.right = clientRect.right + (root.scrollLeft || body.scrollLeft);
2155		r.bottom = clientRect.bottom + (root.scrollTop || body.scrollTop);
2156	}
2157	else
2158	{
2159		var x = 0, y = 0, w = el.offsetWidth, h = el.offsetHeight;
2160		var first = true;
2161		for (; el != null; el = el.offsetParent)
2162		{
2163			if (!first && bRelative && BX.is_relative(el))
2164				break;
2165
2166			x += el.offsetLeft;
2167			y += el.offsetTop;
2168			if (first)
2169			{
2170				first = false;
2171				continue;
2172			}
2173
2174			var elBorderLeftWidth = parseInt(BX.style(el, 'border-left-width')),
2175				elBorderTopWidth = parseInt(BX.style(el, 'border-top-width'));
2176
2177			if (!isNaN(elBorderLeftWidth) && elBorderLeftWidth > 0)
2178				x += elBorderLeftWidth;
2179			if (!isNaN(elBorderTopWidth) && elBorderTopWidth > 0)
2180				y += elBorderTopWidth;
2181		}
2182
2183		r.top = y;
2184		r.left = x;
2185		r.width = w;
2186		r.height = h;
2187		r.right = r.left + w;
2188		r.bottom = r.top + h;
2189	}
2190
2191	for (var i in r) r[i] = parseInt(r[i]);
2192
2193	return r;
2194}
2195
2196
2197BX.align = function(pos, w, h, type)
2198{
2199	if (type)
2200		type = type.toLowerCase();
2201	else
2202		type = '';
2203
2204	var pDoc = document;
2205	if (BX.type.isElementNode(pos))
2206	{
2207		pDoc = pos.ownerDocument;
2208		pos = BX.pos(pos);
2209	}
2210
2211	var x = pos["left"], y = pos["bottom"];
2212
2213	var scroll = BX.GetWindowScrollPos(pDoc);
2214	var size = BX.GetWindowInnerSize(pDoc);
2215
2216	if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0)
2217	{
2218		if(pos["right"] - w >= 0 )
2219			x = pos["right"] - w;
2220		else
2221			x = scroll.scrollLeft;
2222	}
2223
2224	if(((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0) || ~type.indexOf('top'))
2225	{
2226		if(pos["top"] - h >= 0 || ~type.indexOf('top'))
2227			y = pos["top"] - h;
2228		else
2229			y = scroll.scrollTop;
2230	}
2231
2232	return {'left':x, 'top':y};
2233}
2234
2235BX.scrollToNode = function(node)
2236{
2237	var obNode = BX(node);
2238
2239	if (obNode.scrollIntoView)
2240		obNode.scrollIntoView(true);
2241	else
2242	{
2243		var arNodePos = BX.pos(obNode);
2244		window.scrollTo(arNodePos.left, arNodePos.top);
2245	}
2246}
2247
2248/* non-xhr loadings */
2249BX.showWait = function(node, msg)
2250{
2251	node = BX(node) || document.body || document.documentElement;
2252	msg = msg || BX.message('JS_CORE_LOADING');
2253
2254	var container_id = node.id || Math.random();
2255
2256	var obMsg = node.bxmsg = document.body.appendChild(BX.create('DIV', {
2257		props: {
2258			id: 'wait_' + container_id,
2259			className: 'bx-core-waitwindow'
2260		},
2261		text: msg
2262	}));
2263
2264	setTimeout(BX.delegate(_adjustWait, node), 10);
2265
2266	lastWait[lastWait.length] = obMsg;
2267	return obMsg;
2268}
2269
2270BX.closeWait = function(node, obMsg)
2271{
2272	if(node && !obMsg)
2273		obMsg = node.bxmsg;
2274	if(node && !obMsg && BX.hasClass(node, 'bx-core-waitwindow'))
2275		obMsg = node;
2276	if(node && !obMsg)
2277		obMsg = BX('wait_' + node.id);
2278	if(!obMsg)
2279		obMsg = lastWait.pop();
2280
2281	if (obMsg && obMsg.parentNode)
2282	{
2283		for (var i=0,len=lastWait.length;i<len;i++)
2284		{
2285			if (obMsg == lastWait[i])
2286			{
2287				lastWait = BX.util.deleteFromArray(lastWait, i);
2288				break;
2289			}
2290		}
2291
2292		obMsg.parentNode.removeChild(obMsg);
2293		if (node) node.bxmsg = null;
2294		BX.cleanNode(obMsg, true);
2295	}
2296}
2297
2298BX.setKernelJS = function(scripts)
2299{
2300	if (BX.type.isArray(scripts))
2301		arKernelJS = scripts;
2302}
2303
2304BX.getKernelJS = function()
2305{
2306	return arKernelJS;
2307}
2308
2309BX.loadScript = function(script, callback, doc)
2310{
2311	if (!BX.isReady)
2312	{
2313		var _args = arguments;
2314		BX.ready(function() {
2315			BX.loadScript.apply(this, _args);
2316		});
2317		return;
2318	}
2319
2320	doc = doc || document;
2321
2322	if (BX.type.isString(script))
2323		script = [script];
2324	var _callback = function()
2325	{
2326		return (callback && BX.type.isFunction(callback)) ? callback() : null
2327	}
2328	var load_js = function(ind)
2329	{
2330		if(ind >= script.length)
2331			return _callback();
2332
2333		if(!!script[ind])
2334		{
2335			var oHead = doc.getElementsByTagName("head")[0] || doc.documentElement;
2336			var oScript = doc.createElement('script');
2337			oScript.src = script[ind];
2338
2339			var verInd = script[ind].indexOf('.js?');
2340			if(verInd>0)
2341				fileSrc = script[ind].substr(0, verInd + 3);
2342			else
2343				fileSrc = script[ind];
2344
2345			if(_isScriptLoaded(fileSrc))
2346			{
2347				load_js(++ind);
2348			}
2349			else
2350			{
2351				var bLoaded = false;
2352				oScript.onload = oScript.onreadystatechange = function()
2353				{
2354					if (!bLoaded && (!oScript.readyState || oScript.readyState == "loaded" || oScript.readyState == "complete"))
2355					{
2356						bLoaded = true;
2357						setTimeout(function (){load_js(++ind);}, 50);
2358
2359						oScript.onload = oScript.onreadystatechange = null;
2360						if (oHead && oScript.parentNode)
2361						{
2362							oHead.removeChild(oScript);
2363						}
2364					}
2365				}
2366
2367				return oHead.insertBefore(oScript, oHead.firstChild);
2368			}
2369		}
2370		else
2371		{
2372			load_js(++ind);
2373		}
2374	}
2375
2376	load_js(0);
2377}
2378
2379BX.loadCSS = function(arCSS, doc, win)
2380{
2381	if (!BX.isReady)
2382	{
2383		var _args = arguments;
2384		BX.ready(function() {
2385			BX.loadCSS.apply(this, _args);
2386		});
2387		return null;
2388	}
2389
2390	if (BX.type.isString(arCSS))
2391	{
2392		var bSingle = true;
2393		arCSS = [arCSS];
2394	}
2395	var i = 0,
2396		l = arCSS.length,
2397		lnk = null,
2398		pLnk = [];
2399
2400	if (l == 0)
2401		return null;
2402
2403	doc = doc || document;
2404	win = win || window;
2405
2406	_checkCssList();
2407
2408	if (!win.bxhead)
2409	{
2410		var heads = doc.getElementsByTagName('HEAD');
2411		win.bxhead = heads[0];
2412
2413		if (!win.bxhead)
2414		{
2415			return null;
2416		}
2417	}
2418
2419	for (i = 0; i < l; i++)
2420	{
2421		var _check = arCSS[i]
2422				.replace(/\.css(\?\d*)/, '.css')
2423				.replace(/^(http[s]*:)*\/\/[^\/]+/i, '');
2424
2425		if (BX.util.in_array(_check, cssList))
2426			continue;
2427
2428		lnk = document.createElement('LINK');
2429		lnk.href = arCSS[i];
2430		lnk.rel = 'stylesheet';
2431		lnk.type = 'text/css';
2432		win.bxhead.appendChild(lnk);
2433
2434		pLnk.push(lnk);
2435		cssList.push(_check);
2436	}
2437
2438	if (bSingle)
2439		return lnk;
2440
2441	return pLnk;
2442}
2443
2444BX.reload = function(back_url, bAddClearCache)
2445{
2446	if (back_url === true)
2447	{
2448		bAddClearCache = true;
2449		back_url = null;
2450	}
2451
2452	var new_href = back_url || top.location.href;
2453
2454	var hashpos = new_href.indexOf('#'), hash = '';
2455
2456	if (hashpos != -1)
2457	{
2458		hash = new_href.substr(hashpos);
2459		new_href = new_href.substr(0, hashpos);
2460	}
2461
2462	if (bAddClearCache && new_href.indexOf('clear_cache=Y') < 0)
2463		new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + 'clear_cache=Y';
2464
2465	if (hash)
2466	{
2467		// hack for clearing cache in ajax mode components with history emulation
2468		if (bAddClearCache && (hash.substr(0, 5) == 'view/' || hash.substr(0, 6) == '#view/') && hash.indexOf('clear_cache%3DY') < 0)
2469			hash += (hash.indexOf('%3F') == -1 ? '%3F' : '%26') + 'clear_cache%3DY'
2470
2471		new_href = new_href.replace(/(\?|\&)_r=[\d]*/, '');
2472		new_href += (new_href.indexOf('?') == -1 ? '?' : '&') + '_r='+Math.round(Math.random()*10000) + hash;
2473	}
2474
2475	top.location.href = new_href;
2476}
2477
2478BX.clearCache = function()
2479{
2480	BX.showWait();
2481	BX.reload(true);
2482}
2483
2484BX.template = function(tpl, callback, bKillTpl)
2485{
2486	BX.ready(function() {
2487		_processTpl(BX(tpl), callback, bKillTpl);
2488	});
2489}
2490
2491BX.isAmPmMode = function()
2492{
2493	return BX.message('FORMAT_DATETIME').match('T') == null ? false : true;
2494}
2495
2496BX.formatDate = function(date, format)
2497{
2498	date = date || new Date();
2499
2500	var bTime = date.getHours() || date.getMinutes() || date.getSeconds(),
2501		str = !!format
2502			? format :
2503			(bTime ? BX.message('FORMAT_DATETIME') : BX.message('FORMAT_DATE')
2504		);
2505
2506	return str.replace(/YYYY/ig, date.getFullYear())
2507		.replace(/MMMM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0'))
2508		.replace(/MM/ig, BX.util.str_pad_left((date.getMonth()+1).toString(), 2, '0'))
2509		.replace(/DD/ig, BX.util.str_pad_left(date.getDate().toString(), 2, '0'))
2510		.replace(/HH/ig, BX.util.str_pad_left(date.getHours().toString(), 2, '0'))
2511		.replace(/MI/ig, BX.util.str_pad_left(date.getMinutes().toString(), 2, '0'))
2512		.replace(/SS/ig, BX.util.str_pad_left(date.getSeconds().toString(), 2, '0'));
2513}
2514
2515BX.getNumMonth = function(month)
2516{
2517	var wordMonthCut = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
2518	var wordMonth = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'];
2519
2520	var q = month.toUpperCase();
2521	for (i = 1; i <= 12; i++)
2522	{
2523		if (q == BX.message('MON_'+i).toUpperCase() || q == BX.message('MONTH_'+i).toUpperCase() || q == wordMonthCut[i-1].toUpperCase() || q == wordMonth[i-1].toUpperCase())
2524		{
2525			return i;
2526		}
2527	}
2528	return month;
2529}
2530
2531BX.parseDate = function(str)
2532{
2533	if (BX.type.isNotEmptyString(str))
2534	{
2535		var regMonths = '';
2536		for (i = 1; i <= 12; i++)
2537		{
2538			regMonths = regMonths + '|' + BX.message('MON_'+i);
2539		}
2540
2541		var expr = new RegExp('([0-9]+|[a-z]+' + regMonths + ')', 'ig');
2542		var aDate = str.match(expr),
2543			aFormat = BX.message('FORMAT_DATE').match(/(DD|MI|MMMM|MM|M|YYYY)/ig),
2544			i, cnt,
2545			aDateArgs=[], aFormatArgs=[],
2546			aResult={};
2547
2548		if (!aDate)
2549			return null;
2550
2551		if(aDate.length > aFormat.length)
2552		{
2553			aFormat = BX.message('FORMAT_DATETIME').match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/ig);
2554		}
2555
2556		for(i = 0, cnt = aDate.length; i < cnt; i++)
2557		{
2558			if(BX.util.trim(aDate[i]) != '')
2559			{
2560				aDateArgs[aDateArgs.length] = aDate[i];
2561			}
2562		}
2563
2564		for(i = 0, cnt = aFormat.length; i < cnt; i++)
2565		{
2566			if(BX.util.trim(aFormat[i]) != '')
2567			{
2568				aFormatArgs[aFormatArgs.length] = aFormat[i];
2569			}
2570		}
2571
2572
2573		var m = BX.util.array_search('MMMM', aFormatArgs)
2574		if (m > 0)
2575		{
2576			aDateArgs[m] = BX.getNumMonth(aDateArgs[m]);
2577			aFormatArgs[m] = "MM";
2578		}
2579		else
2580		{
2581			m = BX.util.array_search('M', aFormatArgs)
2582			if (m > 0)
2583			{
2584				aDateArgs[m] = BX.getNumMonth(aDateArgs[m]);
2585				aFormatArgs[m] = "MM";
2586			}
2587		}
2588
2589		for(i = 0, cnt = aFormatArgs.length; i < cnt; i++)
2590		{
2591			var k = aFormatArgs[i].toUpperCase();
2592			aResult[k] = k == 'T' || k == 'TT' ? aDateArgs[i] : parseInt(aDateArgs[i], 10);
2593		}
2594
2595		if(aResult['DD'] > 0 && aResult['MM'] > 0 && aResult['YYYY'] > 0)
2596		{
2597			var d = new Date();
2598			d.setDate(1);
2599			d.setFullYear(aResult['YYYY']);
2600			d.setMonth(aResult['MM']-1);
2601			d.setDate(aResult['DD']);
2602			d.setHours(0, 0, 0);
2603
2604			if(
2605				(!isNaN(aResult['HH']) || !isNaN(aResult['GG']) || !isNaN(aResult['H']) || !isNaN(aResult['G']))
2606					&& !isNaN(aResult['MI'])
2607			)
2608			{
2609				if (!isNaN(aResult['H']) || !isNaN(aResult['G']))
2610				{
2611					var bPM = (aResult['T']||aResult['TT']||'am').toUpperCase()=='PM';
2612					aResult['HH'] = parseInt(aResult['H']||aResult['G']||0, 10) + (bPM ? 12 : 0);
2613				}
2614				else
2615				{
2616					aResult['HH'] = parseInt(aResult['HH']||aResult['GG']||0, 10);
2617				}
2618
2619				if (isNaN(aResult['SS']))
2620					aResult['SS'] = 00;
2621
2622				d.setHours(aResult['HH'], aResult['MI'], aResult['SS']);
2623			}
2624
2625			return d;
2626		}
2627	}
2628
2629	return null;
2630}
2631
2632BX.selectUtils =
2633{
2634	addNewOption: function(oSelect, opt_value, opt_name, do_sort, check_unique)
2635	{
2636		oSelect = BX(oSelect);
2637		if(oSelect)
2638		{
2639			var n = oSelect.length;
2640			if(check_unique !== false)
2641			{
2642				for(var i=0;i<n;i++)
2643				{
2644					if(oSelect[i].value==opt_value)
2645					{
2646						return;
2647					}
2648				}
2649			}
2650
2651			var newoption = new Option(opt_name, opt_value, false, false);
2652			oSelect.options[n]=newoption;
2653		}
2654
2655		if(do_sort === true)
2656		{
2657			this.sortSelect(select_id);
2658		}
2659	},
2660
2661	deleteOption: function(oSelect, opt_value)
2662	{
2663		oSelect = BX(oSelect);
2664		if(oSelect)
2665		{
2666			for(var i=0;i<oSelect.length;i++)
2667			{
2668				if(oSelect[i].value==opt_value)
2669				{
2670					oSelect.remove(i);
2671					break;
2672				}
2673			}
2674		}
2675	},
2676
2677	deleteSelectedOptions: function(select_id)
2678	{
2679		var oSelect = BX(select_id);
2680		if(oSelect)
2681		{
2682			var i=0;
2683			while(i<oSelect.length)
2684			{
2685				if(oSelect[i].selected)
2686				{
2687					oSelect[i].selected=false;
2688					oSelect.remove(i);
2689				}
2690				else
2691				{
2692					i++;
2693				}
2694			}
2695		}
2696	},
2697
2698	deleteAllOptions: function(oSelect)
2699	{
2700		oSelect = BX(oSelect);
2701		if(oSelect)
2702		{
2703			for(var i=oSelect.length-1; i>=0; i--)
2704			{
2705				oSelect.remove(i);
2706			}
2707		}
2708	},
2709
2710	optionCompare: function(record1, record2)
2711	{
2712		var value1 = record1.optText.toLowerCase();
2713		var value2 = record2.optText.toLowerCase();
2714		if (value1 > value2) return(1);
2715		if (value1 < value2) return(-1);
2716		return(0);
2717	},
2718
2719	sortSelect: function(oSelect)
2720	{
2721		oSelect = BX(select_id);
2722		if(oSelect)
2723		{
2724			var myOptions = [];
2725			var n = oSelect.options.length;
2726			for (var i=0;i<n;i++)
2727			{
2728				myOptions[i] = {
2729					optText:oSelect[i].text,
2730					optValue:oSelect[i].value
2731				};
2732			}
2733			myOptions.sort(this.optionCompare);
2734			oSelect.length=0;
2735			n = myOptions.length;
2736			for(var i=0;i<n;i++)
2737			{
2738				var newoption = new Option(myOptions[i].optText, myOptions[i].optValue, false, false);
2739				oSelect[i]=newoption;
2740			}
2741		}
2742	},
2743
2744	selectAllOptions: function(oSelect)
2745	{
2746		oSelect = BX(select_id);
2747		if(oSelect)
2748		{
2749			var n = oSelect.length;
2750			for(var i=0;i<n;i++)
2751			{
2752				oSelect[i].selected=true;
2753			}
2754		}
2755	},
2756
2757	selectOption: function(oSelect, opt_value)
2758	{
2759		oSelect = BX(select_id);
2760		if(oSelect)
2761		{
2762			var n = oSelect.length;
2763			for(var i=0;i<n;i++)
2764			{
2765				oSelect[i].selected = (oSelect[i].value == opt_value);
2766			}
2767		}
2768	},
2769
2770	addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort)
2771	{
2772		oSelect = BX(oSelect);
2773		if(!oSelect)
2774			return;
2775		var n = oSelect.length;
2776		for(var i=0; i<n; i++)
2777			if(oSelect[i].selected)
2778				this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique);
2779	},
2780
2781	moveOptionsUp: function(oSelect)
2782	{
2783		oSelect = BX(oSelect)
2784		if(!oSelect)
2785			return;
2786		var n = oSelect.length;
2787		for(var i=0; i<n; i++)
2788		{
2789			if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false)
2790			{
2791				var option1 = new Option(oSelect[i].text, oSelect[i].value);
2792				var option2 = new Option(oSelect[i-1].text, oSelect[i-1].value);
2793				oSelect[i] = option2;
2794				oSelect[i].selected = false;
2795				oSelect[i-1] = option1;
2796				oSelect[i-1].selected = true;
2797			}
2798		}
2799	},
2800
2801	moveOptionsDown: function(oSelect)
2802	{
2803		oSelect = BX(oSelect);
2804		if(!oSelect)
2805			return;
2806		var n = oSelect.length;
2807		for(var i=n-1; i>=0; i--)
2808		{
2809			if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false)
2810			{
2811				var option1 = new Option(oSelect[i].text, oSelect[i].value);
2812				var option2 = new Option(oSelect[i+1].text, oSelect[i+1].value);
2813				oSelect[i] = option2;
2814				oSelect[i].selected = false;
2815				oSelect[i+1] = option1;
2816				oSelect[i+1].selected = true;
2817			}
2818		}
2819	}
2820}
2821
2822
2823
2824/******* HINT ***************/
2825// if function has 2 params - the 2nd one is hint html. otherwise hint_html is third and hint_title - 2nd;
2826// '<div onmouseover="BX.hint(this, 'This is &lt;b&gt;Hint&lt;/b&gt;')"'>;
2827// BX.hint(el, 'This is <b>Hint</b>') - this won't work, use constructor
2828BX.hint = function(el, hint_title, hint_html, hint_id)
2829{
2830	if (null == hint_html)
2831	{
2832		hint_html = hint_title;
2833		hint_title = '';
2834	}
2835
2836	if (null == el.BXHINT)
2837	{
2838		el.BXHINT = new BX.CHint({
2839			parent: el, hint: hint_html, title: hint_title, id: hint_id
2840		});
2841		el.BXHINT.Show();
2842	}
2843}
2844
2845BX.hint_replace = function(el, hint_title, hint_html)
2846{
2847	if (null == hint_html)
2848	{
2849		hint_html = hint_title;
2850		hint_title = '';
2851	}
2852
2853	if (!el || !el.parentNode || !hint_html)
2854			return null;
2855
2856	var obHint = new BX.CHint({
2857		hint: hint_html,
2858		title: hint_title
2859	});
2860
2861	obHint.CreateParent();
2862
2863	el.parentNode.insertBefore(obHint.PARENT, el);
2864	el.parentNode.removeChild(el);
2865
2866	obHint.PARENT.style.marginLeft = '5px';
2867
2868	return el;
2869}
2870
2871BX.CHint = function(params)
2872{
2873	this.PARENT = BX(params.parent);
2874
2875	this.HINT = params.hint;
2876	this.HINT_TITLE = params.title;
2877
2878	this.PARAMS = {}
2879	for (var i in this.defaultSettings)
2880	{
2881		if (null == params[i])
2882			this.PARAMS[i] = this.defaultSettings[i];
2883		else
2884			this.PARAMS[i] = params[i];
2885	}
2886
2887	if (null != params.id)
2888		this.ID = params.id;
2889
2890	this.timer = null;
2891	this.bInited = false;
2892	this.msover = true;
2893
2894	if (this.PARAMS.showOnce)
2895	{
2896		this.__show();
2897		this.msover = false;
2898		this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout);
2899	}
2900	else if (this.PARENT)
2901	{
2902		BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this));
2903		BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this));
2904	}
2905
2906	BX.addCustomEvent('onMenuOpen', BX.delegate(this.disable, this));
2907	BX.addCustomEvent('onMenuClose', BX.delegate(this.enable, this));
2908}
2909
2910BX.CHint.prototype.defaultSettings = {
2911	show_timeout: 1000,
2912	hide_timeout: 500,
2913	dx: 2,
2914	showOnce: false,
2915	preventHide: true,
2916	min_width: 250
2917}
2918
2919BX.CHint.prototype.CreateParent = function(element, params)
2920{
2921	if (this.PARENT)
2922	{
2923		BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this));
2924		BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this));
2925	}
2926
2927	if (!params) params = {}
2928	var type = 'icon';
2929
2930	if (params.type && (params.type == "link" || params.type == "icon"))
2931		type = params.type;
2932
2933	if (element)
2934		type = "element";
2935
2936	if (type == "icon")
2937	{
2938		element = BX.create('IMG', {
2939			props: {
2940				src: params.iconSrc
2941					? params.iconSrc
2942					: "/bitrix/js/main/core/images/hint.gif"
2943			}
2944		});
2945	}
2946	else if (type == "link")
2947	{
2948		element = BX.create("A", {
2949			props: {href: 'javascript:void(0)'},
2950			html: '[?]'
2951		});
2952	}
2953
2954	this.PARENT = element;
2955
2956	BX.bind(this.PARENT, 'mouseover', BX.proxy(this.Show, this));
2957	BX.bind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this));
2958
2959	return this.PARENT;
2960}
2961
2962BX.CHint.prototype.Show = function()
2963{
2964	this.msover = true;
2965
2966	if (null != this.timer)
2967		clearTimeout(this.timer);
2968
2969	this.timer = setTimeout(BX.proxy(this.__show, this), this.PARAMS.show_timeout);
2970}
2971
2972BX.CHint.prototype.Hide = function()
2973{
2974	this.msover = false;
2975
2976	if (null != this.timer)
2977		clearTimeout(this.timer);
2978
2979	this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout);
2980}
2981
2982BX.CHint.prototype.__show = function()
2983{
2984	if (!this.msover || this.disabled) return;
2985	if (!this.bInited) this.Init();
2986
2987	if (this.prepareAdjustPos())
2988	{
2989		this.DIV.style.display = 'block';
2990		this.adjustPos();
2991
2992		BX.bind(window, 'scroll', BX.proxy(this.__onscroll, this));
2993
2994		if (this.PARAMS.showOnce)
2995		{
2996			this.timer = setTimeout(BX.proxy(this.__hide, this), this.PARAMS.hide_timeout);
2997		}
2998	}
2999}
3000
3001BX.CHint.prototype.__onscroll = function()
3002{
3003	if (!BX.admin || !BX.admin.panel || !BX.admin.panel.isFixed()) return;
3004
3005	if (this.scrollTimer) clearTimeout(this.scrollTimer);
3006
3007	this.DIV.style.display = 'none';
3008	this.scrollTimer = setTimeout(BX.proxy(this.Reopen, this), this.PARAMS.show_timeout);
3009}
3010
3011BX.CHint.prototype.Reopen = function()
3012{
3013	if (null != this.timer) clearTimeout(this.timer);
3014	this.timer = setTimeout(BX.proxy(this.__show, this), 50);
3015}
3016
3017BX.CHint.prototype.__hide = function()
3018{
3019	if (this.msover) return;
3020	if (!this.bInited) return;
3021
3022	BX.unbind(window, 'scroll', BX.proxy(this.Reopen, this));
3023
3024	if (this.PARAMS.showOnce)
3025	{
3026		this.Destroy();
3027	}
3028	else
3029	{
3030		this.DIV.style.display = 'none';
3031	}
3032}
3033
3034BX.CHint.prototype.__hide_immediately = function()
3035{
3036	this.msover = false;
3037	this.__hide();
3038}
3039
3040BX.CHint.prototype.Init = function()
3041{
3042	this.DIV = document.body.appendChild(BX.create('DIV', {
3043		props: {className: 'bx-panel-tooltip'},
3044		style: {display: 'none'},
3045		children: [
3046			BX.create('DIV', {
3047				props: {className: 'bx-panel-tooltip-top-border'},
3048				html: '<div class="bx-panel-tooltip-corner bx-panel-tooltip-left-corner"></div><div class="bx-panel-tooltip-border"></div><div class="bx-panel-tooltip-corner bx-panel-tooltip-right-corner"></div>'
3049			}),
3050			(this.CONTENT = BX.create('DIV', {
3051				props: {className: 'bx-panel-tooltip-content'},
3052				children: [
3053					BX.create('DIV', {
3054						props: {className: 'bx-panel-tooltip-underlay'},
3055						children: [
3056							BX.create('DIV', {props: {className: 'bx-panel-tooltip-underlay-bg'}})
3057						]
3058					})
3059				]
3060			})),
3061
3062			BX.create('DIV', {
3063				props: {className: 'bx-panel-tooltip-bottom-border'},
3064				html: '<div class="bx-panel-tooltip-corner bx-panel-tooltip-left-corner"></div><div class="bx-panel-tooltip-border"></div><div class="bx-panel-tooltip-corner bx-panel-tooltip-right-corner"></div>'
3065			})
3066		]
3067	}));
3068
3069	if (this.ID)
3070	{
3071		this.CONTENT.insertBefore(BX.create('A', {
3072			attrs: {href: 'javascript:void(0)'},
3073			props: {className: 'bx-panel-tooltip-close'},
3074			events: {click: BX.delegate(this.Close, this)}
3075		}), this.CONTENT.firstChild)
3076	}
3077
3078	if (this.HINT_TITLE)
3079	{
3080		this.CONTENT.appendChild(
3081			BX.create('DIV', {
3082				props: {className: 'bx-panel-tooltip-title'},
3083				text: this.HINT_TITLE
3084			})
3085		)
3086	}
3087
3088	if (this.HINT)
3089	{
3090		this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT}));
3091	}
3092
3093	if (this.PARAMS.preventHide)
3094	{
3095		BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this));
3096		BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this));
3097	}
3098
3099	this.bInited = true;
3100}
3101
3102BX.CHint.prototype.setContent = function(content)
3103{
3104	this.HINT = content;
3105
3106	if (this.CONTENT_TEXT)
3107		this.CONTENT_TEXT.innerHTML = this.HINT;
3108	else
3109		this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV', {props: {className: 'bx-panel-tooltip-text'}})).appendChild(BX.create('SPAN', {html: this.HINT}));
3110}
3111
3112BX.CHint.prototype.prepareAdjustPos = function()
3113{
3114	this._wnd = {scrollPos: BX.GetWindowScrollPos(),scrollSize:BX.GetWindowScrollSize()};
3115	return BX.style(this.PARENT, 'display') != 'none';
3116}
3117
3118BX.CHint.prototype.getAdjustPos = function()
3119{
3120	var res = {}, pos = BX.pos(this.PARENT);
3121
3122	res.top = pos.bottom + this.PARAMS.dx;
3123
3124	if (BX.admin && BX.admin.panel.DIV)
3125	{
3126		var min_top = BX.admin.panel.DIV.offsetHeight + this.PARAMS.dx;
3127
3128		if (BX.admin.panel.isFixed())
3129		{
3130			min_top += this._wnd.scrollPos.scrollTop;
3131		}
3132	}
3133
3134	if (res.top < min_top)
3135		res.top = min_top;
3136	else
3137	{
3138		if (res.top + this.DIV.offsetHeight > this._wnd.scrollSize.scrollHeight)
3139			res.top = pos.top - this.PARAMS.dx - this.DIV.offsetHeight;
3140	}
3141
3142	res.left = pos.left;
3143	if (pos.left < this.PARAMS.dx) pos.left = this.PARAMS.dx;
3144	else
3145	{
3146		floatWidth = this.DIV.offsetWidth;
3147
3148		var max_left = this._wnd.scrollSize.scrollWidth - floatWidth - this.PARAMS.dx;
3149
3150		if (res.left > max_left)
3151			res.left = max_left;
3152	}
3153
3154	return res;
3155}
3156
3157BX.CHint.prototype.adjustWidth = function()
3158{
3159	if (this.bWidthAdjusted) return;
3160
3161	var w = this.DIV.offsetWidth, h = this.DIV.offsetHeight;
3162
3163	if (w > this.PARAMS.min_width)
3164		w = Math.round(Math.sqrt(1.618*w*h));
3165
3166	if (w < this.PARAMS.min_width)
3167		w = this.PARAMS.min_width;
3168
3169	this.DIV.style.width = w + "px";
3170
3171	if (this._adjustWidthInt)
3172		clearInterval(this._adjustWidthInt);
3173	this._adjustWidthInt = setInterval(BX.delegate(this._adjustWidthInterval, this), 5);
3174
3175	this.bWidthAdjusted = true;
3176}
3177
3178BX.CHint.prototype._adjustWidthInterval = function()
3179{
3180	if (!this.DIV || this.DIV.style.display == 'none')
3181		clearInterval(this._adjustWidthInt);
3182
3183	var
3184		dW = 20,
3185		maxWidth = 1500,
3186		w = this.DIV.offsetWidth,
3187		w1 = this.CONTENT_TEXT.offsetWidth;
3188
3189	if (w > 0 && w1 > 0 && w - w1 < dW && w < maxWidth)
3190	{
3191		this.DIV.style.width = (w + dW) + "px";
3192		return;
3193	}
3194
3195	clearInterval(this._adjustWidthInt);
3196}
3197
3198BX.CHint.prototype.adjustPos = function()
3199{
3200	this.adjustWidth();
3201
3202	var pos = this.getAdjustPos();
3203
3204	this.DIV.style.top = pos.top + 'px';
3205	this.DIV.style.left = pos.left + 'px';
3206}
3207
3208BX.CHint.prototype.Close = function()
3209{
3210	if (this.ID && BX.WindowManager)
3211		BX.WindowManager.saveWindowOptions(this.ID, {display: 'off'});
3212	this.__hide_immediately();
3213	this.Destroy();
3214}
3215
3216BX.CHint.prototype.Destroy = function()
3217{
3218	if (this.PARENT)
3219	{
3220		BX.unbind(this.PARENT, 'mouseover', BX.proxy(this.Show, this));
3221		BX.unbind(this.PARENT, 'mouseout', BX.proxy(this.Hide, this));
3222	}
3223
3224	if (this.DIV)
3225	{
3226		BX.unbind(this.DIV, 'mouseover', BX.proxy(this.Show, this));
3227		BX.unbind(this.DIV, 'mouseout', BX.proxy(this.Hide, this));
3228
3229		BX.cleanNode(this.DIV, true);
3230	}
3231}
3232
3233BX.CHint.prototype.enable = function(){this.disabled = false;}
3234BX.CHint.prototype.disable = function(){this.__hide_immediately(); this.disabled = true;}
3235
3236/* ready */
3237if (document.addEventListener)
3238{
3239	__readyHandler = function()
3240	{
3241		document.removeEventListener("DOMContentLoaded", __readyHandler, false);
3242		runReady();
3243	}
3244}
3245else if (document.attachEvent)
3246{
3247	__readyHandler = function()
3248	{
3249		if (document.readyState === "complete")
3250		{
3251			document.detachEvent("onreadystatechange", __readyHandler);
3252			runReady();
3253		}
3254	}
3255}
3256
3257function bindReady()
3258{
3259	if (!readyBound)
3260	{
3261		readyBound = true;
3262
3263		if (document.readyState === "complete")
3264		{
3265			return runReady();
3266		}
3267
3268		if (document.addEventListener)
3269		{
3270			document.addEventListener("DOMContentLoaded", __readyHandler, false);
3271			window.addEventListener("load", runReady, false);
3272		}
3273		else if (document.attachEvent) // IE
3274		{
3275			document.attachEvent("onreadystatechange", __readyHandler);
3276			window.attachEvent("onload", runReady);
3277
3278			var toplevel = false;
3279			try {toplevel = (window.frameElement == null);} catch(e) {}
3280
3281			if (document.documentElement.doScroll && toplevel)
3282				doScrollCheck();
3283		}
3284	}
3285
3286	return null;
3287}
3288
3289
3290function runReady()
3291{
3292	if (!BX.isReady)
3293	{
3294		if (!document.body)
3295			return setTimeout(runReady, 15);
3296
3297		BX.isReady = true;
3298
3299
3300		if (readyList && readyList.length > 0)
3301		{
3302			var fn, i = 0;
3303			while (readyList && (fn = readyList[i++]))
3304			{
3305				try{
3306					fn.call(document);
3307				}
3308				catch(e){
3309					BX.debug('BX.ready error: ', e);
3310				}
3311			}
3312
3313			readyList = null;
3314		}
3315		// TODO: check ready handlers binded some other way;
3316	}
3317	return null;
3318}
3319
3320// hack for IE
3321function doScrollCheck()
3322{
3323	if (BX.isReady)
3324		return;
3325
3326	try {document.documentElement.doScroll("left");} catch( error ) {setTimeout(doScrollCheck, 1); return;}
3327
3328	runReady();
3329}
3330/* \ready */
3331
3332function _adjustWait()
3333{
3334	if (!this.bxmsg) return;
3335
3336	var arContainerPos = BX.pos(this),
3337		div_top = arContainerPos.top;
3338
3339	if (div_top < BX.GetDocElement().scrollTop)
3340		div_top = BX.GetDocElement().scrollTop + 5;
3341
3342	this.bxmsg.style.top = (div_top + 5) + 'px';
3343
3344	if (this == BX.GetDocElement())
3345	{
3346		this.bxmsg.style.right = '5px';
3347	}
3348	else
3349	{
3350		this.bxmsg.style.left = (arContainerPos.right - this.bxmsg.offsetWidth - 5) + 'px';
3351	}
3352}
3353
3354function _checkDisplay(ob, displayType)
3355{
3356	if (typeof displayType != 'undefined')
3357		ob.BXDISPLAY = displayType;
3358
3359	var d = ob.style.display || BX.style(ob, 'display');
3360	if (d != 'none')
3361	{
3362		ob.BXDISPLAY = ob.BXDISPLAY || d;
3363		return true;
3364	}
3365	else
3366	{
3367		ob.BXDISPLAY = ob.BXDISPLAY || 'block';
3368		return false;
3369	}
3370}
3371
3372function _processTpl(tplNode, cb, bKillTpl)
3373{
3374	if (tplNode)
3375	{
3376		if (bKillTpl)
3377			tplNode.parentNode.removeChild(tplNode);
3378
3379		var res = {}, nodes = BX.findChildren(tplNode, {attribute: 'data-role'}, true);
3380
3381		for (var i = 0, l = nodes.length; i < l; i++)
3382		{
3383			res[nodes[i].getAttribute('data-role')] = nodes[i];
3384		}
3385
3386		cb.apply(tplNode, [res]);
3387	}
3388}
3389
3390function _checkNode(obj, params)
3391{
3392	params = params || {};
3393
3394	if (BX.type.isFunction(params))
3395		return params.call(window, obj);
3396
3397	if (!params.allowTextNodes && !BX.type.isElementNode(obj))
3398		return false;
3399	var i,j,len;
3400	for (i in params)
3401	{
3402		switch(i)
3403		{
3404			case 'tag':
3405			case 'tagName':
3406				if (BX.type.isString(params[i]))
3407				{
3408					if (obj.tagName.toUpperCase() != params[i].toUpperCase())
3409						return false;
3410				}
3411				else if (params[i] instanceof RegExp)
3412				{
3413					if (!params[i].test(obj.tagName))
3414						return false;
3415				}
3416			break;
3417
3418			case 'class':
3419			case 'className':
3420				if (BX.type.isString(params[i]))
3421				{
3422					if (!BX.hasClass(obj, params[i]))
3423						return false;
3424				}
3425				else if (params[i] instanceof RegExp)
3426				{
3427					if (!BX.type.isString(obj.className) || !params[i].test(obj.className))
3428						return false;
3429				}
3430			break;
3431
3432			case 'attr':
3433			case 'attribute':
3434				if (BX.type.isString(params[i]))
3435				{
3436					if (!obj.getAttribute(params[i]))
3437						return false;
3438				}
3439				else if (BX.type.isArray(params[i]))
3440				{
3441					for (j = 0, len = params[i].length; j < len; j++)
3442					{
3443						if (params[i] && !obj.getAttribute(params[i]))
3444							return false;
3445					}
3446				}
3447				else
3448				{
3449					for (j in params[i])
3450					{
3451						var q = obj.getAttribute(j);
3452						if (params[i][j] instanceof RegExp)
3453						{
3454							if (!BX.type.isString(q) || !params[i][j].test(q))
3455								return false;
3456						}
3457						else
3458						{
3459							if (q != '' + params[i][j])
3460								return false;
3461						}
3462					}
3463				}
3464			break;
3465
3466			case 'property':
3467				if (BX.type.isString(params[i]))
3468				{
3469					if (!obj[params[i]])
3470						return false;
3471				}
3472				else if (BX.type.isArray(params[i]))
3473				{
3474					for (j = 0, len = params[i].length; j < len; j++)
3475					{
3476						if (params[i] && !obj[params[i]])
3477							return false;
3478					}
3479				}
3480				else
3481				{
3482					for (j in params[i])
3483					{
3484						if (BX.type.isString(params[i][j]))
3485						{
3486							if (obj[j] != params[i][j])
3487								return false;
3488						}
3489						else if (params[i][j] instanceof RegExp)
3490						{
3491							if (!BX.type.isString(obj[j]) || !params[i][j].test(obj[j]))
3492								return false;
3493						}
3494					}
3495				}
3496			break;
3497
3498			case 'callback':
3499				return params[i](obj);
3500			break;
3501		}
3502	}
3503
3504	return true;
3505}
3506
3507function _checkCssList()
3508{
3509	var linksCol = document.getElementsByTagName('LINK'), links = [];
3510
3511	if(!!linksCol && linksCol.length > 0)
3512	{
3513		for(var i=0;i<linksCol.length;i++)
3514		{
3515			links.push(linksCol[i]);
3516		}
3517	}
3518
3519	if(!!window.arKernelCSS && BX.type.isArray(arKernelCSS))
3520	{
3521		links = BX.util.array_merge(links, arKernelCSS);
3522	}
3523
3524	for (var i = 0; i < links.length; i++)
3525	{
3526		var href = BX.type.isDomNode(links[i]) ? links[i].getAttribute('href') : links[i];
3527		if (!!href && href.replace)
3528		{
3529			cssList.push(href
3530				.replace(/\.css(\?\d*)/, '.css')
3531				.replace(/^(http[s]*:)*\/\/[^\/]+/i, '')
3532			);
3533		}
3534	}
3535	_checkCssList = BX.DoNothing;
3536}
3537
3538/********* Check for currently loaded core scripts ***********/
3539function _isScriptLoaded(fileSrc)
3540{
3541	return (
3542		BX.util.in_array(fileSrc, arKernelJS)
3543		||fileSrc.indexOf('/core/core.js') > 0
3544		||fileSrc.indexOf('/core_access.js') >= 0 && !!BX.Access
3545		||fileSrc.indexOf('/core_admin.js') >= 0 && !!BX.admin
3546		||fileSrc.indexOf('/core_admin_interface.js') >= 0 && !!BX.adminPanel
3547		||fileSrc.indexOf('/core_admin_login.js') >= 0 && !!BX.adminLogin
3548		||fileSrc.indexOf('/core_ajax.js') >= 0 && !!BX.ajax
3549		||fileSrc.indexOf('/core_autosave.js') >= 0 && !!BX.CAutoSave
3550		||fileSrc.indexOf('/core_date.js') >= 0 && !!BX.date
3551		||fileSrc.indexOf('/core_finder.js') >= 0 && !!BX.Finder
3552		||fileSrc.indexOf('/core_fx.js') >= 0 && !!BX.easing
3553		||fileSrc.indexOf('/core_image.js') >= 0 && !!BX.CImageView
3554		||fileSrc.indexOf('/core_ls.js') >= 0 && !!BX.localStorage
3555		||fileSrc.indexOf('/core_popup.js') >= 0 && !!BX.PopupWindowManager
3556		||fileSrc.indexOf('/core_tags.js') >= 0 && !!BX.TagsWindowArea
3557		||fileSrc.indexOf('/core_timer.js') >= 0 && !!BX.timer
3558		||fileSrc.indexOf('/core_tooltip.js') >= 0 && !!BX.tooltip
3559		||fileSrc.indexOf('/core_translit.js') >= 0 && !!BX.translit
3560		||fileSrc.indexOf('/core_window.js') >= 0 && !!BX.WindowManager
3561		||fileSrc.indexOf('/jquery-') >= 0 && !!window.jQuery
3562	);
3563}
3564
3565/* garbage collector */
3566function Trash()
3567{
3568	var i,len;
3569
3570	for (i = 0, len = garbageCollectors.length; i<len; i++)
3571	{
3572		try {
3573			garbageCollectors[i].callback.apply(garbageCollectors[i].context || window);
3574			delete garbageCollectors[i];
3575			garbageCollectors[i] = null;
3576		} catch (e) {}
3577	}
3578
3579	try {BX.unbindAll();} catch(e) {}
3580/*
3581	for (i = 0, len = proxyList.length; i < len; i++)
3582	{
3583		try {
3584			delete proxyList[i];
3585			proxyList[i] = null;
3586		} catch (e) {}
3587	}
3588*/
3589}
3590
3591if(window.attachEvent) // IE
3592	window.attachEvent("onunload", Trash);
3593else if(window.addEventListener) // Gecko / W3C
3594	window.addEventListener('unload', Trash, false);
3595else
3596	window.onunload = Trash;
3597/* \garbage collector */
3598
3599// set empty ready handler
3600BX(BX.DoNothing);
3601window.BX = BX;
3602BX.browser.addGlobalClass();
3603BX.browser.addGlobalFeatures(["boxShadow", "borderRadius", "flexWrap", "boxDirection", "transition", "transform"])
3604})(window);
3605
3606/* End */
3607;
3608; /* Start:/bitrix/js/main/core/core_ajax.js*/
3609;(function(window){
3610
3611if (window.BX.ajax)
3612	return;
3613
3614var
3615	BX = window.BX,
3616
3617	tempDefaultConfig = {},
3618	defaultConfig = {
3619		method: 'GET', // request method: GET|POST
3620		dataType: 'html', // type of data loading: html|json|script
3621		timeout: 0, // request timeout in seconds. 0 for browser-default
3622		async: true, // whether request is asynchronous or not
3623		processData: true, // any data processing is disabled if false, only callback call
3624		scriptsRunFirst: false, // whether to run _all_ found scripts before onsuccess call. script tag can have an attribute "bxrunfirst" to turn  this flag on only for itself
3625		emulateOnload: true,
3626		start: true, // send request immediately (if false, request can be started manually via XMLHttpRequest object returned)
3627		cache: true, // whether NOT to add random addition to URL
3628		preparePost: true, // whether set Content-Type x-www-form-urlencoded in POST
3629		headers: false, // add additional headers, example: [{'name': 'If-Modified-Since', 'value': 'Wed, 15 Aug 2012 08:59:08 GMT'}, {'name': 'If-None-Match', 'value': '0'}]
3630		lsTimeout: 30, //local storage data TTL. useless without lsId.
3631		lsForce: false //wheter to force query instead of using localStorage data. useless without lsId.
3632/*
3633other parameters:
3634	url: url to get/post
3635	data: data to post
3636	onsuccess: successful request callback. BX.proxy may be used.
3637	onfailure: request failure callback. BX.proxy may be used.
3638
3639	lsId: local storage id - for constantly updating queries which can communicate via localStorage. core_ls.js needed
3640
3641any of the default parameters can be overridden. defaults can be changed by BX.aja
3641x.Setup() - for all further requests!
3642*/
3643	},
3644	ajax_session = null,
3645	loadedScripts = {},
3646	loadedScriptsQueue = [],
3647	r = {
3648		'url_utf': /[^\034-\254]+/g,
3649		'script_self': /\/bitrix\/js\/main\/core\/core(_ajax)*.js$/i,
3650		'script_self_window': /\/bitrix\/js\/main\/core\/core_window.js$/i,
3651		'script_self_admin': /\/bitrix\/js\/main\/core\/core_admin.js$/i,
3652		'script_onload': /window.onload/g
3653	};
3654
3655// low-level method
3656BX.ajax = function(config)
3657{
3658	var status, data;
3659
3660	if (!config || !config.url || !BX.type.isString(config.url))
3661	{
3662		return false;
3663	}
3664
3665	for (var i in tempDefaultConfig)
3666		if (typeof (config[i]) == "undefined") config[i] = tempDefaultConfig[i];
3667
3668	tempDefaultConfig = {};
3669
3670	for (var i in defaultConfig)
3671		if (typeof (config[i]) == "undefined") config[i] = defaultConfig[i];
3672
3673	config.method = config.method.toUpperCase();
3674
3675	if (!BX.localStorage)
3676		config.lsId = null;
3677
3678	if (BX.browser.IsIE())
3679	{
3680		var result = r.url_utf.exec(config.url);
3681		if (result)
3682		{
3683			do
3684			{
3685				config.url = config.url.replace(result, BX.util.urlencode(result));
3686				result = r.url_utf.exec(config.url);
3687			} while (result);
3688		}
3689	}
3690
3691	if(config.dataType == 'json')
3692		config.emulateOnload = false;
3693
3694	if (!config.cache && config.method == 'GET')
3695		config.url = BX.ajax._uncache(config.url);
3696
3697	if (config.method == 'POST' && config.preparePost)
3698	{
3699		config.data = BX.ajax.prepareData(config.data);
3700	}
3701
3702	var bXHR = true;
3703	if (config.lsId && !config.lsForce)
3704	{
3705		var v = BX.localStorage.get('ajax-' + config.lsId);
3706		if (v !== null)
3707		{
3708			bXHR = false;
3709
3710			var lsHandler = function(lsData) {
3711				if (lsData.key == 'ajax-' + config.lsId && lsData.value != 'BXAJAXWAIT')
3712				{
3713					var data = lsData.value,
3714						bRemove = !!lsData.oldValue && data == null;
3715					if (!bRemove)
3716						BX.ajax.__run(config, data);
3717					else if (config.onfailure)
3718						config.onfailure("timeout");
3719
3720					BX.removeCustomEvent('onLocalStorageChange', lsHandler);
3721				}
3722			}
3723
3724			if (v == 'BXAJAXWAIT')
3725			{
3726				BX.addCustomEvent('onLocalStorageChange', lsHandler);
3727			}
3728			else
3729			{
3730				setTimeout(function() {lsHandler({key: 'ajax-' + config.lsId, value: v})}, 10);
3731			}
3732		}
3733	}
3734
3735	if (bXHR)
3736	{
3737		config.xhr = BX.ajax.xhr();
3738		if (!config.xhr) return;
3739
3740		if (config.lsId)
3741		{
3742			BX.localStorage.set('ajax-' + config.lsId, 'BXAJAXWAIT', config.lsTimeout);
3743		}
3744
3745		config.xhr.open(config.method, config.url, config.async);
3746		if (config.method == 'POST' && config.preparePost)
3747		{
3748			config.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
3749		}
3750		if (typeof(config.headers) == "object")
3751		{
3752			for (var i = 0; i < config.headers.length; i++)
3753				config.xhr.setRequestHeader(config.headers[i].name, config.headers[i].value);
3754		}
3755
3756		var bRequestCompleted = false;
3757		var onreadystatechange = config.xhr.onreadystatechange = function(additional)
3758		{
3759			if (bRequestCompleted)
3760				return;
3761
3762			if (additional === 'timeout')
3763			{
3764				if (config.onfailure)
3765					config.onfailure("timeout");
3766
3767				BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['timeout', '', config]);
3768
3769				config.xhr.onreadystatechange = BX.DoNothing;
3770				config.xhr.abort();
3771
3772				if (config.async)
3773				{
3774					config.xhr = null;
3775				}
3776			}
3777			else
3778			{
3779				if (config.xhr.readyState == 4 || additional == 'run')
3780				{
3781					status = BX.ajax.xhrSuccess(config.xhr) ? "success" : "error";
3782					bRequestCompleted = true;
3783					config.xhr.onreadystatechange = BX.DoNothing;
3784
3785					// var status = oAjax.arThreads[TID].httpRequest.getResponseHeader('X-Bitrix-Ajax-Status');
3786					// var bRedirect = (status == 'Redirect');
3787
3788					if (status == 'success')
3789					{
3790						var data = config.xhr.responseText;
3791
3792						if (config.lsId)
3793						{
3794							BX.localStorage.set('ajax-' + config.lsId, data, config.lsTimeout);
3795						}
3796
3797						BX.ajax.__run(config, data);
3798					}
3799					else if (config.onfailure)
3800					{
3801						config.onfailure("status", config.xhr.status);
3802						BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['status', config.xhr.status, config]);
3803					}
3804
3805					if (config.async)
3806					{
3807						config.xhr = null;
3808					}
3809				}
3810			}
3811		}
3812
3813		if (config.async && config.timeout > 0)
3814		{
3815			setTimeout(function() {
3816				if (config.xhr && !bRequestCompleted)
3817				{
3818					onreadystatechange("timeout");
3819				}
3820			}, config.timeout * 1000);
3821		}
3822
3823		if (config.start)
3824		{
3825			config.xhr.send(config.data);
3826
3827			if (!config.async)
3828			{
3829				onreadystatechange('run');
3830			}
3831		}
3832
3833		return config.xhr;
3834	}
3835}
3836
3837BX.ajax.xhr = function()
3838{
3839	if (window.XMLHttpRequest)
3840	{
3841		try {return new XMLHttpRequest();} catch(e){}
3842	}
3843	else if (window.ActiveXObject)
3844	{
3845		try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
3846			catch(e) {}
3847		try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
3848			catch(e) {}
3849		try { return new ActiveXObject("Msxml2.XMLHTTP"); }
3850			catch(e) {}
3851		try { return new ActiveXObject("Microsoft.XMLHTTP"); }
3852			catch(e) {}
3853		throw new Error("This browser does not support XMLHttpRequest.");
3854	}
3855
3856	return null;
3857}
3858
3859BX.ajax.__prepareOnload = function(scripts)
3860{
3861	if (scripts.length > 0)
3862	{
3863		BX.ajax['onload_' + ajax_session] = null;
3864
3865		for (var i=0,len=scripts.length;i<len;i++)
3866		{
3867			if (scripts[i].isInternal)
3868			{
3869				scripts[i].JS = scripts[i].JS.replace(r.script_onload, 'BX.ajax.onload_' + ajax_session);
3870			}
3871		}
3872	}
3873
3874	BX.CaptureEventsGet();
3875	BX.CaptureEvents(window, 'load');
3876}
3877
3878BX.ajax.__runOnload = function()
3879{
3880	if (null != BX.ajax['onload_' + ajax_session])
3881	{
3882		BX.ajax['onload_' + ajax_session].apply(window);
3883		BX.ajax['onload_' + ajax_session] = null;
3884	}
3885
3886	var h = BX.CaptureEventsGet();
3887
3888	if (h)
3889	{
3890		for (var i=0; i<h.length; i++)
3891			h[i].apply(window);
3892	}
3893}
3894
3895BX.ajax.__run = function(config, data)
3896{
3897	if (!config.processData)
3898	{
3899		if (config.onsuccess)
3900		{
3901			config.onsuccess(data);
3902		}
3903
3904		BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [data, config]);
3905	}
3906	else
3907	{
3908		data = BX.ajax.processRequestData(data, config);
3909	}
3910}
3911
3912
3913BX.ajax._onParseJSONFailure = function(data)
3914{
3915	this.jsonFailure = true;
3916	this.jsonResponse = data;
3917	this.jsonProactive = /^\[WAF\]/.test(data);
3918}
3919
3920BX.ajax.processRequestData = function(data, config)
3921{
3922	var result, scripts = [], styles = [];
3923	switch (config.dataType.toUpperCase())
3924	{
3925		case 'JSON':
3926			BX.addCustomEvent(config.xhr, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config));
3927			result = BX.parseJSON(data, config.xhr);
3928			BX.removeCustomEvent(config.xhr, 'onParseJSONFailure', BX.proxy(BX.ajax._onParseJSONFailure, config));
3929
3930		break;
3931		case 'SCRIPT':
3932			scripts.push({"isInternal": true, "JS": data, bRunFirst: config.scriptsRunFirst});
3933			config.processScriptsConsecutive = true;
3934			result = data;
3935		break;
3936
3937		default: // HTML
3938			var ob = BX.processHTML(data, config.scriptsRunFirst);
3939			result = ob.HTML; scripts = ob.SCRIPT; styles = ob.STYLE
3940		break;
3941	}
3942
3943	var bSessionCreated = false;
3944	if (null == ajax_session)
3945	{
3946		ajax_session = parseInt(Math.random() * 1000000);
3947		bSessionCreated = true;
3948	}
3949
3950	if (styles.length > 0)
3951		BX.loadCSS(styles);
3952
3953	if (config.emulateOnload)
3954			BX.ajax.__prepareOnload(scripts);
3955
3956	var cb = BX.DoNothing;
3957	if(config.emulateOnload || bSessionCreated)
3958	{
3959		cb = BX.defer(function()
3960		{
3961			if (config.emulateOnload)
3962				BX.ajax.__runOnload();
3963			if (bSessionCreated)
3964				ajax_session = null;
3965			BX.onCustomEvent(config.xhr, 'onAjaxSuccessFinish', [config]);
3966		});
3967	}
3968
3969	try
3970	{
3971		if (!!config.jsonFailure)
3972		{
3973			throw {type: 'json_failure', data: config.jsonResponse, bProactive: config.jsonProactive};
3974		}
3975
3976		config.scripts = scripts;
3977
3978		BX.ajax.processScripts(config.scripts, true);
3979
3980
3981		if (config.onsuccess)
3982		{
3983			config.onsuccess(result);
3984		}
3985
3986		BX.onCustomEvent(config.xhr, 'onAjaxSuccess', [result, config]);
3987
3988		if(!config.processScriptsConsecutive)
3989		{
3990			BX.ajax.processScripts(config.scripts, false, cb);
3991		}
3992		else
3993		{
3994			BX.ajax.processScriptsConsecutive(config.scripts, false);
3995			cb();
3996		}
3997	}
3998	catch (e)
3999	{
4000		if (config.onfailure)
4001			config.onfailure("processing", e);
4002		BX.onCustomEvent(config.xhr, 'onAjaxFailure', ['processing', e, config]);
4003	}
4004}
4005
4006BX.ajax.processScripts = function(scripts, bRunFirst, cb)
4007{
4008	var scriptsExt = [], scriptsInt = '';
4009
4010	cb=cb||BX.DoNothing;
4011
4012	for (var i = 0, length = scripts.length; i < length; i++)
4013	{
4014		if (typeof bRunFirst != 'undefined' && bRunFirst != !!scripts[i].bRunFirst)
4015			continue;
4016
4017		if (scripts[i].isInternal)
4018			scriptsInt += ';' + scripts[i].JS
4019		else
4020			scriptsExt.push(scripts[i].JS);
4021	}
4022
4023	scriptsExt = BX.util.array_unique(scriptsExt);
4024
4025	var l=l1=scriptsExt.length,
4026		f=scriptsInt.length>0?function(){BX.evalGlobal(scriptsInt)}:BX.DoNothing;
4027
4028	if(l>0)
4029	{
4030		var c=function(){if(--l1<=0){f();cb();f=BX.DoNothing;}};
4031		for(var i=0; i<l;i++)
4032		{
4033			BX.loadScript(scriptsExt[i], c);
4034		}
4035	}
4036	else
4037	{
4038		//f();BX.defer(cb)();
4039		f();cb();
4040	}
4041}
4042
4043BX.ajax.processScriptsConsecutive = function(scripts, bRunFirst)
4044{
4045	for (var i = 0, length = scripts.length; i < length; i++)
4046	{
4047		if (null != bRunFirst && bRunFirst != !!scripts[i].bRunFirst)
4048			continue;
4049
4050		if (scripts[i].isInternal)
4051		{
4052			BX.evalGlobal(scripts[i].JS);
4053		}
4054		else
4055		{
4056			BX.ajax.loadScriptAjax([scripts[i].JS]);
4057		}
4058	}
4059}
4060
4061// TODO: extend this function to use with any data objects or forms
4062BX.ajax.prepareData = function(arData, prefix)
4063{
4064	var data = '';
4065	if (BX.type.isString(arData))
4066		data = arData;
4067	else if (null != arData)
4068	{
4069		for(var i in arData)
4070		{
4071			if (!arData.hasOwnProperty(i))
4072				continue;
4073			if (data.length > 0) data += '&';
4074			var name = BX.util.urlencode(i);
4075			if(prefix)
4076				name = prefix + '[' + name + ']';
4077			if(typeof arData[i] == 'object')
4078				data += BX.ajax.prepareData(arData[i], name)
4079			else
4080				data += name + '=' + BX.util.urlencode(arData[i])
4081		}
4082	}
4083	return data;
4084}
4085
4086BX.ajax.xhrSuccess = function(xhr)
4087{
4088	return (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
4089}
4090
4091BX.ajax.Setup = function(config, bTemp)
4092{
4093	bTemp = !!bTemp;
4094
4095	for (var i in config)
4096	{
4097		if (bTemp)
4098			tempDefaultConfig[i] = config[i];
4099		else
4100			defaultConfig[i] = config[i];
4101	}
4102}
4103
4104BX.ajax.replaceLocalStorageValue = function(lsId, data, ttl)
4105{
4106	if (!!BX.localStorage)
4107		BX.localStorage.set('ajax-' + lsId, data, ttl);
4108}
4109
4110
4111BX.ajax._uncache = function(url)
4112{
4113	return url + ((url.indexOf('?') !== -1 ? "&" : "?") + '_=' + (new Date).getTime());
4114}
4115
4116/* simple interface */
4117BX.ajax.get = function(url, data, callback)
4118{
4119	if (BX.type.isFunction(data))
4120	{
4121		callback = data;
4122		data = '';
4123	}
4124
4125	data = BX.ajax.prepareData(data);
4126
4127	if (data)
4128	{
4129		url += (url.indexOf('?') !== -1 ? "&" : "?") + data;
4130		data = '';
4131	}
4132
4133	return BX.ajax({
4134		'method': 'GET',
4135		'dataType': 'html',
4136		'url': url,
4137		'data':  '',
4138		'onsuccess': callback
4139	});
4140}
4141
4142BX.ajax.getCaptcha = function(callback)
4143{
4144	return BX.ajax.loadJSON('/bitrix/tools/ajax_captcha.php', callback);
4145}
4146
4147BX.ajax.insertToNode = function(url, node)
4148{
4149	if (node = BX(node))
4150	{
4151		BX.onCustomEvent('onAjaxInsertToNode', [{url: url, node: node}]);
4152
4153		var show = null;
4154		if (!tempDefaultConfig.denyShowWait)
4155		{
4156			show = BX.showWait(node);
4157			delete tempDefaultConfig.denyShowWait;
4158		}
4159
4160		return BX.ajax.get(url, function(data) {
4161			node.innerHTML = data;
4162			BX.closeWait(node, show);
4163		});
4164	}
4165}
4166
4167BX.ajax.post = function(url, data, callback)
4168{
4169	data = BX.ajax.prepareData(data);
4170
4171	return BX.ajax({
4172		'method': 'POST',
4173		'dataType': 'html',
4174		'url': url,
4175		'data':  data,
4176		'onsuccess': callback
4177	});
4178}
4179
4180/* load and execute external file script with onload emulation */
4181BX.ajax.loadScriptAjax = function(script_src, callback, bPreload)
4182{
4183	if (BX.type.isArray(script_src))
4184	{
4185		for (var i=0,len=script_src.length;i<len;i++)
4186		{
4187			BX.ajax.loadScriptAjax(script_src[i], callback, bPreload);
4188		}
4189	}
4190	else
4191	{
4192		var script_src_test = script_src.replace(/\.js\?.*/, '.js');
4193
4194		if (r.script_self.test(script_src_test)) return;
4195		if (r.script_self_window.test(script_src_test) && BX.CWindow) return;
4196		if (r.script_self_admin.test(script_src_test) && BX.admin) return;
4197
4198		if (typeof loadedScripts[script_src_test] == 'undefined')
4199		{
4200			if (!!bPreload)
4201			{
4202				loadedScripts[script_src_test] = '';
4203				return BX.loadScript(script_src);
4204			}
4205			else
4206			{
4207				return BX.ajax({
4208					url: script_src,
4209					method: 'GET',
4210					dataType: 'script',
4211					processData: true,
4212					emulateOnload: false,
4213					scriptsRunFirst: true,
4214					async: false,
4215					start: true,
4216					onsuccess: function(result) {
4217						loadedScripts[script_src_test] = result;
4218						if (callback)
4219							callback(result);
4220					}
4221				});
4222			}
4223		}
4224		else if (callback)
4225		{
4226			callback(loadedScripts[script_src_test]);
4227		}
4228	}
4229}
4230
4231/* non-xhr loadings */
4232BX.ajax.loadJSON = function(url, data, callback, callback_failure)
4233{
4234	if (BX.type.isFunction(data))
4235	{
4236		callback_failure = callback;
4237		callback = data;
4238		data = '';
4239	}
4240
4241	data = BX.ajax.prepareData(data);
4242
4243	if (data)
4244	{
4245		url += (url.indexOf('?') !== -1 ? "&" : "?") + data;
4246		data = '';
4247	}
4248
4249	return BX.ajax({
4250		'method': 'GET',
4251		'dataType': 'json',
4252		'url': url,
4253		'onsuccess': callback,
4254		'onfailure': callback_failure
4255	});
4256}
4257
4258/*
4259arObs = [{
4260	url: url,
4261	type: html|script|json|css,
4262	callback: function
4263}]
4264*/
4265BX.ajax.load = function(arObs, callback)
4266{
4267	if (!BX.type.isArray(arObs))
4268		arObs = [arObs];
4269
4270	var cnt = 0;
4271
4272	if (!BX.type.isFunction(callback))
4273		callback = BX.DoNothing;
4274
4275	var handler = function(data)
4276		{
4277			if (BX.type.isFunction(this.callback))
4278				this.callback(data);
4279
4280			if (++cnt >= len)
4281				callback();
4282		};
4283
4284	for (var i = 0, len = arObs.length; i<len; i++)
4285	{
4286		switch(arObs.type.toUpperCase())
4287		{
4288			case 'SCRIPT':
4289				BX.loadScript([arObs[i].url], jsBX.proxy(handler, arObs[i]));
4290			break;
4291			case 'CSS':
4292				BX.loadCSS([arObs[i].url]);
4293
4294				if (++cnt >= len)
4295					callback();
4296			break;
4297			case 'JSON':
4298				BX.ajax.loadJSON(arObs.url, jsBX.proxy(handler, arObs[i]));
4299			break;
4300
4301			default:
4302				BX.ajax.get(arObs.url, '', jsBX.proxy(handler, arObs[i]));
4303			break;
4304		}
4305	}
4306}
4307
4308/* ajax form sending */
4309BX.ajax.submit = function(obForm, callback)
4310{
4311	if (!obForm.target)
4312	{
4313		if (null == obForm.BXFormTarget)
4314		{
4315			var frame_name = 'formTarget_' + Math.random();
4316			obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', {
4317				props: {
4318					name: frame_name,
4319					id: frame_name,
4320					src: 'javascript:void(0)'
4321				},
4322				style: {
4323					display: 'none'
4324				}
4325			}));
4326		}
4327
4328		obForm.target = obForm.BXFormTarget.name;
4329	}
4330
4331	obForm.BXFormCallback = callback;
4332	BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm));
4333
4334	BX.submit(obForm);
4335
4336	return false;
4337}
4338
4339BX.ajax.submitComponentForm = function(obForm, container, bWait)
4340{
4341	if (!obForm.target)
4342	{
4343		if (null == obForm.BXFormTarget)
4344		{
4345			var frame_name = 'formTarget_' + Math.random();
4346			obForm.BXFormTarget = document.body.appendChild(BX.create('IFRAME', {
4347				props: {
4348					name: frame_name,
4349					id: frame_name,
4350					src: 'javascript:void(0)'
4351				},
4352				style: {
4353					display: 'none'
4354				}
4355			}));
4356		}
4357
4358		obForm.target = obForm.BXFormTarget.name;
4359	}
4360
4361	if (!!bWait)
4362		var w = BX.showWait(container);
4363
4364	obForm.BXFormCallback = function(d) {
4365		if (!!bWait)
4366			BX.closeWait(w);
4367
4368		BX(container).innerHTML = d;
4369		if (window.bxcompajaxframeonload){
4370			setTimeout("window.bxcompajaxframeonload();window.bxcompajaxframeonload=null;", 10)
4371		};
4372		BX.onCustomEvent('onAjaxSuccess', []);
4373	};
4374
4375	BX.bind(obForm.BXFormTarget, 'load', BX.proxy(BX.ajax._submit_callback, obForm));
4376
4377	return true;
4378}
4379
4380// func will be executed in form context
4381BX.ajax._submit_callback = function()
4382{
4383	//opera and IE8 triggers onload event even on empty iframe
4384	try
4385	{
4386		if(this.BXFormTarget.contentWindow.location.href.indexOf('http') != 0)
4387			return;
4388	} catch (e) {
4389		return;
4390	}
4391
4392	if (this.BXFormCallback)
4393		this.BXFormCallback.apply(this, [this.BXFormTarget.contentWindow.document.body.innerHTML]);
4394
4395	BX.unbindAll(this.BXFormTarget);
4396}
4397
4398// TODO: currently in window extension. move it here.
4399BX.ajax.submitAjax = function(obForm, callback)
4400{
4401
4402}
4403
4404BX.ajax.UpdatePageData = function (arData)
4405{
4406	if (arData.TITLE)
4407		BX.ajax.UpdatePageTitle(arData.TITLE);
4408	if (arData.NAV_CHAIN)
4409		BX.ajax.UpdatePageNavChain(arData.NAV_CHAIN);
4410	if (arData.CSS && arData.CSS.length > 0)
4411		BX.loadCSS(arData.CSS);
4412	if (arData.SCRIPTS && arData.SCRIPTS.length > 0)
4413	{
4414		var f=function(result,config){
4415			if(!!config && BX.type.isArray(config.scripts))
4416			{
4417				for(var i=0,l=arData.SCRIPTS.length;i<l;i++)
4418				{
4419					config.scripts.push({isInternal:false,JS:arData.SCRIPTS[i]});
4420				}
4421			}
4422			else
4423			{
4424				BX.loadScript(arData.SCRIPTS);
4425			}
4426
4427			BX.removeCustomEvent('onAjaxSuccess',f);
4428		}
4429		BX.addCustomEvent('onAjaxSuccess',f);
4430	}
4431}
4432
4433BX.ajax.UpdatePageTitle = function(title)
4434{
4435	var obTitle = BX('pagetitle');
4436	if (obTitle)
4437	{
4438		obTitle.removeChild(obTitle.firstChild);
4439		if (!obTitle.firstChild)
4440			obTitle.appendChild(document.createTextNode(title));
4441		else
4442			obTitle.insertBefore(document.createTextNode(title), obTitle.firstChild);
4443	}
4444
4445	document.title = title;
4446}
4447
4448BX.ajax.UpdatePageNavChain = function(nav_chain)
4449{
4450	var obNavChain = BX('navigation');
4451	if (obNavChain)
4452	{
4453		obNavChain.innerHTML = nav_chain;
4454	}
4455}
4456
4457/* user options handling */
4458BX.userOptions = {
4459	options: null,
4460	bSend: false,
4461	delay: 5000
4462}
4463
4464BX.userOptions.save = function(sCategory, sName, sValName, sVal, bCommon)
4465{
4466	if (null == BX.userOptions.options)
4467		BX.userOptions.options = {};
4468
4469	bCommon = !!bCommon;
4470	BX.userOptions.options[sCategory+'.'+sName+'.'+sValName] = [sCategory, sName, sValName, sVal, bCommon];
4471
4472	var sParam = BX.userOptions.__get();
4473	if (sParam != '')
4474		document.cookie = BX.message('COOKIE_PREFIX')+"_LAST_SETTINGS=" + sParam + "&sessid="+BX.bitrix_sessid()+"; expires=Thu, 31 Dec 2020 23:59:59 GMT; path=/;";
4475
4476	if(!BX.userOptions.bSend)
4477	{
4478		BX.userOptions.bSend = true;
4479		setTimeout(function(){BX.userOptions.send(null)}, BX.userOptions.delay);
4480	}
4481}
4482
4483BX.userOptions.send = function(callback)
4484{
4485	var sParam = BX.userOptions.__get();
4486	BX.userOptions.options = null;
4487	BX.userOptions.bSend = false;
4488
4489	if (sParam != '')
4490	{
4491		document.cookie = BX.message('COOKIE_PREFIX') + "_LAST_SETTINGS=; path=/;";
4492		BX.ajax({
4493			'method': 'GET',
4494			'dataType': 'html',
4495			'processData': false,
4496			'cache': false,
4497			'url': '/bitrix/admin/user_options.php?'+sParam+'&sessid='+BX.bitrix_sessid(),
4498			'onsuccess': callback
4499		});
4500	}
4501}
4502
4503BX.userOptions.del = function(sCategory, sName, bCommon, callback)
4504{
4505	BX.ajax.get('/bitrix/admin/user_options.php?action=delete&c='+sCategory+'&n='+sName+(bCommon == true? '&common=Y':'')+'&sessid='+BX.bitrix_sessid(), callback);
4506}
4507
4508BX.userOptions.__get = function()
4509{
4510	if (!BX.userOptions.options) return '';
4511
4512	var sParam = '', n = -1, prevParam = '', aOpt, i;
4513
4514	for (i in BX.userOptions.options)
4515	{
4516		aOpt = BX.userOptions.options[i];
4517
4518		if (prevParam != aOpt[0]+'.'+aOpt[1])
4519		{
4520			n++;
4521			sParam += '&p['+n+'][c]='+BX.util.urlencode(aOpt[0]);
4522			sParam += '&p['+n+'][n]='+BX.util.urlencode(aOpt[1]);
4523			if (aOpt[4] == true)
4524				sParam += '&p['+n+'][d]=Y';
4525			prevParam = aOpt[0]+'.'+aOpt[1];
4526		}
4527
4528		sParam += '&p['+n+'][v]['+BX.util.urlencode(aOpt[2])+']='+BX.util.urlencode(aOpt[3]);
4529	}
4530
4531	return sParam.substr(1);
4532}
4533
4534BX.ajax.history = {
4535	expected_hash: '',
4536
4537	obParams: null,
4538
4539	obFrame: null,
4540	obImage: null,
4541
4542	obTimer: null,
4543
4544	bInited: false,
4545	bHashCollision: false,
4546	bPushState: !!(history.pushState && BX.type.isFunction(history.pushState)),
4547
4548	startState: null,
4549
4550	init: function(obParams)
4551	{
4552		if (BX.ajax.history.bInited)
4553			return;
4554
4555		this.obParams = obParams;
4556		var obCurrentState = this.obParams.getState();
4557
4558		if (BX.ajax.history.bPushState)
4559		{
4560			BX.ajax.history.expected_hash = window.location.pathname;
4561			if (window.location.search)
4562				BX.ajax.history.expected_hash += window.location.search;
4563
4564			BX.ajax.history.put(obCurrentState, BX.ajax.history.expected_hash, '', true);
4565			// due to some strange thing, chrome calls popstate event on page start. so we should delay it
4566			setTimeout("BX.bind(window, 'popstate', BX.ajax.history.__hashListener);", 500);
4567		}
4568		else
4569		{
4570			BX.ajax.history.expected_hash = window.location.hash;
4571
4572			if (!BX.ajax.history.expected_hash || BX.ajax.history.expected_hash == '#')
4573				BX.ajax.history.expected_hash = '__bx_no_hash__';
4574
4575			jsAjaxHistoryContainer.put(BX.ajax.history.expected_hash, obCurrentState);
4576			BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500);
4577
4578			if (BX.browser.IsIE())
4579			{
4580				BX.ajax.history.obFrame = document.createElement('IFRAME');
4581				BX.hide_object(BX.ajax.history.obFrame);
4582
4583				document.body.appendChild(BX.ajax.history.obFrame);
4584
4585				BX.ajax.history.obFrame.contentWindow.document.open();
4586				BX.ajax.history.obFrame.contentWindow.document.write(BX.ajax.history.expected_hash);
4587				BX.ajax.history.obFrame.contentWindow.document.close();
4588			}
4589			else if (BX.browser.IsOpera())
4590			{
4591				BX.ajax.history.obImage = document.createElement('IMG');
4592				BX.hide_object(BX.ajax.history.obImage);
4593
4594				document.body.appendChild(BX.ajax.history.obImage);
4595
4596				BX.ajax.history.obImage.setAttribute('src', 'javascript:location.href = \'javascript:BX.ajax.history.__hashListener();\';');
4597			}
4598		}
4599
4600		BX.ajax.history.bInited = true;
4601	},
4602
4603	__hashListener: function(e)
4604	{
4605		e = e || window.event || {state:false};
4606
4607		if (BX.ajax.history.bPushState)
4608		{
4609			BX.ajax.history.obParams.setState(e.state||BX.ajax.history.startState);
4610		}
4611		else
4612		{
4613			if (BX.ajax.history.obTimer)
4614			{
4615				window.clearTimeout(BX.ajax.history.obTimer);
4616				BX.ajax.history.obTimer = null;
4617			}
4618
4619			if (null != BX.ajax.history.obFrame)
4620				var current_hash = BX.ajax.history.obFrame.contentWindow.document.body.innerText;
4621			else
4622				var current_hash = window.location.hash;
4623
4624			if (!current_hash || current_hash == '#')
4625				current_hash = '__bx_no_hash__';
4626
4627			if (current_hash.indexOf('#') == 0)
4628				current_hash = current_hash.substring(1);
4629
4630			if (current_hash != BX.ajax.history.expected_hash)
4631			{
4632				var state = jsAjaxHistoryContainer.get(current_hash);
4633				if (state)
4634				{
4635					BX.ajax.history.obParams.setState(state);
4636
4637					BX.ajax.history.expected_hash = current_hash;
4638					if (null != BX.ajax.history.obFrame)
4639					{
4640						var __hash = current_hash == '__bx_no_hash__' ? '' : current_hash;
4641						if (window.location.hash != __hash && window.location.hash != '#' + __hash)
4642							window.location.hash = __hash;
4643					}
4644				}
4645			}
4646
4647			BX.ajax.history.obTimer = setTimeout(BX.ajax.history.__hashListener, 500);
4648		}
4649	},
4650
4651	put: function(state, new_hash, new_hash1, bStartState)
4652	{
4653		if (this.bPushState)
4654		{
4655			if(!bStartState)
4656			{
4657				history.pushState(state, '', new_hash);
4658			}
4659			else
4660			{
4661				BX.ajax.history.startState = state;
4662			}
4663		}
4664		else
4665		{
4666			if (typeof new_hash1 != 'undefined')
4667				new_hash = new_hash1;
4668			else
4669				new_hash = 'view' + new_hash;
4670
4671			jsAjaxHistoryContainer.put(new_hash, state);
4672			BX.ajax.history.expected_hash = new_hash;
4673
4674			window.location.hash = BX.util.urlencode(new_hash);
4675
4676			if (null != BX.ajax.history.obFrame)
4677			{
4678				BX.ajax.history.obFrame.contentWindow.document.open();
4679				BX.ajax.history.obFrame.contentWindow.document.write(new_hash);
4680				BX.ajax.history.obFrame.contentWindow.document.close();
4681			}
4682		}
4683	},
4684
4685	checkRedirectStart: function(param_name, param_value)
4686	{
4687		var current_hash = window.location.hash;
4688		if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1);
4689
4690		var test = current_hash.substring(0, 5);
4691		if (test == 'view/' || test == 'view%')
4692		{
4693			BX.ajax.history.bHashCollision = true;
4694			document.write('<' + 'div id="__ajax_hash_collision_' + param_value + '" style="display: none;">');
4695		}
4696	},
4697
4698	checkRedirectFinish: function(param_name, param_value)
4699	{
4700		document.write('</div>');
4701
4702		var current_hash = window.location.hash;
4703		if (current_hash.substring(0, 1) == '#') current_hash = current_hash.substring(1);
4704
4705		BX.ready(function ()
4706		{
4707			var test = current_hash.substring(0, 5);
4708			if (test == 'view/' || test == 'view%')
4709			{
4710				var obColNode = BX('__ajax_hash_collision_' + param_value);
4711				var obNode = obColNode.firstChild;
4712				BX.cleanNode(obNode);
4713				obColNode.style.display = 'block';
4714
4715				// IE, Opera and Chrome automatically modifies hash with urlencode, but FF doesn't ;-(
4716				if (test != 'view%')
4717					current_hash = BX.util.urlencode(current_hash);
4718
4719				current_hash += (current_hash.indexOf('%3F') == -1 ? '%3F' : '%26') + param_name + '=' + param_value;
4720
4721				var url = '/bitrix/tools/ajax_redirector.php?hash=' + current_hash;
4722
4723				BX.ajax.insertToNode(url, obNode);
4724			}
4725		});
4726	}
4727}
4728
4729BX.ajax.component = function(node)
4730{
4731	this.node = node;
4732}
4733
4734BX.ajax.component.prototype.getState = function()
4735{
4736	var state = {
4737		'node': this.node,
4738		'title': window.document.title,
4739		'data': BX(this.node).innerHTML
4740	};
4741
4742	var obNavChain = BX('navigation');
4743	if (null != obNavChain)
4744		state.nav_chain = obNavChain.innerHTML;
4745
4746	return state;
4747}
4748
4749BX.ajax.component.prototype.setState = function(state)
4750{
4751	BX(state.node).innerHTML = state.data;
4752	BX.ajax.UpdatePageTitle(state.title);
4753
4754	if (state.nav_chain)
4755		BX.ajax.UpdatePageNavChain(state.nav_chain);
4756}
4757
4758var jsAjaxHistoryContainer = {
4759	arHistory: {},
4760
4761	put: function(hash, state)
4762	{
4763		this.arHistory[hash] = state;
4764	},
4765
4766	get: function(hash)
4767	{
4768		return this.arHistory[hash];
4769	}
4770}
4771
4772
4773BX.ajax.FormData = function()
4774{
4775	this.elements = [];
4776	this.files = [];
4777	this.features = {};
4778	this.isSupported();
4779	this.log('BX FormData init');
4780}
4781
4782BX.ajax.FormData.isSupported = function()
4783{
4784	var f = new BX.ajax.FormData()
4785	var result = f.features.supported;
4786	f = null;
4787	return result;
4788}
4789
4790BX.ajax.FormData.prototype.log = function(o)
4791{
4792	if (false) {
4793		try {
4794			if (BX.browser.IsIE()) o = JSON.stringify(o);
4795			console.log(o);
4796		} catch(e) {}
4797	}
4798}
4799
4800BX.ajax.FormData.prototype.isSupported = function()
4801{
4802	var f = {};
4803	f.fileReader = (window.FileReader && window.FileReader.prototype.readAsBinaryString);
4804	f.readFormData = f.sendFormData = !!(window.FormData);
4805	f.supported = !!(f.readFormData && f.sendFormData);
4806	this.features = f;
4807	this.log('features:');
4808	this.log(f);
4809
4810	return f.supported;
4811}
4812
4813BX.ajax.FormData.prototype.append = function(name, value)
4814{
4815	if (typeof(value) === 'object') { // seems to be files element
4816		this.files.push({'name': name, 'value':value});
4817	} else {
4818		this.elements.push({'name': name, 'value':value});
4819	}
4820}
4821
4822BX.ajax.FormData.prototype.send = function(url, callbackOk, callbackProgress, callbackError)
4823{
4824	this.log('FD send');
4825	this.xhr = BX.ajax({
4826			'method': 'POST',
4827			'dataType': 'html',
4828			'url': url,
4829			'onsuccess': callbackOk,
4830			'onfailure': callbackError,
4831			'start': false,
4832			'preparePost':false
4833		});
4834
4835	if (callbackProgress)
4836	{
4837		this.xhr.upload.addEventListener(
4838			'progress',
4839			function(e) {
4840				if (e.lengthComputable)
4841					callbackProgress(e.loaded / e.totalSize);
4842			},
4843			false
4844		);
4845	}
4846
4847	if (this.features.readFormData && this.features.sendFormData)
4848	{
4849		var fd = new FormData();
4850		this.log('use browser formdata');
4851		for (i in this.elements)
4852			fd.append(this.elements[i].name,this.elements[i].value);
4853		for (i in this.files)
4854			fd.append(this.files[i].name, this.files[i].value);
4855		this.xhr.send(fd);
4856	}
4857
4858	return this.xhr;
4859}
4860
4861BX.addCustomEvent('onAjaxFailure', BX.debug);
4862})(window)
4863
4864/* End */
4865;
4866; /* Start:/bitrix/js/main/core/core_fx.js*/
4867;(function(window){
4868
4869var defaultOptions = {
4870	time: 1.0,
4871	step: 0.05,
4872	type: 'linear',
4873
4874	allowFloat: false
4875}
4876
4877/*
4878options: {
4879	start: start value or {param: value, param: value}
4880	finish: finish value or {param: value, param: value}
4881	time: time to transform in seconds
4882	type: linear|accelerated|decelerated|custom func name
4883	callback,
4884	callback_start,
4885	callback_complete,
4886
4887	step: time between steps in seconds
4888	allowFloat: false|true
4889}
4890*/
4891BX.fx = function(options)
4892{
4893	this.options = options;
4894
4895	if (null != this.options.time)
4896		this.options.originalTime = this.options.time;
4897	if (null != this.options.step)
4898		this.options.originalStep = this.options.step;
4899
4900	if (!this.__checkOptions())
4901		return false;
4902
4903	this.__go = BX.delegate(this.go, this);
4904
4905	this.PARAMS = {};
4906}
4907
4908BX.fx.prototype.__checkOptions = function()
4909{
4910	if (typeof this.options.start != typeof this.options.finish)
4911		return false;
4912
4913	if (null == this.options.time) this.options.time = defaultOptions.time;
4914	if (null == this.options.step) this.options.step = defaultOptions.step;
4915	if (null == this.options.type) this.options.type = defaultOptions.type;
4916	if (null == this.options.allowFloat) this.options.allowFloat = defaultOptions.allowFloat;
4917
4918	this.options.time *= 1000;
4919	this.options.step *= 1000;
4920
4921	if (typeof this.options.start != 'object')
4922	{
4923		this.options.start = {_param: this.options.start};
4924		this.options.finish = {_param: this.options.finish};
4925	}
4926
4927	var i;
4928	for (i in this.options.start)
4929	{
4930		if (null == this.options.finish[i])
4931		{
4932			this.options.start[i] = null;
4933			delete this.options.start[i];
4934		}
4935	}
4936
4937	if (!BX.type.isFunction(this.options.type))
4938	{
4939		if (BX.type.isFunction(window[this.options.type]))
4940			this.options.type = window[this.options.type];
4941		else if (BX.type.isFunction(BX.fx.RULES[this.options.type]))
4942			this.options.type = BX.fx.RULES[this.options.type];
4943		else
4944			this.options.type = BX.fx.RULES[defaultOptions.type];
4945	}
4946
4947	return true;
4948}
4949
4950BX.fx.prototype.go = function()
4951{
4952	var timeCurrent = new Date().valueOf();
4953	if (timeCurrent < this.PARAMS.timeFinish)
4954	{
4955		for (var i in this.PARAMS.current)
4956		{
4957			this.PARAMS.current[i][0] = this.options.type.apply(this, [{
4958				start_value: this.PARAMS.start[i][0],
4959				finish_value: this.PARAMS.finish[i][0],
4960				current_value: this.PARAMS.current[i][0],
4961				current_time: timeCurrent - this.PARAMS.timeStart,
4962				total_time: this.options.time
4963			}]);
4964		}
4965
4966		this._callback(this.options.callback);
4967
4968		if (!this.paused)
4969			this.PARAMS.timer = setTimeout(this.__go, this.options.step);
4970	}
4971	else
4972	{
4973		this.stop();
4974	}
4975}
4976
4977BX.fx.prototype._callback = function(cb)
4978{
4979	var tmp = {};
4980
4981	cb = cb || this.options.callback;
4982
4983	for (var i in this.PARAMS.current)
4984	{
4985		tmp[i] = (this.options.allowFloat ? this.PARAMS.current[i][0] : Math.round(this.PARAMS.current[i][0])) + this.PARAMS.current[i][1];
4986	}
4987
4988	return cb.apply(this, [null != tmp['_param'] ? tmp._param : tmp]);
4989}
4990
4991BX.fx.prototype.start = function()
4992{
4993	var i,value, unit;
4994
4995	this.PARAMS.start = {};
4996	this.PARAMS.current = {};
4997	this.PARAMS.finish = {};
4998
4999	for (i in this.options.start)
5000	{
5001		value = +this.options.start[i];
5002		unit = (this.options.start[i]+'').substring((value+'').length);
5003		this.PARAMS.start[i] = [value, unit];
5004		this.PARAMS.current[i] = [value, unit];
5005		this.PARAMS.finish[i] = [+this.options.finish[i], unit];
5006	}
5007
5008	this._callback(this.options.callback_start);
5009	this._callback(this.options.callback);
5010
5011	this.PARAMS.timeStart = new Date().valueOf();
5012	this.PARAMS.timeFinish = this.PARAMS.timeStart + this.options.time;
5013	this.PARAMS.timer = setTimeout(BX.delegate(this.go, this), this.options.step);
5014
5015	return this;
5016}
5017
5018BX.fx.prototype.pause = function()
5019{
5020	if (this.paused)
5021	{
5022		this.PARAMS.timer = setTimeout(this.__go, this.options.step);
5023		this.paused = false;
5024	}
5025	else
5026	{
5027		clearTimeout(this.PARAMS.timer);
5028		this.paused = true;
5029	}
5030}
5031
5032BX.fx.prototype.stop = function(silent)
5033{
5034	silent = !!silent;
5035	if (this.PARAMS.timer)
5036		clearTimeout(this.PARAMS.timer);
5037
5038	if (null != this.options.originalTime)
5039		this.options.time = this.options.originalTime;
5040	if (null != this.options.originalStep)
5041		this.options.step = this.options.originalStep;
5042
5043	this.PARAMS.current = this.PARAMS.finish;
5044	if (!silent) {
5045		this._callback(this.options.callback);
5046		this._callback(this.options.callback_complete);
5047	}
5048}
5049
5050/*
5051type rules of animation
5052 - linear - simple linear animation
5053 - accelerated
5054 - decelerated
5055*/
5056
5057/*
5058	params: {
5059		start_value, finish_value, current_time, total_time
5060	}
5061*/
5062BX.fx.RULES =
5063{
5064	linear: function(params)
5065	{
5066		return params.start_value + (params.current_time/params.total_time) * (params.finish_value - params.start_value);
5067	},
5068
5069	decelerated: function(params)
5070	{
5071		return params.start_value + Math.sqrt(params.current_time/params.total_time) * (params.finish_value - params.start_value);
5072	},
5073
5074	accelerated: function(params)
5075	{
5076		var q = params.current_time/params.total_time;
5077		return params.start_value + q * q * (params.finish_value - params.start_value);
5078	}
5079}
5080
5081/****************** effects realizaion ************************/
5082
5083/*
5084	type = 'fade' || 'scroll' || 'scale' || 'fold'
5085*/
5086
5087BX.fx.hide = function(el, type, opts)
5088{
5089	el = BX(el);
5090
5091	if (typeof type == 'object' && null == opts)
5092	{
5093		opts = type;
5094		type = opts.type
5095	}
5096
5097	if (!BX.type.isNotEmptyString(type))
5098	{
5099		el.style.display = 'none';
5100		return;
5101	}
5102
5103	var fxOptions = BX.fx.EFFECTS[type](el, opts, 0);
5104	fxOptions.callback_complete = function () {
5105		if (opts.hide !== false)
5106			el.style.display = 'none';
5107
5108		if (opts.callback_complete)
5109			opts.callback_complete.apply(this, arguments);
5110	}
5111
5112	return (new BX.fx(fxOptions)).start();
5113}
5114
5115BX.fx.show = function(el, type, opts)
5116{
5117	el = BX(el);
5118
5119	if (typeof type == 'object' && null == opts)
5120	{
5121		opts = type;
5122		type = opts.type
5123	}
5124
5125	if (!opts) opts = {};
5126
5127	if (!BX.type.isNotEmptyString(type))
5128	{
5129		el.style.display = 'block';
5130		return;
5131	}
5132
5133	var fxOptions = BX.fx.EFFECTS[type](el, opts, 1);
5134
5135	fxOptions.callback_complete = function () {
5136		if (opts.show !== false)
5137			el.style.display = 'block';
5138
5139		if (opts.callback_complete)
5140			opts.callback_complete.apply(this, arguments);
5141	}
5142
5143	return (new BX.fx(fxOptions)).start();
5144}
5145
5146BX.fx.EFFECTS = {
5147	scroll: function(el, opts, action)
5148	{
5149		if (!opts.direction) opts.direction = 'vertical';
5150
5151		var param = opts.direction == 'horizontal' ? 'width' : 'height';
5152
5153		var val = parseInt(BX.style(el, param));
5154		if (isNaN(val))
5155		{
5156			val = BX.pos(el)[param];
5157		}
5158
5159		if (action == 0)
5160			var start = val, finish = opts.min_height ? parseInt(opts.min_height) : 0;
5161		else
5162			var finish = val, start = opts.min_height ? parseInt(opts.min_height) : 0;
5163
5164		return {
5165			'start': start,
5166			'finish': finish,
5167			'time': opts.time || defaultOptions.time,
5168			'type': 'linear',
5169			callback_start: function () {
5170				if (BX.style(el, 'position') == 'static')
5171					el.style.position = 'relative';
5172
5173				el.style.overflow = 'hidden';
5174				el.style[param] = start + 'px';
5175				el.style.display = 'block';
5176			},
5177			callback: function (val) {el.style[param] = val + 'px';}
5178		}
5179	},
5180
5181	fade: function(el, opts, action)
5182	{
5183		var fadeOpts = {
5184			'time': opts.time || defaultOptions.time,
5185			'type': action == 0 ? 'decelerated' : 'linear',
5186			'start': action == 0 ? 1 : 0,
5187			'finish': action == 0 ? 0 : 1,
5188			'allowFloat': true
5189		};
5190
5191		if (BX.browser.IsIE() && !BX.browser.IsIE9())
5192		{
5193			fadeOpts.start *= 100; fadeOpts.finish *= 100; fadeOpts.allowFloat = false;
5194
5195			fadeOpts.callback_start = function() {
5196				el.style.display = 'block';
5197				el.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity=" + fadeOpts.start + ")";
5198			};
5199
5200			fadeOpts.callback = function (val) {
5201				(el.filters['DXImageTransform.Microsoft.alpha']||el.filters.alpha).opacity = val;
5202			}
5203		}
5204		else
5205		{
5206			fadeOpts.callback_start = function () {
5207				el.style.display = 'block';
5208			}
5209
5210			fadeOpts.callback = function (val) {
5211				el.style.opacity = el.style.KhtmlOpacity = el.style.MozOpacity = val;
5212			};
5213		}
5214
5215		return fadeOpts;
5216	},
5217
5218	fold: function (el, opts, action) // 'fold' is a combination of two consequential 'scroll' hidings.
5219	{
5220		if (action != 0) return;
5221
5222		var pos = BX.pos(el);
5223		var coef = pos.height / (pos.width + pos.height);
5224		var old_opts = {time: opts.time || defaultOptions.time, callback_complete: opts.callback_complete, hide: opts.hide};
5225
5226		opts.type = 'scroll';
5227		opts.direction = 'vertical';
5228		opts.min_height = opts.min_height || 10;
5229		opts.hide = false;
5230		opts.time = coef * old_opts.time;
5231		opts.callback_complete = function()
5232		{
5233			el.style.whiteSpace = 'nowrap';
5234
5235			opts.direction = 'horizontal';
5236			opts.min_height = null;
5237
5238			opts.time = old_opts.time - opts.time;
5239			opts.hide = old_opts.hide;
5240			opts.callback_complete = old_opts.callback_complete;
5241
5242			BX.fx.hide(el, opts);
5243		}
5244
5245		return BX.fx.EFFECTS.scroll(el, opts, action);
5246	},
5247
5248	scale: function (el, opts, action)
5249	{
5250		var val = {width: parseInt(BX.style(el, 'width')), height: parseInt(BX.style(el, 'height'))};
5251		if (isNaN(val.width) || isNaN(val.height))
5252		{
5253			var pos = BX.pos(el)
5254			val = {width: pos.width, height: pos.height};
5255		}
5256
5257		if (action == 0)
5258			var start = val, finish = {width: 0, height: 0};
5259		else
5260			var finish = val, start = {width: 0, height: 0};
5261
5262		return {
5263			'start': start,
5264			'finish': finish,
5265			'time': opts.time || defaultOptions.time,
5266			'type': 'linear',
5267			callback_start: function () {
5268				el.style.position = 'relative';
5269				el.style.overflow = 'hidden';
5270				el.style.display = 'block';
5271				el.style.height = start.height + 'px';
5272				el.style.width = start.width + 'px';
5273			},
5274			callback: function (val) {
5275				el.style.height = val.height + 'px';
5276				el.style.width = val.width + 'px';
5277			}
5278		}
5279	}
5280}
5281
5282// Color animation
5283//
5284// Set animation rule
5285// BX.fx.colorAnimate.addRule('animationRule1',"#FFF","#faeeb4", "background-color", 100, 1, true);
5286// BX.fx.colorAnimate.addRule('animationRule2',"#fc8282","#ff0000", "color", 100, 1, true);
5287// Params: 1 - animation name, 2 - start color, 3 - end color, 4 - count step, 5 - delay each step, 6 - return color on end animation
5288//
5289// Animate color for element
5290// BX.fx.colorAnimate(BX('element'), 'animationRule1,animationRule2');
5291
5292var defaultOptionsColorAnimation = {
5293	arStack: {},
5294	arRules: {},
5295	globalAnimationId: 0
5296}
5297
5298BX.fx.colorAnimate = function(element, rule, back)
5299{
5300	if (element == null)
5301		return;
5302
5303	animationId = element.getAttribute('data-animation-id');
5304	if (animationId == null)
5305	{
5306		animationId = defaultOptionsColorAnimation.globalAnimationId;
5307		element.setAttribute('data-animation-id', defaultOptionsColorAnimation.globalAnimationId++);
5308	}
5309	var aRuleList = rule.split(/\s*,\s*/);
5310
5311	for (var j	= 0; j < aRuleList.length; j++)
5312	{
5313		rule = aRuleList[j];
5314
5315		if (!defaultOptionsColorAnimation.arRules[rule]) continue;
5316
5317		var i=0;
5318
5319		if (!defaultOptionsColorAnimation.arStack[animationId])
5320		{
5321			defaultOptionsColorAnimation.arStack[animationId] = {};
5322		}
5323		else if (defaultOptionsColorAnimation.arStack[animationId][rule])
5324		{
5325			i = defaultOptionsColorAnimation.arStack[animationId][rule].i;
5326			clearInterval(defaultOptionsColorAnimation.arStack[animationId][rule].tId);
5327		}
5328
5329		if ((i==0 && back) || (i==defaultOptionsColorAnimation.arRules[rule][3] && !back)) continue;
5330
5331		defaultOptionsColorAnimation.arStack[animationId][rule] = {'i':i, 'element': element, 'tId':setInterval('BX.fx.colorAnimate.run("'+animationId+'","'+rule+'")', defaultOptionsColorAnimation.arRules[rule][4]),'back':Boolean(back)};
5332	}
5333}
5334
5335BX.fx.colorAnimate.addRule = function (rule, startColor, finishColor, cssProp, step, delay, back)
5336{
5337	defaultOptionsColorAnimation.arRules[rule] = [
5338		BX.util.hex2rgb(startColor),
5339		BX.util.hex2rgb(finishColor),
5340		cssProp.replace(/\-(.)/g,function(){return arguments[1].toUpperCase();}),
5341		step,
5342		delay || 1,
5343		back || false
5344	];
5345};
5346
5347BX.fx.colorAnimate.run = function(animationId, rule)
5348{
5349	element = defaultOptionsColorAnimation.arStack[animationId][rule].element;
5350
5351    defaultOptionsColorAnimation.arStack[animationId][rule].i += defaultOptionsColorAnimation.arStack[animationId][rule].back?-1:1;
5352 	var finishPercent = defaultOptionsColorAnimation.arStack[animationId][rule].i/defaultOptionsColorAnimation.arRules[rule][3];
5353	var startPercent = 1 - finishPercent;
5354
5355	var aRGBStart = defaultOptionsColorAnimation.arRules[rule][0];
5356	var aRGBFinish = defaultOptionsColorAnimation.arRules[rule][1];
5357
5358	element.style[defaultOptionsColorAnimation.arRules[rule][2]] = 'rgb('+
5359	Math.floor( aRGBStart['r'] * startPercent + aRGBFinish['r'] * finishPercent ) + ','+
5360	Math.floor( aRGBStart['g'] * startPercent + aRGBFinish['g'] * finishPercent ) + ','+
5361	Math.floor( aRGBStart['b'] * startPercent + aRGBFinish['b'] * finishPercent ) +')';
5362
5363	if ( defaultOptionsColorAnimation.arStack[animationId][rule].i == defaultOptionsColorAnimation.arRules[rule][3] || defaultOptionsColorAnimation.arStack[animationId][rule].i ==0)
5364	{
5365		clearInterval(defaultOptionsColorAnimation.arStack[animationId][rule].tId);
5366		if (defaultOptionsColorAnimation.arRules[rule][5])
5367			BX.fx.colorAnimate(defaultOptionsColorAnimation.arStack[animationId][rule].element, rule, true);
5368	}
5369}
5370
5371
5372/*
5373options = {
5374	delay: 100,
5375	duration : 3000,
5376	start : { scroll : document.body.scrollTop, left : 0, opacity :  100 },
5377	finish : { scroll : document.body.scrollHeight, left : 500, opacity : 10 },
5378	transition : BitrixAnimation.makeEaseOut(BitrixAnimation.transitions.quart),
5379
5380	step : function(state)
5381	{
5382		document.body.scrollTop = state.scroll;
5383		button.style.left =  state.left + "px";
5384		button.style.opacity =  state.opacity / 100;
5385	},
5386	complete : function()
5387	{
5388		button.style.background = "green";
5389	}
5390}
5391
5392options =
5393{
5394	delay : 20,
5395	duration : 4000,
5396	transition : BXAnimation.makeEaseOut(BXAnimation.transitions.quart),
5397	progress : function(progress)
5398	{
5399		document.body.scrollTop = Math.round(topMax * progress);
5400		button.style.left =  Math.round(leftMax * progress) + "px";
5401		button.style.opacity =  (100 + Math.round((opacityMin - 100) * progress)) / 100;
5402
5403	},
5404	complete : function()
5405	{
5406		button.style.background = "green";
5407	}
5408}
5409*/
5410
5411BX.easing = function(options)
5412{
5413	this.options = options;
5414	this.timer = null;
5415};
5416
5417BX.easing.prototype.animate = function()
5418{
5419	if (!this.options || !this.options.start || !this.options.finish ||
5420		typeof(this.options.start) != "object" || typeof(this.options.finish) != "object"
5421		)
5422		return null;
5423
5424	for (var propName in this.options.start)
5425	{
5426		if (typeof(this.options.finish[propName]) == "undefined")
5427		{
5428			delete this.options.start[propName];
5429		}
5430	}
5431
5432	this.options.progress = function(progress) {
5433		var state = {};
5434		for (var propName in this.start)
5435			state[propName] = Math.round(this.start[propName] + (this.finish[propName] - this.start[propName]) * progress);
5436
5437		if (this.step)
5438			this.step(state);
5439	};
5440
5441	this.animateProgress();
5442};
5443
5444BX.easing.prototype.stop = function(completed)
5445{
5446	if (this.timer)
5447	{
5448		clearInterval(this.timer);
5449		this.timer = null;
5450
5451		if (completed)
5452			this.options.complete && this.options.complete();
5453	}
5454};
5455
5456BX.easing.prototype.animateProgress = function()
5457{
5458	var start = new Date();
5459	var delta = this.options.transition || BX.easing.transitions.linear;
5460	var duration = this.options.duration || 1000;
5461
5462	this.timer = setInterval(BX.proxy(function() {
5463
5464		var progress = (new Date() - start) / duration;
5465		if (progress > 1)
5466			progress = 1;
5467
5468		this.options.progress(delta(progress));
5469
5470		if (progress == 1)
5471			this.stop(true);
5472
5473	}, this), this.options.delay || 13);
5474
5475};
5476
5477BX.easing.makeEaseInOut = function(delta)
5478{
5479	return function(progress) {
5480		if (progress < 0.5)
5481			return delta( 2 * progress ) / 2;
5482		else
5483			return (2 - delta( 2 * (1-progress) ) ) / 2;
5484	}
5485};
5486
5487BX.easing.makeEaseOut = function(delta)
5488{
5489	return function(progress) {
5490		return 1 - delta(1 - progress);
5491	};
5492};
5493
5494BX.easing.transitions = {
5495
5496	linear : function(progress)
5497	{
5498		return progress;
5499	},
5500
5501	quad : function(progress)
5502	{
5503		return Math.pow(progress, 2);
5504	},
5505
5506	cubic : function(progress) {
5507		return Math.pow(progress, 3);
5508	},
5509
5510	quart : function(progress)
5511	{
5512		return Math.pow(progress, 4);
5513	},
5514
5515	quint : function(progress)
5516	{
5517		return Math.pow(progress, 5);
5518	},
5519
5520	circ : function(progress)
5521	{
5522		return 1 - Math.sin(Math.acos(progress));
5523	},
5524
5525	back : function(progress)
5526	{
5527		return Math.pow(progress, 2) * ((1.5 + 1) * progress - 1.5);
5528	},
5529
5530	elastic: function(progress)
5531	{
5532		return Math.pow(2, 10 * (progress-1)) * Math.cos(20 * Math.PI * 1.5/3 * progress);
5533	},
5534
5535	bounce : function(progress)
5536	{
5537		for(var a = 0, b = 1; 1; a += b, b /= 2) {
5538			if (progress >= (7 - 4 * a) / 11) {
5539				return -Math.pow((11 - 6 * a - 11 * progress) / 4, 2) + Math.pow(b, 2);
5540			}
5541		}
5542	}};
5543
5544
5545})(window);
5546
5547/* End */
5548;
5549; /* Start:/bitrix/js/main/session.js*/
5550function CBXSession()
5551{
5552	var _this = this;
5553	this.mess = {};
5554	this.timeout = null;
5555	this.sessid = null;
5556	this.bShowMess = true;
5557	this.dateStart = new Date();
5558	this.dateInput = new Date();
5559	this.dateCheck = new Date();
5560	this.activityInterval = 0;
5561	this.notifier = null;
5562	
5563	this.Expand = function(timeout, sessid, bShowMess, key)
5564	{
5565		this.timeout = timeout;
5566		this.sessid = sessid;
5567		this.bShowMess = bShowMess;
5568		this.key = key;
5569		
5570		BX.ready(function(){
5571			BX.bind(document, "keypress", _this.OnUserInput);
5572			BX.bind(document.body, "mousemove", _this.OnUserInput);
5573			BX.bind(document.body, "click", _this.OnUserInput);
5574			
5575			setTimeout(_this.CheckSession, (_this.timeout-60)*1000);
5576		})
5577	},
5578		
5579	this.OnUserInput = function()
5580	{
5581		var curr = new Date();
5582		_this.dateInput.setTime(curr.valueOf());
5583	}
5584	
5585	this.CheckSession = function()
5586	{
5587		var curr = new Date();
5588		if(curr.valueOf() - _this.dateCheck.valueOf() < 30000)
5589			return;
5590
5591		_this.activityInterval = Math.round((_this.dateInput.valueOf() - _this.dateStart.valueOf())/1000);
5592		_this.dateStart.setTime(_this.dateInput.valueOf());
5593		var interval = (_this.activityInterval > _this.timeout? (_this.timeout-60) : _this.activityInterval);
5594		BX.ajax.get('/bitrix/tools/public_session.php?sessid='+_this.sessid+'&interval='+interval+'&k='+_this.key, function(data){_this.CheckResult(data)});
5595	}
5596	
5597	this.CheckResult = function(data)
5598	{
5599		if(data == 'SESSION_EXPIRED')
5600		{
5601			if(_this.bShowMess)
5602			{
5603				_this.notifier = document.body.appendChild(BX.create('DIV', {
5604					props: {className: 'bx-session-message'},
5605					style: {top: '-1000px'},
5606					html: '<a class="bx-session-message-close" href="javascript:bxSe
5606ssion.Close()"></a>'+_this.mess.messSessExpired
5607				}));
5608	
5609				var windowScroll = BX.GetWindowScrollPos();
5610				var windowSize = BX.GetWindowInnerSize();
5611
5612				_this.notifier.style.left = parseInt(windowScroll.scrollLeft + windowSize.innerWidth / 2 - parseInt(_this.notifier.clientWidth) / 2) + 'px';
5613
5614				var fxStart = windowScroll.scrollTop - _this.notifier.offsetHeight;
5615				var fxFinish = windowScroll.scrollTop;
5616	
5617				(new BX.fx({
5618					time: 0.5,
5619					step: 0.01,
5620					type: 'accelerated',
5621					start: fxStart,
5622					finish: fxFinish,
5623					callback: function(top){_this.notifier.style.top = top + 'px';},
5624					callback_complete: function()
5625					{
5626						if(BX.browser.IsIE())
5627						{
5628							BX.bind(window, 'scroll', function()
5629							{
5630								var windowScroll = BX.GetWindowScrollPos();
5631								_this.notifier.style.top = windowScroll.scrollTop + 'px';
5632							});
5633						}
5634						else
5635						{
5636							_this.notifier.style.top='0px';
5637							_this.notifier.style.position='fixed';
5638						}
5639					}
5640				})).start();
5641			}
5642		}
5643		else
5644		{
5645			var timeout;
5646			if(data == 'SESSION_CHANGED')
5647				timeout = (_this.timeout-60);
5648			else
5649				timeout = (_this.activityInterval < 60? 60 : (_this.activityInterval > _this.timeout? (_this.timeout-60) : _this.activityInterval));
5650
5651			var curr = new Date();
5652			_this.dateCheck.setTime(curr.valueOf());
5653			setTimeout(_this.CheckSession, timeout*1000);
5654		}
5655	}
5656	
5657	this.Close = function()
5658	{
5659		this.notifier.style.display = 'none';
5660	}
5661}
5662
5663var bxSession = new CBXSession();
5664/* End */
5665;
5666; /* Start:/bitrix/js/main/core/core_window.js*/
5667;(function(window) {
5668if (BX.WindowManager) return;
5669
5670/* windows manager */
5671BX.WindowManager = {
5672	_stack: [],
5673	_runtime_resize: {},
5674	_delta: 2,
5675	_delta_start: 1000,
5676	currently_loaded: null,
5677
5678	settings_category: 'BX.WindowManager.9.5',
5679
5680	register: function (w)
5681	{
5682		this.currently_loaded = null;
5683		var div = w.Get();
5684
5685		div.style.zIndex = w.zIndex = this.GetZIndex();
5686
5687		w.WM_REG_INDEX = this._stack.length;
5688		this._stack.push(w);
5689
5690		if (this._stack.length < 2)
5691		{
5692			BX.bind(document, 'keyup', BX.proxy(this.__checkKeyPress, this));
5693		}
5694	},
5695
5696	unregister: function (w)
5697	{
5698		if (null == w.WM_REG_INDEX)
5699			return null;
5700
5701		var _current;
5702		if (this._stack.length > 0)
5703		{
5704			while ((_current = this.__pop_stack()) != w)
5705			{
5706				if (!_current)
5707				{
5708					_current = null;
5709					break;
5710				}
5711			}
5712
5713			if (this._stack.length <= 0)
5714			{
5715				this.enableKeyCheck();
5716			}
5717
5718			return _current;
5719		}
5720		else
5721		{
5722			return null;
5723		}
5724	},
5725
5726	__pop_stack: function(clean)
5727	{
5728		if (this._stack.length > 0)
5729		{
5730			var _current = this._stack.pop();
5731			_current.WM_REG_INDEX = null;
5732			BX.onCustomEvent(_current, 'onWindowUnRegister', [clean === true]);
5733
5734			return _current;
5735		}
5736		else
5737			return null;
5738	},
5739
5740	clean: function()
5741	{
5742		while (this.__pop_stack(true)){}
5743		this._stack = null;
5744		this.disableKeyCheck();
5745	},
5746
5747	Get: function()
5748	{
5749		if (this.currently_loaded)
5750			return this.currently_loaded;
5751		else if (this._stack.length > 0)
5752			return this._stack[this._stack.length-1];
5753		else
5754			return null;
5755	},
5756
5757	setStartZIndex: function(value)
5758	{
5759		this._delta_start = value;
5760	},
5761
5762	restoreStartZIndex: function()
5763	{
5764		this._delta_start = 1000;
5765	},
5766
5767	GetZIndex: function()
5768	{
5769		return (null != (_current = this._stack[this._stack.length-1])
5770			? parseInt(_current.Get().style.zIndex) + this._delta
5771			: this._delta_start
5772		);
5773	},
5774
5775	__get_check_url: function(url)
5776	{
5777		var pos = url.indexOf('?');
5778		return pos == -1 ? url : url.substring(0, pos);
5779	},
5780
5781	saveWindowSize: function(url, params)
5782	{
5783		var check_url = this.__get_check_url(url);
5784		if (BX.userOptions)
5785		{
5786			BX.userOptions.save(this.settings_category, 'size_' + check_url, 'width', params.width);
5787			BX.userOptions.save(this.settings_category, 'size_' + check_url, 'height', params.height);
5788		}
5789
5790		this._runtime_resize[check_url] = params;
5791	},
5792
5793	saveWindowOptions: function(wnd_id, opts)
5794	{
5795		if (BX.userOptions)
5796		{
5797			for (var i in opts)
5798			{
5799				BX.userOptions.save(this.settings_category, 'options_' + wnd_id, i, opts[i]);
5800			}
5801		}
5802	},
5803
5804	getRuntimeWindowSize: function(url)
5805	{
5806		return this._runtime_resize[this.__get_check_url(url)];
5807	},
5808
5809	disableKeyCheck: function()
5810	{
5811		BX.unbind(document, 'keyup', BX.proxy(this.__checkKeyPress, this));
5812	},
5813
5814	enableKeyCheck: function()
5815	{
5816		BX.bind(document, 'keyup', BX.proxy(this.__checkKeyPress, this));
5817	},
5818
5819	__checkKeyPress: function(e)
5820	{
5821		if (null == e)
5822			e = window.event;
5823
5824		if (e.keyCode == 27)
5825		{
5826			var wnd = BX.WindowManager.Get();
5827			if (wnd && !wnd.unclosable) wnd.Close();
5828		}
5829	}
5830};
5831
5832BX.garbage(BX.WindowManager.clean, BX.WindowManager);
5833
5834/* base button class */
5835BX.CWindowButton = function(params)
5836{
5837	if (params.btn)
5838	{
5839		this.btn = params.btn;
5840		this.parentWindow = params.parentWindow;
5841
5842		if (/save|apply/i.test(this.btn.name))
5843		{
5844			BX.bind(this.btn, 'click', BX.delegate(this.disableUntilError, this));
5845		}
5846	}
5847	else
5848	{
5849		this.title = params.title; // html value attr
5850		this.hint = params.hint; // html title attr
5851		this.id = params.id; // html name and id attrs
5852		this.name = params.name; // html name or value attrs when id and title 're absent
5853		this.className = params.className; // className for button input
5854
5855		this.action = params.action;
5856		this.onclick = params.onclick;
5857
5858		// you can override button creation method
5859		if (params.Button && BX.type.isFunction(params.Button))
5860			this.Button = params.Button;
5861
5862		this.btn = null;
5863	}
5864};
5865
5866BX.CWindowButton.prototype.disable = function()
5867{
5868	if (this.btn)
5869		this.parentWindow.showWait(this.btn);
5870};
5871BX.CWindowButton.prototype.enable = function(){
5872	if (this.btn)
5873		this.parentWindow.closeWait(this.btn);
5874};
5875
5876BX.CWindowButton.prototype.emulate = function()
5877{
5878	if (this.btn && this.btn.disabled)
5879		return;
5880
5881	var act =
5882		this.action
5883		? BX.delegate(this.action, this)
5884		: (
5885			this.onclick
5886			? this.onclick
5887			: (
5888				this.btn
5889				? this.btn.getAttribute('onclick')
5890				: ''
5891			)
5892		);
5893
5894	if (act)
5895	{
5896		setTimeout(act, 50);
5897		if (this.btn && /save|apply/i.test(this.btn.name) && !this.action)
5898		{
5899			this.disableUntilError();
5900		}
5901	}
5902};
5903
5904BX.CWindowButton.prototype.Button = function(parentWindow)
5905{
5906	this.parentWindow = parentWindow;
5907
5908	var btn = {
5909		props: {
5910			'type': 'button',
5911			'name': this.id ? this.id : this.name,
5912			'value': this.title ? this.title : this.name,
5913			'id': this.id
5914		}
5915	};
5916
5917	if (this.hint)
5918		btn.props.title = this.hint;
5919	if (!!this.className)
5920		btn.props.className = this.className;
5921
5922	if (this.action)
5923	{
5924		btn.events = {
5925			'click': BX.delegate(this.action, this)
5926		};
5927	}
5928	else if (this.onclick)
5929	{
5930		if (BX.browser.IsIE())
5931		{
5932			btn.events = {
5933				'click': BX.delegate(function() {eval(this.onclick)}, this)
5934			};
5935		}
5936		else
5937		{
5938			btn.attrs = {
5939				'onclick': this.onclick
5940			};
5941		}
5942	}
5943
5944	this.btn = BX.create('INPUT', btn);
5945
5946	return this.btn;
5947};
5948
5949BX.CWindowButton.prototype.disableUntilError = function() {
5950	this.disable();
5951	if (!this.__window_error_handler_set)
5952	{
5953		BX.addCustomEvent(this.parentWindow, 'onWindowError', BX.delegate(this.enable, this));
5954		this.__window_error_handler_set = true;
5955	}
5956};
5957
5958/* base window class */
5959BX.CWindow = function(div, type)
5960{
5961	this.DIV = div || document.createElement('DIV');
5962
5963	this.SETTINGS = {
5964		resizable: false,
5965		min_height: 0,
5966		min_width: 0,
5967		top: 0,
5968		left: 0,
5969		draggable: false,
5970		drag_restrict: true,
5971		resize_restrict: true
5972	};
5973
5974	this.ELEMENTS = {
5975		draggable: [],
5976		resizer: [],
5977		close: []
5978	};
5979
5980	this.type = type == 'float' ? 'float' : 'dialog';
5981
5982	BX.adjust(this.DIV, {
5983		props: {
5984			className: 'bx-core-window'
5985		},
5986		style: {
5987			'zIndex': 0,
5988			'position': 'absolute',
5989			'display': 'none',
5990			'top': this.SETTINGS.top + 'px',
5991			'left': this.SETTINGS.left + 'px',
5992			'height': '100px',
5993			'width': '100px'
5994		}
5995	});
5996
5997	this.isOpen = false;
5998
5999	BX.addCustomEvent(this, 'onWindowRegister', BX.delegate(this.onRegister, this));
6000	BX.addCustomEvent(this, 'onWindowUnRegister', BX.delegate(this.onUnRegister, this));
6001
6002	this.MOUSEOVER = null;
6003	BX.bind(this.DIV, 'mouseover', BX.delegate(this.__set_msover, this));
6004	BX.bind(this.DIV, 'mouseout', BX.delegate(this.__unset_msover, this));
6005
6006	BX.ready(BX.delegate(function() {
6007		document.body.appendChild(this.DIV);
6008	}, this));
6009};
6010
6011BX.CWindow.prototype.Get = function () {return this.DIV};
6012BX.CWindow.prototype.visible = function() {return this.isOpen;};
6013
6014BX.CWindow.prototype.Show = function(bNotRegister)
6015{
6016	this.DIV.style.display = 'block';
6017
6018	if (!bNotRegister)
6019	{
6020		BX.WindowManager.register(this);
6021		BX.onCustomEvent(this, 'onWindowRegister');
6022	}
6023};
6024
6025BX.CWindow.prototype.Hide = function()
6026{
6027	BX.WindowManager.unregister(this);
6028	this.DIV.style.display = 'none';
6029};
6030
6031BX.CWindow.prototype.onRegister = function()
6032{
6033	this.isOpen = true;
6034};
6035
6036BX.CWindow.prototype.onUnRegister = function(clean)
6037{
6038	this.isOpen = false;
6039
6040	if (clean || (this.PARAMS && this.PARAMS.content_url))
6041	{
6042		if (clean) {BX.onCustomEvent(this, 'onWindowClose', [this, true]);}
6043
6044		if (this.DIV.parentNode)
6045			this.DIV.parentNode.removeChild(this.DIV);
6046	}
6047	else
6048	{
6049		this.DIV.style.display = 'none';
6050	}
6051};
6052
6053BX.CWindow.prototype.CloseDialog = // compatibility
6054BX.CWindow.prototype.Close = function(bImmediately)
6055{
6056	BX.onCustomEvent(this, 'onBeforeWindowClose', [this]);
6057	if (bImmediately !== true)
6058	{
6059		if (this.denyClose)
6060			return false;
6061	}
6062
6063	BX.onCustomEvent(this, 'onWindowClose', [this]);
6064
6065	//this crashes vis editor in ie via onWindowResizeExt event handler
6066	//if (this.bExpanded) this.__expand();
6067	// alternative version:
6068	if (this.bExpanded)
6069	{
6070		var pDocElement = BX.GetDocElement();
6071		BX.unbind(window, 'resize', BX.proxy(this.__expand_onresize, this));
6072		pDocElement.style.overflow = this.__expand_settings.overflow;
6073	}
6074
6075	BX.WindowManager.unregister(this);
6076
6077	return true;
6078};
6079
6080BX.CWindow.prototype.SetResize = function(elem)
6081{
6082	elem.style.cursor = 'se-resize';
6083	BX.bind(elem, 'mousedown', BX.proxy(this.__startResize, this));
6084
6085	this.ELEMENTS.resizer.push(elem);
6086	this.SETTINGS.resizable = true;
6087};
6088
6089BX.CWindow.prototype.SetExpand = function(elem, event_name)
6090{
6091	event_name = event_name || 'click';
6092	BX.bind(elem, event_name, BX.proxy(this.__expand, this));
6093};
6094
6095BX.CWindow.prototype.__expand_onresize = function()
6096{
6097	var windowSize = BX.GetWindowInnerSize();
6098	this.DIV.style.width = windowSize.innerWidth + "px";
6099	this.DIV.style.height = windowSize.innerHeight + "px";
6100
6101	BX.onCustomEvent(this, 'onWindowResize');
6102};
6103
6104BX.CWindow.prototype.__expand = function()
6105{
6106	var pDocElement = BX.GetDocElement();
6107
6108	if (!this.bExpanded)
6109	{
6110		var wndScroll = BX.GetWindowScrollPos(),
6111			wndSize = BX.GetWindowInnerSize();
6112
6113		this.__expand_settings = {
6114			resizable: this.SETTINGS.resizable,
6115			draggable: this.SETTINGS.draggable,
6116			width: this.DIV.style.width,
6117			height: this.DIV.style.height,
6118			left: this.DIV.style.left,
6119			top: this.DIV.style.top,
6120			scrollTop: wndScroll.scrollTop,
6121			scrollLeft: wndScroll.scrollLeft,
6122			overflow: BX.style(pDocElement, 'overflow')
6123		};
6124
6125		this.SETTINGS.resizable = false;
6126		this.SETTINGS.draggable = false;
6127
6128		window.scrollTo(0,0);
6129		pDocElement.style.overflow = 'hidden';
6130
6131		this.DIV.style.top = '0px';
6132		this.DIV.style.left = '0px';
6133
6134		this.DIV.style.width = wndSize.innerWidth + 'px';
6135		this.DIV.style.height = wndSize.innerHeight + 'px';
6136
6137		this.bExpanded = true;
6138
6139		BX.onCustomEvent(this, 'onWindowExpand');
6140		BX.onCustomEvent(this, 'onWindowResize');
6141
6142		BX.bind(window, 'resize', BX.proxy(this.__expand_onresize, this));
6143	}
6144	else
6145	{
6146		BX.unbind(window, 'resize', BX.proxy(this.__expand_onresize, this));
6147
6148		this.SETTINGS.resizable = this.__expand_settings.resizable;
6149		this.SETTINGS.draggable = this.__expand_settings.draggable;
6150
6151		pDocElement.style.overflow = this.__expand_settings.overflow;
6152
6153		this.DIV.style.top = this.__expand_settings.top;
6154		this.DIV.style.left = this.__expand_settings.left;
6155		this.DIV.style.width = this.__expand_settings.width;
6156		this.DIV.style.height = this.__expand_settings.height;
6157
6158		window.scrollTo(this.__expand_settings.scrollLeft, this.__expand_settings.scrollTop);
6159
6160		this.bExpanded = false;
6161
6162		BX.onCustomEvent(this, 'onWindowNarrow');
6163		BX.onCustomEvent(this, 'onWindowResize');
6164
6165	}
6166};
6167
6168BX.CWindow.prototype.Resize = function(x, y)
6169{
6170	var new_width = Math.max(x - this.pos.left + this.dx, this.SETTINGS.min_width);
6171	var new_height = Math.max(y - this.pos.top + this.dy, this.SETTINGS.min_height);
6172
6173	if (this.SETTINGS.resize_restrict)
6174	{
6175		var scrollSize = BX.GetWindowScrollSize();
6176
6177		if (this.pos.left + new_width > scrollSize.scrollWidth - this.dw)
6178			new_width = scrollSize.scrollWidth - this.pos.left - this.dw;
6179	}
6180
6181	this.DIV.style.width = new_width + 'px';
6182	this.DIV.style.height = new_height + 'px';
6183
6184	BX.onCustomEvent(this, 'onWindowResize');
6185};
6186
6187BX.CWindow.prototype.__startResize = function(e)
6188{
6189	if (!this.SETTINGS.resizable)
6190		return false;
6191
6192	if(!e) e = window.event;
6193
6194	this.wndSize = BX.GetWindowScrollPos();
6195	this.wndSize.innerWidth = BX.GetWindowInnerSize().innerWidth;
6196
6197	this.pos = BX.pos(this.DIV);
6198
6199	this.x = e.clientX + this.wndSize.scrollLeft;
6200	this.y = e.clientY + this.wndSize.scrollTop;
6201
6202	this.dx = this.pos.left + this.pos.width - this.x;
6203	this.dy = this.pos.top + this.pos.height - this.y;
6204	this.dw = this.pos.width - parseInt(this.DIV.style.width);
6205
6206	BX.bind(document, "mousemove", BX.proxy(this.__moveResize, this));
6207	BX.bind(document, "mouseup", BX.proxy(this.__stopResize, this));
6208
6209	if(document.body.setCapture)
6210		document.body.setCapture();
6211
6212	document.onmousedown = BX.False;
6213
6214	var b = document.body;
6215	b.ondrag = b.onselectstart = BX.False;
6216	b.style.MozUserSelect = this.DIV.style.MozUserSelect = 'none';
6217	b.style.cursor = 'se-resize';
6218
6219	BX.onCustomEvent(this, 'onWindowResizeStart');
6220
6221	return true;
6222};
6223
6224BX.CWindow.prototype.__moveResize = function(e)
6225{
6226	if(!e) e = window.event;
6227
6228	var windowScroll = BX.GetWindowScrollPos();
6229
6230	var x = e.clientX + windowScroll.scrollLeft;
6231	var y = e.clientY + windowScroll.scrollTop;
6232
6233	if(this.x == x && this.y == y)
6234		return;
6235
6236	this.Resize(x, y);
6237
6238	this.x = x;
6239	this.y = y;
6240};
6241
6242BX.CWindow.prototype.__stopResize = function()
6243{
6244	if(document.body.releaseCapture)
6245		document.body.releaseCapture();
6246
6247	BX.unbind(document, "mousemove", BX.proxy(this.__moveResize, this));
6248	BX.unbind(document, "mouseup", BX.proxy(this.__stopResize, this));
6249
6250	document.onmousedown = null;
6251
6252	var b = document.body;
6253	b.ondrag = b.onselectstart = null;
6254	b.style.MozUserSelect = this.DIV.style.MozUserSelect = '';
6255	b.style.cursor = '';
6256
6257	BX.onCustomEvent(this, 'onWindowResizeFinished')
6258};
6259
6260BX.CWindow.prototype.SetClose = function(elem)
6261{
6262	BX.bind(elem, 'click', BX.proxy(this.Close, this));
6263	this.ELEMENTS.close.push(elem);
6264};
6265
6266BX.CWindow.prototype.SetDraggable = function(elem)
6267{
6268	BX.bind(elem, 'mousedown', BX.proxy(this.__startDrag, this));
6269
6270	elem.style.cursor = 'move';
6271
6272	this.ELEMENTS.draggable.push(elem);
6273	this.SETTINGS.draggable = true;
6274};
6275
6276BX.CWindow.prototype.Move = function(x, y)
6277{
6278	var dxShadow = 1; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6279
6280	var left = parseInt(this.DIV.style.left)+x;
6281	var top = parseInt(this.DIV.style.top)+y;
6282
6283	if (this.SETTINGS.drag_restrict)
6284	{
6285		//Left side
6286		if (left < 0)
6287			left = 0;
6288
6289		//Right side
6290		var scrollSize = BX.GetWindowScrollSize();
6291		var floatWidth = this.DIV.offsetWidth;
6292		var floatHeight = this.DIV.offsetHeight;
6293
6294		if (left > (scrollSize.scrollWidth - floatWidth - dxShadow))
6295			left = scrollSize.scrollWidth - floatWidth - dxShadow;
6296
6297		if (top > (scrollSize.scrollHeight - floatHeight - dxShadow))
6298			top = scrollSize.scrollHeight - floatHeight - dxShadow;
6299
6300		//Top side
6301		if (top < 0)
6302			top = 0;
6303	}
6304
6305	this.DIV.style.left = left+'px';
6306	this.DIV.style.top = top+'px';
6307
6308	//this.AdjustShadow(div);
6309};
6310
6311BX.CWindow.prototype.__startDrag = function(e)
6312{
6313	if (!this.SETTINGS.draggable)
6314		return false;
6315
6316	if(!e) e = window.event;
6317
6318	this.x = e.clientX + document.body.scrollLeft;
6319	this.y = e.clientY + document.body.scrollTop;
6320
6321	this.__bWasDragged = false;
6322	BX.bind(document, "mousemove", BX.proxy(this.__moveDrag, this));
6323	BX.bind(document, "mouseup", BX.proxy(this.__stopDrag, this));
6324
6325	if(document.body.setCapture)
6326		document.body.setCapture();
6327
6328	document.onmousedown = BX.False;
6329
6330	var b = document.body;
6331	b.ondrag = b.onselectstart = BX.False;
6332	b.style.MozUserSelect = this.DIV.style.MozUserSelect = 'none';
6333	b.style.cursor = 'move';
6334	return BX.PreventDefault(e);
6335};
6336
6337BX.CWindow.prototype.__moveDrag = function(e)
6338{
6339	if(!e) e = window.event;
6340
6341	var x = e.clientX + document.body.scrollLeft;
6342	var y = e.clientY + document.body.scrollTop;
6343
6344	if(this.x == x && this.y == y)
6345		return;
6346
6347	this.Move((x - this.x), (y - this.y));
6348	this.x = x;
6349	this.y = y;
6350
6351	if (!this.__bWasDragged)
6352	{
6353		BX.onCustomEvent(this, 'onWindowDragStart');
6354		this.__bWasDragged = true;
6355		BX.bind(BX.proxy_context, "click", BX.PreventDefault);
6356	}
6357
6358	BX.onCustomEvent(this, 'onWindowDrag');
6359};
6360
6361BX.CWindow.prototype.__stopDrag = function(e)
6362{
6363	if(document.body.releaseCapture)
6364		document.body.releaseCapture();
6365
6366	BX.unbind(document, "mousemove", BX.proxy(this.__moveDrag, this));
6367	BX.unbind(document, "mouseup", BX.proxy(this.__stopDrag, this));
6368
6369	document.onmousedown = null;
6370
6371	var b = document.body;
6372	b.ondrag = b.onselectstart = null;
6373	b.style.MozUserSelect = this.DIV.style.MozUserSelect = '';
6374	b.style.cursor = '';
6375
6376	if (this.__bWasDragged)
6377	{
6378		BX.onCustomEvent(this, 'onWindowDragFinished');
6379		var _proxy_context = BX.proxy_context;
6380		setTimeout(function(){BX.unbind(_proxy_context, "click", BX.PreventDefault)}, 100);
6381		this.__bWasDragged = false;
6382	}
6383	return BX.PreventDefault(e);
6384};
6385
6386BX.CWindow.prototype.DenyClose = function()
6387{
6388	this.denyClose = true;
6389};
6390
6391BX.CWindow.prototype.AllowClose = function()
6392{
6393	this.denyClose = false;
6394};
6395
6396BX.CWindow.prototype.ShowError = function(str)
6397{
6398	BX.onCustomEvent(this, 'onWindowError', [str]);
6399
6400	if (this._wait)
6401		BX.closeWait(this._wait);
6402
6403	alert(str);
6404};
6405
6406BX.CWindow.prototype.__set_msover = function() {this.MOUSEOVER = true;};
6407BX.CWindow.prototype.__unset_msover = function() {this.MOUSEOVER = false;};
6408
6409/* dialog window class extends window class */
6410BX.CWindowDialog = function() {
6411	arguments[1] = 'dialog';
6412	BX.CWindowDialog.superclass.constructor.apply(this, arguments);
6413
6414	this.DIV.style.top = '10px';
6415	this.OVERLAY = null;
6416};
6417BX.extend(BX.CWindowDialog, BX.CWindow);
6418
6419BX.CWindowDialog.prototype.__resizeOverlay = function()
6420{
6421	var windowSize = BX.GetWindowScrollSize();
6422	this.OVERLAY.style.width = windowSize.scrollWidth + "px";
6423};
6424
6425BX.CWindowDialog.prototype.CreateOverlay = function(zIndex)
6426{
6427	if (null == this.OVERLAY)
6428	{
6429		var windowSize = BX.GetWindowScrollSize();
6430		this.OVERLAY = document.body.appendChild(BX.create("DIV", {
6431			style: {
6432				position: 'absolute',
6433				top: '0px',
6434				left: '0px',
6435				zIndex: zIndex || (parseInt(this.DIV.style.zIndex)-2),
6436				width: windowSize.scrollWidth + "px",
6437				height: windowSize.scrollHeight + "px"
6438			}
6439		}));
6440	}
6441
6442	return this.OVERLAY;
6443};
6444
6445BX.CWindowDialog.prototype.Show = function()
6446{
6447	BX.CWindowDialog.superclass.Show.apply(this, arguments);
6448
6449	this.CreateOverlay();
6450
6451	this.OVERLAY.style.display = 'block';
6452	this.OVERLAY.style.zIndex = parseInt(this.DIV.style.zIndex)-2;
6453
6454	BX.unbind(window, 'resize', BX.proxy(this.__resizeOverlay, this));
6455	BX.bind(window, 'resize', BX.proxy(this.__resizeOverlay, this));
6456};
6457
6458BX.CWindowDialog.prototype.onUnRegister = function(clean)
6459{
6460	BX.CWindowDialog.superclass.onUnRegister.apply(this, arguments);
6461
6462	if (this.clean)
6463	{
6464		if (this.OVERLAY.parentNode)
6465			this.OVERLAY.parentNode.removeChild(this.OVERLAY);
6466	}
6467	else
6468	{
6469		this.OVERLAY.style.display = 'none';
6470	}
6471
6472	BX.unbind(window, 'resize', BX.proxy(this.__resizeOverlay, this));
6473};
6474
6475/* standard bitrix dialog extends BX.CWindowDialog */
6476/*
6477	arParams = {
6478		(
6479			title: 'dialog title',
6480			head: 'head block html',
6481			content: 'dialog content',
6482			icon: 'head icon classname or filename',
6483
6484			resize_id: 'some id to save resize information'// useless if resizable = false
6485		)
6486		or
6487		(
6488			content_url: url to content load
6489				loaded content scripts can use BX.WindowManager.Get() to get access to the current window object
6490		)
6491
6492		height: window_height_in_pixels,
6493		width: window_width_in_pixels,
6494
6495		draggable: true|false,
6496		resizable: true|false,
6497
6498		min_height: min_window_height_in_pixels, // useless if resizable = false
6499		min_width: min_window_width_in_pixels, // useless if resizable = false
6500
6501		buttons: [
6502			'html_code',
6503			BX.CDialog.btnSave, BX.CDialog.btnCancel, BX.CDialog.btnClose
6504		]
6505	}
6506*/
6507BX.CDialog = function(arParams)
6508{
6509	BX.CDialog.superclass.constructor.apply(this);
6510
6511	this._sender = 'core_window_cdialog';
6512
6513	this.PARAMS = arParams || {};
6514
6515	for (var i in this.defaultParams)
6516	{
6517		if (typeof this.PARAMS[i] == 'undefined')
6518			this.PARAMS[i] = this.defaultParams[i];
6519	}
6520
6521	this.PARAMS.width = (!isNaN(parseInt(this.PARAMS.width)))
6522		? this.PARAMS.width
6523		: this.defaultParams['width'];
6524	this.PARAMS.height = (!isNaN(parseInt(this.PARAMS.height)))
6525		? this.PARAMS.height
6526		: this.defaultParams['height'];
6527
6528	if (this.PARAMS.resize_id || this.PARAMS.content_url)
6529	{
6530		var arSize = BX.WindowManager.getRuntimeWindowSize(this.PARAMS.resize_id || this.PARAMS.content_url);
6531		if (arSize)
6532		{
6533			this.PARAMS.width = arSize.width;
6534			this.PARAMS.height = arSize.height;
6535		}
6536	}
6537
6538	BX.addClass(this.DIV, 'bx-core-adm-dialog');
6539	this.DIV.id = 'bx-admin-prefix';
6540
6541	this.PARTS = {};
6542
6543	this.DIV.style.height = null;
6544	this.DIV.style.width = null;
6545
6546	this.PARTS.TITLEBAR = this.DIV.appendChild(BX.create('DIV', {props: {
6547			className: 'bx-core-adm-dialog-head'
6548		}
6549	}));
6550
6551	this.PARTS.TITLE_CONTAINER = this.PARTS.TITLEBAR.appendChild(BX.create('SPAN', {
6552		props: {className: 'bx-core-adm-dialog-head-inner'},
6553		text: this.PARAMS.title
6554	}));
6555
6556	this.PARTS.TITLEBAR_ICONS = this.PARTS.TITLEBAR.appendChild(BX.create('DIV', {
6557		props: {
6558			className: 'bx-core-adm-dialog-head-icons'
6559		},
6560		children: (this.PARAMS.resizable ? [
6561			BX.create('SPAN', {props: {className: 'bx-core-adm-icon-expand', title: BX.message('JS_CORE_WINDOW_EXPAND')}}),
6562			BX.create('SPAN', {props: {className: 'bx-core-adm-icon-close', title: BX.message('JS_CORE_WINDOW_CLOSE')}})
6563		] : [
6564			BX.create('SPAN', {props: {className: 'bx-core-adm-icon-close', title: BX.message('JS_CORE_WINDOW_CLOSE')}})
6565		])
6566	}));
6567
6568
6569	this.PARTS.CONTENT = this.DIV.appendChild(BX.create('DIV', {
6570		props: {className: 'bx-core-adm-dialog-content-wrap adm-workarea'}
6571	}));
6572
6573	this.PARTS.CONTENT_DATA = this.PARTS.CONTENT.appendChild(BX.create('DIV', {
6574		props: {className: 'bx-core-adm-dialog-content'},
6575		style: {
6576			height: this.PARAMS.height + 'px',
6577			width: this.PARAMS.width + 'px'
6578		}
6579	}));
6580
6581	this.PARTS.HEAD = this.PARTS.CONTENT_DATA.appendChild(BX.create('DIV', {
6582		props: {
6583			className: 'bx-core-adm-dialog-head-block' + (this.PARAMS.icon ? ' ' + this.PARAMS.icon : '')
6584		}
6585	}));
6586
6587	this.SetHead(this.PARAMS.head);
6588	this.SetContent(this.PARAMS.content);
6589	this.SetTitle(this.PARAMS.title);
6590	this.SetClose(this.PARTS.TITLEBAR_ICONS.lastChild);
6591
6592	if (this.PARAMS.resizable)
6593	{
6594		this.SetExpand(this.PARTS.TITLEBAR_ICONS.firstChild);
6595		this.SetExpand(this.PARTS.TITLEBAR, 'dblclick');
6596
6597		BX.addCustomEvent(this, 'onWindowExpand', BX.proxy(this.__onexpand, this));
6598		BX.addCustomEvent(this, 'onWindowNarrow', BX.proxy(this.__onexpand, this));
6599	}
6600
6601	this.PARTS.FOOT = this.PARTS.BUTTONS_CONTAINER = this.PARTS.CONTENT.appendChild(BX.create('DIV', {
6602			props: {
6603				className: 'bx-core-adm-dialog-buttons'
6604			},
6605			// events: {
6606			// 	'click': BX.delegateEvent({property:{type: /button|submit/}}, BX.delegate(function() {this.showWait(BX.proxy_context)}, this))
6607			// },
6608			children: this.ShowButtons()
6609		}
6610	));
6611
6612	if (this.PARAMS.draggable)
6613		this.SetDraggable(this.PARTS.TITLEBAR);
6614
6615	if (this.PARAMS.resizable)
6616	{
6617		this.PARTS.RESIZER = this.DIV.appendChild(BX.create('DIV', {
6618			props: {className: 'bx-core-resizer'}
6619		}));
6620
6621		this.SetResize(this.PARTS.RESIZER);
6622
6623		this.SETTINGS.min_width = this.PARAMS.min_width;
6624		this.SETTINGS.min_height = this.PARAMS.min_height;
6625	}
6626
6627	this.auth_callback = BX.delegate(function(){
6628		this.PARAMS.content = '';
6629		this.hideNotify();
6630		this.Show();
6631	}, this)
6632};
6633BX.extend(BX.CDialog, BX.CWindowDialog);
6634
6635BX.CDialog.prototype.defaultParams = {
6636	width: 700,
6637	height: 400,
6638	min_width: 500,
6639	min_height: 300,
6640
6641	resizable: true,
6642	draggable: true,
6643
6644	title: '',
6645	icon: ''
6646};
6647
6648BX.CDialog.prototype.showWait = function(el)
6649{
6650	if (BX.type.isElementNode(el) && (el.type == 'button' || el.type == 'submit'))
6651	{
6652		BX.defer(function(){el.disabled = true})();
6653
6654		var bSave = (BX.hasClass(el, 'adm-btn-save') || BX.hasClass(el, 'adm-btn-save')),
6655			pos = BX.pos(el, true);
6656
6657		el.bxwaiter = this.PARTS.FOOT.appendChild(BX.create('DIV', {
6658			props: {className: 'adm-btn-load-img' + (bSave ? '-green' : '')},
6659			style: {
6660				top: parseInt((pos.bottom + pos.top)/2 - 10) + 'px',
6661				left: parseInt((pos.right + pos.left)/2 - 10) + 'px'
6662			}
6663		}));
6664
6665		BX.addClass(el, 'adm-btn-load');
6666
6667		this.lastWaitElement = el;
6668
6669		return el.bxwaiter;
6670	}
6671	return null;
6672};
6673
6674BX.CDialog.prototype.closeWait = function(el)
6675{
6676	el = el || this.lastWaitElement;
6677
6678	if (BX.type.isElementNode(el))
6679	{
6680		if (el.bxwaiter)
6681		{
6682			if(el.bxwaiter.parentNode)
6683			{
6684				el.bxwaiter.parentNode.removeChild(el.bxwaiter);
6685			}
6686
6687			el.bxwaiter = null;
6688		}
6689
6690		el.disabled = false;
6691		BX.removeClass(el, 'adm-btn-load');
6692
6693		if (this.lastWaitElement == el)
6694			this.lastWaitElement = null;
6695	}
6696};
6697
6698BX.CDialog.prototype.Authorize = function(arAuthResult)
6699{
6700	this.bSkipReplaceContent = true;
6701	this.ShowError(BX.message('JSADM_AUTH_REQ'));
6702
6703	BX.onCustomEvent(this, 'onWindowError', []);
6704
6705	BX.closeWait();
6706
6707	(new BX.CAuthDialog({
6708		content_url: this.PARAMS.content_url,
6709		auth_result: arAuthResult,
6710		callback: BX.delegate(function(){
6711			if (this.auth_callback)
6712				this.auth_callback()
6713		}, this)
6714	})).Show();
6715};
6716
6717BX.CDialog.prototype.ShowError = function(str)
6718{
6719	BX.onCustomEvent(this, 'onWindowError', [str]);
6720
6721	this.closeWait();
6722
6723	if (this._wait)
6724		BX.closeWait(this._wait);
6725
6726	this.Notify(str, true);
6727};
6728
6729
6730BX.CDialog.prototype.__expandGetSize = function()
6731{
6732	var pDocElement = BX.GetDocElement();
6733	pDocElement.style.overflow = 'hidden';
6734
6735	var wndSize = BX.GetWindowInnerSize();
6736
6737	pDocElement.scrollTop = 0;
6738
6739	this.DIV.style.top = '-' + this.dxShadow + 'px';
6740	this.DIV.style.left = '-' + this.dxShadow + 'px';
6741
6742	return {
6743		width: (wndSize.innerWidth - parseInt(BX.style(this.PARTS.CONTENT, 'padding-right')) - parseInt(BX.style(this.PARTS.CONTENT, 'padding-left'))) + this.dxShadow,
6744		height: (wndSize.innerHeight - this.PARTS.TITLEBAR.offsetHeight - this.PARTS.FOOT.offsetHeight - parseInt(BX.style(this.PARTS.CONTENT, 'padding-top')) - parseInt(BX.style(this.PARTS.CONTENT, 'padding-bottom'))) + this.dxShadow
6745	};
6746};
6747
6748BX.CDialog.prototype.__expand = function()
6749{
6750	var pDocElement = BX.GetDocElement();
6751	this.dxShadow = 2;
6752
6753	if (!this.bExpanded)
6754	{
6755		var wndScroll = BX.GetWindowScrollPos();
6756
6757		this.__expand_settings = {
6758			resizable: this.SETTINGS.resizable,
6759			draggable: this.SETTINGS.draggable,
6760			width: this.PARTS.CONTENT_DATA.style.width,
6761			height: this.PARTS.CONTENT_DATA.style.height,
6762			left: this.DIV.style.left,
6763			top: this.DIV.style.top,
6764			scrollTop: wndScroll.scrollTop,
6765			scrollLeft: wndScroll.scrollLeft,
6766			overflow: BX.style(pDocElement, 'overflow')
6767		};
6768
6769		this.SETTINGS.resizable = false;
6770		this.SETTINGS.draggable = false;
6771
6772		var pos = this.__expandGetSize();
6773
6774		this.PARTS.CONTENT_DATA.style.width = pos.width + 'px';
6775		this.PARTS.CONTENT_DATA.style.height = pos.height + 'px';
6776
6777		window.scrollTo(0,0);
6778		pDocElement.style.overflow = 'hidden';
6779
6780		this.bExpanded = true;
6781
6782		BX.onCustomEvent(this, 'onWindowExpand');
6783		BX.onCustomEvent(this, 'onWindowResize');
6784		BX.onCustomEvent(this, 'onWindowResizeExt', [{'width': pos.width, 'height': pos.height}]);
6785
6786		BX.bind(window, 'resize', BX.proxy(this.__expand_onresize, this));
6787	}
6788	else
6789	{
6790		BX.unbind(window, 'resize', BX.proxy(this.__expand_onresize, this));
6791
6792		this.SETTINGS.resizable = this.__expand_settings.resizable;
6793		this.SETTINGS.draggable = this.__expand_settings.draggable;
6794
6795		pDocElement.style.overflow = this.__expand_settings.overflow;
6796
6797		this.DIV.style.top = this.__expand_settings.top;
6798		this.DIV.style.left = this.__expand_settings.left;
6799		this.PARTS.CONTENT_DATA.style.width = this.__expand_settings.width;
6800		this.PARTS.CONTENT_DATA.style.height = this.__expand_settings.height;
6801		window.scrollTo(this.__expand_settings.scrollLeft, this.__expand_settings.scrollTop);
6802		this.bExpanded = false;
6803
6804		BX.onCustomEvent(this, 'onWindowNarrow');
6805		BX.onCustomEvent(this, 'onWindowResize');
6806		BX.onCustomEvent(this, 'onWindowResizeExt', [{'width': parseInt(this.__expand_settings.width), 'height': parseInt(this.__expand_settings.height)}]);
6807	}
6808};
6809
6810BX.CDialog.prototype.__expand_onresize = function()
6811{
6812	var pos = this.__expandGetSize();
6813
6814	this.PARTS.CONTENT_DATA.style.width = pos.width + 'px';
6815	this.PARTS.CONTENT_DATA.style.height = pos.height + 'px';
6816
6817	BX.onCustomEvent(this, 'onWindowResize');
6818	BX.onCustomEvent(this, 'onWindowResizeExt', [pos]);
6819};
6820
6821BX.CDialog.prototype.__onexpand = function()
6822{
6823	var ob = this.PARTS.TITLEBAR_ICONS.firstChild;
6824	ob.className = BX.toggle(ob.className, ['bx-core-adm-icon-expand', 'bx-core-adm-icon-narrow']);
6825	ob.title = BX.toggle(ob.title, [BX.message('JS_CORE_WINDOW_EXPAND'), BX.message('JS_CORE_WINDOW_NARROW')]);
6826
6827	if (this.PARTS.RESIZER)
6828	{
6829		this.PARTS.RESIZER.style.display = this.bExpanded ? 'none' : 'block';
6830	}
6831};
6832
6833
6834BX.CDialog.prototype.__startResize = function(e)
6835{
6836	if (!this.SETTINGS.resizable)
6837		return false;
6838
6839	if(!e) e = window.event;
6840
6841	this.wndSize = BX.GetWindowScrollPos();
6842	this.wndSize.innerWidth = BX.GetWindowInnerSize().innerWidth;
6843
6844	this.pos = BX.pos(this.PARTS.CONTENT_DATA);
6845
6846	this.x = e.clientX + this.wndSize.scrollLeft;
6847	this.y = e.clientY + this.wndSize.scrollTop;
6848
6849	this.dx = this.pos.left + this.pos.width - this.x;
6850	this.dy = this.pos.top + this.pos.height - this.y;
6851
6852
6853	// TODO: suspicious
6854	this.dw = this.pos.width - parseInt(this.PARTS.CONTENT_DATA.style.width) + parseInt(BX.style(this.PARTS.CONTENT, 'padding-right'));
6855
6856	BX.bind(document, "mousemove", BX.proxy(this.__moveResize, this));
6857	BX.bind(document, "mouseup", BX.proxy(this.__stopResize, this));
6858
6859	if(document.body.setCapture)
6860		document.body.setCapture();
6861
6862	document.onmousedown = BX.False;
6863
6864	var b = document.body;
6865	b.ondrag = b.onselectstart = BX.False;
6866	b.style.MozUserSelect = this.DIV.style.MozUserSelect = 'none';
6867	b.style.cursor = 'se-resize';
6868
6869	BX.onCustomEvent(this, 'onWindowResizeStart');
6870
6871	return true;
6872};
6873
6874BX.CDialog.prototype.Resize = function(x, y)
6875{
6876	var new_width = Math.max(x - this.pos.left + this.dx, this.SETTINGS.min_width);
6877	var new_height = Math.max(y - this.pos.top + this.dy, this.SETTINGS.min_height);
6878
6879	if (this.SETTINGS.resize_restrict)
6880	{
6881		var scrollSize = BX.GetWindowScrollSize();
6882
6883		if (this.pos.left + new_width > scrollSize.scrollWidth - this.dw)
6884			new_width = scrollSize.scrollWidth - this.pos.left - this.dw;
6885	}
6886
6887	this.PARTS.CONTENT_DATA.style.width = new_width + 'px';
6888	this.PARTS.CONTENT_DATA.style.height = new_height + 'px';
6889
6890	BX.onCustomEvent(this, 'onWindowResize');
6891	BX.onCustomEvent(this, 'onWindowResizeExt', [{'height': new_height, 'width': new_width}]);
6892};
6893
6894BX.CDialog.prototype.SetSize = function(obSize)
6895{
6896	this.PARTS.CONTENT_DATA.style.width = obSize.width + 'px';
6897	this.PARTS.CONTENT_DATA.style.height = obSize.height + 'px';
6898
6899	BX.onCustomEvent(this, 'onWindowResize');
6900	BX.onCustomEvent(this, 'onWindowResizeExt', [obSize]);
6901};
6902
6903BX.CDialog.prototype.GetParameters = function(form_name)
6904{
6905	var form = this.GetForm();
6906
6907	if(!form)
6908		return "";
6909
6910	var i, s = "";
6911	var n = form.elements.length;
6912
6913	var delim = '';
6914	for(i=0; i<n; i++)
6915	{
6916		if (s != '') delim = '&';
6917		var el = form.elements[i];
6918		if (el.disabled)
6919			continue;
6920
6921		switch(el.type.toLowerCase())
6922		{
6923			case 'text':
6924			case 'textarea':
6925			case 'password':
6926			case 'hidden':
6927				if (null == form_name && el.name.substr(el.name.length-4) == '_alt' && form.elements[el.name.substr(0, el.name.length-4)])
6928					break;
6929				s += delim + el.name + '=' + BX.util.urlencode(el.value);
6930				break;
6931			case 'radio':
6932				if(el.checked)
6933					s += delim + el.name + '=' + BX.util.urlencode(el.value);
6934				break;
6935			case 'checkbox':
6936				s += delim + el.name + '=' + BX.util.urlencode(el.checked ? 'Y':'N');
6937				break;
6938			case 'select-one':
6939				var val = "";
6940				if (null == form_name && form.elements[el.name + '_alt'] && el.selectedIndex == 0)
6941					val = form.elements[el.name+'_alt'].value;
6942				else
6943					val = el.value;
6944				s += delim + el.name + '=' + BX.util.urlencode(val);
6945				break;
6946			case 'select-multiple':
6947				var j, bAdded = false;
6948				var l = el.options.length;
6949				for (j=0; j<l; j++)
6950				{
6951					if (el.options[j].selected)
6952					{
6953						s += delim + el.name + '=' + BX.util.urlencode(el.options[j].value);
6954						bAdded = true;
6955					}
6956				}
6957				if (!bAdded)
6958					s += delim + el.name + '=';
6959				break;
6960			default:
6961				break;
6962		}
6963	}
6964
6965	return s;
6966};
6967
6968BX.CDialog.prototype.PostParameters = function(params)
6969{
6970	var url = this.PARAMS.content_url;
6971
6972	if (null == params)
6973		params = "";
6974
6975	params += (params == "" ? "" : "&") + "bxsender=" + this._sender;
6976
6977	var index = url.indexOf('?');
6978	if (index == -1)
6979		url += '?' + params;
6980	else
6981		url = url.substring(0, index) + '?' + params + "&" + url.substring(index+1);
6982
6983	BX.showWait();
6984
6985	this.auth_callback = BX.delegate(function(){
6986		this.hideNotify();
6987		this.PostParameters(params);
6988	}, this);
6989
6990	BX.ajax.post(url, this.GetParameters(), BX.delegate(function(result) {
6991		BX.closeWait();
6992		if (!this.bSkipReplaceContent)
6993		{
6994			this.ClearButtons(); // buttons are appended during form reload, so we should clear footer
6995			this.SetContent(result);
6996			this.Show(true);
6997		}
6998
6999		this.bSkipReplaceContent = false;
7000	}, this));
7001};
7002
7003BX.CDialog.prototype.Submit = function(params, url)
7004{
7005	var FORM = this.GetForm();
7006	if (FORM)
7007	{
7008		FORM.onsubmit = null;
7009
7010		FORM.method = 'POST';
7011		if (!FORM.action || url)
7012		{
7013			url = url || this.PARAMS.content_url;
7014			if (null != params)
7015			{
7016				var index = url.indexOf('?');
7017				if (index == -1)
7018					url += '?' + params;
7019				else
7020					url = url.substring(0, index) + '?' + params + "&" + url.substring(index+1);
7021			}
7022
7023			FORM.action = url;
7024		}
7025
7026		if (!FORM._bxsender)
7027		{
7028			FORM._bxsender = FORM.appendChild(BX.create('INPUT', {
7029				attrs: {
7030					type: 'hidden',
7031					name: 'bxsender',
7032					value: this._sender
7033				}
7034			}));
7035		}
7036
7037		this._wait = BX.showWait();
7038
7039		this.auth_callback = BX.delegate(function(){
7040			this.hideNotify();
7041			this.Submit(params);
7042		}, this);
7043
7044		BX.ajax.submit(FORM, BX.delegate(function(){this.closeWait()}, this));
7045	}
7046	else
7047	{
7048		alert('no form registered!');
7049	}
7050};
7051
7052BX.CDialog.prototype.GetForm = function()
7053{
7054	if (null == this.__form)
7055	{
7056		var forms = this.PARTS.CONTENT_DATA.getElementsByTagName('FORM');
7057		this.__form = forms[0] ? forms[0] : null;
7058	}
7059
7060	return this.__form;
7061};
7062
7063BX.CDialog.prototype.GetRealForm = function()
7064{
7065	if (null == this.__rform)
7066	{
7067		var forms = this.PARTS.CONTENT_DATA.getElementsByTagName('FORM');
7068		this.__rform = forms[1] ? forms[1] : (forms[0] ? forms[0] : null);
7069	}
7070
7071	return this.__rform;
7072};
7073
7074BX.CDialog.prototype._checkButton = function(btn)
7075{
7076	var arCustomButtons = ['btnSave', 'btnCancel', 'btnClose'];
7077
7078	for (var i = 0; i < arCustomButtons.length; i++)
7079	{
7080		if (this[arCustomButtons[i]] && (btn == this[arCustomButtons[i]]))
7081			return arCustomButtons[i];
7082	}
7083
7084	return false;
7085};
7086
7087BX.CDialog.prototype.ShowButtons = function()
7088{
7089	var result = [];
7090	if (this.PARAMS.buttons)
7091	{
7092		if (this.PARAMS.buttons.title) this.PARAMS.buttons = [this.PARAMS.buttons];
7093
7094		for (var i=0, len=this.PARAMS.buttons.length; i<len; i++)
7095		{
7096			if (BX.type.isNotEmptyString(this.PARAMS.buttons[i]))
7097			{
7098				result.push(this.PARAMS.buttons[i]);
7099			}
7100			else if (this.PARAMS.buttons[i])
7101			{
7102				//if (!(this.PARAMS.buttons[i] instanceof BX.CWindowButton))
7103				if (!BX.is_subclass_of(this.PARAMS.buttons[i], BX.CWindowButton))
7104				{
7105					var b = this._checkButton(this.PARAMS.buttons[i]); // hack to set links to real CWindowButton object in btnSave etc;
7106					this.PARAMS.buttons[i] = new BX.CWindowButton(this.PARAMS.buttons[i]);
7107					if (b) this[b] = this.PARAMS.buttons[i];
7108				}
7109
7110				result.push(this.PARAMS.buttons[i].Button(this));
7111			}
7112		}
7113	}
7114
7115	return result;
7116};
7117
7118BX.CDialog.prototype.setAutosave = function () {
7119	if (!this.bSetAutosaveDelay)
7120	{
7121		this.bSetAutosaveDelay = true;
7122		setTimeout(BX.proxy(this.setAutosave, this), 10);
7123	}
7124};
7125
7126BX.CDialog.prototype.SetTitle = function(title)
7127{
7128	this.PARAMS.title = title;
7129	BX.cleanNode(this.PARTS.TITLE_CONTAINER).appendChild(document.createTextNode(this.PARAMS.title));
7130};
7131
7132BX.CDialog.prototype.SetHead = function(head)
7133{
7134	this.PARAMS.head = BX.util.trim(head);
7135	this.PARTS.HEAD.innerHTML = this.PARAMS.head || "&nbsp;";
7136	this.PARTS.HEAD.style.display = this.PARAMS.head ? 'block' : 'none';
7137	this.adjustSize();
7138};
7139
7140BX.CDialog.prototype.Notify = function(note, bError)
7141{
7142	if (!this.PARTS.NOTIFY)
7143	{
7144		this.PARTS.NOTIFY = this.DIV.insertBefore(BX.create('DIV', {
7145			props: {className: 'adm-warning-block'},
7146			children: [
7147				BX.create('SPAN', {
7148					props: {className: 'adm-warning-text'}
7149				}),
7150				BX.create('SPAN', {
7151					props: {className: 'adm-warning-icon'}
7152				}),
7153				BX.create('SPAN', {
7154					props: {className: 'adm-warning-close'},
7155					events: {click: BX.proxy(this.hideNotify, this)}
7156				})
7157			]
7158		}), this.DIV.firstChild);
7159	}
7160
7161	if (bError)
7162		BX.addClass(this.PARTS.NOTIFY, 'adm-warning-block-red');
7163	else
7164		BX.removeClass(this.PARTS.NOTIFY, 'adm-warning-block-red');
7165
7166	this.PARTS.NOTIFY.firstChild.innerHTML = note || '&nbsp;';
7167	this.PARTS.NOTIFY.firstChild.style.width = (this.PARAMS.width-50) + 'px';
7168	BX.removeClass(this.PARTS.NOTIFY, 'adm-warning-animate');
7169};
7170
7171BX.CDialog.prototype.hideNotify = function()
7172{
7173	BX.addClass(this.PARTS.NOTIFY, 'adm-warning-animate');
7174};
7175
7176BX.CDialog.prototype.__adjustHeadToIcon = function()
7177{
7178	if (!this.PARTS.HEAD.offsetHeight)
7179	{
7180		setTimeout(BX.delegate(this.__adjustHeadToIcon, this), 50);
7181	}
7182	else
7183	{
7184		if (this.icon_image && this.icon_image.height && this.icon_image.height > this.PARTS.HEAD.offsetHeight - 5)
7185		{
7186			this.PARTS.HEAD.style.height = this.icon_image.height + 5 + 'px';
7187			this.adjustSize();
7188		}
7189
7190		this.icon_image.onload = null;
7191		this.icon_image = null;
7192	}
7193};
7194
7195BX.CDialog.prototype.SetIcon = function(icon_class)
7196{
7197	if (this.PARAMS.icon != icon_class)
7198	{
7199		if (this.PARAMS.icon)
7200			BX.removeClass(this.PARTS.HEAD, this.PARAMS.icon);
7201
7202		this.PARAMS.icon = icon_class;
7203
7204		if (this.PARAMS.icon)
7205		{
7206			BX.addClass(this.PARTS.HEAD, this.PARAMS.icon);
7207
7208			var icon_file = (BX.style(this.PARTS.HEAD, 'background-image') || BX.style(this.PARTS.HEAD, 'backgroundImage'));
7209			if (BX.type.isNotEmptyString(icon_file) && icon_file != 'none')
7210			{
7211				var match = icon_file.match(new RegExp('url\\s*\\(\\s*(\'|"|)(.+?)(\\1)\\s*\\)'));
7212				if(match)
7213				{
7214					icon_file = match[2];
7215					if (BX.type.isNotEmptyString(icon_file))
7216					{
7217						this.icon_image = new Image();
7218						this.icon_image.onload = BX.delegate(this.__adjustHeadToIcon, this);
7219						this.icon_image.src = icon_file;
7220					}
7221				}
7222			}
7223		}
7224	}
7225	this.adjustSize();
7226};
7227
7228BX.CDialog.prototype.SetIconFile = function(icon_file)
7229{
7230	this.icon_image = new Image();
7231	this.icon_image.onload = BX.delegate(this.__adjustHeadToIcon, this);
7232	this.icon_image.src = icon_file;
7233
7234	BX.adjust(this.PARTS.HEAD, {style: {backgroundImage: 'url(' + icon_file + ')', backgroundPosition: 'right 9px'/*'99% center'*/}});
7235	this.adjustSize();
7236};
7237
7238/*
7239BUTTON: {
7240	title: 'title',
7241	'action': function executed in window object context
7242}
7243BX.CDialog.btnSave || BX.CDialog.btnCancel - standard buttons
7244*/
7245
7246BX.CDialog.prototype.SetButtons = function(a)
7247{
7248	if (BX.type.isString(a))
7249	{
7250		if (a.length > 0)
7251		{
7252			this.PARTS.BUTTONS_CONTAINER.innerHTML += a;
7253
7254			var btns = this.PARTS.BUTTONS_CONTAINER.getElementsByTagName('INPUT');
7255			if (btns.length > 0)
7256			{
7257				this.PARAMS.buttons = [];
7258				for (var i = 0; i < btns.length; i++)
7259				{
7260					this.PARAMS.buttons.push(new BX.CWindowButton({btn: btns[i], parentWindow: this}));
7261				}
7262			}
7263		}
7264	}
7265	else
7266	{
7267		this.PARAMS.buttons = a;
7268		BX.adjust(this.PARTS.BUTTONS_CONTAINER, {
7269			children: this.ShowButtons()
7270		});
7271	}
7272	this.adjustSize();
7273};
7274
7275BX.CDialog.prototype.ClearButtons = function()
7276{
7277	BX.cleanNode(this.PARTS.BUTTONS_CONTAINER);
7278	this.adjustSize();
7279};
7280
7281BX.CDialog.prototype.SetContent = function(html)
7282{
7283	this.__form = null;
7284
7285	if (BX.type.isElementNode(html))
7286	{
7287		if (html.parentNode)
7288			html.parentNode.removeChild(html);
7289	}
7290	else if (BX.type.isString(html))
7291	{
7292		html = BX.create('DIV', {html: html});
7293	}
7294
7295	this.PARAMS.content = html;
7296	BX.cleanNode(this.PARTS.CONTENT_DATA);
7297
7298	BX.adjust(this.PARTS.CONTENT_DATA, {
7299		children: [
7300			this.PARTS.HEAD,
7301			BX.create('DIV', {
7302				props: {
7303					className: 'bx-core-adm-dialog-content-wrap-inner'
7304				},
7305				children: [this.PARAMS.content]
7306			})
7307		]
7308	});
7309
7310	if (this.PARAMS.content_url && this.GetForm())
7311	{
7312		this.__form.submitbtn = this.__form.appendChild(BX.create('INPUT', {props:{type:'submit'},style:{display:'none'}}));
7313		this.__form.onsubmit = BX.delegate(this.__submit, this);
7314	}
7315};
7316
7317BX.CDialog.prototype.__submit = function(e)
7318{
7319	for (var i=0,len=this.PARAMS.buttons.length; i<len; i++)
7320	{
7321		if (
7322			this.PARAMS.buttons[i]
7323			&& (
7324				this.PARAMS.buttons[i].name && /save|apply/i.test(this.PARAMS.buttons[i].name)
7325				||
7326				this.PARAMS.buttons[i].btn && this.PARAMS.buttons[i].btn.name && /save|apply/i.test(this.PARAMS.buttons[i].btn.name)
7327			)
7328		)
7329		{
7330			this.PARAMS.buttons[i].emulate();
7331			break;
7332		}
7333	}
7334
7335	return BX.PreventDefault(e);
7336};
7337
7338BX.CDialog.prototype.SwapContent = function(cont)
7339{
7340	cont = BX(cont);
7341
7342	BX.cleanNode(this.PARTS.CONTENT_DATA);
7343	cont.parentNode.removeChild(cont);
7344	this.PARTS.CONTENT_DATA.appendChild(cont);
7345	cont.style.display = 'block';
7346	this.SetContent(cont.innerHTML);
7347};
7348
7349// this method deprecated
7350BX.CDialog.prototype.adjustSize = function()
7351{
7352};
7353
7354// this method deprecated
7355BX.CDialog.prototype.__adjustSize = function()
7356{
7357};
7358
7359BX.CDialog.prototype.adjustSizeEx = function()
7360{
7361	BX.defer(this.__adjustSizeEx, this)();
7362};
7363
7364BX.CDialog.prototype.__adjustSizeEx = function()
7365{
7366	var ob = this.PARTS.CONTENT_DATA.firstChild, new_height = 0;
7367	while (ob)
7368	{
7369		new_height += ob.offsetHeight
7370			+ parseInt(BX.style(ob, 'margin-top'))
7371			+ parseInt(BX.style(ob, 'margin-bottom'));
7372
7373		ob = BX.nextSibling(ob);
7374	}
7375
7376	if (new_height)
7377		this.PARTS.CONTENT_DATA.style.height = new_height + 'px';
7378};
7379
7380
7381BX.CDialog.prototype.__onResizeFinished = function()
7382{
7383	BX.WindowManager.saveWindowSize(
7384		this.PARAMS.resize_id || this.PARAMS.content_url, {height: parseInt(this.PARTS.CONTENT_DATA.style.height), width: parseInt(this.PARTS.CONTENT_DATA.style.width)}
7385	);
7386};
7387
7388BX.CDialog.prototype.Show = function(bNotRegister)
7389{
7390	if ((!this.PARAMS.content) && this.PARAMS.content_url && BX.ajax && !bNotRegister)
7391	{
7392		var wait = BX.showWait();
7393
7394		BX.WindowManager.currently_loaded = this;
7395
7396		this.CreateOverlay(parseInt(BX.style(wait, 'z-index'))-1);
7397		this.OVERLAY.style.display = 'block';
7398		this.OVERLAY.className = 'bx-core-dialog-overlay';
7399
7400		var post_data = '', method = 'GET';
7401		if (this.PARAMS.content_post)
7402		{
7403			post_data = this.PARAMS.content_post;
7404			method = 'POST';
7405		}
7406
7407		var url = this.PARAMS.content_url
7408			+ (this.PARAMS.content_url.indexOf('?')<0?'?':'&')+'bxsender=' + this._sender;
7409
7410		this.auth_callback = BX.delegate(function(){
7411			this.PARAMS.content = '';
7412			this.hideNotify();
7413			this.Show();
7414		}, this);
7415
7416		BX.ajax({
7417			method: method,
7418			dataType: 'html',
7419			url: url,
7420			data: post_data,
7421			onsuccess: BX.delegate(function(data) {
7422				BX.closeWait(null, wait);
7423
7424				this.SetContent(data || '&nbsp;');
7425				this.Show();
7426			}, this),
7427			processScriptsConsecutive: true
7428		});
7429	}
7430	else
7431	{
7432		BX.WindowManager.currently_loaded = null;
7433		BX.CDialog.superclass.Show.apply(this, arguments);
7434
7435		this.adjustPos();
7436
7437		this.OVERLAY.className = 'bx-core-dialog-overlay';
7438
7439		this.__adjustSize();
7440
7441		BX.addCustomEvent(this, 'onWindowResize', BX.proxy(this.__adjustSize, this));
7442
7443		if (this.PARAMS.resizable && (this.PARAMS.content_url || this.PARAMS.resize_id))
7444			BX.addCustomEvent(this, 'onWindowResizeFinished', BX.delegate(this.__onResizeFinished, this));
7445	}
7446};
7447
7448BX.CDialog.prototype.GetInnerPos = function()
7449{
7450	return {'width': parseInt(this.PARTS.CONTENT_DATA.style.width), 'height': parseInt(this.PARTS.CONTENT_DATA.style.height)};
7451};
7452
7453BX.CDialog.prototype.adjustPos = function()
7454{
7455	if (!this.bExpanded)
7456	{
7457		var windowSize = BX.GetWindowInnerSize();
7458		var windowScroll = BX.GetWindowScrollPos();
7459
7460		BX.adjust(this.DIV, {
7461			style: {
7462				left: parseInt(windowScroll.scrollLeft + windowSize.innerWidth / 2 - parseInt(this.DIV.offsetWidth) / 2) + 'px',
7463				top: Math.max(parseInt(windowScroll.scrollTop + windowSize.innerHe
7463ight / 2 - parseInt(this.DIV.offsetHeight) / 2), 0) + 'px'
7464			}
7465		});
7466	}
7467};
7468
7469BX.CDialog.prototype.GetContent = function () {return this.PARTS.CONTENT_DATA};
7470
7471BX.CDialog.prototype.btnSave = BX.CDialog.btnSave = {
7472	title: BX.message('JS_CORE_WINDOW_SAVE'),
7473	id: 'savebtn',
7474	name: 'savebtn',
7475	className: BX.browser.IsIE() && BX.browser.IsDoctype() && !BX.browser.IsIE10() ? '' : 'adm-btn-save',
7476	action: function () {
7477		this.disableUntilError();
7478		this.parentWindow.PostParameters();
7479	}
7480};
7481
7482BX.CDialog.prototype.btnCancel = BX.CDialog.btnCancel = {
7483	title: BX.message('JS_CORE_WINDOW_CANCEL'),
7484	id: 'cancel',
7485	name: 'cancel',
7486	action: function () {
7487		this.parentWindow.Close();
7488	}
7489};
7490
7491BX.CDialog.prototype.btnClose = BX.CDialog.btnClose = {
7492	title: BX.message('JS_CORE_WINDOW_CLOSE'),
7493	id: 'close',
7494	name: 'close',
7495	action: function () {
7496		this.parentWindow.Close();
7497	}
7498};
7499
7500/* special child for admin forms loaded into public page */
7501BX.CAdminDialog = function(arParams)
7502{
7503	BX.CAdminDialog.superclass.constructor.apply(this, arguments);
7504
7505	this._sender = 'core_window_cadmindialog';
7506
7507	BX.addClass(this.DIV, 'bx-core-adm-admin-dialog');
7508
7509	this.PARTS.CONTENT.insertBefore(this.PARTS.HEAD, this.PARTS.CONTENT.firstChild);
7510	this.PARTS.HEAD.className = 'bx-core-adm-dialog-tabs';
7511};
7512BX.extend(BX.CAdminDialog, BX.CDialog);
7513
7514BX.CAdminDialog.prototype.SetHead = function()
7515{
7516	BX.CAdminDialog.superclass.SetHead.apply(this, arguments);
7517
7518	if (this.PARTS.HEAD.firstChild && BX.type.isElementNode(this.PARTS.HEAD.firstChild))
7519	{
7520		var ob = this.PARTS.HEAD.firstChild, new_width = 0;
7521		while (ob)
7522		{
7523			new_width += ob.offsetWidth
7524				+ parseInt(BX.style(ob, 'margin-left'))
7525				+ parseInt(BX.style(ob, 'margin-right'));
7526
7527			ob = BX.nextSibling(ob);
7528		}
7529
7530		this.SETTINGS.min_width = Math.max(new_width, this.SETTINGS.min_width) - 2;
7531		if (this.PARAMS.width < this.SETTINGS.min_width)
7532		{
7533			BX.adjust(this.PARTS.CONTENT_DATA, {
7534				style: {
7535					width: this.SETTINGS.min_width + 'px'
7536				}
7537			});
7538		}
7539	}
7540};
7541
7542BX.CAdminDialog.prototype.SetContent = function(html)
7543{
7544	this.__form = null;
7545
7546	if (BX.type.isElementNode(html))
7547	{
7548		if (html.parentNode)
7549			html.parentNode.removeChild(html);
7550	}
7551
7552	this.PARAMS.content = html;
7553	BX.cleanNode(this.PARTS.CONTENT_DATA);
7554
7555	BX.adjust(this.PARTS.CONTENT_DATA, {
7556		children: [
7557			this.PARAMS.content || '&nbsp;'
7558		]
7559	});
7560
7561	if (this.PARAMS.content_url && this.GetForm())
7562	{
7563		this.__form.appendChild(BX.create('INPUT', {props:{type:'submit'},style:{display:'none'}}));
7564		this.__form.onsubmit = BX.delegate(this.__submit, this);
7565	}
7566};
7567
7568BX.CAdminDialog.prototype.__adjustSizeEx = function()
7569{
7570	var new_height = BX.firstChild(this.PARTS.CONTENT_DATA).offsetHeight;
7571	if (new_height)
7572		this.PARTS.CONTENT_DATA.style.height = new_height + 'px';
7573};
7574
7575BX.CAdminDialog.prototype.__expandGetSize = function()
7576{
7577	var res = BX.CAdminDialog.superclass.__expandGetSize.apply(this, arguments);
7578
7579	res.width -= parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-right')) + parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-left'));
7580	res.height -= parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-top')) + parseInt(BX.style(this.PARTS.CONTENT_DATA, 'padding-bottom'));
7581
7582	res.height -= this.PARTS.HEAD.offsetHeight;
7583
7584	return res;
7585};
7586
7587BX.CAdminDialog.prototype.Submit = function()
7588{
7589	var FORM = this.GetForm();
7590	if (FORM && !FORM['bxpublic'] && !/bxpublic=/.test(FORM.action))
7591	{
7592		FORM.appendChild(BX.create('INPUT', {
7593			props: {
7594				type: 'hidden',
7595				name: 'bxpublic',
7596				value: 'Y'
7597			}
7598		}));
7599	}
7600
7601	return BX.CAdminDialog.superclass.Submit.apply(this, arguments);
7602};
7603
7604BX.CAdminDialog.prototype.btnSave = BX.CAdminDialog.btnSave = {
7605	title: BX.message('JS_CORE_WINDOW_SAVE'),
7606	id: 'savebtn',
7607	name: 'savebtn',
7608	className: 'adm-btn-save',
7609	action: function () {
7610		this.disableUntilError();
7611		this.parentWindow.Submit();
7612	}
7613};
7614
7615BX.CAdminDialog.btnCancel = BX.CAdminDialog.superclass.btnCancel;
7616BX.CAdminDialog.btnClose = BX.CAdminDialog.superclass.btnClose;
7617
7618BX.CDebugDialog = function(arParams)
7619{
7620	BX.CDebugDialog.superclass.constructor.apply(this, arguments);
7621};
7622BX.extend(BX.CDebugDialog, BX.CDialog);
7623
7624BX.CDebugDialog.prototype.ShowDetails = function(div_id)
7625{
7626	var div = BX(div_id);
7627	if (div)
7628	{
7629		if (this.div_detail_current)
7630			this.div_detail_current.style.display = 'none';
7631
7632		div.style.display = 'block';
7633		this.div_detail_current = div;
7634	}
7635};
7636
7637BX.CDebugDialog.prototype.SetContent = function(html)
7638{
7639	if (!html)
7640		return;
7641
7642	var arHtml = html.split('#DIVIDER#');
7643	if (arHtml.length > 1)
7644	{
7645		this.PARAMS.content = arHtml[1];
7646
7647		this.PARTS.CONTENT_DATA.style.overflow = 'hidden';
7648
7649		BX.CDebugDialog.superclass.SetContent.apply(this, [arHtml[1]]);
7650
7651		this.PARTS.CONTENT_INNER = this.PARTS.CONTENT_DATA.firstChild.nextSibling;
7652		this.PARTS.CONTENT_TOP = this.PARTS.CONTENT_DATA.insertBefore(BX.create('DIV', {
7653			props: {
7654				className: 'bx-debug-content-top'
7655			},
7656			html: arHtml[0]
7657		}), this.PARTS.CONTENT_INNER);
7658		this.PARTS.CONTENT_INNER.style.overflow = 'auto';
7659	}
7660	else
7661	{
7662		BX.CDebugDialog.superclass.SetContent.apply(this, arguments);
7663	}
7664};
7665
7666BX.CDebugDialog.prototype.__adjustSize = function()
7667{
7668	BX.CDebugDialog.superclass.__adjustSize.apply(this, arguments);
7669
7670	if (this.PARTS.CONTENT_TOP)
7671	{
7672		var new_height = this.PARTS.CONTENT_DATA.offsetHeight - this.PARTS.HEAD.offsetHeight - this.PARTS.CONTENT_TOP.offsetHeight - 38;
7673
7674		if (new_height > 0)
7675		{
7676			this.PARTS.CONTENT_INNER.style.height = new_height + 'px';
7677		}
7678	}
7679};
7680
7681
7682/* class for dialog window with editors */
7683
7684BX.CEditorDialog = function(arParams)
7685{
7686	BX.CEditorDialog.superclass.constructor.apply(this, arguments);
7687
7688	BX.removeClass(this.PARTS.CONTENT, 'bx-core-adm-dialog-content-wrap');
7689	BX.removeClass(this.PARTS.CONTENT_DATA, 'bx-core-adm-dialog-content');
7690
7691	BX.removeClass(this.PARTS.CONTENT_DATA.lastChild, 'bx-core-adm-dialog-content-wrap-inner');
7692	BX.removeClass(this.PARTS.BUTTONS_CONTAINER, 'bx-core-adm-dialog-buttons');
7693
7694	BX.addClass(this.PARTS.CONTENT, 'bx-core-editor-dialog-content-wrap');
7695	BX.addClass(this.PARTS.CONTENT_DATA, 'bx-core-editor-dialog-content');
7696	BX.addClass(this.PARTS.BUTTONS_CONTAINER, 'bx-core-editor-dialog-buttons');
7697};
7698BX.extend(BX.CEditorDialog, BX.CDialog);
7699
7700BX.CEditorDialog.prototype.SetContent  = function()
7701{
7702	BX.CEditorDialog.superclass.SetContent.apply(this, arguments);
7703
7704	BX.removeClass(this.PARTS.CONTENT_DATA.lastChild, 'bx-core-adm-dialog-content-wrap-inner');
7705};
7706
7707/* class for wizards in admin section */
7708BX.CWizardDialog = function(arParams)
7709{
7710	BX.CWizardDialog.superclass.constructor.apply(this, arguments);
7711
7712	BX.removeClass(this.PARTS.CONTENT, 'bx-core-adm-dialog-content-wrap');
7713	BX.removeClass(this.PARTS.CONTENT_DATA, 'bx-core-adm-dialog-content');
7714	BX.removeClass(this.PARTS.CONTENT_DATA.lastChild, 'bx-core-adm-dialog-content-wrap-inner');
7715	BX.removeClass(this.PARTS.BUTTONS_CONTAINER, 'bx-core-adm-dialog-buttons');
7716
7717	BX.addClass(this.PARTS.CONTENT, 'bx-core-wizard-dialog-content-wrap');
7718};
7719
7720BX.extend(BX.CWizardDialog, BX.CDialog);
7721
7722/* class for auth dialog */
7723BX.CAuthDialog = function(arParams)
7724{
7725	arParams.resizable = false;
7726	arParams.width = 350;
7727	arParams.height = 200;
7728
7729	arParams.buttons = [this.btnSave];
7730
7731	BX.CAuthDialog.superclass.constructor.apply(this, arguments);
7732	this._sender = 'core_window_cauthdialog';
7733
7734	BX.addClass(this.DIV, 'bx-core-auth-dialog');
7735
7736	BX.AUTHAGENT = this;
7737};
7738BX.extend(BX.CAuthDialog, BX.CDialog);
7739
7740BX.CAuthDialog.prototype.btnSave = BX.CAuthDialog.btnSave = {
7741	title: BX.message('JS_CORE_WINDOW_AUTH'),
7742	id: 'savebtn',
7743	name: 'savebtn',
7744	className: 'adm-btn-save',
7745	action: function () {
7746		this.disableUntilError();
7747		this.parentWindow.Submit({}, this.parentWindow.PARAMS.content_url);
7748	}
7749};
7750
7751BX.CAuthDialog.prototype.SetError = function(error)
7752{
7753	BX.closeWait();
7754
7755	if (!!error)
7756		this.ShowError(error.MESSAGE || error);
7757};
7758
7759BX.CAuthDialog.prototype.setAuthResult = function(result)
7760{
7761	BX.closeWait();
7762
7763	if (result === false)
7764	{
7765		this.Close();
7766		if (this.PARAMS.callback)
7767			this.PARAMS.callback();
7768	}
7769	else
7770	{
7771		this.SetError(result);
7772	}
7773};
7774
7775/* MENU CLASSES */
7776
7777BX.CWindowFloat = function(node)
7778{
7779	BX.CWindowFloat.superclass.constructor.apply(this, [node, 'float']);
7780
7781	this.SETTINGS.resizable = false;
7782};
7783BX.extend(BX.CWindowFloat, BX.CWindow);
7784
7785BX.CWindowFloat.prototype.adjustPos = function()
7786{
7787	if (this.PARAMS.parent)
7788		this.adjustToNode();
7789	else if (this.PARAMS.x && this.PARAMS.y)
7790		this.adjustToPos([this.PARAMS.x, this.PARAMS.y]);
7791};
7792
7793BX.CWindowFloat.prototype.adjustToPos = function(pos)
7794{
7795	this.DIV.style.left = parseInt(pos[0]) + 'px';
7796	this.DIV.style.top = parseInt(pos[1]) + 'px';
7797};
7798
7799BX.CWindowFloat.prototype.adjustToNodeGetPos = function()
7800{
7801	return BX.pos(this.PARAMS.parent);
7802};
7803
7804BX.CWindowFloat.prototype.adjustToNode = function(el)
7805{
7806	el = el || this.PARAMS.parent;
7807
7808	this.PARAMS.parent = BX(el);
7809
7810	if (this.PARAMS.parent)
7811	{
7812		var pos = this.adjustToNodeGetPos();
7813
7814		this.DIV.style.top = pos.top + 'px';//(pos.top - 26) + 'px';
7815		this.DIV.style.left = pos.left + 'px';
7816
7817		this.PARAMS.parent.OPENER = this;
7818	}
7819};
7820
7821BX.CWindowFloat.prototype.Show = function()
7822{
7823	this.adjustToPos([-1000, -1000]);
7824	BX.CWindowFloat.superclass.Show.apply(this, arguments);
7825	this.adjustPos();
7826};
7827
7828/* menu opener class */
7829/*
7830{
7831	DOMNode DIV,
7832	BX.CMenu or Array MENU,
7833	TYPE = 'hover' | 'click',
7834	TIMEOUT: 1000
7835	ATTACH_MODE: 'top' | 'right'
7836	ACTIVE_CLASS: className for opener element when menu is opened
7837}
7838*/
7839BX.COpener = function(arParams)
7840{
7841	this.PARAMS = arParams || {};
7842
7843	this.MENU = arParams.MENU || [];
7844
7845	this.DIV = arParams.DIV;
7846	this.ATTACH = arParams.ATTACH || arParams.DIV;
7847	this.ATTACH_MODE = arParams.ATTACH_MODE || 'bottom';
7848
7849	this.ACTIVE_CLASS = arParams.ACTIVE_CLASS || '';
7850	this.LEVEL = arParams.LEVEL || 0;
7851
7852	this.CLOSE_ON_CLICK = typeof arParams.CLOSE_ON_CLICK != 'undefined' ? !!arParams.CLOSE_ON_CLICK : true;
7853	this.ADJUST_ON_CLICK = typeof arParams.ADJUST_ON_CLICK != 'undefined' ? !!arParams.ADJUST_ON_CLICK : true;
7854
7855	this.TYPE = this.PARAMS.TYPE == 'hover' ? 'hover' : 'click';
7856
7857	this._openTimeout = null;
7858
7859	if (this.PARAMS.TYPE == 'hover' && arParams.TIMEOUT !== 0)
7860		this.TIMEOUT = arParams.TIMEOUT || 1000;
7861	else
7862		this.TIMEOUT = 0;
7863
7864	if (!!this.PARAMS.MENU_URL)
7865	{
7866		this.bMenuLoaded = false;
7867		this.bMenuLoading = false;
7868
7869		this.MENU = [{
7870			TEXT: BX.message('JS_CORE_LOADING'),
7871			CLOSE_ON_CLICK: false
7872		}];
7873
7874		if (this.PARAMS.MENU_PRELOAD)
7875		{
7876			BX.defer(this.Load, this)();
7877		}
7878	}
7879
7880	BX.ready(BX.defer(this.Init, this));
7881};
7882
7883BX.COpener.prototype.Init = function()
7884{
7885	this.DIV = BX(this.DIV);
7886
7887	switch (this.TYPE)
7888	{
7889		case 'hover':
7890			BX.bind(this.DIV, 'mouseover', BX.proxy(this.Open, this));
7891			BX.bind(this.DIV, 'click', BX.proxy(this.Toggle, this));
7892		break;
7893
7894		case 'click':
7895			BX.bind(this.DIV, 'click', BX.proxy(this.Toggle, this));
7896		break;
7897	}
7898
7899	//BX.bind(window, 'scroll', BX.delegate(this.__close_immediately, this));
7900
7901	this.bMenuInit = false;
7902};
7903
7904BX.COpener.prototype.Load = function()
7905{
7906	if (this.PARAMS.MENU_URL && !this.bMenuLoaded)
7907	{
7908		if (!this.bMenuLoading)
7909		{
7910			var url = this.PARAMS.MENU_URL;
7911			if (url.indexOf('sessid=') <= 0)
7912				url += (url.indexOf('?') > 0 ? '&' : '?') + 'sessid=' + BX.bitrix_sessid();
7913
7914			this.bMenuLoading = true;
7915			BX.ajax.loadJSON(url, BX.proxy(this.SetMenu, this), BX.proxy(this.LoadFailed, this));
7916		}
7917	}
7918};
7919
7920BX.COpener.prototype.SetMenu = function(menu)
7921{
7922	this.bMenuLoaded = true;
7923	this.bMenuLoading = false;
7924	if (this.bMenuInit)
7925	{
7926		this.MENU.setItems(menu);
7927	}
7928	else
7929	{
7930		this.MENU = menu;
7931	}
7932};
7933
7934BX.COpener.prototype.LoadFailed = function()
7935{
7936	this.bMenuLoading = false;
7937	BX.debug(arguments);
7938};
7939
7940BX.COpener.prototype.checkAdminMenu = function()
7941{
7942	if (document.documentElement.id == 'bx-admin-prefix')
7943		return true;
7944
7945	return !!BX.findParent(this.DIV, {property: {id: 'bx-admin-prefix'}});
7946};
7947
7948BX.COpener.prototype.Toggle = function(e)
7949{
7950	this.__clear_timeout();
7951
7952	if (!this.bMenuInit || !this.MENU.visible())
7953	{
7954		var t = this.TIMEOUT;
7955		this.TIMEOUT = 0;
7956		this.Open(e);
7957		this.TIMEOUT = t;
7958	}
7959	else
7960	{
7961		this.MENU.Close();
7962	}
7963
7964	return !!(e||window.event) && BX.PreventDefault(e);
7965};
7966
7967BX.COpener.prototype.GetMenu = function()
7968{
7969	if (!this.bMenuInit)
7970	{
7971		if (BX.type.isArray(this.MENU))
7972		{
7973			this.MENU = new BX.CMenu({
7974				ITEMS: this.MENU,
7975				ATTACH_MODE: this.ATTACH_MODE,
7976				SET_ID: this.checkAdminMenu() ? 'bx-admin-prefix' : '',
7977				CLOSE_ON_CLICK: !!this.CLOSE_ON_CLICK,
7978				ADJUST_ON_CLICK: !!this.ADJUST_ON_CLICK,
7979				LEVEL: this.LEVEL,
7980				parent: BX(this.DIV),
7981				parent_attach: BX(this.ATTACH)
7982			});
7983
7984			if (this.LEVEL > 0)
7985			{
7986				BX.bind(this.MENU.DIV, 'mouseover', BX.proxy(this._on_menu_hover, this));
7987				BX.bind(this.MENU.DIV, 'mouseout', BX.proxy(this._on_menu_hout, this));
7988			}
7989		}
7990
7991		BX.addCustomEvent(this.MENU, 'onMenuOpen', BX.proxy(this.handler_onopen, this));
7992		BX.addCustomEvent(this.MENU, 'onMenuClose', BX.proxy(this.handler_onclose, this));
7993
7994		BX.addCustomEvent('onMenuItemHover', BX.proxy(this.handler_onover, this));
7995
7996		this.bMenuInit = true;
7997	}
7998
7999	return this.MENU;
8000};
8001
8002BX.COpener.prototype.Open = function()
8003{
8004	this.GetMenu();
8005
8006	this.bOpen = true;
8007
8008	this.__clear_timeout();
8009
8010	if (this.TIMEOUT > 0)
8011	{
8012		BX.bind(this.DIV, 'mouseout', BX.proxy(this.__clear_timeout, this));
8013		this._openTimeout = setTimeout(BX.proxy(this.__open, this), this.TIMEOUT);
8014	}
8015	else
8016	{
8017		this.__open();
8018	}
8019
8020	if (!!this.PARAMS.MENU_URL && !this.bMenuLoaded)
8021	{
8022		this._loadTimeout = setTimeout(BX.proxy(this.Load, this), parseInt(this.TIMEOUT/2));
8023	}
8024
8025	return true;
8026};
8027
8028BX.COpener.prototype.__clear_timeout = function()
8029{
8030	if (!!this._openTimeout)
8031		clearTimeout(this._openTimeout);
8032	if (!!this._loadTimeout)
8033		clearTimeout(this._loadTimeout);
8034
8035	BX.unbind(this.DIV, 'mouseout', BX.proxy(this.__clear_timeout, this));
8036};
8037
8038BX.COpener.prototype._on_menu_hover = function()
8039{
8040	this.bMenuHover = true;
8041
8042	this.__clear_timeout();
8043
8044	if (this.ACTIVE_CLASS)
8045		BX.addClass(this.DIV, this.ACTIVE_CLASS);
8046
8047};
8048
8049BX.COpener.prototype._on_menu_hout = function()
8050{
8051	this.bMenuHover = false;
8052};
8053
8054BX.COpener.prototype.handler_onover = function(level, opener)
8055{
8056	if (this.bMenuHover)
8057		return;
8058
8059	if (opener != this && level == this.LEVEL-1 && this.ACTIVE_CLASS)
8060	{
8061		BX.removeClass(this.DIV, this.ACTIVE_CLASS);
8062	}
8063
8064	if (this.bMenuInit && level <= this.LEVEL-1 && this.MENU.visible())
8065	{
8066		if (opener != this)
8067		{
8068			this.__clear_timeout();
8069			this._openTimeout = setTimeout(BX.proxy(this.Close, this), this.TIMEOUT);
8070		}
8071	}
8072};
8073
8074BX.COpener.prototype.handler_onopen = function()
8075{
8076	this.bOpen = true;
8077
8078	if (this.ACTIVE_CLASS)
8079		BX.addClass(this.DIV, this.ACTIVE_CLASS);
8080
8081	BX.defer(function() {
8082		BX.onCustomEvent(this, 'onOpenerMenuOpen');
8083	}, this)();
8084};
8085
8086BX.COpener.prototype.handler_onclose = function()
8087{
8088	this.bOpen = false;
8089	BX.onCustomEvent(this, 'onOpenerMenuClose');
8090
8091	if (this.ACTIVE_CLASS)
8092		BX.removeClass(this.DIV, this.ACTIVE_CLASS);
8093};
8094
8095BX.COpener.prototype.Close = function()
8096{
8097	if (!this.bMenuInit)
8098		return;
8099
8100	if (!!this._openTimeout)
8101		clearTimeout(this._openTimeout);
8102
8103	this.bOpen = false;
8104
8105	this.__close();
8106};
8107
8108BX.COpener.prototype.__open = function()
8109{
8110	this.__clear_timeout();
8111
8112	if (this.bMenuInit && this.bOpen && !this.MENU.visible())
8113		this.MENU.Show();
8114};
8115
8116BX.COpener.prototype.__close = function()
8117{
8118	if (this.bMenuInit && !this.bOpen && this.MENU.visible())
8119		this.MENU.Hide();
8120};
8121
8122BX.COpener.prototype.__close_immediately = function() {
8123	this.bOpen = false; this.__close();
8124};
8125
8126BX.COpener.prototype.isMenuVisible = function() {
8127	return null != this.MENU.visible && this.MENU.visible()
8128};
8129
8130/* common menu class */
8131
8132BX.CMenu = function(arParams)
8133{
8134	BX.CMenu.superclass.constructor.apply(this);
8135
8136	this.DIV.style.width = 'auto';//this.DIV.firstChild.offsetWidth + 'px';
8137	this.DIV.style.height = 'auto';//this.DIV.firstChild.offsetHeight + 'px';
8138
8139	this.PARAMS = arParams || {};
8140	this.PARTS = {};
8141
8142	this.PARAMS.ATTACH_MODE = this.PARAMS.ATTACH_MODE || 'bottom';
8143	this.PARAMS.CLOSE_ON_CLICK = typeof this.PARAMS.CLOSE_ON_CLICK == 'undefined' ? true : this.PARAMS.CLOSE_ON_CLICK;
8144	this.PARAMS.ADJUST_ON_CLICK = typeof this.PARAMS.ADJUST_ON_CLICK == 'undefined' ? true : this.PARAMS.ADJUST_ON_CLICK;
8145	this.PARAMS.LEVEL = this.PARAMS.LEVEL || 0;
8146
8147	this.DIV.className = 'bx-core-popup-menu bx-core-popup-menu-' + this.PARAMS.ATTACH_MODE + ' bx-core-popup-menu-level' + this.PARAMS.LEVEL + (typeof this.PARAMS.ADDITIONAL_CLASS != 'undefined' ? ' ' + this.PARAMS.ADDITIONAL_CLASS : '');
8148	if (!!this.PARAMS.SET_ID)
8149		this.DIV.id = this.PARAMS.SET_ID;
8150
8151	if (this.PARAMS.LEVEL == 0)
8152	{
8153		this.ARROW = this.DIV.appendChild(BX.create('SPAN', {props: {className: 'bx-core-popup-menu-angle'}, style: {left:'15px'}}));
8154	}
8155
8156	if (!!this.PARAMS.CLASS_NAME)
8157		this.DIV.className += ' ' + this.PARAMS.CLASS_NAME;
8158
8159	BX.bind(this.DIV, 'click', BX.eventCancelBubble);
8160
8161	this.ITEMS = [];
8162
8163	this.setItems(this.PARAMS.ITEMS);
8164
8165	BX.addCustomEvent('onMenuOpen', BX.proxy(this._onMenuOpen, this));
8166	BX.addCustomEvent('onMenuItemSelected', BX.proxy(this.Hide, this));
8167};
8168BX.extend(BX.CMenu, BX.CWindowFloat);
8169
8170BX.CMenu.broadcastCloseEvent = function()
8171{
8172	BX.onCustomEvent("onMenuItemSelected");
8173};
8174
8175BX.CMenu._toggleChecked = function()
8176{
8177	BX.toggleClass(this, 'bx-core-popup-menu-item-checked');
8178};
8179
8180BX.CMenu._itemDblClick = function()
8181{
8182	window.location.href = this.href;
8183};
8184
8185BX.CMenu.prototype.toggleArrow = function(v)
8186{
8187	if (!!this.ARROW)
8188	{
8189		if (typeof v == 'undefined')
8190		{
8191			v = this.ARROW.style.visibility == 'hidden';
8192		}
8193
8194		this.ARROW.style.visibility = !!v ? 'visible' : 'hidden';
8195	}
8196};
8197
8198BX.CMenu.prototype.visible = function()
8199{
8200	return this.DIV.style.display !== 'none';
8201};
8202
8203BX.CMenu.prototype._onMenuOpen = function(menu, menu_level)
8204{
8205	if (this.visible())
8206	{
8207		if (menu_level == this.PARAMS.LEVEL && menu != this)
8208		{
8209			this.Hide();
8210		}
8211	}
8212};
8213
8214BX.CMenu.prototype.onUnRegister = function()
8215{
8216	if (!this.visible())
8217		return;
8218
8219	this.Hide();
8220};
8221
8222BX.CMenu.prototype.setItems = function(items)
8223{
8224	this.PARAMS.ITEMS = items;
8225
8226	BX.cleanNode(this.DIV);
8227
8228	if (!!this.ARROW)
8229		this.DIV.appendChild(this.ARROW);
8230
8231	if (this.PARAMS.ITEMS)
8232	{
8233		this.PARAMS.ITEMS = BX.util.array_values(this.PARAMS.ITEMS);
8234
8235		var bIcons = false;
8236		var cnt = 0;
8237		for (var i = 0, len = this.PARAMS.ITEMS.length; i < len; i++)
8238		{
8239			if ((i == 0 || i == len-1) && this.PARAMS.ITEMS[i].SEPARATOR)
8240				continue;
8241
8242			cnt++;
8243
8244			if (!bIcons)
8245				bIcons = !!this.PARAMS.ITEMS[i].GLOBAL_ICON;
8246
8247			this.addItem(this.PARAMS.ITEMS[i], i);
8248		}
8249
8250		// Occam turning in his grave
8251		if (cnt === 1)
8252			BX.addClass(this.DIV, 'bx-core-popup-menu-single-item');
8253		else
8254			BX.removeClass(this.DIV, 'bx-core-popup-menu-single-item');
8255
8256		if (!bIcons)
8257			BX.addClass(this.DIV, 'bx-core-popup-menu-no-icons');
8258		else
8259			BX.removeClass(this.DIV, 'bx-core-popup-menu-no-icons');
8260
8261	}
8262};
8263
8264BX.CMenu.prototype.addItem = function(item)
8265{
8266	this.ITEMS.push(item);
8267
8268	if (item.SEPARATOR)
8269	{
8270		item.NODE = BX.create(
8271			'DIV', {props: {className: 'bx-core-popup-menu-separator'}}
8272		);
8273	}
8274	else
8275	{
8276		var bHasMenu = (!!item.MENU
8277			&& (
8278				(BX.type.isArray(item.MENU) && item.MENU.length > 0)
8279				|| item.MENU instanceof BX.CMenu
8280			) || !!item.MENU_URL
8281		);
8282
8283		if (item.DISABLED)
8284		{
8285			item.CLOSE_ON_CLICK = false;
8286			item.LINK = null;
8287			item.ONCLICK = null;
8288			item.ACTION = null;
8289		}
8290
8291		item.NODE = BX.create(!!item.LINK || BX.browser.IsIE() && !BX.browser.IsDoctype() ? 'A' : 'SPAN', {
8292			props: {
8293				className: 'bx-core-popup-menu-item'
8294					+ (bHasMenu ? ' bx-core-popup-menu-item-opener' : '')
8295					+ (!!item.DEFAULT ? ' bx-core-popup-menu-item-default' : '')
8296					+ (!!item.DISABLED ? ' bx-core-popup-menu-item-disabled' : '')
8297					+ (!!item.CHECKED ? ' bx-core-popup-menu-item-checked' : ''),
8298				title: !!BX.message['MENU_ENABLE_TOOLTIP'] ? item.TITLE || '' : '',
8299				BXMENULEVEL: this.PARAMS.LEVEL
8300			},
8301			attrs: !!item.LINK || BX.browser.IsIE() && !BX.browser.IsDoctype() ? {href: item.LINK || 'javascript:void(0)'} : {},
8302			events: {
8303				mouseover: function()
8304				{
8305					BX.onCustomEvent('onMenuItemHover', [this.BXMENULEVEL, this.OPENER])
8306				}
8307			},
8308			html: '<span class="bx-core-popup-menu-item-icon' + (item.GLOBAL_ICON ? ' '+item.GLOBAL_ICON : '') + '"></span><span class="bx-core-popup-menu-item-text">'+item.TEXT+'</span>'
8309		});
8310
8311		if (bHasMenu && !item.DISABLED)
8312		{
8313			item.NODE.OPENER = new BX.COpener({
8314				DIV: item.NODE,
8315				ACTIVE_CLASS: 'bx-core-popup-menu-item-opened',
8316				TYPE: 'hover',
8317				MENU: item.MENU,
8318				MENU_URL: item.MENU_URL,
8319				MENU_PRELOAD: !!item.MENU_PRELOAD,
8320				LEVEL: this.PARAMS.LEVEL + 1,
8321				ATTACH_MODE:'right',
8322				TIMEOUT: 500
8323			});
8324		}
8325		else if (this.PARAMS.CLOSE_ON_CLICK && (typeof item.CLOSE_ON_CLICK == 'undefined' || !!item.CLOSE_ON_CLICK))
8326		{
8327			BX.bind(item.NODE, 'click', BX.CMenu.broadcastCloseEvent);
8328		}
8329		else if (this.PARAMS.ADJUST_ON_CLICK && (typeof item.ADJUST_ON_CLICK == 'undefined' || !!item.ADJUST_ON_CLICK))
8330		{
8331			BX.bind(item.NODE, 'click', BX.defer(this.adjustPos, this));
8332		}
8333
8334		if (bHasMenu && !!item.LINK)
8335		{
8336			BX.bind(item.NODE, 'dblclick', BX.CMenu._itemDblClick);
8337		}
8338
8339		if (typeof item.CHECKED != 'undefined')
8340		{
8341			BX.bind(item.NODE, 'click', BX.CMenu._toggleChecked);
8342		}
8343
8344		item.ONCLICK = item.ACTION || item.ONCLICK;
8345		if (!!item.ONCLICK)
8346		{
8347			if (BX.type.isString(item.ONCLICK))
8348			{
8349				item.ONCLICK = new Function("event", item.ONCLICK);
8350			}
8351
8352			BX.bind(item.NODE, 'click', item.ONCLICK);
8353		}
8354	}
8355
8356	this.DIV.appendChild(item.NODE);
8357};
8358
8359BX.CMenu.prototype._documentClickBind = function()
8360{
8361	this._documentClickUnBind();
8362	BX.bind(document, 'click', BX.proxy(this._documentClick, this));
8363};
8364
8365BX.CMenu.prototype._documentClickUnBind = function()
8366{
8367	BX.unbind(document, 'click', BX.proxy(this._documentClick, this));
8368};
8369
8370BX.CMenu.prototype._documentClick = function(e)
8371{
8372	e = e||window.event;
8373	if(!!e && !(BX.getEventButton(e) & BX.MSLEFT))
8374		return;
8375
8376	this.Close();
8377};
8378
8379BX.CMenu.prototype.Show = function()
8380{
8381	BX.onCustomEvent(this, 'onMenuOpen', [this, this.PARAMS.LEVEL]);
8382	BX.CMenu.superclass.Show.apply(this, []);
8383
8384	this.bCloseEventFired = false;
8385
8386	BX.addCustomEvent(this.PARAMS.parent_attach, 'onChangeNodePosition', BX.proxy(this.adjustToNode, this));
8387
8388	(BX.defer(this._documentClickBind, this))();
8389};
8390
8391BX.CMenu.prototype.Close = // we shouldn't 'Close' window - only hide
8392BX.CMenu.prototype.Hide = function()
8393{
8394	if (!this.visible())
8395		return;
8396
8397	BX.removeCustomEvent(this.PARAMS.parent_attach, 'onChangeNodePosition', BX.proxy(this.adjustToNode, this));
8398
8399	this._documentClickUnBind();
8400
8401	if (!this.bCloseEventFired)
8402	{
8403		BX.onCustomEvent(this, 'onMenuClose', [this, this.PARAMS.LEVEL]);
8404		this.bCloseEventFired = true;
8405	}
8406	BX.CMenu.superclass.Hide.apply(this, arguments);
8407
8408
8409//	this.DIV.onclick = null;
8410	//this.PARAMS.parent.onclick = null;
8411};
8412
8413BX.CMenu.prototype.__adjustMenuToNode = function()
8414{
8415	var pos = BX.pos(this.PARAMS.parent_attach),
8416		bFixed = !!BX.findParent(this.PARAMS.parent_attach, BX.is_fixed);
8417
8418	if (bFixed)
8419		this.DIV.style.position = 'fixed';
8420	else
8421		this.DIV.style.position = 'absolute';
8422
8423	if (!pos.top)
8424	{
8425		this.DIV.style.top = '-1000px';
8426		this.DIV.style.left = '-1000px';
8427	}
8428
8429	if (this.bTimeoutSet) return;
8430
8431	var floatWidth = this.DIV.offsetWidth, floatHeight = this.DIV.offsetHeight;
8432	if (!floatWidth)
8433	{
8434		setTimeout(BX.delegate(function(){
8435			this.bTimeoutSet = false; this.__adjustMenuToNode();
8436		}, this), 100);
8437
8438		this.bTimeoutSet = true;
8439		return;
8440	}
8441
8442	var menu_pos = {},
8443		wndSize = BX.GetWindowSize();
8444
8445/*
8446	if (BX.browser.IsIE() && !BX.browser.IsDoctype())
8447	{
8448		pos.top -= 4; pos.bottom -= 4;
8449		pos.left -= 2; pos.right -= 2;
8450	}
8451*/
8452
8453	switch (this.PARAMS.ATTACH_MODE)
8454	{
8455		case 'bottom':
8456			menu_pos.top = pos.bottom + 9;
8457			menu_pos.left = pos.left;
8458
8459			if (!!this.ARROW)
8460			{
8461				var arrowPos = parseInt(this.ARROW.style.left);
8462				if (pos.width > floatWidth)
8463					arrowPos = parseInt(floatWidth/2 - 7);
8464				else
8465					arrowPos = parseInt(Math.min(floatWidth, pos.width)/2 - 7);
8466
8467				if (arrowPos < 7)
8468				{
8469					menu_pos.left -= 15;
8470					arrowPos += 15;
8471				}
8472			}
8473
8474			if (menu_pos.left > wndSize.scrollWidth - floatWidth - 10)
8475			{
8476				var orig_menu_pos = menu_pos.left;
8477				menu_pos.left = wndSize.scrollWidth - floatWidth - 10;
8478
8479				if (!!this.ARROW)
8480					arrowPos += orig_menu_pos - menu_pos.left;
8481			}
8482
8483			if (bFixed)
8484			{
8485				menu_pos.left -= wndSize.scrollLeft;
8486			}
8487
8488			if (!!this.ARROW)
8489				this.ARROW.style.left = arrowPos + 'px';
8490		break;
8491		case 'right':
8492			menu_pos.top = pos.top-1;
8493			menu_pos.left = pos.right;
8494
8495			if (menu_pos.left > wndSize.scrollWidth - floatWidth - 10)
8496			{
8497				menu_pos.left = pos.left - floatWidth - 1;
8498			}
8499		break;
8500	}
8501
8502	if (bFixed)
8503	{
8504		menu_pos.top -= wndSize.scrollTop;
8505	}
8506
8507	if (!!this.ARROW)
8508		this.ARROW.className = 'bx-core-popup-menu-angle';
8509
8510	if((menu_pos.top + floatHeight >
8510 wndSize.scrollTop + wndSize.innerHeight)
8511		|| (menu_pos.top + floatHeight > wndSize.scrollHeight))
8512	{
8513		var new_top = this.PARAMS.ATTACH_MODE == 'bottom'
8514			? pos.top - floatHeight - 9
8515			: pos.bottom - floatHeight + 1;
8516
8517		if((new_top > wndSize.scrollTop)
8518			|| (menu_pos.top + floatHeight > wndSize.scrollHeight))
8519		{
8520			if ((menu_pos.top + floatHeight > wndSize.scrollHeight))
8521			{
8522				menu_pos.top = Math.max(0, wndSize.scrollHeight-floatHeight);
8523				this.toggleArrow(false);
8524			}
8525			else
8526			{
8527				menu_pos.top = new_top;
8528
8529				if (!!this.ARROW)
8530					this.ARROW.className = 'bx-core-popup-menu-angle-bottom';
8531			}
8532		}
8533	}
8534
8535	if (menu_pos.top + menu_pos.left == 0)
8536	{
8537		this.Hide();
8538	}
8539	else
8540	{
8541		this.DIV.style.top = menu_pos.top + 'px';
8542		this.DIV.style.left = menu_pos.left + 'px';
8543	}
8544};
8545
8546BX.CMenu.prototype.adjustToNode = function(el)
8547{
8548	this.PARAMS.parent_attach = BX(el) || this.PARAMS.parent_attach || this.PARAMS.parent;
8549	this.__adjustMenuToNode();
8550};
8551
8552
8553/* components toolbar class */
8554
8555BX.CMenuOpener = function(arParams)
8556{
8557	BX.CMenuOpener.superclass.constructor.apply(this);
8558
8559	this.PARAMS = arParams || {};
8560	this.setParent(this.PARAMS.parent);
8561	this.PARTS = {};
8562
8563	this.SETTINGS.drag_restrict = true;
8564
8565	this.defaultAction = null;
8566
8567	this.timeout = 500;
8568
8569	this.DIV.className = 'bx-component-opener';
8570	this.DIV.ondblclick = BX.PreventDefault;
8571
8572	if (this.PARAMS.component_id)
8573	{
8574		this.PARAMS.transform = !!this.PARAMS.transform;
8575	}
8576
8577	this.OPENERS = [];
8578
8579	this.DIV.appendChild(BX.create('SPAN', {
8580		props: {className: 'bx-context-toolbar' + (this.PARAMS.transform ? ' bx-context-toolbar-vertical-mode' : '')}
8581	}));
8582
8583	//set internal structure and register draggable element
8584	this.PARTS.INNER = this.DIV.firstChild.appendChild(BX.create('SPAN', {
8585		props: {className: 'bx-context-toolbar-inner'},
8586		html: '<span class="bx-context-toolbar-drag-icon"></span><span class="bx-context-toolbar-vertical-line"></span><br>'
8587	}));
8588
8589	this.EXTRA_BUTTONS = {};
8590
8591	var btnCount = 0;
8592	for (var i = 0, len = this.PARAMS.menu.length; i < len; i++)
8593	{
8594		var item = this.addItem(this.PARAMS.menu[i]);
8595		if (null != item)
8596		{
8597			btnCount++;
8598			this.PARTS.INNER.appendChild(item);
8599			this.PARTS.INNER.appendChild(BX.create('BR'));
8600		}
8601	}
8602	var bHasButtons = btnCount > 0;
8603
8604	//menu items will be attached here
8605
8606	this.PARTS.ICONS = this.PARTS.INNER.appendChild(BX.create('SPAN', {
8607		props: {className: 'bx-context-toolbar-icons'}
8608	}));
8609
8610	if (this.PARAMS.component_id)
8611	{
8612		this.PARAMS.pin = !!this.PARAMS.pin;
8613
8614		if (bHasButtons)
8615			this.PARTS.ICONS.appendChild(BX.create('SPAN', {props: {className: 'bx-context-toolbar-separator'}}));
8616
8617		this.PARTS.ICON_PIN = this.PARTS.ICONS.appendChild(BX.create('A', {
8618			attrs: {
8619				href: 'javascript:void(0)'
8620			},
8621			props: {
8622				className: this.PARAMS.pin
8623							? 'bx-context-toolbar-pin-fixed'
8624							: 'bx-context-toolbar-pin'
8625			},
8626			events: {
8627				click: BX.delegate(this.__pin_btn_clicked, this)
8628			}
8629		}));
8630	}
8631
8632
8633	if (this.EXTRA_BUTTONS['components2_props'])
8634	{
8635		var btn = this.EXTRA_BUTTONS['components2_props'] || {URL: 'javascript:void(0)'};
8636		if (null == this.defaultAction)
8637		{
8638			this.defaultAction = btn.ONCLICK;
8639			this.defaultActionTitle = btn.TITLE || btn.TEXT;
8640		}
8641
8642		btn.URL = 'javascript:' + BX.util.urlencode(btn.ONCLICK);
8643
8644		this.ATTACH = this.PARTS.ICONS.appendChild(BX.create('SPAN', {
8645			props: {className: 'bx-context-toolbar-button bx-context-toolbar-button-settings' },
8646			children:
8647			[
8648				BX.create('SPAN',
8649				{
8650					props:{className: 'bx-context-toolbar-button-inner'},
8651					children:
8652					[
8653						BX.create('A', {
8654							attrs: {href: btn.URL},
8655							events: {
8656								mouseover: BX.proxy(this.__msover_text, this),
8657								mouseout: BX.proxy(this.__msout_text, this),
8658								mousedown: BX.proxy(this.__msdown_text, this)
8659							},
8660							html: '<span class="bx-context-toolbar-button-icon bx-context-toolbar-settings-icon"></span>'
8661						}),
8662						BX.create('A', {
8663							attrs: {href: 'javascript: void(0)'},
8664							props: {className: 'bx-context-toolbar-button-arrow'},
8665							events: {
8666								mouseover: BX.proxy(this.__msover_arrow, this),
8667								mouseout: BX.proxy(this.__msout_arrow, this),
8668								mousedown: BX.proxy(this.__msdown_arrow, this)
8669							},
8670							html: '<span class="bx-context-toolbar-button-arrow"></span>'
8671						})
8672					]
8673				})
8674			]
8675		}));
8676
8677		this.OPENER = this.ATTACH.firstChild.lastChild;
8678
8679		var opener = this.attachMenu(this.EXTRA_BUTTONS['components2_submenu']['MENU']);
8680
8681		BX.addCustomEvent(opener, 'onOpenerMenuOpen', BX.proxy(this.__menu_open, this));
8682		BX.addCustomEvent(opener, 'onOpenerMenuClose', BX.proxy(this.__menu_close, this));
8683	}
8684
8685	if (btnCount > 1)
8686	{
8687		this.PARTS.ICONS.appendChild(BX.create('span', { props: {className: 'bx-context-toolbar-separator bx-context-toolbar-separator-switcher'}}));
8688
8689		this.ICON_TRANSFORM = this.PARTS.ICONS.appendChild(BX.create('A', {
8690			attrs: {href: 'javascript: void(0)'},
8691			props: {className: 'bx-context-toolbar-switcher'},
8692			events: {
8693				click: BX.delegate(this.__trf_btn_clicked, this)
8694			}
8695		}));
8696	}
8697
8698	if (this.PARAMS.HINT)
8699	{
8700		this.DIV.BXHINT = this.HINT = new BX.CHint({
8701			parent: this.DIV,
8702			hint:this.PARAMS.HINT.TEXT || '',
8703			title: this.PARAMS.HINT.TITLE || '',
8704			hide_timeout: this.timeout/2,
8705			preventHide: false
8706		});
8707	}
8708
8709	BX.addCustomEvent(this, 'onWindowDragFinished', BX.delegate(this.__onMoveFinished, this));
8710	BX.addCustomEvent('onDynamicModeChange', BX.delegate(this.__onDynamicModeChange, this));
8711	BX.addCustomEvent('onTopPanelCollapse', BX.delegate(this.__onPanelCollapse, this));
8712
8713	BX.addCustomEvent('onMenuOpenerMoved', BX.delegate(this.checkPosition, this));
8714	BX.addCustomEvent('onMenuOpenerUnhide', BX.delegate(this.checkPosition, this));
8715
8716	if (this.OPENERS)
8717	{
8718		for (i=0,len=this.OPENERS.length; i<len; i++)
8719		{
8720			BX.addCustomEvent(this.OPENERS[i], 'onOpenerMenuOpen', BX.proxy(this.__hide_hint, this));
8721		}
8722	}
8723};
8724BX.extend(BX.CMenuOpener, BX.CWindowFloat);
8725
8726BX.CMenuOpener.prototype.setParent = function(new_parent)
8727{
8728	new_parent = BX(new_parent);
8729	if(new_parent.OPENER && new_parent.OPENER != this)
8730	{
8731		new_parent.OPENER.Close();
8732		new_parent.OPENER.clearHoverHoutEvents();
8733	}
8734
8735	if(this.PARAMS.parent && this.PARAMS.parent != new_parent)
8736	{
8737		this.clearHoverHoutEvents();
8738		this.PARAMS.parent.OPENER = null;
8739	}
8740
8741	this.PARAMS.parent = new_parent;
8742	this.PARAMS.parent.OPENER = this;
8743};
8744
8745BX.CMenuOpener.prototype.setHoverHoutEvents = function(hover, hout)
8746{
8747	if(!this.__opener_events_set)
8748	{
8749		BX.bind(this.Get(), 'mouseover', hover);
8750		BX.bind(this.Get(), 'mouseout', hout);
8751		this.__opener_events_set = true;
8752	}
8753};
8754
8755BX.CMenuOpener.prototype.clearHoverHoutEvents = function()
8756{
8757	if(this.Get())
8758	{
8759		BX.unbindAll(this.Get());
8760		this.__opener_events_set = false;
8761	}
8762};
8763
8764
8765BX.CMenuOpener.prototype.unclosable = true;
8766
8767BX.CMenuOpener.prototype.__check_intersection = function(pos_self, pos_other)
8768{
8769	return !(pos_other.right <= pos_self.left || pos_other.left >= pos_self.right
8770			|| pos_other.bottom <= pos_self.top || pos_other.top >= pos_self.bottom);
8771};
8772
8773
8774BX.CMenuOpener.prototype.__msover_text = function() {
8775	this.bx_hover = true;
8776	if (!this._menu_open)
8777		BX.addClass(this.ATTACH, 'bx-context-toolbar-button-text-hover');
8778};
8779
8780BX.CMenuOpener.prototype.__msout_text = function() {
8781	this.bx_hover = false;
8782	if (!this._menu_open)
8783		BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-text-hover bx-context-toolbar-button-text-active');
8784};
8785
8786BX.CMenuOpener.prototype.__msover_arrow = function() {
8787	this.bx_hover = true;
8788	if (!this._menu_open)
8789		BX.addClass(this.ATTACH, 'bx-context-toolbar-button-arrow-hover');
8790};
8791
8792BX.CMenuOpener.prototype.__msout_arrow = function() {
8793	this.bx_hover = false;
8794	if (!this._menu_open)
8795		BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-arrow-hover bx-context-toolbar-button-arrow-active');
8796};
8797
8798BX.CMenuOpener.prototype.__msdown_text = function() {
8799	this.bx_active = true;
8800	if (!this._menu_open)
8801		BX.addClass(this.ATTACH, 'bx-context-toolbar-button-text-active');
8802};
8803
8804BX.CMenuOpener.prototype.__msdown_arrow = function() {
8805	this.bx_active = true;
8806	if (!this._menu_open)
8807		BX.addClass(this.ATTACH, 'bx-context-toolbar-button-arrow-active');
8808};
8809
8810BX.CMenuOpener.prototype.__menu_close = function() {
8811	this._menu_open = false;
8812	this.bx_active = false;
8813	BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-active bx-context-toolbar-button-text-active bx-context-toolbar-button-arrow-active');
8814	if (!this.bx_hover)
8815	{
8816		BX.removeClass(this.ATTACH, 'bx-context-toolbar-button-hover bx-context-toolbar-button-text-hover bx-context-toolbar-button-arrow-hover');
8817		this.bx_hover = false;
8818	}
8819};
8820
8821BX.CMenuOpener.prototype.__menu_open = function() {
8822	this._menu_open = true;
8823};
8824
8825BX.CMenuOpener.prototype.checkPosition = function()
8826{
8827	if (this.isMenuVisible() || this.DIV.style.display == 'none'
8828		|| this == BX.proxy_context || BX.proxy_context.zIndex > this.zIndex)
8829		return;
8830
8831	this.correctPosition(BX.proxy_context);
8832};
8833
8834BX.CMenuOpener.prototype.correctPosition = function(opener)
8835{
8836	var pos_self = BX.pos(this.DIV), pos_other = BX.pos(opener.Get());
8837	if (this.__check_intersection(pos_self, pos_other))
8838	{
8839		var new_top = pos_other.top - pos_self.height;
8840		if (new_top < 0)
8841			new_top = pos_other.bottom;
8842
8843		this.DIV.style.top = new_top + 'px';
8844
8845		BX.addCustomEvent(opener, 'onMenuOpenerHide', BX.proxy(this.restorePosition, this));
8846		BX.onCustomEvent(this, 'onMenuOpenerMoved');
8847	}
8848};
8849
8850BX.CMenuOpener.prototype.restorePosition = function()
8851{
8852	if (!this.MOUSEOVER && !this.isMenuVisible())
8853	{
8854		if (this.originalPos)
8855			this.DIV.style.top = this.originalPos.top + 'px';
8856
8857		BX.removeCustomEvent(BX.proxy_context, 'onMenuOpenerHide', BX.proxy(this.restorePosition, this));
8858		if (this.restore_pos_timeout) clearTimeout(this.restore_pos_timeout);
8859	}
8860	else
8861	{
8862		this.restore_pos_timeout = setTimeout(BX.proxy(this.restorePosition, this), this.timeout);
8863	}
8864};
8865
8866
8867BX.CMenuOpener.prototype.Show = function()
8868{
8869	BX.CMenuOpener.superclass.Show.apply(this, arguments);
8870
8871	this.SetDraggable(this.PARTS.INNER.firstChild);
8872
8873	this.DIV.style.width = 'auto';
8874	this.DIV.style.height = 'auto';
8875
8876	if (!this.PARAMS.pin)
8877	{
8878		this.DIV.style.left = '-1000px';
8879		this.DIV.style.top = '-1000px';
8880
8881		this.Hide();
8882	}
8883	else
8884	{
8885		this.bPosAdjusted = true;
8886		this.bMoved = true;
8887
8888		if (this.PARAMS.top) this.DIV.style.top = this.PARAMS.top + 'px';
8889		if (this.PARAMS.left) this.DIV.style.left = this.PARAMS.left + 'px';
8890
8891		this.DIV.style.display = (!BX.admin.dynamic_mode || BX.admin.dynamic_mode_show_borders) ? 'block' : 'none';
8892
8893		if (this.DIV.style.display == 'block')
8894		{
8895			setTimeout(BX.delegate(function() {BX.onCustomEvent(this, 'onMenuOpenerUnhide')}, this), 50);
8896		}
8897	}
8898};
8899
8900BX.CMenuOpener.prototype.executeDefaultAction = function()
8901{
8902	if (this.defaultAction)
8903	{
8904		if (BX.type.isFunction(this.defaultAction))
8905			this.defaultAction();
8906		else if(BX.type.isString(this.defaultAction))
8907			BX.evalGlobal(this.defaultAction);
8908	}
8909};
8910
8911BX.CMenuOpener.prototype.__onDynamicModeChange = function(val)
8912{
8913	this.DIV.style.display = val ? 'block' : 'none';
8914};
8915
8916BX.CMenuOpener.prototype.__onPanelCollapse = function(bCollapsed, dy)
8917{
8918	this.DIV.style.top = (parseInt(this.DIV.style.top) + dy) + 'px';
8919	if (this.PARAMS.pin)
8920	{
8921		this.__savePosition();
8922	}
8923};
8924
8925BX.CMenuOpener.prototype.__onMoveFinished = function()
8926{
8927	BX.onCustomEvent(this, 'onMenuOpenerMoved');
8928
8929	this.bMoved = true;
8930
8931	if (this.PARAMS.pin)
8932		this.__savePosition();
8933};
8934
8935BX.CMenuOpener.prototype.__savePosition = function()
8936{
8937	var arOpts = {};
8938
8939	arOpts.pin = this.PARAMS.pin;
8940	if (!this.PARAMS.pin)
8941	{
8942		arOpts.top = false; arOpts.left = false; arOpts.transform = false;
8943	}
8944	else
8945	{
8946		arOpts.transform = this.PARAMS.transform;
8947		if (this.bMoved)
8948		{
8949			arOpts.left = parseInt(this.DIV.style.left);
8950			arOpts.top = parseInt(this.DIV.style.top);
8951		}
8952	}
8953
8954	BX.WindowManager.saveWindowOptions(this.PARAMS.component_id, arOpts);
8955};
8956
8957BX.CMenuOpener.prototype.__pin_btn_clicked = function() {this.Pin()};
8958BX.CMenuOpener.prototype.Pin = function(val)
8959{
8960	if (null == val)
8961		this.PARAMS.pin = !this.PARAMS.pin;
8962	else
8963		this.PARAMS.pin = !!val;
8964
8965	this.PARTS.ICON_PIN.className = (this.PARAMS.pin ? 'bx-context-toolbar-pin-fixed' : 'bx-context-toolbar-pin');
8966
8967	this.__savePosition();
8968};
8969
8970BX.CMenuOpener.prototype.__trf_btn_clicked = function() {this.Transform()};
8971BX.CMenuOpener.prototype.Transform = function(val)
8972{
8973	if (null == val)
8974		this.PARAMS.transform = !this.PARAMS.transform;
8975	else
8976		this.PARAMS.transform = !!val;
8977
8978	if (this.bMoved)
8979	{
8980		var pos = BX.pos(this.DIV);
8981	}
8982
8983	if (this.PARAMS.transform)
8984		BX.addClass(this.DIV.firstChild, 'bx-context-toolbar-vertical-mode');
8985	else
8986		BX.removeClass(this.DIV.firstChild, 'bx-context-toolbar-vertical-mode');
8987
8988	if (!this.bMoved)
8989	{
8990		this.adjustPos();
8991	}
8992	else
8993	{
8994		this.DIV.style.left = (pos.right - this.DIV.offsetWidth - (BX.browser.IsIE() && !BX.browser.IsDoctype() ? 2 : 0)) + 'px';
8995	}
8996
8997	this.__savePosition();
8998};
8999
9000BX.CMenuOpener.prototype.adjustToNodeGetPos = function()
9001{
9002	var pos = BX.pos(this.PARAMS.parent/*, true*/);
9003
9004	var scrollSize = BX.GetWindowScrollSize();
9005	var floatWidth = this.DIV.offsetWidth;
9006
9007	pos.left -= BX.admin.__border_dx;
9008	pos.top -= BX.admin.__border_dx;
9009
9010	if (true || !this.PARAMS.transform)
9011	{
9012		pos.top -= 45;
9013	}
9014
9015	if (pos.left > scrollSize.scrollWidth - floatWidth)
9016	{
9017		pos.left = scrollSize.scrollWidth - floatWidth;
9018	}
9019
9020	return pos;
9021};
9022
9023BX.CMenuOpener.prototype.addItem = function(item)
9024{
9025	if (item.TYPE)
9026	{
9027		this.EXTRA_BUTTONS[item.TYPE] = item;
9028		return null;
9029	}
9030	else
9031	{
9032		var q = new BX.CMenuOpenerItem(item);
9033		if (null == this.defaultAction)
9034		{
9035			if (q.item.ONCLICK)
9036			{
9037				this.defaultAction = item.ONCLICK;
9038			}
9039			else if (q.item.MENU)
9040			{
9041				this.defaultAction = BX.delegate(function() {this.Open()}, q.item.OPENER);
9042			}
9043
9044			this.defaultActionTitle = item.TITLE || item.TEXT;
9045
9046			BX.addClass(q.Get(), 'bx-content-toolbar-default');
9047		}
9048		if (q.item.OPENER) this.OPENERS[this.OPENERS.length] = q.item.OPENER;
9049		return q.Get();
9050	}
9051};
9052
9053BX.CMenuOpener.prototype.attachMenu = function(menu)
9054{
9055	var opener = new BX.COpener({
9056		'DIV':  this.OPENER,
9057		'ATTACH': this.ATTACH,
9058		'MENU': menu,
9059		'TYPE': 'click'
9060	});
9061
9062	this.OPENERS[this.OPENERS.length] = opener;
9063
9064	return opener;
9065};
9066
9067BX.CMenuOpener.prototype.__hide_hint = function()
9068{
9069	if (this.HINT) this.HINT.__hide_immediately();
9070};
9071
9072BX.CMenuOpener.prototype.isMenuVisible = function()
9073{
9074	for (var i=0,len=this.OPENERS.length; i<len; i++)
9075	{
9076		if (this.OPENERS[i].isMenuVisible())
9077			return true;
9078	}
9079
9080	return false;
9081};
9082
9083BX.CMenuOpener.prototype.Hide = function()
9084{
9085	if (!this.PARAMS.pin)
9086	{
9087		this.DIV.style.display = 'none';
9088		BX.onCustomEvent(this, 'onMenuOpenerHide');
9089	}
9090};
9091BX.CMenuOpener.prototype.UnHide = function()
9092{
9093	this.DIV.style.display = 'block';
9094	if (!this.bPosAdjusted && !this.PARAMS.pin)
9095	{
9096		this.adjustPos();
9097		this.bPosAdjusted = true;
9098	}
9099
9100	if (null == this.originalPos && !this.bMoved)
9101	{
9102		this.originalPos = BX.pos(this.DIV);
9103	}
9104
9105	BX.onCustomEvent(this, 'onMenuOpenerUnhide');
9106};
9107
9108BX.CMenuOpenerItem = function(item)
9109{
9110	this.item = item;
9111
9112	if (this.item.ACTION && !this.item.ONCLICK)
9113	{
9114		this.item.ONCLICK = this.item.ACTION;
9115	}
9116
9117	this.DIV = BX.create('SPAN');
9118	this.DIV.appendChild(BX.create('SPAN', {props: {className: 'bx-context-toolbar-button-underlay'}}));
9119
9120	this.WRAPPER = this.DIV.appendChild(BX.create('SPAN', {
9121		props: {className: 'bx-context-toolbar-button-wrapper'},
9122		children: [
9123			BX.create('SPAN', {
9124				props: {className: 'bx-context-toolbar-button', title: item.TITLE},
9125				children: [
9126					BX.create('SPAN', {
9127						props: {className: 'bx-context-toolbar-button-inner'}
9128					})
9129				]
9130			})
9131		]
9132	}));
9133
9134	var btn_icon = BX.create('SPAN', {
9135		props: {className: 'bx-context-toolbar-button-icon' + (this.item.ICON || this.item.ICONCLASS ? ' ' + (this.item.ICON || this.item.ICONCLASS) : '')},
9136		attrs: (
9137				!(this.item.ICON || this.item.ICONCLASS)
9138				&&
9139				(this.item.SRC || this.item.IMAGE)
9140			)
9141			? {
9142				style: 'background: scroll transparent url(' + (this.item.SRC || this.item.IMAGE) + ') no-repeat center center !important;'
9143			}
9144			: {}
9145	}), btn_text = BX.create('SPAN', {
9146		props: {className: 'bx-context-toolbar-button-text'},
9147		text: this.item.TEXT
9148	});
9149
9150	if (this.item.ACTION && !this.item.ONCLICK)
9151	{
9152		this.item.ONCLICK = this.item.ACTION;
9153	}
9154
9155	this.bHasMenu = !!this.item.MENU;
9156	this.bHasAction = !!this.item.ONCLICK;
9157
9158	if (this.bHasAction)
9159	{
9160		this.LINK = this.WRAPPER.firstChild.firstChild.appendChild(BX.create('A', {
9161			attrs: {
9162				'href': 'javascript: void(0)'
9163			},
9164			events: {
9165				mouseover: this.bHasMenu ? BX.proxy(this.__msover_text, this) : BX.proxy(this.__msover, this),
9166				mouseout: this.bHasMenu ? BX.proxy(this.__msout_text, this) : BX.proxy(this.__msout, this),
9167				mousedown: this.bHasMenu ? BX.proxy(this.__msdown_text, this) : BX.proxy(this.__msdown, this)
9168			},
9169			children: [btn_icon, btn_text]
9170		}));
9171
9172		if (this.bHasMenu)
9173		{
9174			this.LINK_MENU = this.WRAPPER.firstChild.firstChild.appendChild(BX.create('A', {
9175				props: {className: 'bx-context-toolbar-button-arrow'},
9176				attrs: {
9177					'href': 'javascript: void(0)'
9178				},
9179				events: {
9180					mouseover: BX.proxy(this.__msover_arrow, this),
9181					mouseout: BX.proxy(this.__msout_arrow, this),
9182					mousedown: BX.proxy(this.__msdown_arrow, this)
9183				},
9184				children: [
9185					BX.create('SPAN', {props: {className: 'bx-context-toolbar-button-arrow'}})
9186				]
9187			}));
9188		}
9189
9190	}
9191	else if (this.bHasMenu)
9192	{
9193		this.item.ONCLICK = null;
9194
9195		this.LINK = this.LINK_MENU = this.WRAPPER.firstChild.firstChild.appendChild(BX.create('A', {
9196			attrs: {
9197				'href': 'javascript: void(0)'
9198			},
9199			events: {
9200				mouseover: BX.proxy(this.__msover, this),
9201				mouseout: BX.proxy(this.__msout, this),
9202				mousedown: BX.proxy(this.__msdown, this)
9203			},
9204			children: [
9205				btn_icon,
9206				btn_text
9207			]
9208		}));
9209
9210		this.LINK.appendChild(BX.create('SPAN', {props: {className: 'bx-context-toolbar-single-button-arrow'}}));
9211
9212	}
9213
9214	if (this.bHasMenu)
9215	{
9216		this.item.SUBMENU = new BX.CMenu({
9217			ATTACH_MODE:'bottom',
9218			ITEMS:this.item['MENU'],
9219			//PARENT_MENU:this.parentMenu,
9220			parent: this.LINK_MENU,
9221			parent_attach: this.WRAPPER.firstChild
9222		});
9223
9224		this.item.OPENER = new BX.COpener({
9225			DIV: this.LINK_MENU,
9226			TYPE: 'click',
9227			MENU: this.item.SUBMENU
9228		});
9229
9230		BX.addCustomEvent(this.item.OPENER, 'onOpenerMenuOpen', BX.proxy(this.__menu_open, this));
9231		BX.addCustomEvent(this.item.OPENER, 'onOpenerMenuClose', BX.proxy(this.__menu_close, this));
9232	}
9233
9234	if (this.bHasAction)
9235	{
9236		BX.bind(this.LINK, 'click', BX.delegate(this.__click, this));
9237	}
9238};
9239
9240BX.CMenuOpenerItem.prototype.Get = function() {return this.DIV;};
9241BX.CMenuOpenerItem.prototype.__msover = function() {
9242	this.bx_hover = true;
9243	if (!this._menu_open)
9244		BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-hover');
9245};
9246BX.CMenuOpenerItem.prototype.__msout = function() {
9247	this.bx_hover = false;
9248	if (!this._menu_open)
9249		BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-hover bx-context-toolbar-button-active');
9250};
9251BX.CMenuOpenerItem.prototype.__msover_text = function() {
9252	this.bx_hover = true;
9253	if (!this._menu_open)
9254		BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-text-hover');
9255};
9256BX.CMenuOpenerItem.prototype.__msout_text = function() {
9257	this.bx_hover = false;
9258	if (!this._menu_open)
9259		BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-text-hover bx-context-toolbar-button-text-active');
9260};
9261BX.CMenuOpenerItem.prototype.__msover_arrow = function() {
9262	this.bx_hover = true;
9263	if (!this._menu_open)
9264		BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-arrow-hover');
9265};
9266BX.CMenuOpenerItem.prototype.__msout_arrow = function() {
9267	this.bx_hover = false;
9268	if (!this._menu_open)
9269		BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-arrow-hover bx-context-toolbar-button-arrow-active');
9270};
9271BX.CMenuOpenerItem.prototype.__msdown = function() {
9272	this.bx_active = true;
9273	if (!this._menu_open)
9274		BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-active');
9275};
9276BX.CMenuOpenerItem.prototype.__msdown_text = function() {
9277	this.bx_active = true;
9278	if (!this._menu_open)
9279		BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-text-active');
9280};
9281BX.CMenuOpenerItem.prototype.__msdown_arrow = function() {
9282	this.bx_active = true;
9283	if (!this._menu_open)
9284		BX.addClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-arrow-active');
9285};
9286BX.CMenuOpenerItem.prototype.__menu_close = function() {
9287
9288	this._menu_open = false;
9289	this.bx_active = false;
9290	BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-active bx-context-toolbar-button-text-active bx-context-toolbar-button-arrow-active');
9291	if (!this.bx_hover)
9292	{
9293		BX.removeClass(this.LINK.parentNode.parentNode, 'bx-context-toolbar-button-hover bx-context-toolbar-button-text-hover bx-context-toolbar-button-arrow-hover');
9294		this.bx_hover = false;
9295	}
9296};
9297BX.CMenuOpenerItem.prototype.__menu_open = function() {
9298	this._menu_open = true;
9299};
9300
9301BX.CMenuOpenerItem.prototype.__click = function() {BX.evalGlobal(this.item.ONCLICK)};
9302
9303/* global page opener class */
9304BX.CPageOpener = function(arParams)
9305{
9306	//if (null == arParams.pin) arParams.pin = true;
9307	BX.CPageOpener.superclass.constructor.apply(this, arguments);
9308
9309	this.timeout = 505;
9310
9311	window.PAGE_EDIT_CONTROL = this;
9312};
9313BX.extend(BX.CPageOpener, BX.CMenuOpener);
9314
9315BX.CPageOpener.prototype.checkPosition = function()
9316{
9317	if (/*this.isMenuVisible() || this.DIV.style.display == 'none' || */this == BX.proxy_context)
9318		return;
9319
9320	this.correctPosition(BX.proxy_context);
9321};
9322
9323BX.CPageOpener.prototype.correctPosition = function(opener)
9324{
9325	if (this.bPosCorrected) return;
9326	if (this.DIV.style.display == 'none')
9327	{
9328		var pos_self = this.adjustToNodeGetPos();
9329		pos_self.bottom = pos_self.top + 30;
9330		pos_self.right = pos_self.left + 300;
9331	}
9332	else
9333	{
9334		pos_self = BX.pos(this.DIV);
9335	}
9336
9337	var pos_other = BX.pos(opener.Get());
9338	if (this.__check_intersection(pos_self, pos_other))
9339	{
9340		this.DIV.style.display = 'none';
9341		BX.addCustomEvent(opener, 'onMenuOpenerHide', BX.proxy(this.restorePosition, this));
9342
9343		this.bPosCorrected = true;
9344	}
9345};
9346
9347BX.CPageOpener.prototype.restorePosition = function()
9348{
9349	if (BX.proxy_context && BX.proxy_context.Get().style.display == 'none')
9350	{
9351		this.bPosCorrected = false;
9352
9353		if (this.PARAMS.parent.bx_over || this.PARAMS.pin)
9354			this.UnHide();
9355
9356		BX.removeCustomEvent('onMenuOpenerHide', BX.proxy(this.restorePosition, this));
9357	}
9358};
9359
9360BX.CPageOpener.prototype.UnHide = function()
9361{
9362	if (!this.bPosCorrected)
9363		BX.CPageOpener.superclass.UnHide.apply(this, arguments);
9364};
9365
9366BX.CPageOpener.prototype.Remove = function()
9367{
9368	BX.admin.removeComponentBorder(this.PARAMS.parent);
9369	BX.userOptions.save('global', 'settings', 'page_edit_control_enable', 'N');
9370	this.DIV.style.display = 'none';
9371};
9372
9373/******* HINT ***************/
9374BX.CHintSimple = function()
9375{
9376	BX.CHintSimple.superclass.constructor.apply(this, arguments);
9377};
9378BX.extend(BX.CHintSimple, BX.CHint);
9379
9380BX.CHintSimple.prototype.Init = function()
9381{
9382	this.DIV = document.body.appendChild(BX.create('DIV', {props: {className: 'bx-tooltip-simple'}, style: {display: 'none'}, children: [(this.CONTENT = BX.create('DIV'))]}));
9383
9384	if (this.HINT_TITLE)
9385		this.CONTENT.appendChild(BX.create('B', {text: this.HINT_TITLE}));
9386
9387	if (this.HINT)
9388		this.CONTENT_TEXT = this.CONTENT.appendChild(BX.create('DIV')).appendChild(BX.create('SPAN', {html: this.HINT}));
9389
9390	if (this.PARAMS.preventHide)
9391	{
9392		BX.bind(this.DIV, 'mouseout', BX.proxy(this.Hide, this));
9393		BX.bind(this.DIV, 'mouseover', BX.proxy(this.Show, this));
9394	}
9395
9396	this.bInited = true;
9397};
9398
9399/*************************** admin informer **********************************/
9400BX.adminInformer = {
9401
9402	itemsShow: 3,
9403
9404	Init: function (itemsShow)
9405	{
9406		if(itemsShow)
9407			BX.adminInformer.itemsShow = itemsShow;
9408
9409		var informer = BX("admin-informer");
9410
9411		if(informer)
9412			document.body.appendChild(informer);
9413
9414		BX.addCustomEvent("onTopPanelCollapse", BX.proxy(BX.adminInformer.Close, BX.adminInformer));
9415	},
9416
9417	Toggle: function(notifyBlock)
9418	{
9419		var informer = BX("admin-informer");
9420
9421		if(!informer)
9422			return false;
9423
9424		var pos = BX.pos(notifyBlock);
9425
9426		informer.style.top = (parseInt(pos.top)+parseInt(pos.height)+7)+'px';
9427		informer.style.left = pos.left+'px';
9428
9429		if(!BX.hasClass(informer, "adm-informer-active"))
9430			BX.adminInformer.Show(informer);
9431		else
9432			BX.adminInformer.Hide(informer);
9433
9434		return false;
9435	},
9436
9437	Close: function()
9438	{
9439		BX.adminInformer.Hide(BX("admin-informer"));
9440	},
9441
9442	OnInnerClick: function(event)
9443	{
9444		var target = event.target || event.srcElement;
9445
9446		if(target.nodeName.toLowerCase() != 'a' || BX.hasClass(target,"adm-informer-footer"))
9447		{
9448			return BX.PreventDefault(event);
9449		}
9450
9451		return true;
9452	},
9453
9454	ToggleExtra : function()
9455	{
9456		var footerLink = BX("adm-informer-footer");
9457
9458		if (BX.hasClass(footerLink, "adm-informer-footer-collapsed"))
9459			this.ShowAll();
9460		else
9461			this.HideExtra();
9462
9463		return false;
9464	},
9465
9466	ShowAll: function()
9467	{
9468		var informer = BX("admin-informer");
9469		for(var i=0; i<informer.children.length; i++)
9470
9471			if(BX.hasClass(informer.children[i], "adm-informer-item") && informer.children[i].style.display == "none") {
9472				informer.children[i].style.display = "block";
9473			}
9474
9475		var footerLink = BX("adm-informer-footer");
9476
9477		if(footerLink.textContent !== undefined)
9478			footerLink.textContent = BX.message('JSADM_AI_HIDE_EXTRA');
9479		else
9480			footerLink.innerText = BX.message('JSADM_AI_HIDE_EXTRA');
9481
9482		BX.removeClass(footerLink, "adm-informer-footer-collapsed");
9483
9484		return false;
9485	},
9486
9487	HideExtra: function()
9488	{
9489		var informer = BX("admin-informer");
9490		var hided = 0;
9491
9492		for(var i=BX.adminInformer.itemsShow+1; i<informer.children.length; i++)
9493		{
9494			if (BX.hasClass(informer.children[i], "adm-informer-item") && informer.children[i].style.display == "block") {
9495				informer.children[i].style.display = "none";
9496				hided++;
9497			}
9498		}
9499
9500		var footerLink = BX("adm-informer-footer");
9501
9502		var linkText = BX.message('JSADM_AI_ALL_NOTIF')+" ("+(BX.adminInformer.itemsShow+parseInt(hided))+")";
9503
9504		if(footerLink.textContent !== undefined)
9505			footerLink.textContent = linkText;
9506		else
9507			footerLink.innerText = linkText;
9508
9509		BX.addClass(footerLink, "adm-informer-footer-collapsed");
9510
9511		return false;
9512	},
9513
9514	Show: function(informer)
9515	{
9516		var notifButton = BX("adm-header-notif-block");
9517		if (notifButton)
9518			BX.addClass(notifButton, "adm-header-notif-block-active");
9519
9520		BX.onCustomEvent(informer, 'onBeforeAdminInformerShow');
9521		setTimeout(
9522			BX.proxy(function() {
9523					BX.bind(document, "click", BX.proxy(BX.adminInformer.Close, BX.adminInformer));
9524				},
9525				BX.adminInformer
9526			),0
9527		);
9528		BX.addClass(informer, "adm-informer-active");
9529		setTimeout(function() {BX.addClass(informer, "adm-informer-animate");},0);
9530	},
9531
9532	Hide: function(informer)
9533	{
9534		var notifButton = BX("adm-header-notif-block");
9535		if (notifButton)
9536			BX.removeClass(notifButton, "adm-header-notif-block-active");
9537
9538		BX.unbind(document, "click", BX.proxy(BX.adminInformer.Close, BX.adminInformer));
9539
9540		BX.removeClass(informer, "adm-informer-animate");
9541
9542		if (this.IsAnimationSupported())
9543			setTimeout(function() {BX.removeClass(informer, "adm-informer-active");}, 300);
9544		else
9545			BX.removeClass(informer, "adm-informer-active");
9546
9547		BX.onCustomEvent(informer, 'onAdminInformerHide');
9548		//setTimeout(function() {BX.adminInformer.HideExtra();},500);
9549	},
9550
9551	IsAnimationSupported : function()
9552	{
9553		var d = document.body || document.documentElement;
9554		if (typeof(d.style.transition) == "string")
9555			return true;
9556		else if (typeof(d.style.MozTransition) == "string")
9557			return true;
9558		else if (typeof(d.style.OTransition) == "string")
9559			return true;
9560		else if (typeof(d.style.WebkitTransition) == "string")
9561			return true;
9562		else if (typeof(d.style.msTransition) == "string")
9563			return true;
9564
9565		return false;
9566	},
9567
9568
9569	SetItemHtml: function(itemIdx, html)
9570	{
9571		var itemHtmlDiv = BX("adm-informer-item-html-"+itemIdx);
9572
9573		if(!itemHtmlDiv)
9574			return false;
9575
9576		itemHtmlDiv.innerHTML = html;
9577
9578		return true;
9579	},
9580
9581	SetItemFooter: function(itemIdx, html)
9582	{
9583		var itemFooterDiv = BX("adm-informer-item-footer-"+itemIdx);
9584
9585		if(!itemFooterDiv)
9586			return false;
9587
9588		itemFooterDiv.innerHTML = html;
9589
9590		if(html)
9591			itemFooterDiv.style.display = "block";
9592		else
9593			itemFooterDiv.style.display = "none";
9594
9595		return true;
9596	}
9597
9598};
9599
9600}
9600)(window);
9601
9602/* End */
9603;
9604; /* Start:/bitrix/js/main/core/core_admin.js*/
9605(function(window){
9606if (BX.admin) return;
9607
9608BX.admin = {
9609	/* settings */
9610	__border_style: 'solid 1px #777f8c', // 'dashed 1px orange',
9611	__bg_style: '#777f8c', // 'dashed 1px orange',
9612	__border_dx: 0,
9613	__border_min_height: 12,
9614	__border_menu_timeout: 500,
9615
9616	__borders_last_comp_pos: {},
9617
9618	/* borders cache */
9619	__borders: null,
9620
9621	dynamic_mode: false,
9622	dynamic_mode_show_borders: false,
9623
9624	timer: null,
9625
9626	/* method */
9627	createComponentBorder: function()
9628	{
9629		BX.admin.__borders = {};
9630		BX.admin.__borders.cont = document.body.appendChild(BX.create('DIV', {style: {
9631			display: 'none',
9632			height: '0px',
9633			width: '0px'
9634		}}));
9635
9636		BX.admin.__borders.top = BX.admin.__borders.cont.appendChild(BX.create('DIV', {style: {
9637			position: 'absolute',
9638			height: '1px',
9639			fontSize: '1px',
9640			overflow: 'hidden',
9641			zIndex: 990,
9642			//borderTop: BX.admin.__border_style
9643			background: BX.admin.__bg_style
9644		}}));
9645		BX.admin.__borders.right = BX.admin.__borders.cont.appendChild(BX.create('DIV', {style: {
9646			position: 'absolute',
9647			width: '1px',
9648			fontSize: '1px',
9649			overflow: 'hidden',
9650			zIndex: 990,
9651			//borderRight: BX.admin.__border_style
9652			background: BX.admin.__bg_style
9653		}}));
9654		BX.admin.__borders.bottom = BX.admin.__borders.cont.appendChild(BX.create('DIV', {style: {
9655			position: 'absolute',
9656			height: '1px',
9657			fontSize: '1px',
9658			overflow: 'hidden',
9659			zIndex: 990,
9660			//borderTop: BX.admin.__border_style
9661			background: BX.admin.__bg_style
9662		}}));
9663		BX.admin.__borders.left = BX.admin.__borders.cont.appendChild(BX.create('DIV', {style: {
9664			position: 'absolute',
9665			width: '1px',
9666			fontSize: '1px',
9667			overflow: 'hidden',
9668			zIndex: 990,
9669			//borderLeft: BX.admin.__border_style
9670			background: BX.admin.__bg_style
9671		}}));
9672	},
9673
9674	__borders_adjust: function()
9675	{
9676		var pos = BX.pos(this),
9677			dx = BX.admin.__border_dx;
9678
9679		var db = BX.browser.IsIE() && !BX.browser.IsDoctype() ? 2 : 0
9680
9681		BX.adjust(BX.admin.__borders.top, {style: {
9682			'top': (pos.top - dx - db) + 'px',
9683			'left': (pos.left - dx - db) + 'px',
9684			'width': (pos.width + dx*2) + 'px'
9685		}});
9686		BX.adjust(BX.admin.__borders.right, {style: {
9687			'top': (pos.top - dx - db) + 'px',
9688			'left': (pos.right + dx - 1 - db) + 'px',
9689			'height': (pos.height + dx*2) + 'px'
9690		}});
9691		BX.adjust(BX.admin.__borders.bottom, {style: {
9692			'top': (pos.bottom + dx - db) + 'px',
9693			'left': (pos.left - dx - db) + 'px',
9694			'width': (pos.width + dx*2) + 'px'
9695		}});
9696		BX.adjust(BX.admin.__borders.left, {style: {
9697			'top': (pos.top - dx - db) + 'px',
9698			'left': (pos.left - dx - db) + 'px',
9699			'height': (pos.height + dx*2) + 'px'
9700		}});
9701
9702		BX.admin.__borders_last_comp_pos = pos;
9703	},
9704
9705	setComponentBorder: function(comp)
9706	{
9707		if (!BX.isReady)
9708			return BX.ready(function() {BX.admin.setComponentBorder(comp)});
9709
9710		if (null == BX.admin.__borders)
9711			BX.admin.createComponentBorder();
9712
9713		comp = BX(comp);
9714		if (!comp) return;
9715
9716		if (comp.children.length > 0)
9717		{
9718			var c = comp.firstChild, new_comp = null, cnt = 0;
9719			while (c)
9720			{
9721				if (BX.type.isElementNode(c) && c.tagName.toUpperCase() != 'SCRIPT')
9722				{
9723					cnt++;
9724					if (cnt > 1 || !BX.is_relative(c) && !BX.is_float(c))
9725					{
9726						cnt = -1;
9727						break;
9728					}
9729					new_comp = c;
9730				}
9731				c = c.nextSibling;
9732			}
9733
9734			if (cnt == 1 && new_comp)
9735			{
9736				if (comp.OPENER)
9737				{
9738					comp.OPENER.setParent(new_comp);
9739				}
9740
9741				comp = new_comp;
9742			}
9743		}
9744
9745		if (BX.admin.dynamic_mode)
9746		{
9747			BX.addCustomEvent(window, 'onDynamicModeChange', BX.delegate(BX.admin.__empty_comp_onmodechange, comp));
9748		}
9749
9750		BX.admin.__empty_comp_onmodechange.apply(comp, [!BX.admin.dynamic_mode || BX.admin.dynamic_mode_show_borders]);
9751
9752		BX.bind(comp, 'mouseover', BX.admin.__borders_show);
9753		BX.bind(comp, 'mouseout', BX.admin.__borders_hide);
9754
9755		if (comp.OPENER && comp.OPENER.defaultAction)
9756		{
9757			comp.title = BX.message('ADMIN_INCLAREA_DBLCLICK') + ' - ' + comp.OPENER.defaultActionTitle;
9758			BX.bind(comp, 'dblclick', BX.admin.__borders_dblclick);
9759		}
9760	},
9761
9762	removeComponentBorder: function(comp)
9763	{
9764		comp = BX(comp);
9765		if (!comp) return;
9766
9767		BX.unbind(comp, 'mouseover', BX.admin.__borders_show);
9768		BX.unbind(comp, 'mouseout', BX.admin.__borders_hide);
9769
9770		if (comp.bx_msover)
9771		{
9772			BX.admin.__borders_hide.apply(comp);
9773		}
9774	},
9775
9776	__empty_comp_onmodechange: function(val)
9777	{
9778		if (this.offsetHeight <= BX.admin.__border_min_height)
9779		{
9780			if (val)
9781			{
9782				if (BX.browser.IsIE() && !BX.browser.IsDoctype())
9783					this.style.height = BX.admin.__border_min_height + 'px';
9784				else
9785					this.style.minHeight = BX.admin.__border_min_height + 'px';
9786
9787				BX.addClass(this, 'bx-context-toolbar-empty-area');
9788			}
9789			else
9790			{
9791				if (BX.browser.IsIE() && !BX.browser.IsDoctype())
9792					this.style.height = null;
9793				else
9794					this.style.minHeight = null;
9795
9796				BX.removeClass(this, 'bx-context-toolbar-empty-area');
9797			}
9798		}
9799	},
9800
9801	__borders_dblclick: function(e)
9802	{
9803		if (
9804			(!BX.admin.dynamic_mode || BX.admin.dynamic_mode_show_borders)
9805			&& this.OPENER && this.OPENER.defaultAction
9806		)
9807		{
9808			this.OPENER.executeDefaultAction();
9809			return BX.PreventDefault(e);
9810		}
9811		return true;
9812	},
9813
9814	__borders_show: function(e)
9815	{
9816		e = e || window.event;
9817
9818		var q = BX.is_relative(this) ? this.parentNode : this;
9819		if (BX.admin.dynamic_mode && !BX.admin.dynamic_mode_show_borders)
9820		{
9821			if (q.title) {q._title = q.title; q.title = '';}
9822
9823			return;
9824		}
9825
9826		if (q._title) {q.title = q._title;}
9827
9828		if (!BX.admin.__borders_adjusted)
9829		{
9830			BX.admin.__borders.cont.style.display = 'block';
9831			BX.admin.__borders_adjust.apply(this);
9832			BX.admin.__borders_adjusted = true;
9833		}
9834
9835		this.bx_msover = true;
9836
9837		if (this.OPENER)
9838		{
9839			if (this.bxtimer) clearTimeout(this.bxtimer);
9840			this.bxtimer = setTimeout(BX.proxy(BX.admin.__borders_menu_show, this), this.OPENER.timeout || BX.admin.__border_menu_timeout);
9841			this.OPENER.setHoverHoutEvents(
9842				BX.proxy(BX.admin.__borders_show, this),
9843				BX.proxy(BX.admin.__borders_hide, this)
9844			);
9845		}
9846
9847		//return BX.PreventDefault(e);
9848	},
9849
9850	__borders_menu_show: function()
9851	{
9852		if (this.bx_msover && this.OPENER)
9853		{
9854			this.OPENER.UnHide();
9855		}
9856	},
9857
9858	__borders_hide: function()
9859	{
9860		if (BX.admin.dynamic_mode && !BX.admin.dynamic_mode_show_borders)
9861			return;
9862
9863		if (this.OPENER && this.OPENER.isMenuVisible())
9864		{
9865			setTimeout(BX.admin.__borders_hide, 3*BX.admin.__border_menu_timeout);
9866			return;
9867		}
9868
9869		BX.admin.__borders.cont.style.display = 'none';
9870		BX.admin.__borders_adjusted = false;
9871
9872		this.bx_msover = false;
9873
9874		if (this.OPENER)
9875		{
9876			var to = BX.admin.__get_hide_timeout(this.OPENER);
9877			if (this.bxtimer) clearTimeout(this.bxtimer);
9878			this.bxtimer = setTimeout(BX.proxy(BX.admin.__borders_menu_hide, this), to);
9879		}
9880	},
9881
9882	__borders_menu_hide: function(e)
9883	{
9884		if (!this.bx_msover && this.OPENER)
9885		{
9886			this.OPENER.Hide();
9887		}
9888	},
9889
9890	__get_hide_timeout: function(opener)
9891	{
9892		var to = BX.admin.__border_menu_timeout;
9893		return to;
9894		if (BX.admin.__borders_last_comp_pos.top)
9895		{
9896			var pos = {top: parseInt(opener.Get().style.top), left: parseInt(opener.Get().style.left)}
9897			var bpos = BX.admin.__borders_last_comp_pos;
9898
9899			if (pos.top <= bpos.bottom && pos.top >= bpos.top && pos.left <= bpos.right && pos.left >= bpos.left)
9900			{
9901				return to;
9902			}
9903
9904			var dist = {
9905				top: Math.min(Math.abs(BX.admin.__borders_last_comp_pos.top - pos.top), Math.abs(BX.admin.__borders_last_comp_pos.bottom - pos.top)),
9906				left: Math.min(Math.abs(BX.admin.__borders_last_comp_pos.top - pos.left), Math.abs(BX.admin.__borders_last_comp_pos.bottom - pos.left))
9907			}
9908
9909			dist = Math.sqrt(dist.top*dist.top + dist.left*dist.left);
9910
9911			to += 2*dist;
9912			return to;
9913		}
9914
9915	}
9916};
9917
9918BX.admin.panel = {
9919	state: {
9920		fixed: false,
9921		collapsed: false
9922	},
9923
9924	DIV: null,
9925	BACKDIV: null,
9926	BACKFRAME: null,
9927	NOTIFY: null,
9928
9929	buttons: [],
9930
9931	Init: function()
9932	{
9933		var q;
9934
9935		BX.admin.panel.DIV = BX('bx-panel');
9936
9937		if (BX.admin.panel.DIV)
9938		{
9939			BX.setUnselectable(BX.admin.panel.DIV);
9940
9941			q = BX('bx-panel-toggle');
9942			if (q)
9943			{
9944				q.onclick = function(event)
9945				{
9946					BX.admin.toggle.toggleStatus();
9947					event = event || window.event;
9948					BX.PreventDefault(event);
9949				}
9950			}
9951
9952			q = BX('bx-panel-toggle-icon');
9953			if (q)
9954			{
9955				BX.bind(q, "mousedown", BX.proxy(BX.admin.toggle.start, BX.admin.toggle));
9956				BX.bind(q, "click", BX.PreventDefault);
9957			}
9958
9959			q = BX('bx-panel-hider');
9960			if (q)
9961			{
9962				BX.admin.panel.DIV.ondblclick = BX('bx-panel-expander').onclick = q.onclick = BX.admin.panel.Collapse;
9963
9964				BX('bx-panel-tabs').ondblclick = BX.PreventDefault;
9965				var sw = BX('bx-panel-switcher');
9966				if (sw) sw.ondblclick = BX.PreventDefault;
9967			}
9968
9969			q = BX('bx-panel-pin');
9970			if (q)
9971			{
9972				BX.bind(q, 'click', function() {
9973					var bFixed = BX.hasClass(this, 'bx-panel-pin-fixed');
9974					if (bFixed)
9975						BX.removeClass(this, 'bx-panel-pin-fixed');
9976					else
9977						BX.addClass(this, 'bx-panel-pin-fixed');
9978
9979					BX.userOptions.save('admin_panel', 'settings', 'fix', (bFixed? 'off':'on'));
9980				});
9981
9982				BX.bind(q, 'click', BX.admin.panel.Fix);
9983
9984				if (BX.admin.panel.state.fixed) BX.admin.panel.Fix();
9985			}
9986
9987			for (var i=0,len=BX.admin.panel.buttons.length; i<len; i++)
9988			{
9989				var btn = BX(BX.admin.panel.buttons[i]['ID']);
9990
9991				if (btn)
9992				{
9993					if (BX.admin.panel.buttons[i].HOVER_CSS)
9994					{
9995						btn.bx_hover_class = BX.admin.panel.buttons[i].HOVER_CSS;
9996						if (BX.admin.panel.buttons[i].ACTIVE_CSS)
9997							btn.bx_active_class = BX.admin.panel.buttons[i].ACTIVE_CSS;
9998
9999						BX.bind(btn, 'mouseover', BX.admin.panel.__btn_hover);
10000						BX.bind(btn, 'mouseout', BX.admin.panel.__btn_hout);
10001						BX.bind(btn, 'mousedown', BX.admin.panel.__btn_down);
10002					}
10003
10004					if (BX.admin.panel.buttons[i].MENU)
10005					{
10006						var opener = new BX.COpener({
10007							DIV: btn,
10008							ATTACH:btn.parentNode.parentNode,
10009							MENU: BX.admin.panel.buttons[i].MENU,
10010							TYPE: 'click'
10011						});
10012
10013						BX.addCustomEvent(opener, 'onOpenerMenuOpen', BX.delegate(BX.admin.panel.__btn_menuopen, btn));
10014						BX.addCustomEvent(opener, 'onOpenerMenuClose', BX.delegate(BX.admin.panel.__btn_menuclose, btn));
10015					}
10016
10017					if (BX.admin.panel.buttons[i].HINT)
10018					{
10019						var target = BX.admin.panel.buttons[i].HINT.TARGET ? btn.parentNode.parentNode : btn;
10020						if (BX.admin.panel.buttons[i].HINT.ID)
10021						{
10022							BX.hint(target, BX.admin.panel.buttons[i].HINT.TITLE, BX.admin.panel.buttons[i].HINT.TEXT, BX.admin.panel.buttons[i].HINT.ID)
10023						}
10024						else
10025						{
10026							target.BXHINT = new BX.CHint({
10027								parent: target, hint: BX.admin.panel.buttons[i].HINT.TEXT, title: BX.admin.panel.buttons[i].HINT.TITLE, id: BX.admin.panel.buttons[i].HINT.ID
10028							});
10029						}
10030					}
10031
10032					btn.ondblclick = BX.PreventDefault;
10033
10034					if (BX.browser.IsIE())
10035						btn.setAttribute('hideFocus', 'hidefocus');
10036				}
10037			}
10038		}
10039
10040		BX.admin.panel.buttons = []; q = null;
10041	},
10042
10043	__view_mode_toggle: function(e)
10044	{
10045		var this1 = BX('bx-panel-toggle');
10046
10047		var captiontext = BX('bx-panel-toggle-caption-mode');
10048		if (this1.className=='bx-panel-toggle-on')
10049		{
10050			this1.className='bx-panel-toggle-off';
10051			captiontext.innerHTML=BX.message('ADMIN_SHOW_MODE_OFF');
10052			BX.admin.dynamic_mode_show_borders = false;
10053			this1.href = this1.href.replace('bitrix_include_areas=N', 'bitrix_include_areas=Y');
10054		}
10055		else
10056		{
10057			this1.className = 'bx-panel-toggle-on';
10058			captiontext.innerHTML=BX.message('ADMIN_SHOW_MODE_ON');
10059			BX.admin.dynamic_mode_show_borders = true;
10060			this1.href = this1.href.replace('bitrix_include_areas=Y', 'bitrix_include_areas=N');
10061		}
10062
10063		if (null != this.BXHINT)
10064			this.BXHINT.Destroy();
10065
10066		this.BXHINT = new BX.CHint({
10067			parent: this,
10068			title: BX.message('AMDIN_SHOW_MODE_TITLE'),
10069			hint: BX.admin.dynamic_mode_show_borders
10070					? BX.message('ADMIN_SHOW_MODE_ON_HINT')
10071					: BX.message('ADMIN_SHOW_MODE_OFF_HINT'),
10072			showOnce: true,
10073			preventHide: true,
10074			show_timeout: 0,
10075			hide_timeout: 2000
10076		});
10077
10078		BX.userOptions.save('admin_panel', 'settings', 'edit', (BX.admin.dynamic_mode_show_borders ? 'on' : 'off'));
10079
10080		BX.onCustomEvent(window, 'onDynamicModeChange', [BX.admin.dynamic_mode_show_borders]);
10081
10082		return BX.eventReturnFalse(e);
10083	},
10084
10085	__btn_hover: function() {
10086		this.bx_hover = true;
10087		if (!BX.admin.panel._menu_open) BX.addClass(this.parentNode.parentNode, this.bx_hover_class);
10088	},
10089	__btn_hout: function()
10090	{
10091		this.bx_hover = false;
10092		if (!BX.admin.panel._menu_open) BX.removeClass(this.parentNode.parentNode, this.bx_hover_class);
10093		BX.admin.panel.__btn_inactive.apply(this);
10094	},
10095
10096	__btn_down: function()
10097	{
10098		//BX.bind(document, "mouseup", BX.proxy(BX.admin.panel.__btn_up, this));
10099		BX.admin.panel.__btn_active.apply(this);
10100	},
10101
10102	__btn_up : function()
10103	{
10104		BX.unbind(document, "mouseup", BX.proxy(BX.admin.panel.__btn_up, this));
10105		BX.admin.panel.__btn_inactive.apply(this);
10106	},
10107
10108	__btn_active: function()
10109	{
10110		this.bx_active = true;
10111		if (!BX.admin.panel._menu_open)
10112			BX.addClass(this.parentNode.parentNode, this.bx_active_class);
10113	},
10114
10115	__btn_inactive: function()
10116	{
10117		this.bx_active = false;
10118		if (!BX.admin.panel._menu_open)
10119			BX.removeClass(this.parentNode.parentNode, this.bx_active_class);
10120	},
10121
10122	__btn_menuopen: function()
10123	{
10124		if (this.bx_hover)
10125			BX.admin.panel.__btn_hover.apply(this);
10126
10127		if (this.bx_active)
10128			BX.admin.panel.__btn_active.apply(this);
10129
10130		BX.admin.panel._menu_open = true;
10131	},
10132
10133	__btn_menuclose: function()
10134	{
10135		BX.admin.panel._menu_open = false;
10136		if (!this.bx_hover)
10137			BX.admin.panel.__btn_hout.apply(this);
10138
10139		//if (!this.bx_active)
10140		BX.admin.panel.__btn_inactive.apply(this);
10141	},
10142
10143	RegisterButton: function(btn)
10144	{
10145		BX.admin.panel.buttons[BX.admin.panel.buttons.length] = btn;
10146	},
10147
10148	Collapse: function(e)
10149	{
10150		e = e || window.event;
10151
10152		BX.admin.panel.state.collapsed = !(BX.admin.panel.DIV.className.indexOf('bx-panel-folded')>-1);
10153		var y_start = BX.admin.panel.DIV.offsetHeight;
10154
10155		var hider = BX("bx-panel-hider", true);
10156		var expander = BX("bx-panel-expander", true);
10157		var toggle = BX("bx-panel-toggle");
10158
10159		if (BX.admin.panel.state.collapsed)
10160		{
10161			BX.admin.toggle.unset();
10162			BX("bx-panel-userinfo").insertBefore(toggle.parentNode.removeChild(toggle), expander);
10163			BX.addClass(BX.admin.panel.DIV, "bx-panel-folded");
10164		}
10165		else
10166		{
10167			BX.admin.toggle.unset();
10168			BX("bx-panel-switcher").insertBefore(toggle.parentNode.removeChild(toggle), hider);
10169			BX.removeClass(BX.admin.panel.DIV, "bx-panel-folded");
10170		}
10171
10172		var dy = BX.admin.panel.DIV.offsetHeight - y_start;
10173
10174		BX.userOptions.save('admin_panel', 'settings', 'collapsed', (BX.admin.panel.state.collapsed ? 'on':'off'));
10175
10176		BX.admin.panel.__adjustBackDiv();
10177
10178		BX.onCustomEvent('onTopPanelCollapse', [BX.admin.panel.state.collapsed, dy]);
10179
10180		return BX.PreventDefault(e);
10181	},
10182
10183	isFixed: function()
10184	{
10185		return BX.admin.panel.DIV.className.indexOf('bx-panel-fixed') > -1;
10186	},
10187
10188	Fix: function()
10189	{
10190		if (null == BX.admin.panel.BACKDIV)
10191			BX.admin.panel.BACKDIV = BX('bx-panel-back');
10192		var bFixed = BX.admin.panel.isFixed();
10193
10194		var bIE = BX.browser.IsIE();
10195		if(bIE)
10196		{
10197			try {BX.admin.panel.DIV.style.removeExpression("top");} catch(e) {bIE = false;}
10198		}
10199
10200		if(bFixed)
10201		{
10202			BX.removeClass(BX.admin.panel.DIV, bIE ? 'bx-panel-fixed-ie' : 'bx-panel-fixed');
10203			BX.admin.panel.BACKDIV.style.display = 'none';
10204			if(bIE)
10205			{
10206				BX.admin.panel.DIV.style.cssText = "position: static !important;";
10207
10208				if(BX.admin.panel.BACKFRAME)
10209					BX.admin.panel.BACKFRAME.style.visibility = 'hidden';
10210			}
10211		}
10212		else
10213		{
10214			if(bIE)
10215			{
10216				try{BX.admin.panel.DIV.style.setExpression("top", "0");} catch(e) {bIE = false;}
10217			}
10218
10219			if (bIE)
10220				BX.admin.panel.DIV.style.cssText = "";
10221
10222			BX.addClass(BX.admin.panel.DIV, bIE ? 'bx-panel-fixed-ie' : 'bx-panel-fixed');
10223
10224			if(bIE)
10225			{
10226				if(document.body.currentStyle.backgroundImage == 'none')
10227				{
10228					document.body.style.backgroundImage = "url(/bitrix/images/1.gif)";
10229					document.body.style.backgroundAttachment = "fixed";
10230					document.body.style.backgroundRepeat = "no-repeat";
10231				}
10232				BX.admin.panel.DIV.style.setExpression("top", "eval((document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop)");
10233				BX.admin.panel.DIV.style.setExpression("left", "eval((document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft)");
10234				BX.admin.panel.DIV.style.setExpression("width", "eval((document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth)");
10235			}
10236
10237			BX.admin.panel.__adjustBackDiv();
10238			BX.admin.panel.BACKDIV.style.display = 'block';
10239
10240			if(bIE)
10241			{
10242				if(BX.admin.panel.BACKFRAME)
10243					BX.admin.panel.BACKFRAME.style.visibility = 'visible';
10244				else
10245					BX.admin.panel.CreateFrame();
10246			}
10247		}
10248
10249		BX.onCustomEvent('onTopPanelFix', [!bFixed]);
10250	},
10251
10252	__adjustBackDiv: function()
10253	{
10254		if (BX.admin.panel.BACKDIV)
10255		{
10256			var h = BX.admin.panel.DIV.offsetHeight+'px';
10257			BX.admin.panel.BACKDIV.style.height = h;
10258
10259			var frame = BX("bx-panel-frame");
10260			if (BX.admin.panel.BACKFRAME)
10261				BX.admin.panel.BACKFRAME.style.height = h;
10262		}
10263	},
10264
10265	CreateFrame: function()
10266	{
10267		BX.admin.panel.BACKFRAME = document.body.appendChild(BX.create('IFRAME', {
10268			props: {
10269				id: "bx-panel-frame"
10270			},
10271			style: {
10272				position: 'absolute',
10273				overflow: 'hidden',
10274				zIndex: parseInt(BX.admin.panel.DIV.currentStyle.zIndex)-1,
10275				height: BX.admin.panel.DIV.offsetHeight + "px"
10276			}
10277		}));
10278
10279		BX.admin.panel.BACKFRAME.style.setExpression("top", "eval(document.body.scrollTop)");
10280		BX.admin.panel.BACKFRAME.style.setExpression("left", "eval(document.body.scrollLeft)");
10281		BX.admin.panel.BACKFRAME.style.setExpression("width", "eval(document.body.clientWidth)");
10282	},
10283
10284	Notify: function(str)
10285	{
10286		if (!BX.isReady)
10287		{
10288			var _args = arguments;
10289			BX.ready(function() {BX.admin.panel.Notify.apply(this, _args);});
10290			return;
10291		}
10292
10293		if (!BX.admin.panel.DIV) return;
10294
10295		if (null == BX.admin.panel.NOTIFY)
10296		{
10297			BX.admin.panel.NOTIFY = BX.admin.panel.DIV.appendChild(BX.create('DIV', {
10298				props: {className: 'adm-warning-block'},
10299				html:
10300					'<span class="adm-warning-text">'+(str||'&nbsp;')+'</span><span onclick="BX.admin.panel.hideNotify(this.parentNode)" class="adm-warning-close"></span>'
10301			}));
10302
10303		}
10304
10305		BX.removeClass(BX.admin.panel.NOTIFY, 'adm-warning-animate');
10306
10307		BX.admin.panel.__adjustBackDiv();
10308	},
10309
10310
10311	hideNotify: function(element)
10312	{
10313		var element = BX.type.isDomNode(element)? element: this;
10314
10315		if (!!element && !!element.parentNode && !!element.parentNode.parentNode)
10316		{
10317			BX.addClass(element, 'adm-warning-animate');
10318		}
10319
10320		if (BX.type.isDomNode(element) && element.getAttribute('data-ajax') == "Y")
10321		{
10322			var notifyId = parseInt(element.getAttribute('data-id'));
10323			if (notifyId > 0)
10324			{
10325				BX.ajax({
10326					url: '/bitrix/admin/admin_notify.php',
10327					method: 'POST',
10328					dataType: 'json',
10329					data: {'ID' : notifyId, 'sessid': BX.bitrix_sessid()}
10330				});
10331			}
10332		}
10333
10334		(BX.defer(BX.admin.panel.__adjustBackDiv, this))();
10335		setTimeout(BX.proxy(BX.admin.panel.__adjustBackDiv, this), 310);
10336	}
10337
10338	/*,
10339	setZIndex: function()
10340	{
10341		var zIndex = BX.WindowManager.GetZIndex()-6;
10342		BX.admin.panel.DIV.setAttribute('style', 'z-index: ' + zIndex + ' !important;');
10343	}
10344	*/
10345};
10346
10347BX.admin.toggle = {
10348
10349	icon : null,
10350	indicator : null,
10351	toggle : null,
10352	caption : null,
10353
10354	pageX : 0,
10355	initIconPos : 0,
10356	initIndicatorPos : 0,
10357
10358	minLeft : -3,
10359	maxLeft : 17,
10360
10361	unset : function()
10362	{
10363		this.icon = this.indicator = this.toggle = this.caption = null;
10364	},
10365
10366	start : function(event)
10367	{
10368		event = event || window.event;
10369
10370		if (!this._init() || !event)
10371			return;
10372
10373		BX.fixEventPageX(event);
10374		this.pageX = event.pageX;
10375		this.initIconPos = parseInt(BX.style(this.icon, "left"));
10376		this.initIndicatorPos = BX.hasClass(this.toggle, "bx-panel-toggle-on") ? -270 : -290;
10377
10378		BX.removeClass(this.toggle, "bx-panel-toggle-animate");
10379
10380		BX.bind(document, "mousemove", BX.proxy(this._onMouseMove, this));
10381		BX.bind(document, "mouseup", BX.proxy(this._onMouseUp, this));
10382
10383		document.body.onselectstart = BX.False;
10384		document.body.ondragstart = BX.False;
10385		document.body.style.MozUserSelect = "none";
10386	},
10387
10388	_init : function()
10389	{
10390		if (this.toggle)
10391			return true;
10392
10393		this.toggle = BX("bx-panel-toggle");
10394		this.icon = BX("bx-panel-toggle-icon");
10395		this.indicator = BX("bx-panel-toggle-indicator");
10396		this.caption = BX("bx-panel-toggle-caption-mode");
10397
10398		return (this.toggle && this.icon && this.indicator && this.caption);
10399	},
10400
10401	_onMouseMove : function(event)
10402	{
10403		event = event || window.event;
10404		BX.fixEventPageX(event);
10405		this._moveToggle(event.pageX - this.pageX);
10406	},
10407
10408	_onMouseUp : function()
10409	{
10410		var pos = parseInt(BX.style(this.icon, "left"));
10411		if (this.initIconPos == pos)
10412		{
10413			this.toggleStatus();
10414		}
10415		else
10416		{
10417			var half = this.minLeft + Math.floor((this.maxLeft - this.minLeft) / 2);
10418			if (pos >= half)
10419			{
10420				BX.addClass(this.toggle, "bx-panel-toggle-on bx-panel-toggle-animate");
10421				BX.removeClass(this.toggle, "bx-panel-toggle-off");
10422				this._changePosition(true);
10423			}
10424			else
10425			{
10426				BX.addClass(this.toggle, "bx-panel-toggle-off bx-panel-toggle-animate");
10427				BX.removeClass(this.toggle, "bx-panel-toggle-on");
10428				this._changePosition(false);
10429			}
10430		}
10431
10432		this.icon.style.cssText = "";
10433		this.indicator.style.cssText = "";
10434
10435		BX.unbind(document, "mousemove", BX.proxy(this._onMouseMove, this));
10436		BX.unbind(document, "mouseup", BX.proxy(this._onMouseUp, this));
10437
10438		document.body.onselectstart = null;
10439		document.body.ondragstart = null;
10440		document.body.style.MozUserSelect = "";
10441	},
10442
10443	_changePosition : function(on)
10444	{
10445		var firstNode = this.caption.childNodes[0];
10446
10447		if ( (on && firstNode.id == "bx-panel-toggle-caption-mode-on") || (!on && firstNode.id == "bx-panel-toggle-caption-mode-off"))
10448			return;
10449		this.caption.appendChild(this.caption.removeChild(firstNode));
10450
10451		if (BX.admin.dynamic_mode)
10452		{
10453			if (on)
10454			{
10455				BX.admin.dynamic_mode_show_borders = true;
10456				this.toggle.href = this.toggle.href.replace('bitrix_include_areas=Y', 'bitrix_include_areas=N');
10457			}
10458			else
10459			{
10460				BX.admin.dynamic_mode_show_borders = false;
10461				this.toggle.href = this.toggle.href.replace('bitrix_include_areas=N', 'bitrix_include_areas=Y');
10462			}
10463
10464			if (null != BX.admin.panel.BXHINT)
10465				BX.admin.panel.BXHINT.Destroy();
10466
10467			BX.admin.panel.BXHINT = new BX.CHint({
10468				parent: this.toggle,
10469				title: BX.message('AMDIN_SHOW_MODE_TITLE'),
10470				hint: BX.admin.dynamic_mode_show_borders
10471					? BX.message('ADMIN_SHOW_MODE_ON_HINT')
10472					: BX.message('ADMIN_SHOW_MODE_OFF_HINT'),
10473				showOnce: true,
10474				preventHide: true,
10475				show_timeout: 0,
10476				hide_timeout: 2000
10477			});
10478
10479			BX.userOptions.save('admin_panel', 'settings', 'edit', (BX.admin.dynamic_mode_show_borders ? 'on' : 'off'));
10480			BX.onCustomEvent(window, 'onDynamicModeChange', [BX.admin.dynamic_mode_show_borders]);
10481		}
10482		else
10483		{
10484			BX.reload(this.toggle.href);
10485		}
10486	},
10487
10488	_moveToggle : function(offset)
10489	{
10490		var newPos = this.initIconPos + offset;
10491		newPos = Math.min(this.maxLeft, Math.max(newPos, this.minLeft));
10492		this.icon.style.cssText = "left:" + newPos + "px !important";
10493		this.indicator.style.cssText = "background-position: " + ( this.initIndicatorPos + newPos - this.initIconPos) + "px -1751px !important";
10494
10495	},
10496
10497	toggleStatus : function()
10498	{
10499		if (!this._init())
10500			return;
10501
10502		if (BX.hasClass(this.toggle, "bx-panel-toggle-off"))
10503		{
10504			BX.addClass(this.toggle, "bx-panel-toggle-on bx-panel-toggle-animate");
10505			BX.removeClass(this.toggle, "bx-panel-toggle-off");
10506			this._changePosition(true);
10507		}
10508		else
10509		{
10510			BX.addClass(this.toggle, "bx-panel-toggle-off bx-panel-toggle-animate");
10511			BX.removeClass(this.toggle, "bx-panel-toggle-on");
10512			this._changePosition(false);
10513		}
10514	}
10515};
10516
10517BX.admin.startMenuRecent = function(itemInfo)
10518{
10519	BX.ajax.get('/bitrix/admin/get_start_menu.php', {
10520		mode: 'save_recent',
10521		url: itemInfo['LINK'],
10522		text: itemInfo['TEXT'],
10523		title: itemInfo['TITLE'],
10524		icon: itemInfo['GLOBAL_ICON'],
10525		sessid:BX.bitrix_sessid()
10526	});
10527}
10528
10529BX.admin.startMenuFavAdd = function(back_url)
10530{
10531	window.location.href = '/bitrix/admin/favorite_edit.php?lang='+BX.message('LANGUAGE_ID')+'&name='+BX.util.urlencode(document.title)+'&addurl='+BX.util.urlencode(window.location.href)+'&encoded=Y' + (!!back_url ? '&back_url_pub=' + BX.util.urlencode(back_url) : '');
10532}
10533
10534/************************** init admin panel **********************************/
10535BX.ready(function() {
10536	BX.admin.panel.Init();
10537});
10538//BX.addCustomEvent('onWindowRegister', BX.admin.panel.setZIndex);
10539//BX.addCustomEvent('onWindowUnRegister', BX.admin.panel.setZIndex);
10540
10541})(window);
10542
10543/* End */
10544;
10545; /* Start:/bitrix/js/fileman/sticker.js*/
10546function BXSticker(Params, Stickers, MESS)
10547{
10548	this.MESS = MESS;
10549	this.Stickers = Stickers || [];
10550	this.Params = Params;
10551	this.sessid_get = Params.sessid_get;
10552	this.bShowStickers = Params.bShowStickers;
10553	this.curEditorStickerInd = false;
10554	this.oneGifSrc = '/bitrix/images/1.gif';
10555	this.colorSchemes = [
10556		{name: 'bxst-yellow', color: '#FFFCB3', title: this.MESS.Yellow},
10557		{name: 'bxst-green', color: '#DBFCCD', title: this.MESS.Green},
10558		{name: 'bxst-blue', color: '#DCE7F7', title: this.MESS.Blue},
10559		{name: 'bxst-red', color: '#FCDFDF', title: this.MESS.Red},
10560		{name: 'bxst-purple', color: '#F6DAF8', title: this.MESS.Purple},
10561		{name: 'bxst-gray', color: '#F5F5F5', title: this.MESS.Gray}
10562	];
10563
10564	this.curPageCount = this.Params.curPageCount;
10565
10566	// Init hotkeys
10567	if (this.Params.useHotkeys)
10568		BX.bind(document, 'keyup', BX.proxy(this.OnKeyUp, this));
10569
10570	// Object contains result from ajax requests
10571	window.__bxst_result = {};
10572
10573	if (Params.bShowStickers)
10574		this.Init(Params);
10575}
10576
10577BXSticker.prototype = {
10578	Init: function(Params)
10579	{
10580		this.oMarkerConfig = {
10581			attr: {
10582				title : true,
10583				src : true,
10584				href : true,
10585				alt : true,
10586				'class' : true,
10587				className : true,
10588				id : true,
10589				name : true,
10590				type : true,
10591				value : true
10592			},
10593			impAttr: {
10594				src : true,
10595				id : true,
10596				name : true,
10597				href : true
10598			}
10599		};
10600
10601		this.Params.changeColorEffect = true;
10602		this.arStickers = [];
10603		this.posReg = {};
10604		this.bInited = true;
10605		this.access = this.Params.access;
10606
10607		this._arSavedStickers = {};
10608
10609		BX.bind(document, 'mousedown', BX.proxy(this.OnMousedown, this));
10610		var _this = this;
10611		BX.addCustomEvent('onMenuOpen', function(){
10612			var pEl = BX.findChild(BX('bxst-show-sticker-icon'), {className: 'icon'}, true);
10613			if (pEl)
10614			{
10615				if (_this.bShowStickers)
10616					BX.addClass(pEl, "checked");
10617				else
10618					BX.removeClass(pEl, "checked");
10619			}
10620			_this.UpdateStickersCount();
10621		});
10622
10623		this.DisplayStickers(!!Params.bVisEffects);
10624
10625		this.ShowEditor({ind: -1});
10626	},
10627
10628	ShowAll: function(bShow, bAddStickers)
10629	{
10630		if (typeof bShow == 'undefined')
10631			bShow = !this.bShowStickers;
10632
10633		var _this = this;
10634		var pEl = BX.findChild(BX('bxst-show-sticker-icon'), {className: 'icon'}, true);
10635		if (pEl)
10636		{
10637			if (bShow)
10638				BX.addClass(pEl, "checked");
10639			else
10640				BX.removeClass(pEl, "checked");
10641		}
10642
10643		this.bShowStickers = bShow;
10644		window.__bxst_result.show = null;
10645		window.__bxst_result.stickers = null;
10646
10647		this.Request(
10648			bShow ? 'show_stickers' : 'hide_stickers',
10649			{
10650				pageUrl : this.Params.pageUrl,
10651				b_inited : this.bInited ? "Y" : "N"
10652			},
10653			function(res)
10654			{
10655				if (_this.bInited)
10656					return;
10657
10658				_this.bShowStickers = window.__bxst_result.show;
10659				if (window.__bxst_result.stickers)
10660				{
10661					_this.Stickers = window.__bxst_result.stickers;
10662					_this.Params.bVisEffects = true;
10663					if (!_this.bInited)
10664						_this.Init(_this.Params);
10665
10666					if (bAddStickers)
10667						_this.AddSticker();
10668				}
10669			}
10670		);
10671
10672		if (!bShow)
10673		{
10674			this.HideAll();
10675		}
10676		else if(bShow && this.bInited)
10677		{
10678			var oSt;
10679			for (var i = 0, l = this.arStickers.length; i < l; i++)
10680			{
10681				oSt = this.arStickers[i];
10682				oSt.pWin.Get().style.display = "block";
10683				oSt.pShadow.style.display = "block";
10684
10685				//Hide marker if it exist
10686				if (oSt.pMarker)
10687					oSt.pMarker.style.display = "";
10688			}
10689		}
10690	},
10691
10692	HideAll: function()
10693	{
10694		var oSt;
10695		for (var i = 0, l = this.arStickers.length; i < l; i++)
10696		{
10697			oSt = this.arStickers[i];
10698			oSt.pWin.Get().style.display = "none";
10699			oSt.pShadow.style.display = "none";
10700
10701			//Hide marker if it exist
10702			//if (oSt.pMarkerNode)
10703			//	BX.removeClass(oSt.pMarkerNode, 'bxst-sicked');
10704			if (oSt.pMarker)
10705				oSt.pMarker.style.display = "none";
10706		}
10707	},
10708
10709	AddSticker: function(Sticker, bVisEffects, bShowEditor)
10710	{
10711		if (!this.bInited)
10712			return this.ShowAll(true, true);
10713
10714		if(!this.bShowStickers && this.bInited)
10715			this.ShowAll(true, false);
10716
10717		if (this.curEditorStickerInd !== false) // If we press add sticker hot key in the
10718		{
10719			var _this = this;
10720			this.SaveAndCloseEditor(this.curEditorStickerInd, true, true);
10721			return setTimeout(function(){_this.AddSticker(Sticker, bVisEffects, bShowEditor);}, 300);
10722		}
10723
10724		var oSticker;
10725		if (Sticker)
10726		{
10727			oSticker = this.ConvertStickerObj(Sticker);
10728		}
10729		else
10730		{
10731			oSticker = {
10732				bNew: true,
10733				personal: false,
10734				colorInd: parseInt(this.Params.start_color),
10735				width: parseInt(this.Params.start_width),
10736				height: parseInt(this.Params.start_height),
10737				collapsed: false,
10738				completed: false,
10739				info: "&nbsp;"
10740			};
10741		}
10742
10743		var ind = this.CreateWindow(oSticker, !!bVisEffects, bShowEditor);
10744
10745		if (oSticker.bNew)
10746			this.SetMarker(ind, 'area');
10747	},
10748
10749	CreateWindow: function(oSticker, bVisEffects, bShowEditor)
10750	{
10751		// Init common window object with basic functionality
10752		var pWin = new BX.CWindow(false, 'float');
10753		pWin.Show(true); // Show window
10754		pWin.Get().style.zIndex = pWin.zIndex = this.Params.zIndex;
10755
10756		// Set resize limits
10757		pWin.SETTINGS.min_width = this.Params.min_width;
10758		pWin.SETTINGS.min_height = this.Params.min_height;
10759		BX.addClass(pWin.Get(), 'bx-sticker');
10760		pWin.DenyClose();
10761
10762		var
10763			bReadonly = this.access == 'R',
10764			bNew = !!oSticker.bNew,
10765			_this = this,
10766			pTypeCont,
10767			ind = this.arStickers.length,// Index of element in arStickers array
10768			pHead = pWin.Get().appendChild(BX.create("DIV", {props: {className: 'bxst-header', id: 'bxst_head_' + ind}})),
10769			pIdsCont = pHead.appendChild(BX.create("DIV", {props: {className: 'bxst-id-cont bxst-title'}, html: oSticker.id > 0 ? '<a href="' + this.Params.pageUrl + "?show_sticker=" + oSticker.id + '"><span>' + oSticker.id + '</span></a>' : ''})),
10770			pCheckCont = pHead.appendChild(BX.create("DIV", {props: {className: 'bxst-check-cont'}})),
10771			pCheck = pCheckCont.appendChild(BX.create("INPUT", {props: {id: 'bxst_conplited_' + ind, name: 'bxst_conplited_' + ind, type: "checkbox", value: "Y", title: this.MESS.Complete}})),
10772			pCheckLabel = pCheckCont.appendChild(BX.create("LABEL", {attrs: {'for' : 'bxst_conplited_' + ind, title: this.MESS.Complete}, text: this.MESS.CompleteLabel})),
10773			pCollapsedTitle = pHead.appendChild(BX.create("DIV", {props: {id: 'bxst_col_title_' + ind, className: 'bxst-col-title-cont', title: this.MESS.UnCollapseTitle}})),
10774			pCloseBut = pHead.appendChild(BX.create("DIV", {props: {className: 'bxst-close bxst-but', title: this.MESS.Close}})).appendChild(BX.create("IMG", {props: {id: 'bxst_close_' + ind, src: this.oneGifSrc, className: 'bxst-sprite'}})),
10775			pCollapseBut = pHead.appendChild(BX.create("DIV", {props: {className: 'bxst-collapse bxst-but'}})).appendChild(BX.create("IMG", {props: {id: 'bxst_collapse_' + ind, src: this.oneGifSrc, className: 'bxst-sprite', title: this.MESS.Collapse}}));
10776
10777		if (bNew || this.Params.curUserId == oSticker.authorId)
10778		{
10779			pTypeCont = pHead.appendChild(BX.create("DIV", {props: {id: 'bxst_type_' + ind, className: 'bxst-type-cont'}}));
10780			// Create type selector personal-public
10781			pTypeCont.appendChild(BX.create("DIV", {props: {className: 'bxst-type-l bxst-type-corn'}}));
10782			pTypeCont.appendChild(BX.create("DIV", {props: {className: 'bxst-type-c bxst-type-c-publ'}})).appendChild(BX.create("SPAN", {props: {}, text: this.MESS.Public}));
10783			pTypeCont.appendChild(BX.create("DIV", {props: {className: 'bxst-type-c  bxst-type-c-pers'}})).appendChild(BX.create("SPAN", {props: {}, text: this.MESS.Personal}));
10784			pTypeCont.appendChild(BX.create("DIV", {props: {className: 'bxst-type-r bxst-type-corn'}}));
10785
10786			if (!bReadonly)
10787				pTypeCont.onclick = function(){if(!pWin.__stWasDragged){_this.SetType(parseInt(this.id.substr('bxst_type_'.length)), true);}};
10788
10789			this.SetUnselectable([pTypeCont]);
10790		}
10791
10792		var pBody = pWin.Get().appendChild(BX.create("DIV", {props: {id: 'bxst_body_' + ind, className: 'bxst-content'}}));
10793		var pContentArea = pBody.appendChild(BX.create("DIV", {props: {id: 'bxst_content_' + ind, className: 'bxst-content-area'}}));
10794
10795		var
10796			pFoot = pWin.Get().appendChild(BX.create("DIV", {props: {className: 'bxst-footer'}})),
10797			pMarkerAreaBut = pFoot.appendChild(BX.create("DIV", {props: {className: 'bxst-marker-area-but'}})).appendChild(BX.create("IMG", {props: {id: 'bxst_marker_but0_' + ind, src: this.oneGifSrc, className: 'bxst-sprite', title: this.MESS.SetMarkerArea}})),
10798			pMarkerElementBut = pFoot.appendChild(BX.create("DIV", {props: {className: 'bxst-marker-elem-but'}})).appendChild(BX.create("IMG", {props: {id: 'bxst_marker_but1_' + ind, src: this.oneGifSrc, className: 'bxst-sprite', title: this.MESS.SetMarkerEl}}
10798)),
10799			pColorBut = pFoot.appendChild(BX.create("DIV", {props: {className: 'bxst-ctrl-txt bxst-color-but'}})).appendChild(BX.create("SPAN", {props: {id: 'bxst_color_' + ind}, text: this.MESS.Color})),
10800			pAddBut = pFoot.appendChild(BX.create("DIV", {props: {className: 'bxst-ctrl-txt bxst-add-but'}})).appendChild(BX.create("SPAN", {props: {id: 'bxst_add_but_' + ind}, text: this.MESS.Add})),
10801
10802			pResizer = pFoot.appendChild(BX.create("DIV", {props: {className: 'bxst-resizer'}})).appendChild(BX.create("IMG", {props: {src: this.oneGifSrc, className: 'bxst-sprite'}}));
10803
10804		var pInfo = pFoot.appendChild(BX.create("DIV", {props: {className: 'bxst-info-icon'}})).appendChild(BX.create("IMG", {props: {id: 'bxst_info_' + ind, src: this.oneGifSrc, className: 'bxst-sprite'}, style: {display: bNew ? 'none' : 'block'}}));
10805		var pHint = new BX.CHintSimple({parent: pInfo, hint: oSticker.info});
10806
10807		if (bReadonly)
10808			BX.addClass(pWin.Get(), 'bx-sticker-readonly');
10809
10810		// Adjust position to the center of the window.
10811		var windowSize = BX.GetWindowInnerSize();
10812		var windowScroll = BX.GetWindowScrollPos();
10813
10814		if (bNew || oSticker.left <= 0 || oSticker.top <= 0)
10815		{
10816			oSticker.left = pWin.Get().style.left = parseInt(windowScroll.scrollLeft + windowSize.innerWidth / 2 - parseInt(pWin.Get().offsetWidth) / 2) + Math.round(oSticker.width / 2);
10817			oSticker.top = Math.max(parseInt(windowScroll.scrollTop + windowSize.innerHeight / 2 - parseInt(pWin.Get().offsetHeight) / 2), 0) - Math.round(oSticker.height / 2);
10818		}
10819
10820		pWin.StickerInd = ind;
10821
10822		if (bNew)
10823			pAddBut.style.display = 'none';
10824
10825		// Create shadow
10826		pShadow = document.body.appendChild(BX.create("DIV", {props: {className: 'bxst-shadow'}, style: {zIndex: parseInt(pWin.Get().style.zIndex) - 5}}));
10827
10828		this.RegisterSticker({
10829			obj: oSticker,
10830			pWin: pWin,
10831			pCheck: pCheck,
10832			pCloseBut: pCloseBut,
10833			pCollapseBut: pCollapseBut,
10834			pCollapsedTitle: pCollapsedTitle,
10835			pBody: pBody,
10836			pHead: pHead,
10837			pTypeCont: pTypeCont || false,
10838			pContentArea: pContentArea,
10839			pIdsCont: pIdsCont,
10840			pShadow: pShadow,
10841			bButPanelShowed: true,
10842			pMarkerAreaBut: pMarkerAreaBut,
10843			pMarkerElementBut: pMarkerElementBut,
10844			pColorBut: pColorBut,
10845			pAddBut: pAddBut,
10846			pInfo: pInfo,
10847			pHint: pHint,
10848			_over: !bNew && !bShowEditor,
10849			bButPanelShowed: !bNew && !bShowEditor
10850		});
10851
10852		this.AdjustToSize(ind, oSticker.width, oSticker.height);
10853		this.SetColorScheme(ind, oSticker.colorInd, false);
10854		this.SetType(ind, false, oSticker.personal ? 'personal' : 'public');
10855		this.SetCompleted(ind, oSticker.completed, false);
10856		this.CollapseSticker(ind, false, oSticker.collapsed);
10857
10858		pWin.SetDraggable(pHead);
10859		BX.addCustomEvent(pWin, 'onWindowDragStart', function(){this.__stWasDragged = true;});
10860		BX.addCustomEvent(pWin, 'onWindowDragFinished', function(){_this.OnDragEnd(this);});
10861		BX.addCustomEvent(pWin, 'onWindowDrag', function(){_this.OnDragDrop(this);});
10862
10863		// Set and config resizer
10864		pWin.SetResize(pResizer);
10865		BX.addCustomEvent(pWin, 'onWindowResize', function(){_this.AdjustToSize(this.StickerInd);});
10866		BX.addCustomEvent(pWin, 'onWindowResizeStart', function(){_this.OnResizeStart(this);});
10867		BX.addCustomEvent(pWin, 'onWindowResizeFinished', function(){_this.OnResizeEnd(this);});
10868
10869		// Control events
10870		pHead.ondblclick = function(){_this.CollapseSticker(parseInt(this.id.substr('bxst_head_'.length)), true);}
10871		pCollapseBut.onclick = function(){if(!pWin.__stWasDragged){_this.CollapseSticker(parseInt(this.id.substr('bxst_collapse_'.length)), true);}};
10872
10873		if (!bReadonly)
10874		{
10875			// Control events
10876			pCloseBut.onclick = function(){if(!pWin.__stWasDragged){_this.CloseSticker(parseInt(this.id.substr('bxst_close_'.length)), true);}};
10877			//pTypeCont.onclick = function(){if(!pWin.__stWasDragged){_this.SetType(parseInt(this.id.substr('bxst_type_'.length)), true);}};
10878			pAddBut.onclick = function(){_this.AddToSticker(parseInt(this.id.substr('bxst_add_but_'.length)));};
10879			pCheck.onclick = function(){if(!pWin.__stWasDragged){_this.SetCompleted(parseInt(this.id.substr('bxst_conplited_'.length)), !!this.checked, true);}};
10880			pColorBut.onclick = function(){_this.ShowColorSelector(parseInt(this.id.substr('bxst_color_'.length)));};
10881
10882			pMarkerAreaBut.onclick = function(){_this.SetMarker(parseInt(this.id.substr('bxst_marker_but0_'.length)), 'area');};
10883			pMarkerElementBut.onclick = function(){_this.SetMarker(parseInt(this.id.substr('bxst_marker_but1_'.length)),  'element');};
10884		}
10885		else
10886		{
10887			pCheck.disabled = true;
10888		}
10889
10890		// Hide Buttons Panel instead of calling ShowButtonsPanel method
10891		if (!bNew && !bShowEditor && !oSticker.collapsed)
10892			pWin.Get().style.height = (oSticker.height - 24) + "px";
10893
10894		if (bNew)
10895		{
10896			var pos = this.GetSuitablePosition(oSticker.left, oSticker.top);
10897			if (pos !== true)
10898			{
10899				oSticker.left = pos.left;
10900				oSticker.top = pos.top;
10901			}
10902		}
10903		else
10904		{
10905			pIdsCont.style.display = "block";
10906		}
10907		this.RegisterPosition(oSticker.left, oSticker.top);
10908
10909		// Set start position
10910		pWin.Get().style.left = oSticker.left + 'px';
10911		pWin.Get().style.top = oSticker.top + 'px';
10912
10913		this.SupaFlySticker(ind);
10914		this.AdjustShadow(ind);
10915
10916		// Set unselectable elements
10917		this.SetUnselectable([pCloseBut, pCollapseBut, pColorBut, pMarkerAreaBut, pMarkerAreaBut, pResizer]);
10918
10919		if (bNew || bShowEditor === true)
10920		{
10921			this.ShowEditor({ind: ind});
10922
10923			if (bShowEditor)
10924			{
10925				this.OnDivMouseOver(ind, true);
10926				this.DisplayMarker(ind);
10927			}
10928		}
10929		else
10930		{
10931			pBody.style.overflow = 'auto';
10932			pContentArea.innerHTML = oSticker.html_content;
10933			//this.ShowButtonsPanel(ind, false, false);
10934			this.DisplayMarker(ind);
10935
10936			if (oSticker.id == this.Params.focusOnSticker)
10937			{
10938				window.scrollTo(0, oSticker.top > 200 ? oSticker.top - 200 : 0);
10939				this.Hightlight(ind, true);
10940				this.BlinkRed(ind);
10941			}
10942		}
10943
10944
10945		if (!bReadonly)
10946		{
10947			pBody.onclick = function()
10948			{
10949				if (!this.id)
10950					return;
10951				var ind = parseInt(this.id.substr('bxst_body_'.length));
10952				if (_this.curEditorStickerInd !== ind)
10953					_this.ShowEditor({ind: ind});
10954			};
10955		}
10956
10957		// Hide and show buttons panel
10958		pWin.Get().onmouseover = function(){_this.OnDivMouseOver(ind, true);};
10959		pWin.Get().onmouseout = function(){_this.OnDivMouseOver(ind, false);};
10960
10961		return ind;
10962	},
10963
10964	UpdateNewSticker: function(ind)
10965	{
10966		var oSt = this.arStickers[ind];
10967		oSt.pAddBut.style.display = 'block';
10968		oSt.pInfo.style.display = 'block';
10969		oSt.pIdsCont.style.display = "block";
10970		oSt.pIdsCont.innerHTML = '<a href="' + this.Params.pageUrl + "?show_sticker=" + oSt.obj.id + '"><span>' + oSt.obj.id + '</span></a>';
10971
10972		if (ind === this.curEditorStickerInd && typeof window.oLHESticker == 'object')
10973		{
10974			setTimeout(function(){oLHESticker.SetFocusToEnd();}, 100);
10975			setTimeout(function(){oLHESticker.SetFocusToEnd();}, 500);
10976		}
10977	},
10978
10979	RegisterPosition: function(l, t)
10980	{
10981		var
10982			d = 20,
10983			l1 = Math.round(l / d) * d,
10984			t1 = Math.round(t / d) * d;
10985
10986		this.posReg[l1 + "_" + t1] = true;
10987	},
10988
10989	GetSuitablePosition: function(l, t, bAdjust)
10990	{
10991		var
10992			d = 20,
10993			l1 = Math.round(l / d) * d,
10994			t1 = Math.round(t / d) * d;
10995
10996		if (this.posReg[l1 + "_" + t1])
10997			return this.GetSuitablePosition(l + d, t + d, true);
10998		else if (bAdjust)
10999			return {left: l, top: t};
11000
11001		return true;
11002	},
11003
11004	RegisterSticker: function(oSt)
11005	{
11006		this.arStickers.push(oSt);
11007		return this.arStickers.length - 1;
11008	},
11009
11010	AdjustToSize: function(ind, w, h)
11011	{
11012		var contHeight, oSt = this.arStickers[ind];
11013		if (typeof w == 'undefined' || typeof h == 'undefined')
11014		{
11015			w = parseInt(oSt.pWin.Get().style.width);
11016			h = parseInt(oSt.pWin.Get().style.height);
11017		}
11018		else
11019		{
11020			oSt.pWin.Get().style.width = w + "px";
11021			oSt.pWin.Get().style.height = h + "px";
11022		}
11023
11024		if (BX.browser.IsIE() && !BX.browser.IsDoctype())
11025			contHeight = h - 19 /* header section */ - 27 /* footer section */ - 0;
11026		else
11027			contHeight = h - 19 /* header section */ - 24 /* footer section */ - 0;
11028
11029		if (window.oLHESticker)
11030		{
11031			window.oLHESticker.pFrame.style.width = (w - 2)+ "px";
11032			window.oLHESticker.pFrame.style.height = (contHeight - 2) + "px";
11033			window.oLHESticker.ResizeFrame(contHeight - 2);
11034		}
11035
11036		oSt.pCollapsedTitle.style.width = (w - 100) + "px";
11037		oSt.pBody.style.height = contHeight + "px";
11038
11039		this.AdjustShadow(ind);
11040	},
11041
11042	AdjustShadow: function(ind)
11043	{
11044		var oSt = this.arStickers[ind];
11045
11046		if (oSt.obj.closed && oSt.pShadow.parentNode)
11047			return oSt.pShadow.parentNode.removeChild(oSt.pShadow);
11048
11049		oSt.pShadow.style.top = (parseInt(oSt.pWin.Get().style.top) + 4) + "px";
11050		oSt.pShadow.style.left = (parseInt(oSt.pWin.Get().style.left) + 3) + "px";
11051		oSt.pShadow.style.width = oSt.pWin.Get().style.width;
11052		oSt.pShadow.style.height = oSt.pWin.Get().style.height;
11053	},
11054
11055	AdjustEditorSizeAndPos: function(ind)
11056	{
11057		var oSt = this.arStickers[ind];
11058		this.pEditorCont.style.top = (parseInt(oSt.pWin.Get().style.top) + 20) + "px";
11059		this.pEditorCont.style.left = oSt.pWin.Get().style.left;
11060		this.pEditorCont.style.width = oSt.pWin.Get().style.width;
11061		this.pEditorCont.style.height = oSt.pBody.style.height;
11062		this.pEditorCont.style.zIndex = parseInt(oSt.pWin.Get().style.zIndex) + 10;
11063	},
11064
11065	AdjustHintToCursor: function(pHint, e)
11066	{
11067		pHint.style.left = (e.realX + 30) + "px";
11068		pHint.style.top = (e.realY - 12) + "px";
11069	},
11070
11071	AdjustScrollPosToCursor: function()
11072	{
11073	},
11074
11075	AdjustStickerToArea: function(ind)
11076	{
11077		var
11078			x, y,
11079			size = BX.GetWindowInnerSize(document),
11080			scroll = BX.GetWindowScrollPos(document),
11081			oSt = this.arStickers[ind],
11082			deltaH = (oSt.obj.marker && oSt.obj.marker.adjust) ? 0 : 10;
11083
11084		if (oSt.pMarker && oSt.obj.marker)
11085		{
11086			x = oSt.obj.marker.left + oSt.obj.marker.width - 60;
11087			y = oSt.obj.marker.top - oSt.obj.height + deltaH;
11088
11089			if (x + oSt.obj.width >
11089 size.innerWidth)
11090				x = size.innerWidth - oSt.obj.width - 30;
11091
11092			if (y < scroll.scrollTop + 50)
11093				y = oSt.obj.marker.top + oSt.obj.marker.height - deltaH;
11094		}
11095
11096		this.MoveToPos(ind, {left: x, top: y});
11097		oSt.obj.top = y;
11098		oSt.obj.left = x;
11099
11100		if (this.arStickers[ind].obj.id)
11101			this.SaveSticker(ind);
11102	},
11103
11104	MoveToPos: function(ind, resPos)
11105	{
11106		var oSt = this.arStickers[ind];
11107		var
11108			startTop = parseInt(oSt.obj.top),
11109			startLeft = parseInt(oSt.obj.left),
11110			endTop = parseInt(resPos.top),
11111			endLeft = parseInt(resPos.left),
11112			curTop = parseInt(startTop),
11113			curLeft = parseInt(startLeft),
11114
11115			_this = this,
11116			count = 0,
11117			bUp = startTop > endTop,
11118			bLeft = startLeft > endLeft,
11119			time = BX.browser.IsIE() ? 10 : 10,
11120			d = BX.browser.IsIE() ? 10 : 10,
11121			d1 = Math.ceil(Math.abs((startLeft - endLeft) / 50)),
11122			d2 = Math.ceil(Math.abs((startTop - endTop) / 50)),
11123			dx = bLeft ? -d1 : d1,
11124			dy = bUp ? -d2 : d2;
11125
11126		var SetPos = function(t, l)
11127		{
11128			if (t !== false)
11129				oSt.pWin.Get().style.top = t + "px";
11130			if (l !== false)
11131				oSt.pWin.Get().style.left = l + "px";
11132			_this.AdjustShadow(ind);
11133		};
11134
11135		var Interval = setInterval(function()
11136			{
11137				if (endTop != curTop && curTop !== false)
11138					curTop += Math.round(dy * count / 2);
11139				if (endLeft != curLeft && curLeft !== false)
11140					curLeft += Math.round(dx * count / 2);
11141
11142				if (curTop !== false && (!bUp && curTop >= endTop || bUp && curTop <= endTop))
11143					curTop = endTop;
11144
11145				if (curLeft !== false && (!bLeft && curLeft >= endLeft || bLeft && curLeft <= endLeft))
11146					curLeft = endLeft;
11147
11148				SetPos(curTop, curLeft);
11149
11150				if (curTop == endTop)
11151					curTop = false;
11152
11153				if (curLeft == endLeft)
11154					curLeft = false;
11155
11156				if (curTop === false && curLeft === false)
11157				{
11158					clearInterval(Interval);
11159					return _this.OnDragEnd(oSt.pWin);
11160				}
11161				count++;
11162			},
11163			time
11164		);
11165	},
11166
11167	ChangeColor: function(ind, colorInd, bEffect, bFadeIn)
11168	{
11169		var oSt = this.arStickers[ind];
11170		if (!this.Params.changeColorEffect)
11171			bEffect = false;
11172
11173		if (bEffect && bFadeIn === true)
11174		{
11175			this.Params.start_color = colorInd;
11176			return this.ShowColorOverlay(ind, colorInd, true);
11177		}
11178		else if((bEffect && bFadeIn === false) || !bEffect)
11179		{
11180			this.SetColorScheme(ind, colorInd, true);
11181			if (bEffect)
11182				return this.ShowColorOverlay(ind, colorInd, false);
11183		}
11184	},
11185
11186	SetColorScheme: function(ind, colorInd, bSave)
11187	{
11188		// If we have editor
11189		if (ind === this.curEditorStickerInd && typeof window.oLHESticker == 'object')
11190		{
11191			if (window.oLHESticker.pEditorDocument && window.oLHESticker.pEditorDocument.body)
11192				window.oLHESticker.pEditorDocument.body.className = this.colorSchemes[colorInd].name;
11193		}
11194
11195		this.arStickers[ind].obj.colorInd = colorInd;
11196		for (var i = 0, l = this.colorSchemes.length; i < l; i++)
11197		{
11198			if (i == colorInd)
11199				BX.addClass(this.arStickers[ind].pWin.Get(), this.colorSchemes[i].name);
11200			else
11201				BX.removeClass(this.arStickers[ind].pWin.Get(), this.colorSchemes[i].name);
11202		}
11203
11204		if (this.arStickers[ind].pMarker)
11205			this.arStickers[ind].pMarker.className = 'bxst-sticker-marker ' + this.colorSchemes[colorInd].name;
11206
11207		if (bSave && this.arStickers[ind].obj.id > 0)
11208		{
11209			var _this = this;
11210			if (this.arStickers[ind]._colTimeout)
11211			{
11212				clearTimeout(this.arStickers[ind]._colTimeout);
11213				this.arStickers[ind]._colTimeout = null;
11214			}
11215
11216			// Save color with some delay for fast clicking colot controll
11217			// this.arStickers[ind]._colTimeout = setTimeout(function()
11218			// {
11219				//_this.arStickers[ind]._colTimeout = null;
11220				_this.SaveSticker(ind);
11221			//}, 800);
11222		}
11223	},
11224
11225	SetType: function(ind, bSave, type)
11226	{
11227		var
11228			oSt = this.arStickers[ind],
11229			bPersonal = (typeof type == 'undefined') ? !oSt.obj.personal : type == 'personal';
11230
11231		if (!oSt.pTypeCont)
11232			return;
11233
11234		if (bPersonal)
11235		{
11236			BX.addClass(oSt.pTypeCont, 'bxst-type-pers');
11237			BX.removeClass(oSt.pTypeCont, 'bxst-type-publ');
11238			oSt.pTypeCont.title = this.MESS.PersonalTitle;
11239		}
11240		else
11241		{
11242			BX.addClass(oSt.pTypeCont, 'bxst-type-publ');
11243			BX.removeClass(oSt.pTypeCont, 'bxst-type-pers');
11244			oSt.pTypeCont.title = this.MESS.PublicTitle;
11245		}
11246		oSt.obj.personal = bPersonal;
11247
11248		if (oSt.obj.id && bSave) // Sticker already created - we change type and save it
11249			this.SaveSticker(ind);
11250	},
11251
11252	SetCompleted: function(ind, bChecked, bSave)
11253	{
11254		this.arStickers[ind].obj.completed = bChecked;
11255		this.arStickers[ind].pCheck.checked = bChecked;
11256
11257		if (bChecked)
11258		{
11259			//BX.addClass(this.arStickers[ind].pWin.Get(), "bxst-completed");
11260			//this.arStickers[ind].pShadow.style.display = 'none';
11261		}
11262		else
11263		{
11264			//BX.removeClass(this.arStickers[ind].pWin.Get(), "bxst-completed");
11265			//this.arStickers[ind].pShadow.style.display = 'block';
11266		}
11267
11268		if (this.arStickers[ind].obj.id && bSave)
11269			this.SaveSticker(ind);
11270	},
11271
11272	CloseSticker: function(ind, bSave, bClose)
11273	{
11274		var oSt = this.arStickers[ind];
11275		if (bSave && oSt.obj.authorName && this.Params.curUserId != oSt.obj.authorId && !confirm(this.MESS.CloseConfirm.replace("#USER_NAME#", oSt.obj.authorName)))
11276			return;
11277
11278		oSt.obj.closed = !oSt.obj.closed;
11279
11280		if (ind === this.curEditorStickerInd)
11281			this.curEditorStickerInd = false;
11282
11283		this.arStickers[ind].pWin.Close(true);
11284		this.arStickers[ind].pWin.onUnRegister(true);
11285
11286		//Hide marker if it exist
11287		if (oSt.pMarkerNode)
11288			BX.removeClass(oSt.pMarkerNode, 'bxst-sicked');
11289		if (oSt.pMarker && oSt.pMarker.parentNode)
11290			oSt.pMarker.parentNode.removeChild(oSt.pMarker);
11291
11292		this.AdjustShadow(ind);
11293
11294		if (this.arStickers[ind].obj.id && bSave)
11295		{
11296			this.SaveSticker(ind);
11297			BX.admin.panel.Notify(this.MESS.CloseNotify.replace(/(.*?)#LINK#(.*?)#LINK#/ig, "$1<span class=\"bxst-close-notify-link\" onclick=\"window.oBXSticker.ShowList(\'current\'); return false;\">$2</span>"));
11298		}
11299
11300		var a = document.body.getElementsByTagName('A');
11301		if (a && a[0])
11302			BX.focus(a[0]);
11303	},
11304
11305	CollapseSticker: function(ind, bSave, bCollapse)
11306	{
11307		var oSt = this.arStickers[ind];
11308
11309		if (typeof bCollapse == 'undefined')
11310			bCollapse = !oSt.obj.collapsed;
11311
11312		if (bSave && this.curEditorStickerInd === ind)
11313			this.SaveAndCloseEditor(ind, true, false);
11314
11315		if (bCollapse)
11316		{
11317			BX.addClass(oSt.pWin.Get(), "bxst-collapsed");
11318			oSt.pCollapseBut.title = this.MESS.UnCollapse;
11319			oSt.pWin.Get().style.height = '19px';
11320			oSt.pCollapsedTitle.innerHTML = this.GetCollapsedContent(oSt.obj.html_content);
11321		}
11322		else
11323		{
11324			BX.removeClass(oSt.pWin.Get(), "bxst-collapsed");
11325			oSt.pCollapseBut.title = this.MESS.Collapse;
11326			oSt.pWin.Get().style.height = parseInt(oSt.obj.height) + 'px';
11327		}
11328
11329		this.AdjustShadow(ind);
11330
11331		oSt.obj.collapsed = bCollapse;
11332
11333		if (oSt.obj.id && bSave)
11334			this.SaveSticker(ind);
11335	},
11336
11337	OnDragEnd: function(pWin)
11338	{
11339		setTimeout(function(){pWin.__stWasDragged = false;}, 200);
11340		var ind = pWin.StickerInd;
11341
11342		this.arStickers[ind].obj.top = parseInt(pWin.Get().style.top);
11343		this.arStickers[ind].obj.left = parseInt(pWin.Get().style.left);
11344
11345		this.SaveSticker(ind);
11346	},
11347
11348	OnDragDrop: function(pWin)
11349	{
11350		this.AdjustShadow(pWin.StickerInd);
11351	},
11352
11353	OnResizeEnd: function(pWin)
11354	{
11355		var ind = pWin.StickerInd;
11356		this.arStickers[ind].bResizingNow = false;
11357		this.arStickers[ind].obj.width = parseInt(pWin.Get().style.width);
11358		this.arStickers[ind].obj.height = parseInt(pWin.Get().style.height);
11359
11360		if (this.arStickers[ind].obj.id)
11361			this.SaveSticker(ind);
11362	},
11363
11364	OnResizeStart: function(pWin)
11365	{
11366		this.arStickers[pWin.StickerInd].bResizingNow = true;
11367	},
11368
11369	ShowEditor: function(Params)
11370	{
11371		var
11372			bPreload = Params.ind === -1,
11373			_this = this,
11374			oSt = this.arStickers[Params.ind];
11375
11376		// Create if it's necessary and move to the current sticker window
11377		// (We have one editor and simply append it to different sticker windows)
11378		if (!this.pEditorCont)
11379			this.pEditorCont = (bPreload ? document.body : oSt.pBody).appendChild(BX.create("DIV", {props: {className: 'bxst-lhe-cont'}}));
11380
11381		this.pEditorCont.style.visibility = 'hidden';
11382
11383		// Editor already loaded
11384		if (window.oLHESticker)
11385		{
11386			if (this.bLoadLHEEditor) // Fist init
11387			{
11388				this.PrepareEditorAfterLoading();
11389				this.bLoadLHEEditor = false;
11390			}
11391
11392			if (!bPreload)
11393				this.DisplayEditor(oSt, Params.ind);
11394		}
11395		else if(!this.bLoadLHEEditor) // Init loading
11396		{
11397			this.Request('load_lhe', {}, function(res)
11398			{
11399				_this.pEditorCont.innerHTML = res;
11400				var interval = setInterval(function() // Timeout for DOM rendering
11401				{
11402					if (typeof window.LoadLHE_LHEBxStickers == 'undefined')
11403						return;
11404
11405					clearInterval(interval);
11406
11407					if (!_this.bLoadLHEEditor && !window.oLHESticker)
11408						LoadLHE_LHEBxStickers();
11409
11410					return setTimeout(function()
11411					{
11412						_this.bLoadLHEEditor = true;
11413						_this.ShowEditor(Params);
11414					}, 50);
11415				}, 50);
11416			});
11417		}
11418		else if (_this.bLoadLHEEditor && !window.oLHESticker) // Waiting for loading complete
11419		{
11420			return setTimeout(function(){_this.ShowEditor(Params);}, 50);
11421		}
11422	},
11423
11424	PrepareEditorAfterLoading: function()
11425	{
11426		if (!oLHESticker)
11427			return;
11428
11429		oLHESticker.oSpecialParsers['st_title'] = {
11430			Parse: function(sName, sContent, pLEditor)
11431			{
11432				sContent = sContent.replace(/\[ST_TITLE\]((?:\s|\S)*?)\[\/ST_TITLE\]/ig, '<span id="'+ pLEditor.SetBxTag(false, {tag: "st_title"}) + '" class="bxst-title" >$1</span>');
11433				return sContent;
11434			},
11435			UnParse: function(bxTag, pNode, pLEditor)
11436			{
11437				var res = "[ST_TITLE]";
11438				for(i = 0; i < pNode.arNodes.length; i++)
11439					res += pLEditor._RecursiveGetHTML(pNode.arNodes[i]);
11440				res += "[/ST_TITLE]";
11441				return res;
11442			}
11443		};
11444
11445		BX.addCustomEvent(oLHESticker, "OnUnParseContentAfter", function()
11446		{
11447			this.__sContent = this.__sContent.replace(/\[\/ST_TITLE\](?:\n|\r)+/ig, "[/ST_TITLE]\n");
11448		});
11449	},
11450
11451	DisplayEditor: function(oSt, ind, bJustDisplay)
11452	{
11453		var _this = this;
11454
11455		if (!bJustDisplay)
11456		{
11457			// Append editor
11458			oSt.pBody.appendChild(this.pEditorCont);
11459			this.AdjustToSize(ind);
11460			oLHESticker.SetContent(oSt.obj.content || (this.GetNewStickerContent() + "\n"));
11461			oLHESticker.CreateFrame(); // We need to recreate editable frame after reappending editor container
11462			oLHESticker.SetEditorContent(oLHESticker.content);
11463			window.oLHESticker.pEditorDocument.body.className = this.colorSchemes[oSt.obj.colorInd].name;
11464
11465			if (this.Params.useHotkeys)
11466				BX.bind(window.oLHESticker.pEditorDocument, 'keyup', BX.proxy(this.OnKeyUp, this));
11467
11468			setTimeout(function(){try{window.oLHESticker.pEditorDocument.execCommand("styleWithCSS", false, false);}catch(e){}}, 100);
11469			setTimeout(function(){try{window.oLHESticker.pEditorDocument.execCommand("styleWithCSS", false, false);}catch(e){}}, 500);
11470			setTimeout(function(){try{window.oLHESticker.pEditorDocument.execCommand("styleWithCSS", false, false);}catch(e){}}, 1000);
11471
11472			this.curEditorStickerInd = ind;
11473			oSt.pBody.style.overflow = 'hidden';
11474
11475			// Slow div motion for editor loading timeout
11476			var
11477				curTop = 0,
11478				d = 1,
11479				maxTop = 22;
11480
11481			var movePanelInterval = setInterval(function()
11482			{
11483				if (curTop >= maxTop)
11484					curTop = maxTop;
11485				else
11486					curTop += d;
11487
11488				oSt.pContentArea.style.top = curTop + "px";
11489				if (curTop == maxTop)
11490				{
11491					clearInterval(movePanelInterval);
11492					_this.DisplayEditor(oSt, ind, true);
11493				}
11494			}, BX.browser.IsIE() ? 5 : 10);
11495		}
11496		else
11497		{
11498			setTimeout(function()
11499			{
11500				oSt.pBody.style.overflow = 'auto';
11501				_this.pEditorCont.style.visibility = 'visible';
11502				oSt.pContentArea.style.display = 'none';
11503				_this.pEditorCont.style.display = 'block';
11504
11505				setTimeout(function(){oLHESticker.SetFocusToEnd();}, 100);
11506			}, 100);
11507		}
11508	},
11509
11510	AddToSticker: function(ind)
11511	{
11512		var oSt = this.arStickers[ind];
11513		if (this.curEditorStickerInd === ind && window.oLHESticker)
11514		{
11515			oLHESticker.SetFocusToEnd();
11516			oLHESticker.InsertHTML("<br />" + oLHESticker.ParseContent(this.GetNewStickerContent()) + "<br />");
11517			setTimeout(function(){oLHESticker.SetFocusToEnd();}, 100);
11518		}
11519		else
11520		{
11521			oSt.obj.content += "\n" + this.GetNewStickerContent();
11522			this.ShowEditor({ind: ind});
11523		}
11524	},
11525
11526	Request : function(action, postParams, callBack, bShowWaitWin)
11527	{
11528		bShowWaitWin = bShowWaitWin === true;
11529
11530		if (bShowWaitWin)
11531			BX.showWait();
11532
11533		var actionUrl = '/bitrix/admin/fileman_stickers.php?sticker_action=' + action + "&" + this.sessid_get + '&site_id=' + this.Params.site_id;
11534		return BX.ajax.post(actionUrl, postParams || {},
11535			function(result)
11536			{
11537				if (bShowWaitWin)
11538					BX.closeWait();
11539
11540				if(callBack)
11541					setTimeout(function(){callBack(result);}, 10);
11542			}
11543		);
11544	},
11545
11546	SetUnselectable: function(arNodes)
11547	{
11548		if (typeof arNodes != 'object')
11549			arNodes = [arNodes];
11550
11551		for (var i = 0, l = arNodes.length; i < l; i++)
11552		{
11553			BX.setUnselectable(arNodes[i]);
11554			arNodes[i].ondragstart = function (e){return BX.PreventDefault(e);};
11555		}
11556	},
11557
11558	ShowColorOverlay: function(ind, colorInd, bFadeIn)
11559	{
11560		var
11561			_this = this,
11562			it = 0, interval,
11563			oSt = this.arStickers[ind];
11564
11565		if (!this.pColorOverlay)
11566			this.pColorOverlay = document.body.appendChild(BX.create("DIV", {props: {className: 'bx-sticker-overlay'}}));
11567
11568		this.pColorOverlay.style.zIndex = parseInt(oSt.pWin.Get().style.zIndex) + 10;
11569		this.pColorOverlay.style.top = oSt.pWin.Get().style.top;
11570		this.pColorOverlay.style.left = oSt.pWin.Get().style.left;
11571		this.pColorOverlay.style.width = oSt.pWin.Get().style.width;
11572		this.pColorOverlay.style.height = oSt.pWin.Get().style.height;
11573
11574		interval = setInterval(function()
11575		{
11576			if (it > 2)
11577			{
11578				if (bFadeIn)
11579					_this.ChangeColor(ind, colorInd, true, false);
11580				else
11581					_this.pColorOverlay.className = 'bx-sticker-overlay';
11582				return clearInterval(interval);
11583			}
11584
11585			if (bFadeIn)
11586				_this.pColorOverlay.className = 'bx-sticker-overlay bx-sticker-op-' 
11586+ it;
11587			else
11588				_this.pColorOverlay.className = 'bx-sticker-overlay bx-sticker-op-' + (3 -it);
11589
11590			it++;
11591		}, 20);
11592	},
11593
11594	DisplayStickers: function(bVisEffects)
11595	{
11596		for (var i = 0, l = this.Stickers.length; i < l; i++)
11597			this.AddSticker(this.Stickers[i], bVisEffects);
11598	},
11599
11600	MousePos: function (e)
11601	{
11602		if(window.event)
11603			e = window.event;
11604
11605		if(e.pageX || e.pageY)
11606		{
11607			e.realX = e.pageX;
11608			e.realY = e.pageY;
11609		}
11610		else if(e.clientX || e.clientY)
11611		{
11612			e.realX = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
11613			e.realY = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
11614		}
11615		return e;
11616	},
11617
11618	SaveAndCloseEditor: function(ind, bClose, bSaveSticker)
11619	{
11620		if (!window.oLHESticker || this.bLoadLHEEditor)
11621		{
11622			var _this = this;
11623			return setTimeout(function(){_this.SaveAndCloseEditor(ind, bClose);}, 100);
11624		}
11625
11626		var oSt = this.arStickers[ind];
11627		oLHESticker.SaveContent();
11628		var content = oLHESticker.GetContent();
11629		var htmlContent = oLHESticker.ParseContent(content);
11630
11631		oSt.obj.html_content = htmlContent;
11632		oSt.pContentArea.innerHTML = htmlContent;
11633		this.arStickers[ind].obj.content = content;
11634
11635		if (bClose !== false)
11636		{
11637			oSt.pContentArea.style.display = 'block';
11638			this.pEditorCont.style.display = 'none';
11639			oSt.pContentArea.style.top = '0px';
11640			oSt.pBody.style.overflow = 'auto';
11641			this.curEditorStickerInd = false;
11642		}
11643
11644		if (bSaveSticker !== false)
11645			this.SaveSticker(ind);
11646	},
11647
11648	GetNewStickerContent: function()
11649	{
11650		var zeroInt = function(x)
11651		{
11652			x = parseInt(x);
11653			if (isNaN(x))
11654				x = 0;
11655			return x < 10 ? '0' + x.toString() : x.toString();
11656		}
11657		var oDate = new Date();
11658		var strDate = this.Params.strDate + " " + zeroInt(oDate.getHours()) + ':' + zeroInt(oDate.getMinutes());
11659		return "[ST_TITLE]" + BX.util.htmlspecialchars(this.Params.curUserName) + ' ' + strDate + "[/ST_TITLE]\n";
11660	},
11661
11662	SaveSticker: function(ind)
11663	{
11664		if (this.access == 'R') // Readonly
11665			return;
11666
11667		if (this.curEditorStickerInd === ind)
11668			this.SaveAndCloseEditor(ind, false, false);
11669
11670		var oSt = this.arStickers[ind];
11671		var _this = this;
11672		var reqid = Math.round(Math.random() * 100000);
11673		window.__bxst_result[reqid] = false;
11674
11675		if (typeof oSt.obj.content == 'undefined')
11676			oSt.obj.content = this.GetNewStickerContent() + "\n";
11677
11678		if (oSt.obj.bNew)
11679		{
11680			if (this._arSavedStickers[ind]) // prevent double saving
11681				return;
11682			this._arSavedStickers[ind] = true;
11683		}
11684
11685		this.Request('save_sticker',
11686			{
11687				reqid : reqid,
11688				id: oSt.obj.bNew ? 0 : oSt.obj.id,
11689				page_url: this.Params.pageUrl,
11690				page_title: this.Params.pageTitle,
11691
11692				personal: oSt.obj.personal ? 'Y' : 'N',
11693				content: oSt.obj.content,
11694
11695				width: oSt.obj.width,
11696				height: oSt.obj.height,
11697				top: oSt.obj.top,
11698				left: oSt.obj.left,
11699				color: oSt.obj.colorInd,
11700
11701				collapsed: oSt.obj.collapsed ? 'Y' : 'N',
11702				completed: oSt.obj.completed ? 'Y' : 'N',
11703				closed: oSt.obj.closed ? 'Y' : 'N',
11704
11705				marker: oSt.obj.marker
11706			},
11707			function()
11708			{
11709				if (window.__bxst_result[reqid])
11710				{
11711					var bNew = !!oSt.obj.bNew;
11712					_this.arStickers[ind].obj = _this.ConvertStickerObj(window.__bxst_result[reqid]);
11713					if (_this.arStickers[ind].pHint)
11714					{
11715						_this.arStickers[ind].pHint.HINT = _this.arStickers[ind].obj.info;
11716						if (_this.arStickers[ind].pHint.CONTENT_TEXT)
11717							_this.arStickers[ind].pHint.CONTENT_TEXT.innerHTML = _this.arStickers[ind].obj.info;
11718					}
11719
11720					if (bNew)
11721					{
11722						_this.UpdateNewSticker(ind);
11723
11724						if (!_this.arStickers[ind].obj.closed)
11725						{
11726							_this.curPageCount++;
11727							_this.UpdateStickersCount();
11728						}
11729					}
11730					else
11731					{
11732						if (_this.arStickers[ind].obj.closed)
11733						{
11734							_this.curPageCount--;
11735							_this.UpdateStickersCount();
11736						}
11737					}
11738				}
11739				window.__bxst_result[reqid] = null;
11740			}
11741		);
11742	},
11743
11744	GetCollapsedContent: function(content)
11745	{
11746		var colContent = '';
11747		if (content.indexOf('bxst-title') != -1)
11748		{
11749			colContent = content.replace(/<span[^>]*?class="bxst-title"[^>]*?>((?:\s|\S)*?)<\/span>/ig, function(str, title)
11750			{
11751				if (title.indexOf(String.fromCharCode(160)) > 0)
11752					return '<span class="bxst-title">' + title.substr(0, title.indexOf(String.fromCharCode(160))) + "</span> ";
11753				return title;
11754			});
11755
11756			colContent = colContent.replace(/<br( \/)?>/ig, ' ');
11757		}
11758		// else
11759		// {
11760
11761		// }
11762
11763		if (colContent != '')
11764			return colContent;
11765
11766		return content;
11767	},
11768
11769	ConvertStickerObj: function(Sticker)
11770	{
11771		return {
11772			bNew: false,
11773			id: parseInt(Sticker.ID),
11774			personal: Sticker.PERSONAL == 'Y',
11775			colorInd: Sticker.COLOR || 0,
11776			content: Sticker.CONTENT,
11777			html_content: Sticker.HTML_CONTENT,
11778			top: parseInt(Sticker.POS_TOP),
11779			left: parseInt(Sticker.POS_LEFT),
11780			width: parseInt(Sticker.WIDTH),
11781			height: parseInt(Sticker.HEIGHT),
11782			collapsed: Sticker.COLLAPSED == 'Y',
11783			completed: Sticker.COMPLETED == 'Y',
11784			closed: Sticker.CLOSED == 'Y',
11785			info: Sticker.INFO,
11786			authorName: Sticker.AUTHOR,
11787			authorId: Sticker.CREATED_BY,
11788			marker: (Sticker.MARKER_ADJUST || Sticker.MARKER_WIDTH || Sticker.MARKER_HEIGHT)  ?
11789				{
11790					top: parseInt(Sticker.MARKER_TOP),
11791					left: parseInt(Sticker.MARKER_LEFT),
11792					width: parseInt(Sticker.MARKER_WIDTH),
11793					height: parseInt(Sticker.MARKER_HEIGHT),
11794					adjust: Sticker.MARKER_ADJUST
11795				}
11796				: {}
11797		};
11798	},
11799
11800	SetMarker: function(ind, mode)
11801	{
11802		var _this = this;
11803		var oSt = this.arStickers[ind];
11804		this.bHightlightElementMode = false;
11805		this.bSelectAreaMode = false;
11806
11807		BX.removeClass(oSt.pMarkerElementBut, 'bxst-pressed');
11808		BX.removeClass(oSt.pMarkerAreaBut, 'bxst-pressed');
11809
11810		if (!this.oMarker)
11811			this.oMarker = {};
11812
11813		this.oMarker.StickerInd = ind;
11814
11815		//Hide marker if it exist
11816		if (oSt.pMarkerNode)
11817			BX.removeClass(oSt.pMarkerNode, 'bxst-sicked');
11818
11819		if (oSt.pMarker)
11820		{
11821			oSt.pMarker.style.display = "none";
11822			oSt.pMarker.style.top = "-1000px";
11823		}
11824		if (oSt.markerResizer && oSt.markerResizer.cont)
11825			oSt.markerResizer.cont.style.display = "none";
11826
11827		if (oSt.obj && oSt.obj.marker)
11828			oSt.obj.marker = {};
11829
11830		this.oMarker.node = null;
11831
11832		oSt.bSetMarkerMode = true;
11833		if (mode == 'area')
11834		{
11835			BX.addClass(oSt.pMarkerAreaBut, 'bxst-pressed');
11836			setTimeout(function(){_this.bSelectAreaMode = true;}, 10);
11837
11838			// Create overlay
11839			if (!this.oMarker.pOverlay)
11840				this.oMarker.pOverlay = document.body.appendChild(BX.create('DIV', {props: {className: 'bxst-marker-overlay'}}));
11841			// Show overlay
11842			this.oMarker.pOverlay.style.display = 'block';
11843
11844			// Adjust overlay to size
11845			var ss = BX.GetWindowScrollSize(document);
11846			this.oMarker.pOverlay.style.width = ss.scrollWidth + "px";
11847			this.oMarker.pOverlay.style.height = ss.scrollHeight + "px";
11848
11849			// Create hint near cursor
11850			if (!this.oMarker.pCursorHint)
11851				this.oMarker.pCursorHint = document.body.appendChild(BX.create('DIV', {props: {className: 'bxst-cursor-hint'}, text: this.MESS.CursorHint}));
11852
11853			this.oMarker.pCursorHint.style.top = '';
11854			this.oMarker.pCursorHint.style.left = '';
11855			this.oMarker.pCursorHint.style.display = 'block';
11856
11857			// Marker selection area object
11858			this.oMarker.pWnd = document.body.appendChild(BX.create('DIV'));
11859			this.oMarker.pWnd.className = 'bxst-cur-marker ' + this.colorSchemes[oSt.obj.colorInd].name;
11860		}
11861		else // Element
11862		{
11863			BX.addClass(oSt.pMarkerElementBut, 'bxst-pressed');
11864			setTimeout(function(){_this.bHightlightElementMode = true;}, 10);
11865		}
11866
11867		// Add events
11868		BX.bind(document, 'mousemove', BX.proxy(this.OnMouseMove, this));
11869		//BX.bind(document, 'mousedown', BX.proxy(this.OnMousedown, this));
11870		BX.bind(document, 'mouseup', BX.proxy(this.OnMouseUp, this));
11871	},
11872
11873	OnMousedown: function(e)
11874	{
11875		//if(!this.bHightlightElementMode && !this.bSelectAreaMode)
11876		//{
11877			if (this.curEditorStickerInd !== false && window.oLHESticker && !window.oLHESticker.bPopup)
11878			{
11879				var oSt = this.arStickers[this.curEditorStickerInd];
11880				if (oSt && oSt.pWin.Get())
11881				{
11882					var
11883						bSelMode = this.bSelectAreaMode || this.bHightlightElementMode,
11884						d = 3,
11885						top = parseInt(oSt.pWin.Get().style.top) - d,
11886						left = parseInt(oSt.pWin.Get().style.left) - d,
11887						right = left + parseInt(oSt.pWin.Get().style.width) + d * 2,
11888						bottom = top + parseInt(oSt.pWin.Get().style.height) + d * 2;
11889
11890					e = this.MousePos(e);
11891					if (e.realX < left || e.realX > right || e.realY < top || e.realY > bottom)
11892						this.SaveAndCloseEditor(this.curEditorStickerInd, !bSelMode, !bSelMode);
11893				}
11894			}
11895		//}
11896
11897		// Start to draw selection marker area
11898		if (this.bSelectAreaMode)
11899		{
11900			e = this.MousePos(e);
11901			this.bDrawMarkerMode = true;
11902			if (this.oMarker.pCursorHint)
11903				this.oMarker.pCursorHint.style.display = 'none';
11904
11905			this.oMarker.from = {top: e.realY, left: e.realX};
11906		}
11907		else if (this.bHightlightElementMode) // Start to draw marker area
11908		{
11909			var bPrevent = false;
11910			if (this.pCurMarkeredNode)
11911			{
11912				bPrevent = true;
11913				var cn = this.pCurMarkeredNode.pNode.className;
11914				if (cn && (cn.indexOf('bx-sticker') != -1 || cn.indexOf('bxst') != -1) && cn.indexOf('bxst-sicked') == -1)
11915					bPrevent = false;
11916				if (bPrevent)
11917					bPrevent = !BX.findParent(this.pCurMarkeredNode.pNode, {className: new RegExp('bx-sticker', 'ig')});
11918			}
11919
11920			// Prevent to go away from page
11921			if (bPrevent)
11922				return BX.PreventDefault(e);
11923			else
11924				this.MarkerHightlightNode(); // Restore onmousedown and onclick events
11925		}
11926	},
11927
11928	OnMouseMove: function(e)
11929	{
11930		if(this.bHightlightElementMode)
11931		{
11932			var pEl;
11933			if (e.target)
11934				pEl = e.target;
11935			else if (e.srcElement)
11936				pEl = e.srcElement;
11937			if (pEl.nodeType == 3)
11938				pEl = pEl.parentNode;
11939
11940			if (pEl && pEl.nodeName)
11941				this.MarkerHightlightNode(pEl);
11942		}
11943
11944		if (this.bSelectAreaMode)
11945		{
11946			e = this.MousePos(e);
11947
11948			if (this.oMarker.pCursorHint)
11949				this.AdjustHintToCursor(this.oMarker.pCursorHint, e);
11950
11951			if (!this.bDrawMarkerMode)
11952				return;
11953
11954			// We down mouse button and try to drop: unhightlight element and start to select area
11955			//this.bHightlightElementMode = false;
11956			//this.MarkerHightlightNode();
11957
11958			this.oMarker.to = {top: e.realY, left: e.realX};
11959			var
11960				top = this.oMarker.from.top,
11961				left = this.oMarker.from.left,
11962				w = Math.abs(this.oMarker.to.left - this.oMarker.from.left),
11963				h = Math.abs(this.oMarker.to.top - this.oMarker.from.top);
11964
11965			//00.00 - 3.00
11966			if (this.oMarker.to.top <= this.oMarker.from.top && this.oMarker.to.left >= this.oMarker.from.left)
11967			{
11968				top = this.oMarker.to.top;
11969				left = this.oMarker.from.left;
11970			}
11971			// 3.00 - 6.00
11972			else if (this.oMarker.to.top > this.oMarker.from.top && this.oMarker.to.left > this.oMarker.from.left)
11973			{
11974				top = this.oMarker.from.top;
11975				left = this.oMarker.from.left;
11976			}
11977			// 6.00 - 9.00
11978			else if (this.oMarker.to.top > this.oMarker.from.top && this.oMarker.to.left < this.oMarker.from.left)
11979			{
11980				top = this.oMarker.from.top;
11981				left = this.oMarker.to.left;
11982			}
11983			// 9.00 - 12.00
11984			else if (this.oMarker.to.top < this.oMarker.from.top && this.oMarker.to.left < this.oMarker.from.left)
11985			{
11986				top = this.oMarker.to.top;
11987				left = this.oMarker.to.left;
11988			}
11989
11990			this.oMarker.pWnd.style.display = "block";
11991			this.oMarker.pWnd.style.width = w + "px";
11992			this.oMarker.pWnd.style.height = h + "px";
11993			this.oMarker.pWnd.style.top = top + "px";
11994			this.oMarker.pWnd.style.left = left + "px";
11995
11996			this.oMarker.top = top;
11997			this.oMarker.left = left;
11998			this.oMarker.width = w;
11999			this.oMarker.height = h;
12000		}
12001	},
12002
12003	OnMouseUp: function(e)
12004	{
12005		if (this.bHightlightElementMode && this.pCurMarkeredNode)
12006		{
12007			var bPrevent = false;
12008			var cn = this.pCurMarkeredNode.pNode.className;
12009			if (cn && (cn.indexOf('bx-sticker') != -1 || cn.indexOf('bxst') != -1) && cn.indexOf('bxst-sicked') == -1)
12010				bPrevent = true;
12011			if (!bPrevent)
12012				bPrevent = !!BX.findParent(this.pCurMarkeredNode.pNode, {className: new RegExp('bx-sticker', 'ig')});
12013
12014			if (!bPrevent)
12015				this.oMarker.node = this.pCurMarkeredNode.pNode;
12016		}
12017
12018		// Reset
12019		this.bDrawMarkerMode = false;
12020		this.bHightlightElementMode = false;
12021		this.bSelectAreaMode = false;
12022
12023		if (this.oMarker.StickerInd >= 0 && this.arStickers[this.oMarker.StickerInd])
12024		{
12025			var oSt = this.arStickers[this.oMarker.StickerInd];
12026			BX.removeClass(oSt.pMarkerElementBut, 'bxst-pressed');
12027			BX.removeClass(oSt.pMarkerAreaBut, 'bxst-pressed');
12028			oSt.bSetMarkerMode = false;
12029		}
12030
12031		// Kill events
12032		BX.unbind(document, 'mousemove', BX.proxy(this.OnMouseMove, this));
12033		//BX.unbind(document, 'mousedown', BX.proxy(this.OnMousedown, this));
12034		BX.unbind(document, 'mouseup', BX.proxy(this.OnMouseUp, this));
12035
12036		if (this.oMarker.pOverlay)
12037			this.oMarker.pOverlay.style.display = 'none';
12038		if (this.oMarker.pCursorHint)
12039			this.oMarker.pCursorHint.style.display = 'none';
12040
12041		// if (bPrevent)
12042			// this.SetMarker(this.oMarker.StickerInd);
12043		// else
12044		if (!bPrevent)
12045			this.CreateMarker(this.oMarker);
12046	},
12047
12048	MarkerHightlightNode: function(node)
12049	{
12050		if (this.pCurMarkeredNode)
12051		{
12052			if (this.pCurMarkeredNode.onclick)
12053				this.pCurMarkeredNode.pNode.onclick = this.pCurMarkeredNode.onclick;
12054			if (this.pCurMarkeredNode.onmousedown)
12055				this.pCurMarkeredNode.pNode.onmousedown = this.pCurMarkeredNode.onmousedown;
12056
12057			BX.removeClass(this.pCurMarkeredNode.pNode, 'bxst-sicked');
12058		}
12059
12060		if (node)
12061		{
12062			this.pCurMarkeredNode = {pNode: node};
12063
12064			if (node.onclick)
12065				this.pCurMarkeredNode.onclick = node.onclick;
12066			if (node.onmousedown)
12067				this.pCurMarkeredNode.onmousedown = node.onmousedown;
12068
12069			node.onmousedown = BX.proxy(this.OnMousedown, this);
12070			node.onclick = function(){return BX.PreventDefault(arguments[0]);};
12071
12072			BX.addClass(node, 'bxst-sicked');
12073		}
12074		else
12075		{
12076			this.pCurMarkeredNode = false;
12077		}
12078	},
12079
12080	CreateMarker: function(oMarker)
12081	{
12082		if (!oMarker)
12083			return;
12084
12085		var oSt = this.arStickers[oMarker.StickerInd];
12086
12087		if (oMarker.node)
12088		{
12089			oSt.pMarkerNode = oMarker.node;
12090			oSt.obj.marker = {adjust: this.GetNodeAdjustInfo(oMarker.node)};
12091
12092			var pos = BX.pos(oSt.pMarkerNode);
12093			if (pos)
12094			{
12095				oSt.obj.marker.top = pos.top - 2;
12096				oSt.obj.marker.left = pos.left - 2;
12097				oSt.obj.marker.width = pos.width - 4;
12098				oSt.obj.marker.height = pos.height - 4;
12099			}
12100		}
12101		else
12102		{
12103			oSt.obj.marker = {
12104				top: oMarker.top,
12105				left: oMarker.left,
12106				width: oMarker.width,
12107				height: oMarker.height
12108			};
12109
12110			this.InitMagicAdjust(oMarker.StickerInd);
12111		}
12112
12113		if (oSt.obj.marker && (oSt.obj.marker.adjust || (oSt.obj.marker.width && oSt.obj.marker.height && oSt.obj.marker.top && oSt.obj.marker.left)))
12114		{
12115			this.DisplayMarker(oMarker.StickerInd, true);
12116			this.AdjustStickerToArea(oMarker.StickerInd);
12117		}
12118
12119		if (this.oMarker.pWnd)
12120			this.oMarker.pWnd.style.display = "none";
12121
12122		if (!oSt.pWin.__stWasDragged)
12123			this.SaveSticker(oMarker.StickerInd);
12124	},
12125
12126	DisplayMarker: function(ind, bNew)
12127	{
12128		var oSt = this.arStickers[ind];
12129		if (oSt.pMarker)
12130			oSt.pMarker.style.display = "none";
12131
12132		if (oSt.obj.marker && oSt.obj.marker.adjust)
12133		{
12134			if (!oSt.pMarkerNode)
12135				oSt.pMarkerNode = this.FindMarkerNode(oSt.obj.marker.adjust);
12136
12137			if (oSt.pMarkerNode)
12138			{
12139				var pos = BX.pos(oSt.pMarkerNode);
12140				if (pos)
12141				{
12142					if (!oSt.pMarker)
12143						oSt.pMarker = document.body.appendChild(BX.create('DIV', {props: {className: 'bxst-sticker-marker ' + this.colorSchemes[oSt.obj.colorInd].name}}));
12144
12145					if (bNew)
12146						BX.addClass(oSt.pMarker, "bxst-marker-over");
12147
12148					oSt.pMarker.style.display = "";
12149					oSt.pMarker.style.width = (pos.width - 4) + "px";
12150					oSt.pMarker.style.height = (pos.height - 4) + "px";
12151					oSt.pMarker.style.top = (pos.top - 2) + "px";
12152					oSt.pMarker.style.left = (pos.left - 2) + "px";
12153				}
12154
12155				//return BX.addClass(oSt.pMarkerNode, 'bxst-sicked'); // We find node and select it
12156				BX.removeClass(oSt.pMarkerNode, 'bxst-sicked');
12157				return; // We find node and select it
12158			}
12159		}
12160
12161		// Select area
12162		if (oSt.obj.marker && oSt.obj.marker.width > 0)
12163		{
12164			if (!oSt.pMarker)
12165				oSt.pMarker = document.body.appendChild(BX.create('DIV', {props: {className: 'bxst-sticker-marker ' + this.colorSchemes[oSt.obj.colorInd].name}}));
12166
12167			if (bNew)
12168				BX.addClass(oSt.pMarker, "bxst-marker-over");
12169
12170			oSt.pMarker.style.display = "";
12171			oSt.pMarker.style.width = oSt.obj.marker.width + "px";
12172			oSt.pMarker.style.height = oSt.obj.marker.height + "px";
12173			oSt.pMarker.style.top = oSt.obj.marker.top + "px";
12174			oSt.pMarker.style.left = oSt.obj.marker.left + "px";
12175		}
12176	},
12177
12178	InitMagicAdjust: function(ind)
12179	{
12180		return;
12181
12182		if (!this.magicNodes)
12183		{
12184			var arLinks = document.getElementsByTagName('A');
12185			// var arImgs = document.getElementsByTagName('IMG');
12186			// var arDivs = document.getElementsByTagName('DIV');
12187
12188
12189			var i, len, el, nodes = [], w, h, t, l;
12190
12191			//
12192			len = arLinks.length;
12193
12194			for (i = 0; i < len; i++)
12195			{
12196				//w = arLinks[i].offsetWidth;
12197				//h = arLinks[i].offsetHeight;
12198				// t = arLinks[i].offsetTop;
12199				// l = arLinks[i].offsetLeft;
12200
12201				//console.info(w, h, t, l);
12202
12203				//if (w > 0 && h > 0 && t > 0 && l > 0)
12204				if (arLinks[i].offsetWidth > 0)
12205				{
12206					var pos = BX.pos(arLinks[i]);
12207					nodes.push({el: arLinks[i], pos: pos});
12208
12209					//nodes.push({el: arLinks[i], w: w, h: h, t: t, l: l, r: l + w, b: t + h});
12210				}
12211			}
12212
12213			this.magicNodes = {
12214				nodes: nodes
12215			};
12216		}
12217
12218		//return;
12219		var
12220			node,
12221			oSt = this.arStickers[ind],
12222			mTop = oSt.obj.marker.top,
12223			mLeft = oSt.obj.marker.left,
12224			mWidth = oSt.obj.marker.width,
12225			mHeight = oSt.obj.marker.height,
12226			mRight = mLeft + mWidth,
12227			mBottom = mTop + mHeight;
12228
12229		len = this.magicNodes.nodes.length;
12230		for (i = 0; i < len; i++)
12231		{
12232			node = this.magicNodes.nodes[i];
12233			// if (node.el.id == 'ch1')
12234				// console.dir(node);
12235
12236			if (node.pos.top >= mTop && node.pos.left >= mLeft && node.pos.right <= mRight && node.pos.bottom <= mBottom)
12237			{
12238				//console.info(node.el);
12239			}
12240		}
12241
12242		// oSt.obj.marker = {
12243			// top: oMarker.top,
12244			// left: oMarker.left,
12245			// width: oMarker.width,
12246			// height: oMarker.height
12247		// };
12248	},
12249
12250	GetNodeAdjustInfo: function(node)
12251	{
12252		var nodeInfo = this._GetNodeAdjustInfo(node);
12253		nodeInfo = this._GetNodeAdjustSiblings(node, nodeInfo);
12254		return nodeInfo;
12255	},
12256
12257	_GetNodeAdjustInfo: function(node)
12258	{
12259		var nodeInfo = {
12260			nodeName: node.nodeName.toLowerCase(),
12261			attr: {},
12262			innerHTML: null
12263		};
12264
12265		if (node.innerHTML && node.innerHTML.length)
12266		{
12267			nodeInfo.innerHTML = BX.util.trim(node.innerHTML.toLowerCase());
12268
12269			nodeInfo.innerHTML = nodeInfo.innerHTML.replace(/class=""/ig, '');
12270			nodeInfo.innerHTML = nodeInfo.innerHTML.replace(/class=''/ig, '');
12271			nodeInfo.innerHTML = nodeInfo.innerHTML.replace(/\n+/ig, '');
12272			nodeInfo.innerHTML = nodeInfo.innerHTML.replace(/\r+/ig, '');
12273			nodeInfo.innerHTML = nodeInfo.innerHTML.replace(/\s+/ig, ' ');
12274
12275			if (nodeInfo.innerHTML.length > 250)
12276				nodeInfo.innerHTML = nodeInfo.innerHTML.substr(0, 250);
12277		}
12278
12279		if (node.attributes)
12280		{
12281			var i, l = node.attributes.length;
12282			for (i = 0; i < l; i++)
12283			{
12284				name = node.attributes[i].name;
12285				if (!name || typeof name != 'string')
12286					continue;
12287				name = name.toLowerCase();
12288				if (this.oMarkerConfig.attr[name])
12289				{
12290					val = node.attributes[i].value;
12291					if (name == 'class' || name == 'classname')
12292					{
12293						name = 'classname';
12294						val = val.replace('bxst-sicked', '');
12295						val = BX.util.trim(val);
12296					}
12297
12298					if (val.length > 0)
12299						nodeInfo.attr[name] = val;
12300				}
12301			}
12302		}
12303		return nodeInfo;
12304	},
12305
12306	_GetNodeAdjustSiblings: function(node, nodeInfo)
12307	{
12308		nodeInfo.withId = {};
12309
12310		var pParent = BX.findParent(node, {attr : {id: new RegExp('.+', 'ig')}});
12311		if (pParent)
12312			nodeInfo.withId.parent = pParent.getAttribute('id');
12313
12314		var pChildren = BX.findChild(node, {attr : {id: new RegExp('.+', 'ig')}}, true, true);
12315		if (pChildren)
12316		{
12317			nodeInfo.withId.children = [];
12318			for (var i = 0, l = pChildren.length; i < l; i++)
12319				nodeInfo.withId.children.push(pChildren[i].getAttribute('id'));
12320		}
12321
12322		var pPrevSibling = BX.findPreviousSibling(node, {attr : {id: new RegExp('.+', 'ig')}});
12323		if (pPrevSibling)
12324			nodeInfo.withId.prevSibling = pPrevSibling.getAttribute('id');
12325
12326		var pNextSibling = BX.findNextSibling(node, {attr : {id: new RegExp('.+', 'ig')}});
12327		if (pNextSibling)
12328			nodeInfo.withId.nextSibling = pNextSibling.getAttribute('id');
12329
12330		return nodeInfo;
12331	},
12332
12333	FindMarkerNode: function(nodeInfo)
12334	{
12335		var node = false;
12336		if (!nodeInfo || !nodeInfo.nodeName)
12337			return false;
12338
12339		if (!nodeInfo.attr)
12340			nodeInfo.attr = {};
12341
12342		// Simple and easy way
12343		if (nodeInfo.attr.id)
12344			node = BX(nodeInfo.attr.id);
12345
12346		var arFindedNodes = [];
12347		var res;
12348
12349		if (!node)
12350		{
12351			if (!nodeInfo.withId)
12352				nodeInfo.withId = {};
12353
12354			// Find by prev sibling
12355			if (nodeInfo.withId.prevSibling)
12356			{
12357				var nextNode = BX(nodeInfo.withId.prevSibling);
12358				if (nextNode)
12359				{
12360					while(nextNode = nextNode.nextSibling)
12361					{
12362						res = this.TestNodeWithAttributes(nextNode, nodeInfo);
12363						if (res)
12364							arFindedNodes.push(res);
12365
12366						if (res.coincide == 100)
12367							break;
12368					}
12369				}
12370			}
12371
12372			// Find by next sibling
12373			if (nodeInfo.withId.nextSibling)
12374			{
12375				var prevNode = BX(nodeInfo.withId.nextSibling);
12376				if (prevNode)
12377				{
12378					while(prevNode = prevNode.previousSibling)
12379					{
12380						res = this.TestNodeWithAttributes(prevNode, nodeInfo);
12381						if (res)
12382							arFindedNodes.push(res);
12383
12384						if (res.coincide == 100)
12385							break;
12386					}
12387				}
12388			}
12389
12390			// Find by child
12391			if (nodeInfo.withId.children)
12392			{
12393				var i, l = nodeInfo.withId.children.length, child, parNode;
12394				for (i = 0; i < l; i++)
12395				{
12396					child = BX(nodeInfo.withId.children[i]);
12397					if (child)
12398					{
12399						parNode = child;
12400						while (true)
12401						{
12402							parNode = BX.findParent(parNode, {tagName: nodeInfo.nodeName});
12403							if (!parNode)
12404								break;
12405
12406							res = this.TestNodeWithAttributes(prevNode, nodeInfo);
12407							if (res)
12408								arFindedNodes.push(res);
12409
12410							if (res.coincide == 100)
12411								break;
12412						}
12413					}
12414				}
12415			}
12416
12417			// Find by parent
12418			var parent;
12419			if (nodeInfo.withId.parent)
12420				parent = BX(nodeInfo.withId.parent);
12421			if (!parent)
12422				parent = document.body;
12423
12424			var arAllNodes = parent.getElementsByTagName(nodeInfo.nodeName);
12425			var i, l = arAllNodes.length;
12426			for (i = 0; i < l; i++)
12427			{
12428				res = this.TestNodeWithAttributes(arAllNodes[i], nodeInfo);
12429				if (res)
12430					arFindedNodes.push(res);
12431				if (res.coincide == 100)
12432					break;
12433			}
12434		}
12435		else
12436		{
12437			arFindedNodes.push({coincide: 100, node: node, bImpAttrCoincide: true});
12438		}
12439
12440		var i, l = arFindedNodes.length;
12441		var arRealNodes = [], maxCoincide = 0, mostRealNode = false;
12442
12443		for (i = 0; i < l; i++)
12444		{
12445			if (arFindedNodes[i].coincide > maxCoincide)
12446			{
12447				maxCoincide = arFindedNodes[i].coincide;
12448				mostRealNode = arFindedNodes[i].node;
12449				arRealNodes = [];
12450			}
12451
12452			if (arFindedNodes[i].coincide == maxCoincide && arFindedNodes[i].node != mostRealNode)
12453				arRealNodes.push(arFindedNodes[i].node);
12454		}
12455
12456		if (arRealNodes.length == 0 && mostRealNode)
12457			return mostRealNode;
12458		else
12459			arRealNodes[0];
12460
12461		return false;
12462	},
12463
12464	TestNodeWithAttributes: function(pNode, nodeInfo)
12465	{
12466		if (!pNode || !pNode.nodeName)
12467			return false;
12468
12469		var res = {coincide: 0, node: pNode};
12470		var info = this._GetNodeAdjustInfo(pNode);
12471
12472		if (info.nodeName != nodeInfo.nodeName)
12473			return false;
12474
12475		var delta = 0;
12476		var bInnerHTML = typeof nodeInfo.innerHTML == 'string';
12477		if (typeof info.innerHTML != 'string' && bInnerHTML)
12478			return false;
12479
12480		var count = 0;
12481		for (i in nodeInfo.attr)
12482			if (typeof nodeInfo.attr[i] == 'string')
12483				count++;
12484
12485		if (count > 0)
12486		{
12487			delta = 100 / (count + (bInnerHTML ? 1 : 0));
12488			var bImpAttrCoincide = true;
12489
12490			for (i in nodeInfo.attr)
12491			{
12492				if (typeof nodeInfo.attr[i] == 'string')
12493				{
12494					// We have similar attributes
12495					if (nodeInfo.attr[i] == info.attr[i])
12496						res.coincide += delta;
12497					else if (this.oMarkerConfig.impAttr[i])
12498						bImpAttrCoincide = false;
12499				}
12500			}
12501
12502			res.bImpAttrCoincide = bImpAttrCoincide;
12503		}
12504
12505		if (bInnerHTML && info.innerHTML == nodeInfo.innerHTML)
12506			res.coincide += count > 0 ? delta : 95;
12507		res.coincide = Math.round(res.coincide);
12508
12509		if (res.coincide > 0)
12510			return res;
12511		return false;
12512	},
12513
12514	OnDivMouseOver: function(ind, bOver)
12515	{
12516		var oSt = this.arStickers[ind];
12517		if (oSt.bSetMarkerMode)
12518			return this.ShowButtonsPanel(ind, true, false);
12519
12520		oSt._over = bOver;
12521
12522		if (oSt._overTimeout)
12523			clearTimeout(oSt._overTimeout);
12524
12525		var _this = this;
12526		oSt._overTimeout = setTimeout(function()
12527		{
12528			if (oSt._over == bOver)
12529			{
12530				_this.ShowButtonsPanel(ind, bOver);
12531				_this.Hightlight(ind, bOver);
12532			}
12533		}, bOver ? 100 : 500);
12534	},
12535
12536	ShowButtonsPanel: function(ind, bShow, bEffects)
12537	{
12538		if (!this.Params.bHideBottom)
12539		{
12540			bShow = true;
12541			bEffects = false;
12542		}
12543
12544		bEffects = bEffects !== false;
12545
12546		var
12547			_this = this,
12548			oSt = this.arStickers[ind],
12549			h = 24, d = 3, i = 1,
12550			curHeight = oSt.obj.height - (oSt.bButPanelShowed ? 0 : h),
12551			resHeight = curHeight + h * (bShow ? 1 : -1),
12552			time = BX.browser.IsIE() ? 3 : 10;
12553
12554		if (this.bSelectAreaMode || this.bHightlightElementMode // Set marker mode
12555		|| oSt.obj.collapsed || oSt.obj.closed || oSt.bColSelShowed || oSt.bResizingNow) // Sticker params
12556			return;
12557
12558		if (oSt.bButPanelShowed == bShow)
12559		{
12560			oSt.pWin.Get().style.height = curHeight + 'px';
12561			return this.AdjustShadow(ind);
12562		}
12563
12564		var sbpInterval = setInterval(function()
12565		{
12566			curHeight += d * i * (bShow ? 1 : -1 );
12567			if (bShow && curHeight >= resHeight || !bShow && curHeight <= resHeight)
12568				curHeight = resHeight;
12569
12570			oSt.pWin.Get().style.height = curHeight + 'px';
12571			_this.AdjustShadow(ind);
12572
12573			if (curHeight == resHeight)
12574			{
12575				clearInterval(sbpInterval);
12576				oSt.bButPanelShowed = bShow;
12577			}
12578
12579			i++;
12580		}, time);
12581	},
12582
12583	ShowColorSelector: function(ind)
12584	{
12585		var
12586			_this = this,
12587			oSt = this.arStickers[ind], b;
12588
12589		if (!oSt)
12590			return;
12591
12592		if (!oSt.pColSelector)
12593		{
12594			oSt.pColSelector = document.body.appendChild(BX.create("DIV", {props: {className: 'bxst-col-sel'}}));
12595			for (var i = 0, l = this.colorSchemes.length; i < l; i++)
12596			{
12597				b = oSt.pColSelector.appendChild(BX.create("SPAN", {props: {id: 'bxst_' + ind + '_' + i, className: 'bxst-col-pic ' + this.colorSchemes[i].name, title: this.colorSchemes[i].title}}));
12598				b.onclick = function(){
12599					_this.ChangeColor(ind, parseInt(this.id.substr(('bxst_' + ind + '_').length)), true, true);
12600					_this.ShowColorSelector(ind); // Hide
12601				};
12602			}
12603			oSt.pColSelector.style.zIndex = this.Params.zIndex + 20;
12604		}
12605
12606		oSt.bColSelShowed = !oSt.bColSelShowed;
12607		if (oSt.bColSelShowed)
12608		{
12609			var pos = BX.pos(oSt.pColorBut);
12610			oSt.pColSelector.style.top = (parseInt(pos.top) + 16) + "px";
12611			oSt.pColSelector.style.left = (pos.left) + "px";
12612			oSt.pColSelector.style.display = "block";
12613
12614			this.ShowOverlay(true, this.Params.zIndex + 15);
12615			this.pTransOverlay.onmousedown = function(){_this.ShowColorSelector(ind);};
12616			BX.bind(document, 'keydown', BX.proxy(function(e){this.OnKeyDown(e, ind);}, this));
12617		}
12618		else //hide
12619		{
12620			oSt.pColSelector.style.display = "none";
12621			this.ShowOverlay(false);
12622			BX.unbind(document, 'keydown', BX.proxy(function(e){this.OnKeyDown(e, ind);}, this));
12623		}
12624	},
12625
12626	ShowOverlay: function(bShow, zIndex)
12627	{
12628		if (!this.pTransOverlay)
12629			this.pTransOverlay = document.body.appendChild(BX.create('DIV', {props: {className: 'bxst-trans-overlay'}}));
12630
12631		if (bShow)
12632		{
12633			this.pTransOverlay.style.display = "block";
12634			this.pTransOverlay.style.zIndex = zIndex || 800;
12635
12636			// Adjust overlay to size
12637			var ss = BX.GetWindowScrollSize(document);
12638			this.pTransOverlay.style.width = ss.scrollWidth + "px";
12639			this.pTransOverlay.style.height = ss.scrollHeight + "px";
12640		}
12641		else
12642		{
12643			this.pTransOverlay.style.display = "none";
12644			this.pTransOverlay.onmousedown = BX.False;
12645		}
12646	},
12647
12648	OnKeyDown: function(e, ind)
12649	{
12650		if(!e)
12651			e = window.event;
12652
12653		var key = e.which || e.keyCode;
12654		if (key == 27) // Esc
12655		{
12656			var oSt = this.arStickers[ind];
12657			if (oSt && oSt.bColSelShowed)
12658				this.ShowColorSelector(ind); // Hide
12659		}
12660	},
12661
12662	SupaFlySticker: function()
12663	{
12664		return;
12665		var windowSize = BX.GetWindowInnerSize();
12666
12667		var
12668			st_w = 350, // Sticker width
12669			st_h = 200, // sticker height
12670			st_left = 1125, // sticker left
12671			st_top = 100, // Sticker top
12672			st_x = Math.round(st_left + st_w / 2), // Sticker center X
12673			st_y = Math.round(st_top + st_h / 2), // Sticker center Y
12674			win_w = windowSize.innerWidth,
12675			win_h = windowSize.innerHeight,
12676			x0 = Math.round(win_w / 2),
12677			y0 = Math.round(win_h / 2);
12678
12679		// console.info('x0 = ', x0, 'y0 = ', y0);
12680		// console.info('st_x = ', st_x, 'st_y = ', st_y);
12681
12682		// A * x + B * y + C = 0
12683		var A = y0 - st_y;
12684		var B = st_x - x0;
12685		var C = (x0 * st_y) - (y0 * st_x);
12686
12687		//console.info('A = ', A, 'B = ', B, 'C = ', C);
12688
12689		//var start_x = win_w;
12690		//var start_y = - (C + A * start_x) / B;
12691		//console.info(start_x, start_y);
12692		//var k = st_x / st_y;
12693		//console.info(k);
12694
12695		//Center
12696		var div = document.body.appendChild(BX.create("DIV", {style: {background: "#00f", position: "absolute", width: "5px", height: "5px", zIndex: 2000}}));
12697		div.style.left = x0 + "px";
12698		div.style.top = y0 + "px";
12699
12700		//Center
12701		var div = document.body.appendChild(BX.create("DIV", {style: {background: "#0f0", position: "absolute", width: "5px", height: "5px", zIndex: 2000}}));
12702		div.style.left = st_x + "px";
12703		div.style.top = st_y + "px";
12704
12705		//return;
12706		// var x = x0;
12707		// for (var i = 0; i < 200; i++)
12708		// {
12709			// var div = document.body.appendChild(BX.create("DIV", {style: {background: "red", position: "absolute", width: "2px", height: "2px", zIndex: 2000}}));
12710
12711			// var start_x = x;
12712			// var start_y = - (C + A * start_x) / B;
12713
12714			// div.style.left = Math.round(start_x) + "px";
12715			// div.style.top = Math.round(start_y) + "px";
12716
12717			// x += 10;
12718			// //console.info(div);
12719		// }
12720
12721		// var start_x = win_w;
12722		// var start_y = - (C + A * start_x) / B;
12723
12724		var start_y = 0;
12725		var start_x = - (C + B * start_y) / A;
12726
12727		var div = document.body.appendChild(BX.create("DIV", {style: {background: "red", position: "absolute", width: "10px", height: "10px", zIndex: 2000}}));
12728		div.style.left = start_x + "px";
12729		div.style.top = start_y + "px";
12730		//console.info(div);
12731
12732		return;
12733		//var start_x = Math.round((win_w + st_w) / 2  + win_w / 2);
12734		var start_x = win_w;
12735		var start_y = Math.round(start_x / k - win_h / 2);
12736
12737		var start_left = Math.round(start_x + st_w / 2);
12738		var start_top = Math.round(start_y - st_h / 2);
12739
12740		var div = document.body.appendChild(BX.create("DIV", {style: {background: "#ffff80", position: "absolute", width: st_w + "px", height: st_h + "px", zIndex: 2000}}));
12741
12742		div.style.left = start_left + "px";
12743		div.style.top = start_top + "px";
12744	},
12745
12746	Hightlight: function(ind, bOver)
12747	{
12748		var
12749			oSt = this.arStickers[ind];
12750
12751		if (oSt.bOver === bOver)
12752			return;
12753
12754		oSt.bOver = bOver;
12755		if (bOver)
12756		{
12757			if (oSt.pMarker)
12758				BX.addClass(oSt.pMarker, "bxst-marker-over");
12759
12760			BX.addClass(oSt.pWin.Get(), "bx-sticker-over");
12761			BX.addClass(oSt.pHead, "bxst-header-over");
12762
12763			oSt.pWin.Get().style.top = (parseInt(oSt.pWin.Get().style.top) - 1) + "px";
12764			oSt.pWin.Get().style.left = (parseInt(oSt.pWin.Get().style.left) - 1) + "px";
12765		}
12766		else
12767		{
12768			if (oSt.pMarker)
12769				BX.removeClass(oSt.pMarker, "bxst-marker-over");
12770
12771			BX.removeClass(oSt.pWin.Get(), "bx-sticker-over");
12772			BX.removeClass(oSt.pHead, "bxst-header-over");
12773			oSt.pWin.Get().style.top = (parseInt(oSt.pWin.Get().style.top) + 1) + "px";
12774			oSt.pWin.Get().style.left = (parseInt(oSt.pWin.Get().style.left) + 1) + "px";
12775		}
12776	},
12777
12778	BlinkRed: function(ind)
12779	{
12780		var
12781			_this = this,
12782			rep = 4,
12783			it = 0, it0 =0, interval,
12784			oSt = this.arStickers[ind];
12785
12786		if (!this.pBlinkRed)
12787			this.pBlinkRed = document.body.appendChild(BX.create("DIV", {props: {className: 'bxst-blink-red'}}));
12788
12789		this.pBlinkRed.style.zIndex = parseInt(oSt.pWin.Get().style.zIndex) + 10;
12790		this.pBlinkRed.style.top = oSt.pWin.Get().style.top;
12791		this.pBlinkRed.style.left = oSt.pWin.Get().style.left;
12792		this.pBlinkRed.style.width = oSt.pWin.Get().style.width;
12793		this.pBlinkRed.style.height = oSt.pWin.Get().style.height;
12794
12795		bFadeIn = true;
12796		interval = setInterval(function()
12797		{
12798			if (it > 2)
12799			{
12800				if (bFadeIn)
12801				{
12802					_this.pBlinkRed.className = 'bxst-blink-red bx-sticker-op-3';
12803					it = 1;
12804				}
12805				else
12806				{
12807					_this.pBlinkRed.className = 'bxst-blink-red';
12808					it = 0;
12809				}
12810
12811				it0++;
12812				bFadeIn = !bFadeIn;
12813				if (it0 >= rep)
12814					clearInterval(interval);
12815
12816				return;
12817			}
12818
12819			if (bFadeIn)
12820				_this.pBlinkRed.className = 'bxst-blink-red bx-sticker-op-' 
12820+ it;
12821			else
12822				_this.pBlinkRed.className = 'bxst-blink-red bx-sticker-op-' + (3 - it);
12823			it++;
12824		}, BX.browser.IsIE() ? 30 : 60);
12825	},
12826
12827	ShowList: function(type)
12828	{
12829		if (!this.List)
12830			this.List = new BXStickerList(this);
12831
12832		this.List.Show(type);
12833	},
12834
12835	OnKeyUp: function(e)
12836	{
12837		if(!e)
12838			e = window.event;
12839
12840		var key = e.which || e.keyCode;
12841		if (key == 17) // Ctrl
12842		{
12843			var _this = this;
12844			this._bCtrlPressed = true;
12845			setTimeout(function(){_this._bCtrlPressed = false;}, 400);
12846		}
12847		else if (key == 16) // Shift
12848		{
12849			var _this = this;
12850			this._bShiftPressed = true;
12851			setTimeout(function(){_this._bShiftPressed = false;}, 400);
12852		}
12853		else if ((this._bShiftPressed || e.shiftKey)  && (e.ctrlKey || this._bCtrlPressed))
12854		{
12855			if (key == 83 && this.Params.access == 'W')  // CTRL + SHIFT + S
12856			{
12857				this.AddSticker();
12858				return BX.PreventDefault(e);
12859			}
12860			else if(key == 88) // CTRL + SHIFT + X
12861			{
12862				this.ShowAll();
12863				return BX.PreventDefault(e);
12864			}
12865			else if(key == 76) // CTRL + SHIFT + L
12866			{
12867				this.ShowList('current');
12868				return BX.PreventDefault(e);
12869			}
12870		}
12871	},
12872
12873	UpdateStickersCount: function()
12874	{
12875		if (this.curPageCount < 0 || isNaN(parseInt(this.curPageCount)))
12876			this.curPageCount = 0;
12877
12878		var pEl = BX.findChild(BX('bxst-show-sticker-icon'), {tagName: 'B'}, true);
12879		if (pEl)
12880			pEl.innerHTML = "(" + this.curPageCount + ")";
12881	}
12882};
12883
12884function BXStickerList(BXSticker)
12885{
12886	this.BXSticker = BXSticker;
12887	this.access = this.BXSticker.access;
12888	this.MESS = this.BXSticker.MESS;
12889	this.arCurPageIds = {};
12890}
12891
12892BXStickerList.prototype = {
12893	Show: function(type)
12894	{
12895		if (this.bShowed)
12896			return;
12897
12898		var Config = {
12899			content_url: '/bitrix/admin/fileman_stickers.php?sticker_action=show_list&' + this.BXSticker.sessid_get + '&cur_page=' + this.BXSticker.Params.pageUrl + '&type=' + type + '&site_id=' + this.BXSticker.Params.site_id,
12900			title : this.MESS.StickerListTitle,
12901			width: this.BXSticker.Params.listWidth,
12902			height: this.BXSticker.Params.listHeight,
12903			min_width: 800,
12904			min_height: 400,
12905			resizable: true,
12906			resize_id: 'bx_sticker_list_resize_id'
12907		};
12908
12909		this.type = type;
12910		this.bRefreshPage = false;
12911		this.naviSize = this.BXSticker.Params.listNaviSize;
12912		this.oDialog = new BX.CDialog(Config);
12913		this.oDialog.Show();
12914		this.oDialog.SetButtons([this.oDialog.btnClose]);
12915		this.bShowed = true;
12916
12917		var _this = this;
12918		BX.addCustomEvent(this.oDialog, 'onWindowUnRegister', function()
12919		{
12920			_this.bShowed = false;
12921			if (_this.bRefreshPage)
12922				window.location = window.location;
12923		});
12924		//BX.addCustomEvent(this.oDialog, 'onWindowResize', function(){_this.AdjustToSize();});
12925
12926		// Adjust Navi size
12927		BX.addCustomEvent(this.oDialog, 'onWindowResizeFinished', function(){_this.AdjustNaviSize();});
12928		BX.addCustomEvent(this.oDialog, 'onWindowExpand', function(){_this.AdjustNaviSize();});
12929		BX.addCustomEvent(this.oDialog, 'onWindowNarrow', function(){_this.AdjustNaviSize();});
12930	},
12931
12932	OnLoad: function(count)
12933	{
12934		this.pAllBut = BX('bxstl_fil_all_but');
12935		this.pMyBut = BX('bxstl_fil_my_but');
12936		this.pColorCont = BX('bxstl_col_cont');
12937		this.pOpenedBut = BX('bxstl_fil_opened_but');
12938		this.pClosedBut = BX('bxstl_fil_closed_but');
12939		this.pAllStickersBut = BX('bxstl_fil_all_p_but');
12940
12941		this.pItemsTable = BX('bxstl_items_table');
12942		this.pItemsTableCnt = BX('bxstl_items_table_cnt');
12943		this.pNaviCont = BX('bxstl_navi_cont');
12944
12945		if (this.access == 'W')
12946		{
12947			this.pActionSel = BX('bxstl_action_sel');
12948			this.pActionBut = BX('bxstl_action_ok');
12949		}
12950
12951		this.pPageSelect = BX('bxstl_fil_page_sel');
12952
12953		if (this.type == 'current')
12954		{
12955			this.BXSticker.Params.filterParams.status = 'all';
12956			this.BXSticker.Params.filterParams.page = 'current';
12957		}
12958		else if (this.type == 'all')
12959		{
12960			this.BXSticker.Params.filterParams.status = 'opened';
12961			this.BXSticker.Params.filterParams.page = 'all';
12962		}
12963
12964		var _this = this;
12965		var _col = this.BXSticker.Params.filterParams.colors;
12966		if (_col && _col != 'all' && _col.length > 0)
12967		{
12968			this.checkedColors = [false, false, false, false, false, false];
12969			for (var i = 0, l = _col.length; i < l; i++)
12970				if (_col[i] != 99)
12971					this.checkedColors[parseInt(_col[i])] = true;
12972		}
12973		else
12974		{
12975			this.checkedColors = [true, true, true, true, true, true];
12976		}
12977
12978		if (!this.bRefreshPage && window.__bxst_result.cur_page_ids !== false && typeof window.__bxst_result.cur_page_ids == 'object')
12979		{
12980			for (var i in window.__bxst_result.cur_page_ids)
12981				this.arCurPageIds[parseInt(window.__bxst_result.cur_page_ids[i])] = true;
12982		}
12983
12984		/* Colors filter*/
12985		var i, l = this.BXSticker.colorSchemes.length, col, pCol, __s = (BX.browser.IsIE() && !BX.browser.IsDoctype()) ? 'style="width: 12px; height: 12px"' : '';
12986		for (i = 0; i < l; i++)
12987		{
12988			col = this.BXSticker.colorSchemes[i];
12989			pCol = this.pColorCont.appendChild(BX.create("DIV", {props: {id: 'bxstl_color_' + i, className: 'bxstl-color-pick' + (this.checkedColors[i] ? ' bxstl-color-pick-ch' : ''), title: col.title}, html: '<div class="bxstl-col-pic-l"></div><div class="bxstl-col-pic-c"><div class="' + col.name + '" ' + __s + '>&nbsp;</div></div><div class="bxstl-col-pic-r"></div>'}));
12990			pCol.onclick = function()
12991			{
12992				var colorInd = parseInt(this.id.substr('bxstl_color_'.length));
12993				_this.checkedColors[colorInd] = !_this.checkedColors[colorInd];
12994				if (_this.checkedColors[colorInd])
12995					BX.addClass(this, 'bxstl-color-pick-ch');
12996				else
12997					BX.removeClass(this, 'bxstl-color-pick-ch');
12998
12999				_this.ReloadList();
13000			};
13001		}
13002
13003		/* Stickers type: my | all*/
13004		this.SetStickerType(this.BXSticker.Params.filterParams.type, false);
13005		this.pAllBut.onclick = function(){_this.SetStickerType('all')};
13006		this.pMyBut.onclick = function(){_this.SetStickerType('my')};
13007
13008		/* Stickers status: opened | closed | all*/
13009		this.SetStickerStatus(this.BXSticker.Params.filterParams.status, false);
13010		this.pOpenedBut.onclick = function(){_this.SetStickerStatus('opened');};
13011		this.pClosedBut.onclick = function(){_this.SetStickerStatus('closed');};
13012		this.pAllStickersBut.onclick = function(){_this.SetStickerStatus('all');};
13013
13014		if (this.access == 'W')
13015			this.pActionBut.onclick = function(){_this.Action();};
13016		this.pPageSelect.onchange = function(){_this.SetPage(this.value);};
13017
13018		this.SetPage(this.BXSticker.Params.filterParams.page == 'current' ? this.BXSticker.Params.pageUrl : this.BXSticker.Params.filterParams.page, false);
13019
13020		count = parseInt(count);
13021		this.oDialog.SetTitle(this.MESS.StickerListTitle + " (" + count + ")");
13022
13023		this.EnableActionBut(false);
13024		//this.AdjustToSize();
13025	},
13026
13027	SetStickerStatus: function(status, bReload)
13028	{
13029		if (status == 'opened')
13030		{
13031			BX.addClass(this.pOpenedBut, 'bxstl-but-checked');
13032			BX.removeClass(this.pClosedBut, 'bxstl-but-checked');
13033			BX.removeClass(this.pAllStickersBut, 'bxstl-but-checked');
13034		}
13035		else if (status == 'closed')
13036		{
13037			BX.removeClass(this.pOpenedBut, 'bxstl-but-checked');
13038			BX.addClass(this.pClosedBut, 'bxstl-but-checked');
13039			BX.removeClass(this.pAllStickersBut, 'bxstl-but-checked');
13040		}
13041		else
13042		{
13043			BX.removeClass(this.pOpenedBut, 'bxstl-but-checked');
13044			BX.removeClass(this.pClosedBut, 'bxstl-but-checked');
13045			BX.addClass(this.pAllStickersBut, 'bxstl-but-checked');
13046		}
13047
13048		this.StickersStatus = status;
13049		if (bReload !== false)
13050			this.ReloadList();
13051	},
13052
13053	SetStickerType: function(type, bReload)
13054	{
13055		if (type == 'all')
13056		{
13057			BX.addClass(this.pAllBut, 'bxstl-but-checked');
13058			BX.removeClass(this.pMyBut, 'bxstl-but-checked');
13059		}
13060		else
13061		{
13062			BX.addClass(this.pMyBut, 'bxstl-but-checked');
13063			BX.removeClass(this.pAllBut, 'bxstl-but-checked');
13064		}
13065
13066		this.StickersType = type;
13067		if (bReload !== false)
13068			this.ReloadList();
13069	},
13070
13071	SetPage: function(value, bReload)
13072	{
13073		this.pPageSelect.value = value;
13074		this.StickersPage = value;
13075
13076		if (bReload !== false)
13077			this.ReloadList();
13078	},
13079
13080	NaviGet: function(page, navNum)
13081	{
13082		var params = {};
13083		params['PAGEN_' + navNum] = page;
13084		this.ReloadList(params)
13085	},
13086
13087	ReloadList: function(params)
13088	{
13089		var _this = this;
13090		if (!params)
13091			params = {};
13092
13093		params.sticker_just_res = 'Y';
13094		params.colors = [99];
13095		params.sticker_type = this.StickersType;
13096		params.sticker_status = this.StickersStatus;
13097		params.sticker_page = this.StickersPage;
13098		params.navi_size = this.naviSize;
13099		params.cur_page = this.BXSticker.Params.pageUrl;
13100		params.type = this.type;
13101
13102		// Fetch filter color params
13103		var i, l = this.checkedColors.length;
13104		for (i = 0; i < l; i++)
13105			if (this.checkedColors[i] === true)
13106				params.colors.push(i);
13107
13108		window.__bxst_result.list_rows_count = false;
13109		window.__bxst_result.cur_page_ids = false;
13110		this.BXSticker.Request('show_list', params,
13111			function(result)
13112			{
13113				var arRes = result.split('#BX_STICKER_SPLITER#');
13114				if (arRes.length == 2)
13115				{
13116					_this.pItemsTableCnt.innerHTML = arRes[0];
13117					_this.pNaviCont.innerHTML = arRes[1];
13118				}
13119
13120				// Display count of selected rows in title
13121				if (window.__bxst_result.list_rows_count !== false)
13122					_this.oDialog.SetTitle(_this.MESS.StickerListTitle + " (" + parseInt(window.__bxst_result.list_rows_count) + ")");
13123
13124				if (!_this.bRefreshPage && window.__bxst_result.cur_page_ids !== false && typeof window.__bxst_result.cur_page_ids == 'object')
13125				{
13126					for (var i in window.__bxst_result.cur_page_ids)
13127						_this.arCurPageIds[parseInt(window.__bxst_result.cur_page_ids[i])] = true;
13128				}
13129
13130				_this.pItemsTable = BX('bxstl_items_table');
13131				_this.EnableActionBut(false);
13132			}, true
13133		);
13134	},
13135
13136	AdjustToSize: function(w, h)
13137	{
13138		return;
13139		// if (typeof w == 'undefined' || typeof h == 'undefined')
13140		// {
13141			// w = parseInt(this.oDialog.GetContent().style.width);
13142			// h = parseInt(this.oDialog.GetContent().style.height);
13143		// }
13144
13145		// var
13146			// idW = 25, // ID
13147			// dateW = 150, // Date
13148			// colorW = 52, // Color
13149			// authorW = 120, // Author
13150			// actionW = 30, // Author
13151			// textW = titleW = Math.round((w - 20 - idW - dateW - colorW - authorW - actionW) / 2);
13152
13153		// var tr = this.pItemsTable.rows[0];
13154		// tr.cells[0].style.width = idW + 'px';
13155		// tr.cells[1].style.width = titleW + 'px'
13156		// tr.cells[2].style.width = dateW + 'px';
13157		// tr.cells[3].style.width = textW + 'px';
13158		// tr.cells[4].style.width = colorW + 'px';
13159		// tr.cells[5].style.width = authorW + 'px';
13160		// tr.cells[6].style.width = actionW + 'px';
13161
13162		//this.pItemsTableCnt.style.height = (h - 80 /* header */ - 80 /* footer */) + "px";
13163	},
13164
13165	AdjustNaviSize: function()
13166	{
13167		var
13168			newNaviSize,
13169			h = parseInt(this.oDialog.GetContent().style.height),
13170			rowHeight = 40,
13171			maxHeight = (h - 100 /* header */ - 80 /* footer */);
13172
13173		if (maxHeight != (rowHeight * this.naviSize))
13174			newNaviSize = Math.floor(maxHeight / rowHeight);
13175
13176		if (newNaviSize < 5)
13177			newNaviSize = 5;
13178		if (newNaviSize > 30)
13179			newNaviSize = 30;
13180
13181		if (this.naviSize != newNaviSize)
13182		{
13183			this.naviSize = newNaviSize;
13184			this.ReloadList();
13185		}
13186	},
13187
13188	CheckAll: function(checked)
13189	{
13190		var i, l = this.pItemsTable.rows.length, bFind = false;
13191		for (i = 1; i < l; i++)
13192		{
13193			if (this.pItemsTable.rows[i].cells.length == 7)
13194			{
13195				this.pItemsTable.rows[i].cells[6].firstChild.checked = !!checked;
13196				bFind = true;
13197			}
13198		}
13199
13200		if (bFind)
13201			this.EnableActionBut(checked);
13202	},
13203
13204	Action: function()
13205	{
13206		if (this.access != 'W')
13207			return;
13208
13209		var action = this.pActionSel.value;
13210		if (action == '' || (action == 'del' && !confirm(this.MESS.DelConfirm)))
13211			return;
13212
13213		var i, l = this.pItemsTable.rows.length, arIds = [];
13214		for (i = 1; i < l; i++)
13215		{
13216			if (this.pItemsTable.rows[i].cells.length < 7)
13217				continue;
13218			ch = this.pItemsTable.rows[i].cells[6].firstChild;
13219			if (ch.checked)
13220			{
13221				arIds.push(ch.value);
13222				if (!this.bRefreshPage && this.arCurPageIds[parseInt(ch.value)])
13223					this.bRefreshPage = true;
13224			}
13225		}
13226		this.ReloadList({list_action: action, list_ids: arIds});
13227	},
13228
13229	EnableActionBut: function(bEnable)
13230	{
13231		if (this.access != 'W')
13232			return;
13233
13234		if (bEnable == 'check')
13235		{
13236			var i, l = this.pItemsTable.rows.length, bEnable = false;
13237			for (i = 1; i < l; i++)
13238			{
13239				if (this.pItemsTable.rows[i].cells.length < 7)
13240					continue;
13241				if (this.pItemsTable.rows[i].cells[6].firstChild.checked)
13242				{
13243					bEnable = true;
13244					break;
13245				}
13246			}
13247		}
13248		this.pActionBut.disabled = !bEnable;
13249		this.pActionSel.disabled = !bEnable;
13250	}
13251};
13252
13253/* End */
13254;
13255; /* Start:/bitrix/js/main/utils.js*/
13256var phpVars;
13257if(!phpVars)
13258{
13259	phpVars = {
13260		ADMIN_THEME_ID: '.default',
13261		LANGUAGE_ID: 'en',
13262		FORMAT_DATE: 'DD.MM.YYYY',
13263		FORMAT_DATETIME: 'DD.MM.YYYY HH:MI:SS',
13264		opt_context_ctrl: false,
13265		cookiePrefix: 'BITRIX_SM',
13266		titlePrefix: '',
13267		bitrix_sessid: '',
13268		messHideMenu: '',
13269		messShowMenu: '',
13270		messHideButtons: '',
13271		messShowButtons: '',
13272		messFilterInactive: '',
13273		messFilterActive: '',
13274		messFilterLess: '',
13275		messLoading: 'Loading...',
13276		messMenuLoading: '',
13277		messMenuLoadingTitle: '',
13278		messNoData: '',
13279		messExpandTabs: '',
13280		messCollapseTabs: '',
13281		messPanelFixOn: '',
13282		messPanelFixOff: '',
13283		messPanelCollapse: '',
13284		messPanelExpand: ''
13285	};
13286}
13287
13288var jsUtils =
13289{
13290	arEvents: Array(),
13291
13292	addEvent: function(el, evname, func, capture)
13293	{
13294		if(el.attachEvent) // IE
13295			el.attachEvent("on" + evname, func);
13296		else if(el.addEventListener) // Gecko / W3C
13297			el.addEventListener(evname, func, false);
13298		else
13299			el["on" + evname] = func;
13300		this.arEvents[this.arEvents.length] = {'element': el, 'event': evname, 'fn': func};
13301	},
13302
13303	removeEvent: function(el, evname, func)
13304	{
13305		if(el.detachEvent) // IE
13306			el.detachEvent("on" + evname, func);
13307		else if(el.removeEventListener) // Gecko / W3C
13308			el.removeEventListener(evname, func, false);
13309		else
13310			el["on" + evname] = null;
13311	},
13312
13313	removeAllEvents: function(el)
13314	{
13315		var i;
13316		for(i=0; i<this.arEvents.length; i++)
13317		{
13318			if(this.arEvents[i] && (el==false || el==this.arEvents[i].element))
13319			{
13320				jsUtils.removeEvent(this.arEvents[i].element, this.arEvents[i].event, this.arEvents[i].fn);
13321				this.arEvents[i] = null;
13322			}
13323		}
13324		if(el==false)
13325			this.arEvents.length = 0;
13326	},
13327
13328	IsDoctype: function()
13329	{
13330		if (document.compatMode)
13331			return (document.compatMode == "CSS1Compat");
13332
13333		if (document.documentElement && document.documentElement.clientHeight)
13334			return true;
13335
13336		return false;
13337	},
13338
13339	GetRealPos: function(el)
13340	{
13341		if(window.BX)
13342			return BX.pos(el);
13343
13344		if(!el || !el.offsetParent)
13345			return false;
13346
13347		var res = Array();
13348		res["left"] = el.offsetLeft;
13349		res["top"] = el.offsetTop;
13350		var objParent = el.offsetParent;
13351
13352		while(objParent && objParent.tagName != "BODY")
13353		{
13354			res["left"] += objParent.offsetLeft;
13355			res["top"] += objParent.offsetTop;
13356			objParent = objParent.offsetParent;
13357		}
13358		res["right"] = res["left"] + el.offsetWidth;
13359		res["bottom"] = res["top"] + el.offsetHeight;
13360
13361		return res;
13362	},
13363
13364	FindChildObject: function(obj, tag_name, class_name, recursive)
13365	{
13366		if(!obj)
13367			return null;
13368		var tag = tag_name.toUpperCase();
13369		var cl = (class_name? class_name.toLowerCase() : null);
13370		var n = obj.childNodes.length;
13371		for(var j=0; j<n; j++)
13372		{
13373			var child = obj.childNodes[j];
13374			if(child.tagName && child.tagName.toUpperCase() == tag)
13375				if(!class_name || child.className.toLowerCase() == cl)
13376					return child;
13377			if(recursive == true)
13378			{
13379				var deepChild;
13380				if((deepChild = jsUtils.FindChildObject(child, tag_name, class_name, true)))
13381					return deepChild;
13382			}
13383		}
13384		return null;
13385	},
13386
13387	FindParentObject: function(obj, tag_name, class_name)
13388	{
13389		if(!obj)
13390			return null;
13391		var o = obj;
13392		var tag = tag_name.toUpperCase();
13393		var cl = (class_name? class_name.toLowerCase() : null);
13394		while(o.parentNode)
13395		{
13396			var parent = o.parentNode;
13397			if(parent.tagName && parent.tagName.toUpperCase() == tag)
13398				if(!class_name || parent.className.toLowerCase() == cl)
13399					return parent;
13400			o = parent;
13401		}
13402		return null;
13403	},
13404
13405	FindNextSibling: function(obj, tag_name)
13406	{
13407		if(!obj)
13408			return null;
13409		var o = obj;
13410		var tag = tag_name.toUpperCase();
13411		while(o.nextSibling)
13412		{
13413			var sibling = o.nextSibling;
13414			if(sibling.tagName && sibling.tagName.toUpperCase() == tag)
13415				return sibling;
13416			o = sibling;
13417		}
13418		return null;
13419	},
13420
13421	FindPreviousSibling: function(obj, tag_name)
13422	{
13423		if(!obj)
13424			return null;
13425		var o = obj;
13426		var tag = tag_name.toUpperCase();
13427		while(o.previousSibling)
13428		{
13429			var sibling = o.previousSibling;
13430			if(sibling.tagName && sibling.tagName.toUpperCase() == tag)
13431				return sibling;
13432			o = sibling;
13433		}
13434		return null;
13435	},
13436
13437	bOpera : navigator.userAgent.toLowerCase().indexOf('opera') != -1,
13438	bIsIE : document.attachEvent && navigator.userAgent.toLowerCase().indexOf('opera') == -1,
13439
13440	IsIE: function()
13441	{
13442		return this.bIsIE;
13443	},
13444
13445	IsOpera: function()
13446	{
13447		return this.bOpera;
13448	},
13449
13450	IsSafari: function()
13451	{
13452		var userAgent = navigator.userAgent.toLowerCase();
13453		return (/webkit/.test(userAgent));
13454	},
13455
13456	IsEditor: function()
13457	{
13458		var userAgent = navigator.userAgent.toLowerCase();
13459		var version = (userAgent.match( /.+(msie)[\/: ]([\d.]+)/ ) || [])[2];
13460		var safari = /webkit/.test(userAgent);
13461
13462		if (this.IsOpera() || (document.all && !document.compatMode && version < 6) || safari)
13463			return false;
13464
13465		return true;
13466	},
13467
13468	ToggleDiv: function(div)
13469	{
13470		var style = document.getElementById(div).style;
13471		if(style.display!="none")
13472			style.display = "none";
13473		else
13474			style.display = "block";
13475		return (style.display != "none");
13476	},
13477
13478	urlencode: function(s)
13479	{
13480		return escape(s).replace(new RegExp('\\+','g'), '%2B');
13481	},
13482
13483	OpenWindow: function(url, width, height)
13484	{
13485		var w = screen.width, h = screen.height;
13486		if(this.IsOpera())
13487		{
13488			w = document.body.offsetWidth;
13489			h = document.body.offsetHeight;
13490		}
13491		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));
13492	},
13493
13494	SetPageTitle: function(s)
13495	{
13496		document.title = phpVars.titlePrefix+s;
13497		var h1 = document.getElementsByTagName("H1");
13498		if(h1)
13499			h1[0].innerHTML = s;
13500	},
13501
13502	LoadPageToDiv: function(url, div_id)
13503	{
13504		var div = document.getElementById(div_id);
13505		if(!div)
13506			return;
13507		CHttpRequest.Action = function(result)
13508		{
13509			CloseWaitWindow();
13510			document.getElementById(div_id).innerHTML = result;
13511		}
13512		ShowWaitWindow();
13513		CHttpRequest.Send(url);
13514	},
13515
13516	trim: function(s)
13517	{
13518		if (typeof s == 'string' || typeof s == 'object' && s.constructor == String)
13519		{
13520			var r, re;
13521
13522			re = /^[\s\r\n]+/g;
13523			r = s.replace(re, "");
13524			re = /[\s\r\n]+$/g;
13525			r = r.replace(re, "");
13526			return r;
13527		}
13528		else
13529			return s;
13530	},
13531
13532	Redirect: function(args, url)
13533	{
13534		var e = null, bShift = false;
13535		if(args && args.length > 0)
13536			e = args[0];
13537		if(!e)
13538			e = window.event;
13539		if(e)
13540			bShift = e.shiftKey;
13541
13542		if(bShift)
13543			window.open(url);
13544		else
13545		{
13546			window.location.href=url;
13547		}
13548	},
13549
13550	False: function(){return false;},
13551
13552	AlignToPos: function(pos, w, h)
13553	{
13554		var x = pos["left"], y = pos["bottom"];
13555
13556		var scroll = jsUtils.GetWindowScrollPos();
13557		var size = jsUtils.GetWindowInnerSize();
13558
13559		if((size.innerWidth + scroll.scrollLeft) - (pos["left"] + w) < 0)
13560		{
13561			if(pos["right"] - w >= 0 )
13562				x = pos["right"] - w;
13563			else
13564				x = scroll.scrollLeft;
13565		}
13566
13567		if((size.innerHeight + scroll.scrollTop) - (pos["bottom"] + h) < 0)
13568		{
13569			if(pos["top"] - h >= 0)
13570				y = pos["top"] - h;
13571			else
13572				y = scroll.scrollTop;
13573		}
13574
13575		return {'left':x, 'top':y};
13576	},
13577
13578	// evaluate js string in window scope
13579	EvalGlobal: function(script)
13580	{
13581		try {
13582		if (window.execScript)
13583			window.execScript(script, 'javascript');
13584		else if (jsUtils.IsSafari())
13585			window.setTimeout(script, 0);
13586		else
13587			window.eval(script);
13588		} catch (e) {/*alert("Error! jsUtils.EvalGlobal");*/}
13589	},
13590
13591	GetStyleValue: function(el, styleProp)
13592	{
13593		var res;
13594		if(el.currentStyle)
13595			res = el.currentStyle[styleProp];
13596		else if(window.getComputedStyle)
13597			res = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
13598		if(!res)
13599			res = '';
13600		return res;
13601	},
13602
13603	GetWindowInnerSize: function(pDoc)
13604	{
13605		var width, height;
13606		if (!pDoc)
13607			pDoc = document;
13608
13609		if (self.innerHeight) // all except Explorer
13610		{
13611			width = self.innerWidth;
13612			height = self.innerHeight;
13613		}
13614		else if (pDoc.documentElement && (pDoc.documentElement.clientHeight || pDoc.documentElement.clientWidth)) // Explorer 6 Strict Mode
13615		{
13616			width = pDoc.documentElement.clientWidth;
13617			height = pDoc.documentElement.clientHeight;
13618		}
13619		else if (pDoc.body) // other Explorers
13620		{
13621			width = pDoc.body.clientWidth;
13622			height = pDoc.body.clientHeight;
13623		}
13624		return {innerWidth : width, innerHeight : height};
13625	},
13626
13627	GetWindowScrollPos: function(pDoc)
13628	{
13629		var left, top;
13630		if (!pDoc)
13631			pDoc = document;
13632
13633		if (self.pageYOffset) // all except Explorer
13634		{
13635			left = self.pageXOffset;
13636			top = self.pageYOffset;
13637		}
13638		else if (pDoc.documentElement && (pDoc.documentElement.scrollTop || pDoc.documentElement.scrollLeft)) // Explorer 6 Strict
13639		{
13640			left = document.documentElement.scrollLeft;
13641			top = document.documentElement.scrollTop;
13642		}
13643		else if (pDoc.body) // all other Explorers
13644		{
13645			left = pDoc.body.scrollLeft;
13646			top = pDoc.body.scrollTop;
13647		}
13648		return {scrollLeft : left, scrollTop : top};
13649	},
13650
13651	GetWindowScrollSize: function(pDoc)
13652	{
13653		var width, height;
13654		if (!pDoc)
13655			pDoc = document;
13656
13657		if ( (pDoc.compatMode && pDoc.compatMode == "CSS1Compat"))
13658		{
13659			width = pDoc.documentElement.scrollWidth;
13660			height = pDoc.documentElement.scrollHeight;
13661		}
13662		else
13663		{
13664			if (pDoc.body.scrollHeight > pDoc.body.offsetHeight)
13665				height = pDoc.body.scrollHeight;
13666			else
13667				height = pDoc.body.offsetHeight;
13668
13669			if (pDoc.body.scrollWidth > pDoc.body.offsetWidth ||
13670				(pDoc.compatMode && pDoc.compatMode == "BackCompat") ||
13671				(pDoc.documentElement && !pDoc.documentElement.clientWidth)
13672			)
13673				width = pDoc.body.scrollWidth;
13674			else
13675				width = pDoc.body.offsetWidth;
13676		}
13677		return {scrollWidth : width, scrollHeight : height};
13678	},
13679
13680	GetWindowSize: function()
13681	{
13682		var innerSize = jsUtils.GetWindowInnerSize();
13683		var scrollPos = jsUtils.GetWindowScrollPos();
13684		var scrollSize = jsUtils.GetWindowScrollSize();
13685
13686		return  {
13687			innerWidth : innerSize.innerWidth, innerHeight : innerSize.innerHeight,
13688			scrollLeft : scrollPos.scrollLeft, scrollTop : scrollPos.scrollTop,
13689			scrollWidth : scrollSize.scrollWidth, scrollHeight : scrollSize.scrollHeight
13690		};
13691	},
13692
13693
13694	arCustomEvents: {},
13695
13696	addCustomEvent: function(eventName, eventHandler, arParams, handlerContextObject)
13697	{
13698		if (!this.arCustomEvents[eventName])
13699			this.arCustomEvents[eventName] = [];
13700
13701		if (!arParams)
13702			arParams = [];
13703		if (!handlerContextObject)
13704			handlerContextObject = false;
13705
13706		this.arCustomEvents[eventName].push(
13707			{
13708				handler: eventHandler,
13709				arParams: arParams,
13710				obj: handlerContextObject
13711			}
13712		);
13713	},
13714
13715	removeCustomEvent: function(eventName, eventHandler)
13716	{
13717		if (!this.arCustomEvents[eventName])
13718			return;
13719
13720		var l = this.arCustomEvents[eventName].length;
13721		if (l == 1)
13722		{
13723			delete this.arCustomEvents[eventName];
13724			return;
13725		}
13726
13727		for (var i = 0; i < l; i++)
13728		{
13729			if (!this.arCustomEvents[eventName][i])
13730				continue;
13731			if (this.arCustomEvents[eventName][i].handler == eventHandler)
13732			{
13733				delete this.arCustomEvents[eventName][i];
13734				return;
13735			}
13736		}
13737	},
13738
13739	onCustomEvent: function(eventName, arEventParams)
13740	{
13741		if (!this.arCustomEvents[eventName])
13742			return;
13743
13744		if (!arEventParams)
13745			arEventParams = [];
13746
13747		var h;
13748		for (var i = 0, l = this.arCustomEvents[eventName].length; i < l; i++)
13749		{
13750			h = this.arCustomEvents[eventName][i];
13751			if (!h || !h.handler)
13752				continue;
13753
13754			if (h.obj)
13755				h.handler.call(h.obj, h.arParams, arEventParams);
13756			else
13757				h.handler(h.arParams, arEventParams);
13758		}
13759	},
13760
13761	loadJSFile: function(arJs, oCallBack, pDoc)
13762	{
13763		if (!pDoc)
13764			pDoc = document;
13765		if (typeof arJs == 'string')
13766			arJs = [arJs];
13767		var callback = function()
13768		{
13769			if (!oCallBack)
13770				return;
13771			if (typeof oCallBack == 'function')
13772				return oCallBack();
13773			if (typeof oCallBack != 'object' || !oCallBack.func)
13774				return;
13775			var p = oCallBack.params || {};
13776			if (oCallBack.obj)
13777				oCallBack.func.apply(oCallBack.obj, p);
13778			else
13779				oCallBack.func(p);
13780		};
13781		var load_js = function(ind)
13782		{
13783			if (ind >= arJs.length)
13784				return callback();
13785			var oSript = pDoc.body.appendChild(pDoc.createElement('script'));
13786			oSript.src = arJs[ind];
13787			var bLoaded = false;
13788			oSript.onload = oSript.onreadystatechange = function()
13789			{
13790				if (!bLoaded && (!oSript.readyState || oSript.readyState == "loaded" || oSript.readyState == "complete"))
13791				{
13792					bLoaded = true;
13793					setTimeout(function (){load_js(++ind);}, 50);
13794				}
13795			};
13796		};
13797		load_js(0);
13798	},
13799
13800	loadCSSFile: function(arCSS, pDoc, pWin)
13801	{
13802		if (typeof arCSS == 'string')
13803		{
13804			var bSingle = true;
13805			arCSS = [arCSS];
13806		}
13807		var i, l = arCSS.length, pLnk = [];
13808		if (l == 0)
13809			return;
13810		if (!pDoc)
13811			pDoc = document;
13812		if (!pWin)
13813			pWin = window;
13814		if (!pWin.bxhead)
13815		{
13816			var heads = pDoc.getElementsByTagName('HEAD');
13817			pWin.bxhead = heads[0];
13818		}
13819		if (!pWin.bxhead)
13820			return;
13821		for (i = 0; i < l; i++)
13822		{
13823			var lnk = document.createElement('LINK');
13824			lnk.href = arCSS[i];
13825			lnk.rel = 'stylesheet';
13826			lnk.type = 'text/css';
13827			pWin.bxhead.appendChild(lnk);
13828			pLnk.push(lnk);
13829		}
13830		if (bSingle)
13831			return lnk;
13832		return pLnk;
13833	},
13834
13835	appendBXHint : function(node, html)
13836	{
13837		if (!node || !node.parentNode || !html)
13838			return;
13839		var oBXHint = new BXHint(html);
13840		node.parentNode.insertBefore(oBXHint.oIcon, node);
13841		node.parentNode.removeChild(node);
13842		oBXHint.oIcon.style.marginLeft = "5px";
13843	},
13844
13845	PreventDefault : function(e)
13846	{
13847		if(!e) e = window.event;
13848		if(e.stopPropagation)
13849		{
13850			e.preventDefault();
13851			e.stopPropagation();
13852		}
13853		else
13854		{
13855			e.cancelBubble = true;
13856			e.returnValue = false;
13857		}
13858		return false;
13859	},
13860
13861	CreateElement: function(tag, arAttr, arStyles, pDoc)
13862	{
13863		if (!pDoc)
13864			pDoc = document;
13865		var pEl = pDoc.createElement(tag), p;
13866		if(arAttr)
13867		{
13868			for(p in arAttr)
13869			{
13870				if(p == 'className' || p == 'class')
13871				{
13872					pEl.setAttribute('class', arAttr[p]);
13873					if (jsUtils.IsIE())
13874						pEl.setAttribute('className', arAttr[p]);
13875					continue;
13876				}
13877
13878				if (arAttr[p] != undefined && arAttr[p] != null)
13879					pEl.setAttribute(p, arAttr[p]);
13880			}
13881		}
13882		if(arStyles)
13883		{
13884			for(p in arStyles)
13885				pEl.style[p] = arStyles[p];
13886		}
13887		return pEl;
13888	},
13889
13890	in_array: function(needle, haystack)
13891	{
13892		for(var i=0; i<haystack.length; i++)
13893		{
13894			if(haystack[i] == needle)
13895				return true;
13896		}
13897		return false;
13898	},
13899
13900	htmlspecialchars: function(str)
13901	{
13902		if(!str.replace)
13903			return str;
13904
13905		return str.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
13906	}
13907}
13908
13909/************************************************/
13910
13911function JCFloatDiv()
13912{
13913	var _this = this;
13914	this.floatDiv = null;
13915	this.x = this.y = 0;
13916
13917	this.Create = function(arParams)
13918	{
13919		var div = document.body.appendChild(document.createElement("DIV"));
13920		div.id = arParams.id;
13921		div.style.position = 'absolute';
13922		div.style.left = '-10000px';
13923		div.style.top = '-10000px';
13924		if(arParams.className)
13925			div.className = arParams.className;
13926		if(arParams.zIndex)
13927			div.style.zIndex = arParams.zIndex;
13928		if(arParams.width)
13929			div.style.width = arParams.width+'px';
13930		if(arParams.height)
13931			div.style.height = arParams.height+'px';
13932		return div;
13933	}
13934
13935	this.Show = function(div, left, top, dxShadow, restrictDrag, showSubFrame)
13936	{
13937		if (showSubFrame !== false)
13938			showSubFrame = true;
13939		var zIndex = parseInt(div.style.zIndex);
13940		if(zIndex <= 0 || isNaN(zIndex))
13941			zIndex = 100;
13942
13943		//document.title = 'zIndex = ' + zIndex;
13944		div.style.zIndex = zIndex;
13945
13946		if (left < 0)
13947			left = 0;
13948
13949		if (top < 0)
13950			top = 0;
13951
13952		div.style.left = parseInt(left) + "px";
13953		div.style.top = parseInt(top) + "px";
13954
13955		if(jsUtils.IsIE() && showSubFrame === true)
13956		{
13957			var frame = document.getElementById(div.id+"_frame");
13958			if(!frame)
13959			{
13960				frame = document.createElement("IFRAME");
13961				frame.src = "javascript:''";
13962				frame.id = div.id+"_frame";
13963				frame.style.position = 'absolute';
13964				frame.style.borderWidth = '0px';
13965				frame.style.zIndex = zIndex-1;
13966				document.body.appendChild(frame);
13967			}
13968			frame.style.width = div.offsetWidth + "px";
13969			frame.style.height = div.offsetHeight + "px";
13970			frame.style.left = div.style.left;
13971			frame.style.top = div.style.top;
13972			frame.style.visibility = 'visible';
13973		}
13974
13975		/*Restrict drag*/
13976		div.restrictDrag = restrictDrag || false;
13977
13978		/*shadow*/
13979		if(isNaN(dxShadow))
13980			dxShadow = 5;
13981
13982		if(dxShadow > 0)
13983		{
13984			var img = document.getElementById(div.id+'_shadow');
13985			if(!img)
13986			{
13987				if(jsUtils.IsIE())
13988				{
13989		 			img = document.createElement("DIV");
13990		 			img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/bitr
13990ix/themes/"+phpVars.ADMIN_THEME_ID+"/images/shadow.png',sizingMethod='scale')";
13991				}
13992				else
13993				{
13994		 			img = document.createElement("IMG");
13995					img.src = '/bitrix/themes/' + phpVars.ADMIN_THEME_ID+'/images/shadow.png';
13996				}
13997				img.id = div.id+'_shadow';
13998				img.style.position = 'absolute';
13999				img.style.zIndex = zIndex-2;
14000				img.style.left = '-1000px';
14001				img.style.top = '-1000px';
14002				img.style.lineHeight = 'normal';
14003				img.className = "bx-js-float-shadow";
14004				document.body.appendChild(img);
14005			}
14006			img.style.width = div.offsetWidth+'px';
14007			img.style.height = div.offsetHeight+'px';
14008			img.style.left = parseInt(div.style.left)+dxShadow+'px';
14009			img.style.top = parseInt(div.style.top)+dxShadow+'px';
14010			img.style.visibility = 'visible';
14011		}
14012		div.dxShadow = dxShadow;
14013	}
14014
14015	this.Close = function(div)
14016	{
14017		if(!div)
14018			return;
14019		var sh = document.getElementById(div.id+"_shadow");
14020		if(sh)
14021			sh.style.visibility = 'hidden';
14022
14023		var frame = document.getElementById(div.id+"_frame");
14024		if(frame)
14025			frame.style.visibility = 'hidden';
14026	}
14027
14028	this.Move = function(div, x, y)
14029	{
14030		if(!div)
14031			return;
14032
14033		var dxShadow = div.dxShadow;
14034		var left = parseInt(div.style.left)+x;
14035		var top = parseInt(div.style.top)+y;
14036
14037		if (div.restrictDrag)
14038		{
14039			//Left side
14040			if (left < 0)
14041				left = 0;
14042
14043			//Right side
14044			if ( (document.compatMode && document.compatMode == "CSS1Compat"))
14045				windowWidth = document.documentElement.scrollWidth;
14046			else
14047			{
14048				if (document.body.scrollWidth > document.body.offsetWidth ||
14049					(document.compatMode && document.compatMode == "BackCompat") ||
14050					(document.documentElement && !document.documentElement.clientWidth)
14051				)
14052					windowWidth = document.body.scrollWidth;
14053				else
14054					windowWidth = document.body.offsetWidth;
14055			}
14056
14057			var floatWidth = div.offsetWidth;
14058			if (left > (windowWidth - floatWidth - dxShadow))
14059				left = windowWidth - floatWidth - dxShadow;
14060
14061			//Top side
14062			if (top < 0)
14063				top = 0;
14064		}
14065
14066		div.style.left = left+'px';
14067		div.style.top = top+'px';
14068
14069		this.AdjustShadow(div);
14070	}
14071
14072	this.HideShadow = function(div)
14073	{
14074		var sh = document.getElementById(div.id + "_shadow");
14075		sh.style.visibility = 'hidden';
14076	}
14077
14078	this.UnhideShadow = function(div)
14079	{
14080		var sh = document.getElementById(div.id + "_shadow");
14081		sh.style.visibility = 'visible';
14082	}
14083
14084	this.AdjustShadow = function(div)
14085	{
14086		var sh = document.getElementById(div.id + "_shadow");
14087		if(sh && sh.style.visibility != 'hidden')
14088		{
14089			var dxShadow = div.dxShadow;
14090
14091			sh.style.width = div.offsetWidth+'px';
14092			sh.style.height = div.offsetHeight+'px';
14093			sh.style.left = parseInt(div.style.left)+dxShadow+'px';
14094			sh.style.top = parseInt(div.style.top)+dxShadow+'px';
14095		}
14096
14097		var frame = document.getElementById(div.id+"_frame");
14098		if(frame)
14099		{
14100			frame.style.width = div.offsetWidth + "px";
14101			frame.style.height = div.offsetHeight + "px";
14102			frame.style.left = div.style.left;
14103			frame.style.top = div.style.top;
14104		}
14105	}
14106
14107	this.StartDrag = function(e, div)
14108	{
14109		if(!e)
14110			e = window.event;
14111		this.x = e.clientX + document.body.scrollLeft;
14112		this.y = e.clientY + document.body.scrollTop;
14113		this.floatDiv = div;
14114
14115		jsUtils.addEvent(document, "mousemove", this.MoveDrag);
14116		document.onmouseup = this.StopDrag;
14117		if(document.body.setCapture)
14118			document.body.setCapture();
14119
14120		document.onmousedown = jsUtils.False;
14121		var b = document.body;
14122		b.ondrag = jsUtils.False;
14123		b.onselectstart = jsUtils.False;
14124		b.style.MozUserSelect = _this.floatDiv.style.MozUserSelect = 'none';
14125		b.style.cursor = 'move';
14126	}
14127
14128	this.StopDrag = function(e)
14129	{
14130		if(document.body.releaseCapture)
14131			document.body.releaseCapture();
14132
14133		jsUtils.removeEvent(document, "mousemove", _this.MoveDrag);
14134		document.onmouseup = null;
14135
14136		this.floatDiv = null;
14137
14138		document.onmousedown = null;
14139		var b = document.body;
14140		b.ondrag = null;
14141		b.onselectstart = null;
14142		b.style.MozUserSelect = _this.floatDiv.style.MozUserSelect = '';
14143		b.style.cursor = '';
14144	}
14145
14146	this.MoveDrag = function(e)
14147	{
14148		var x = e.clientX + document.body.scrollLeft;
14149		var y = e.clientY + document.body.scrollTop;
14150
14151		if(_this.x == x && _this.y == y)
14152			return;
14153
14154		_this.Move(_this.floatDiv, (x - _this.x), (y - _this.y));
14155		_this.x = x;
14156		_this.y = y;
14157	}
14158}
14159var jsFloatDiv = new JCFloatDiv();
14160
14161/************************************************/
14162
14163var BXHint = function(innerHTML, element, addParams)
14164{
14165	this.oDivOver = false;
14166	this.timeOutID = null;
14167	this.oIcon = null;
14168	this.freeze = false;
14169	this.x = 0;
14170	this.y = 0;
14171	this.time = 700;
14172
14173	if (!innerHTML)
14174		innerHTML = "";
14175	this.Create(innerHTML, element, addParams);
14176}
14177
14178BXHint.prototype.Create = function(innerHTML, element, addParams)
14179{
14180	var
14181		_this = this,
14182		width = 0,
14183		height = 0,
14184		className = null,
14185		type = "icon";
14186	this.bWidth = true;
14187
14188	if (addParams)
14189	{
14190		if (addParams.width === false)
14191			this.bWidth = false;
14192		else if (addParams.width)
14193			width = addParams.width;
14194
14195		if (addParams.height)
14196			height = addParams.height;
14197
14198		if (addParams.className)
14199			className = addParams.className;
14200
14201		if (addParams.type && (addParams.type == "link" || addParams.type == "icon"))
14202			type = addParams.type;
14203		if (addParams.time > 0)
14204			this.time = addParams.time;
14205	}
14206
14207	if (element)
14208		type = "element";
14209
14210	if (type == "icon")
14211	{
14212		var element = document.createElement("IMG");
14213		element.src = (addParams && addParams.iconSrc) ? addParams.iconSrc : "/bitrix/themes/"+phpVars.ADMIN_THEME_ID+"/public/popup/hint.gif";
14214		element.ondrag = jsUtils.False;
14215	}
14216	else if (type == "link")
14217	{
14218		var element = document.createElement("A");
14219		element.href = "";
14220		element.onclick = function(e){return false;}
14221		element.innerHTML = "[?]";
14222	}
14223
14224	this.element = element;
14225	if (type == "element")
14226	{
14227		if(addParams && addParams.show_on_click)
14228		{
14229			jsUtils.addEvent(
14230				element,
14231				"click",
14232				function (event)
14233				{
14234					if (!event)
14235						event = window.event;
14236					_this.GetMouseXY(event);
14237					_this.timeOutID = setTimeout(function () {_this.Show(innerHTML,width,height,className) }, 10);
14238				}
14239			);
14240		}
14241		else
14242		{
14243			jsUtils.addEvent(
14244				element,
14245				"mouseover",
14246				function (event)
14247				{
14248					if (!event)
14249						event = window.event;
14250					_this.GetMouseXY(event);
14251					_this.timeOutID = setTimeout(function () {_this.Show(innerHTML,width,height,className) }, 750);
14252				}
14253			);
14254		}
14255
14256		jsUtils.addEvent(
14257			element,
14258			"mouseout",
14259			function(event)
14260			{
14261				if (_this.timeOutID)
14262					clearTimeout(_this.timeOutID);
14263				_this.SmartHide(_this);
14264			}
14265		);
14266	}
14267	else
14268	{
14269		this.oIcon = element;
14270		element.onmouseover = function(event) {if (!event) event = window.event; _this.GetMouseXY(event); _this.Show(innerHTML,width,height,className)};
14271		element.onmouseout = function() {_this.SmartHide(_this);};
14272	}
14273}
14274
14275BXHint.prototype.IsFrozen = function()
14276{
14277	return this.freeze;
14278}
14279
14280BXHint.prototype.Freeze = function()
14281{
14282	this.freeze = true;
14283	this.Hide();
14284}
14285
14286BXHint.prototype.UnFreeze = function()
14287{
14288	this.freeze = false;
14289}
14290
14291BXHint.prototype.GetMouseXY = function(event)
14292{
14293	if (event.pageX || event.pageY)
14294	{
14295		this.x = event.pageX;
14296		this.y = event.pageY;
14297	}
14298	else if (event.clientX || event.clientY)
14299	{
14300		this.x = event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
14301		this.y = event.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
14302	}
14303}
14304
14305BXHint.prototype.Show = function(innerHTML, width, height, className)
14306{
14307	//Delete previous hint
14308	var old = document.getElementById("__BXHint_div");
14309	if (old)
14310		this.Hide();
14311
14312	if (this.freeze)
14313		return;
14314
14315	var _this = this;
14316	var oDiv = document.body.appendChild(document.createElement("DIV"));
14317	oDiv.onmouseover = function(){_this.oDivOver = true};
14318	oDiv.onmouseout = function(){_this.oDivOver = false; _this.SmartHide(_this);}
14319	oDiv.id = "__BXHint_div";
14320	oDiv.className = (className) ? className : "bxhint";
14321	oDiv.style.position = 'absolute';
14322	if (width && this.bWidth)
14323		oDiv.style.width = width + "px";
14324
14325	if (height)
14326		oDiv.style.height = height + "px";
14327	oDiv.innerHTML = innerHTML;
14328
14329	var w = oDiv.offsetWidth;
14330	var h = oDiv.offsetHeight;
14331	if (this.bWidth)
14332	{
14333		if (!width && w>200)
14334			w = Math.round(Math.sqrt(1.618*w*h));
14335		oDiv.style.width = w + "px";
14336		h = oDiv.offsetHeight;
14337	}
14338
14339	var pos = {left : this.x + 10, right : this.x + w, top : this.y, bottom : this.y + h};
14340
14341	pos = this.AlignToPos(pos, w, h);
14342
14343	oDiv.style.zIndex = 2100;
14344
14345	jsFloatDiv.Show(oDiv, pos.left, pos.top,3);
14346
14347//	oDiv.ondrag = jsUtils.False;
14348//	oDiv.onselectstart = jsUtils.False;
14349//	oDiv.style.MozUserSelect = 'none';
14350	oDiv = null;
14351}
14352
14353BXHint.prototype.AlignToPos = function(pos, w, h)
14354{
14355	var body = document.body;
14356	if((body.clientWidth + body.scrollLeft) < (pos.left + w))
14357		pos.left = (pos.left - w >= 0) ? (pos.left - w) : body.scrollLeft;
14358
14359	if((body.clientHeight + body.scrollTop) - (pos["bottom"]) < 0)
14360		pos.top = (pos.top - h >= 0) ? (pos.top - h) : body.scrollTop;
14361
14362	return pos;
14363}
14364
14365BXHint.prototype.Hide = function()
14366{
14367	var oDiv = document.getElementById("__BXHint_div");
14368
14369	if (!oDiv)
14370		return;
14371
14372	jsFloatDiv.Close(oDiv);
14373	oDiv.parentNode.removeChild(oDiv);
14374	oDiv = null;
14375}
14376
14377BXHint.prototype.SmartHide = function(_this)
14378{
14379	setTimeout(function ()
14380		{
14381			if (!_this.oDivOver)
14382				_this.Hide();
14383		}, 100
14384	);
14385}
14386
14387/************************************************/
14388
14389function WaitOnKeyPress(e)
14390{
14391	if(!e) e = window.event
14392	if(!e) return;
14393	if(e.keyCode == 27)
14394		CloseWaitWindow();
14395}
14396
14397function ShowWaitWindow()
14398{
14399	CloseWaitWindow();
14400
14401	var obWndSize = jsUtils.GetWindowSize();
14402
14403	var div = document.body.appendChild(document.createElement("DIV"));
14404	div.id = "wait_window_div";
14405	div.innerHTML = phpVars.messLoading;
14406	div.className = "waitwindow";
14407	//div.style.left = obWndSize.scrollLeft + (obWndSize.innerWidth - div.offsetWidth) - (jsUtils.IsIE() ? 5 : 20) + "px";
14408	div.style.right = (5 - obWndSize.scrollLeft) + 'px';
14409	div.style.top = obWndSize.scrollTop + 5 + "px";
14410
14411	if(jsUtils.IsIE())
14412	{
14413		var frame = document.createElement("IFRAME");
14414		frame.src = "javascript:''";
14415		frame.id = "wait_window_frame";
14416		frame.className = "waitwindow";
14417		frame.style.width = div.offsetWidth + "px";
14418		frame.style.height = div.offsetHeight + "px";
14419		frame.style.right = div.style.right;
14420		frame.style.top = div.style.top;
14421		document.body.appendChild(frame);
14422	}
14423	jsUtils.addEvent(document, "keypress", WaitOnKeyPress);
14424}
14425
14426function CloseWaitWindow()
14427{
14428	jsUtils.removeEvent(document, "keypress", WaitOnKeyPress);
14429
14430	var frame = document.getElementById("wait_window_frame");
14431	if(frame)
14432		frame.parentNode.removeChild(frame);
14433
14434	var div = document.getElementById("wait_window_div");
14435	if(div)
14436		div.parentNode.removeChild(div);
14437}
14438
14439/************************************************/
14440
14441var jsSelectUtils =
14442{
14443	addNewOption: function(select_id, opt_value, opt_name, do_sort, check_unique)
14444	{
14445		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
14446		if(oSelect)
14447		{
14448			var n = oSelect.length;
14449			if(check_unique !== false)
14450			{
14451				for(var i=0;i<n;i++)
14452					if(oSelect[i].value==opt_value)
14453						return;
14454			}
14455			var newoption = new Option(opt_name, opt_value, false, false);
14456			oSelect.options[n]=newoption;
14457		}
14458		if(do_sort === true)
14459			this.sortSelect(select_id);
14460	},
14461
14462	deleteOption: function(select_id, opt_value)
14463	{
14464		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
14465		if(oSelect)
14466		{
14467			for(var i=0;i<oSelect.length;i++)
14468				if(oSelect[i].value==opt_value)
14469				{
14470					oSelect.remove(i);
14471					break;
14472				}
14473		}
14474	},
14475
14476	deleteSelectedOptions: function(select_id)
14477	{
14478		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
14479		if(oSelect)
14480		{
14481			var i=0;
14482			while(i<oSelect.length)
14483				if(oSelect[i].selected)
14484				{
14485					oSelect[i].selected=false;
14486					oSelect.remove(i);
14487				}
14488				else
14489					i++;
14490		}
14491	},
14492
14493	deleteAllOptions: function(oSelect)
14494	{
14495		if(oSelect)
14496		{
14497			for(var i=oSelect.length-1; i>=0; i--)
14498				oSelect.remove(i);
14499		}
14500	},
14501
14502	optionCompare: function(record1, record2)
14503	{
14504		var value1 = record1.optText.toLowerCase();
14505		var value2 = record2.optText.toLowerCase();
14506		if (value1 > value2) return(1);
14507		if (value1 < value2) return(-1);
14508		return(0);
14509	},
14510
14511	sortSelect: function(select_id)
14512	{
14513		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
14514		if(oSelect)
14515		{
14516			var myOptions = [];
14517			var n = oSelect.options.length;
14518			for (var i=0;i<n;i++)
14519			{
14520				myOptions[i] = {
14521					optText:oSelect[i].text,
14522					optValue:oSelect[i].value
14523				};
14524			}
14525			myOptions.sort(this.optionCompare);
14526			oSelect.length=0;
14527			n = myOptions.length;
14528			for(var i=0;i<n;i++)
14529			{
14530				var newoption = new Option(myOptions[i].optText, myOptions[i].optValue, false, false);
14531				oSelect[i]=newoption;
14532			}
14533		}
14534	},
14535
14536	selectAllOptions: function(select_id)
14537	{
14538		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
14539		if(oSelect)
14540		{
14541			var n = oSelect.length;
14542			for(var i=0;i<n;i++)
14543				oSelect[i].selected=true;
14544		}
14545	},
14546
14547	selectOption: function(select_id, opt_value)
14548	{
14549		var oSelect = (typeof(select_id) == 'string' || select_id instanceof String? document.getElementById(select_id) : select_id);
14550		if(oSelect)
14551		{
14552			var n = oSelect.length;
14553			for(var i=0;i<n;i++)
14554				oSelect[i].selected = (oSelect[i].value == opt_value);
14555		}
14556	},
14557
14558	addSelectedOptions: function(oSelect, to_select_id, check_unique, do_sort)
14559	{
14560		if(!oSelect)
14561			return;
14562		var n = oSelect.length;
14563		for(var i=0; i<n; i++)
14564			if(oSelect[i].selected)
14565				this.addNewOption(to_select_id, oSelect[i].value, oSelect[i].text, do_sort, check_unique);
14566	},
14567
14568	moveOptionsUp: function(oSelect)
14569	{
14570		if(!oSelect)
14571			return;
14572		var n = oSelect.length;
14573		for(var i=0; i<n; i++)
14574		{
14575			if(oSelect[i].selected && i>0 && oSelect[i-1].selected == false)
14576			{
14577				var option1 = new Option(oSelect[i].text, oSelect[i].value);
14578				var option2 = new Option(oSelect[i-1].text, oSelect[i-1].value);
14579				oSelect[i] = option2;
14580				oSelect[i].selected = false;
14581				oSelect[i-1] = option1;
14582				oSelect[i-1].selected = true;
14583			}
14584		}
14585	},
14586
14587	moveOptionsDown: function(oSelect)
14588	{
14589		if(!oSelect)
14590			return;
14591		var n = oSelect.length;
14592		for(var i=n-1; i>=0; i--)
14593		{
14594			if(oSelect[i].selected && i<n-1 && oSelect[i+1].selected == false)
14595			{
14596				var option1 = new Option(oSelect[i].text, oSelect[i].value);
14597				var option2 = new Option(oSelect[i+1].text, oSelect[i+1].value);
14598				oSelect[i] = option2;
14599				oSelect[i].selected = false;
14600				oSelect[i+1] = option1;
14601				oSelect[i+1].selected = true;
14602			}
14603		}
14604	}
14605
14606}
14607
14608/************************************************/
14609/* End */
14610;
14611; /* Start:/bitrix/js/main/admin_tools.js*/
14612var phpVars;
14613if(!phpVars)
14614{
14615	phpVars = {
14616		ADMIN_THEME_ID: '.default',
14617		LANGUAGE_ID: 'en',
14618		FORMAT_DATE: 'DD.MM.YYYY',
14619		FORMAT_DATETIME: 'DD.MM.YYYY HH:MI:SS',
14620		opt_context_ctrl: false,
14621		cookiePrefix: 'BITRIX_SM',
14622		titlePrefix: '',
14623		bitrix_sessid: '',
14624		messHideMenu: '',
14625		messShowMenu: '',
14626		messHideButtons: '',
14627		messShowButtons: '',
14628		messFilterInactive: '',
14629		messFilterActive: '',
14630		messFilterLess: '',
14631		messLoading: 'Loading...',
14632		messMenuLoading: '',
14633		messMenuLoadingTitle: '',
14634		messNoData: '',
14635		messExpandTabs: '',
14636		messCollapseTabs: '',
14637		messPanelFixOn: '',
14638		messPanelFixOff: '',
14639		messPanelCollapse: '',
14640		messPanelExpand: '',
14641		messFavAddSucc: '',
14642		messFavAddErr: '',
14643		messFavDelSucc: '',
14644		messFavDelErr: ''
14645	};
14646}
14647
14648function JCSplitter(params)
14649{
14650	this.params = params;
14651
14652	this.Highlight = function(on)
14653	{
14654		var control = document.getElementById(this.params.control);
14655		var div = document.getElementById(this.params.divShown);
14656		if(div.style.display!="none")
14657			control.className = this.params.classShown+(on? 'sel':'');
14658		else
14659			control.className = this.params.classHidden+(on? 'sel':'');
14660	}
14661
14662	this.Toggle = function()
14663	{
14664		var visible = jsUtils.ToggleDiv(this.params.divShown);
14665		jsUtils.ToggleDiv(this.params.divHidden);
14666		this.Highlight(false);
14667		document.getElementById(this.params.control).title = (visible? this.params.messHide : this.params.messShow);
14668		return visible;
14669	}
14670}
14671
14672/************************************************/
14673
14674function JCAdminMenu(sOpenedSections)
14675{
14676	var _this = this;
14677	this.sMenuSelected='';
14678	this.x = 0;
14679	this.divToResize = null;
14680	this.divToBound = null;
14681	this.toggle = false;
14682	this.oSections = {};
14683	this.request = new JCHttpRequest();
14684
14685	var aSect = sOpenedSections.split(',');
14686	for(var i in aSect)
14687		this.oSections[aSect[i]] = true;
14688
14689	this.verSplitter = new JCSplitter({
14690		control:'vdividercell',
14691		divShown:'menudiv', divHidden:'hiddenmenucontainer',
14692		messHide:phpVars.messHideMenu, messShow:phpVars.messShowMenu,
14693		classShown:'vdividerknob vdividerknobleft', classHidden:'vdividerknob vdividerknobright'
14694	});
14695	this.horSplitter = new JCSplitter({
14696		control:'hdividercell',
14697		divShown:'buttonscontainer', divHidden:'smbuttonscontainer',
14698		messHide:phpVars.messHideButtons, messShow:phpVars.messShowButtons,
14699		classShown:'hdividerknob hdividerknobup', classHidden:'hdividerknob hdividerknobdown'
14700	});
14701
14702	this.verSplitterToggle = function()
14703	{
14704		var visible = this.verSplitter.Toggle();
14705		jsUserOptions.SaveOption('admin_menu', 'pos', 'ver', (visible? 'on':'off'));
14706	}
14707
14708	this.horSplitterToggle = function()
14709	{
14710		var visible = this.horSplitter.Toggle();
14711		jsUserOptions.SaveOption('admin_menu', 'pos', 'hor', (visible? 'on':'off'));
14712	}
14713
14714	this.ToggleMenu = function(menu_id, menu_text)
14715	{
14716		var div = document.getElementById(menu_id);
14717		if(div.style.display!="none")
14718			return;
14719
14720		/*menu div*/
14721		if(this.sMenuSelected != "")
14722			document.getElementById(this.sMenuSelected).style.display = 'none';
14723		div.style.display = "block";
14724
14725		/*button*/
14726		document.getElementById('menutitle').innerHTML = menu_text;
14727
14728		document.getElementById('btn_'+this.sMenuSelected).className = 'button';
14729		document.getElementById('smbtn_'+this.sMenuSelected).className = 'smbutton';
14730		document.getElementById('btn_'+menu_id).className = 'button buttonsel';
14731		document.getElementById('smbtn_'+menu_id).className = 'smbutton smbuttonsel';
14732
14733		this.sMenuSelected = menu_id;
14734	}
14735
14736	this.StartDrag = function()
14737	{
14738		if(this.toggle)
14739			return;
14740		if(document.getElementById('menudiv').style.display == 'none')
14741			return;
14742
14743		this.divToBound = document.getElementById("menu_min_width");
14744		this.divToResize = document.getElementById('menucontainer');
14745		this.x = this.divToResize.offsetWidth;
14746
14747		jsUtils.addEvent(document, "mousemove", _this.ResizeMenu);
14748		document.onmouseup = this.StopDrag;
14749
14750		var b = document.body;
14751	    b.ondrag = jsUtils.False;
14752	    b.onselectstart = jsUtils.False;
14753	    b.style.MozUserSelect = 'none';
14754	    b.style.cursor = 'e-resize';
14755    }
14756
14757	this.StopDrag = function(e)
14758	{
14759		jsUtils.removeEvent(document, "mousemove", _this.ResizeMenu);
14760		document.onmouseup = null;
14761
14762		var b = document.body;
14763		b.ondrag = null;
14764		b.onselectstart = null;
14765		b.style.MozUserSelect = '';
14766	    b.style.cursor = '';
14767
14768	    if(window.onresize)
14769	    	window.onresize();
14770
14771		jsUserOptions.SaveOption('admin_menu', 'pos', 'width', parseInt(_this.divToResize.style.width));
14772	}
14773
14774	this.ResizeMenu = function(e)
14775	{
14776		var x = e.clientX + document.body.scrollLeft;
14777		if(	_this.x == x)
14778			return;
14779
14780		var div = _this.divToResize;
14781		var mnu = _this.divToBound;
14782
14783		if(x < mnu.offsetWidth)
14784		{
14785			div.style.width = mnu.offsetWidth+'px';
14786			_this.x = x;
14787			return;
14788		}
14789
14790		div.style.width = div.offsetWidth+(x - _this.x)+'px';
14791		_this.x = x;
14792	}
14793
14794	this.ToggleSection = function(cell, div_id, level)
14795	{
14796		if(jsUtils.ToggleDiv(div_id))
14797		{
14798			if(level <= 2)
14799				this.oSections[div_id] = true;
14800			cell.className='sign signminus';
14801		}
14802		else
14803		{
14804			this.oSections[div_id] = false;
14805			cell.className='sign signplus';
14806		}
14807
14808		if(level <= 2)
14809		{
14810			var sect='';
14811			for(var i in this.oSections)
14812				if(this.oSections[i] == true)
14813					sect += (sect != ''? ',':'')+i;
14814			jsUserOptions.SaveOption('admin_menu', 'pos', 'sections', sect);
14815		}
14816	}
14817
14818	this.ToggleDynSection = function(cell, module_id, div_id, level)
14819	{
14820		function MenuText(text)
14821		{
14822			var s = '';
14823			for(var i=0; i<level; i++)
14824				s += '<td><div class="menuindent"></div></td>\n';
14825			return(
14826				'<div class="menuline">'+
14827				'<table cellspacing="0">'+
14828				'	<tr>'+s+
14829				'		<td class="menutext menutext-loading">'+text+'</td>'+
14830				'	</tr>'+
14831				'</table>'+
14832				'</div>');
14833		}
14834
14835		var div = document.getElementById(div_id);
14836		if(div.innerHTML == '')
14837		{
14838			div.innerHTML = MenuText(phpVars.messMenuLoading);
14839
14840			this.request.Action = function(result)
14841			{
14842				result = jsUtils.trim(result);
14843				div.innerHTML = (result != ''? result : MenuText(phpVars.messNoData));
14844			}
14845			this.request.Send('/bitrix/admin/get_menu.php?lang='+phpVars.LANGUAGE_ID+'&admin_mnu_module_id='+module_id+'&admin_mnu_menu_id='+encodeURIComponent(div_id));
14846		}
14847		this.ToggleSection(cell, div_id, level);
14848	}
14849}
14850
14851
14852
14853/***************************************/
14854
14855function JCAdminList(table_id)
14856{
14857	var _this = this;
14858	this.table_id = table_id;
14859
14860	this.InitTable = function()
14861	{
14862		var tbl = document.getElementById(this.table_id);
14863		if(!tbl || tbl.rows.length<1 || tbl.rows[0].cells.length<1)
14864			return;
14865
14866		var i;
14867		var nCols = tbl.rows[0].cells.length;
14868		var sortedIndex = -1;
14869
14870		/*head row mousover action*/
14871		for(i=0; i<nCols; i++)
14872		{
14873			var j;
14874			var cell_sort = tbl.rows[1].cells[i];
14875			var sort_table = jsUtils.FindChildObject(cell_sort, "table", "sorting");
14876
14877			for(j=0; j<2; j++)
14878			{
14879				var cell = tbl.rows[j].cells[i];
14880
14881				cell.onmouseover = function(){_this.HighlightGutter(this, true)};
14882				cell.onmouseout = function(){_this.HighlightGutter(this, false)};
14883
14884				/*expand sorting table behaviour on parent cell*/
14885				if(sort_table)
14886				{
14887					cell.onclick = sort_table.onclick;
14888					cell.title = sort_table.title;
14889					cell.style.cursor = "pointer";
14890
14891					if(j == 0)
14892					{
14893						var cl = sort_table.rows[0].cells[1].className.toLowerCase();
14894						if(cl == "sign up" || cl == "sign down")
14895						{
14896							cell.className += ' sorted';
14897							sortedIndex = i;
14898						}
14899					}
14900				}
14901			}
14902			if(sort_table)
14903				sort_table.onclick = null;
14904		}
14905
14906		var n = tbl.rows.length;
14907		for(i=0; i<n; i++)
14908		{
14909			var row = tbl.rows[i];
14910
14911			/*first and last columns style classes*/
14912			row.cells[0].className += ' left';
14913	 		row.cells[row.cells.length-1].className += ' right';
14914
14915	 		if(row.className && row.className == 'footer')
14916	 			continue;
14917
14918			/*sorted column*/
14919			if(sortedIndex != -1 && sortedIndex < row.cells.length)
14920				row.cells[sortedIndex].className += ' sorted';
14921
14922			if(i>=2)
14923			{
14924				/*first column checkbox action*/
14925				var checkbox = row.cells[0].childNodes[0];
14926				if(checkbox && checkbox.tagName && checkbox.tagName.toUpperCase() == "INPUT" && checkbox.type.toUpperCase() == "CHECKBOX")
14927				{
14928					checkbox.onclick = function(){_this.SelectRow(this); _this.EnableActions()};
14929					jsUtils.addEvent(row, "click", _this.OnClickRow);
14930				}
14931
14932				/*rows mousover action*/
14933				row.onmouseover = function(){_this.HighlightRow(this, true)};
14934				row.onmouseout = function(){_this.HighlightRow(this, false)};
14935
14936				if(i%2 == 0)
14937					row.className += ' odd';
14938				else
14939					row.className += ' even';
14940
14941				if(row.oncontextmenu)
14942				{
14943					jsUtils.addEvent(row, "contextmenu",
14944						function(e)
14945						{
14946							if(!e) e = window.event;
14947							if(!phpVars.opt_context_ctrl && e.ctrlKey || phpVars.opt_context_ctrl && !e.ctrlKey)
14948								return;
14949
14950							var targetElement;
14951							if(e.target) targetElement = e.target;
14952							else if(e.srcElement) targetElement = e.srcElement;
14953
14954							while(targetElement && !targetElement.oncontextmenu)
14955								targetElement = jsUtils.FindParentObject(targetElement, "tr");
14956
14957							var x = e.clientX + document.body.scrollLeft;
14958							var y = e.clientY + document.body.scrollTop;
14959							var pos = {};
14960							pos['left'] = pos['right'] = x;
14961							pos['top'] = pos['bottom'] = y;
14962
14963							var menu = window[_this.table_id+"_menu"];
14964							menu.PopupHide();
14965							menu.SetItems(targetElement.oncontextmenu());
14966							menu.BuildItems();
14967							menu.PopupShow(pos);
14968
14969							e.returnValue = false;
14970							if(e.preventDefault) e.preventDefault();
14971						}
14972					);
14973				}
14974			}
14975		}
14976
14977		if(tbl.rows.length > 2)
14978		{
14979			tbl.rows[2].className += ' top';
14980			tbl.rows[tbl.rows.length-1].className += ' bottom';
14981		}
14982	}
14983
14984	this.Destroy = function(bLast)
14985	{
14986		var tbl = document.getElementById(this.table_id);
14987		if(!tbl || tbl.rows.length<1 || tbl.rows[0].cells.length<1)
14988			return;
14989
14990		var i;
14991		var nCols = tbl.rows[0].cells.length;
14992		for(i=0; i<nCols; i++)
14993		{
14994			var j;
14995			for(j=0; j<2; j++)
14996			{
14997				var cell = tbl.rows[j].cells[i];
14998				cell.onmouseover = null;
14999				cell.onmouseout = null;
15000				cell.onclick = null;
15001			}
15002		}
15003		var n = tbl.rows.length;
15004		for(i=0; i<n; i++)
15005		{
15006			var row = tbl.rows[i];
15007			var checkbox = row.cells[0].childNodes[0];
15008			if(checkbox && checkbox.onclick)
15009				checkbox.onclick = null;
15010			row.onmouseover = null;
15011			row.onmouseout = null;
15012			jsUtils.removeAllEvents(row);
15013		}
15014		if(bLast == true)
15015			_this = null;
15016	}
15017
15018	this.HighlightGutter = function(cell, on)
15019	{
15020		var table = cell.parentNode.parentNode.parentNode;
15021		var gutter = table.rows[0].cells[cell.cellIndex];
15022		if(on)
15023			gutter.className += ' over';
15024		else
15025			gutter.className = gutter.className.replace(/\s*over/i, '');
15026	}
15027
15028	this.HighlightRow = function(row, on)
15029	{
15030		if(on)
15031			row.className += ' over';
15032		else
15033			row.className = row.className.replace(/\s*over/i, '');
15034	}
15035
15036	this.SelectRow = function(checkbox)
15037	{
15038		var row = checkbox.parentNode.parentNode;
15039		var tbl = row.parentNode.parentNode;
15040		var span = document.getElementById(tbl.id+'_selected_span');
15041		var selCount = parseInt(span.innerHTML);
15042
15043		if(checkbox.checked)
15044		{
15045			row.className += ' selected';
15046			selCount++;
15047		}
15048		else
15049		{
15050			row.className = row.className.replace(/\s*selected/ig, '');
15051			selCount--;
15052		}
15053		span.innerHTML = selCount;
15054
15055		var checkAll = document.getElementById(tbl.id+'_check_all');
15056		if(selCount == tbl.rows.length-2)
15057			checkAll.checked = true;
15058		else
15059			checkAll.checked = false;
15060	}
15061
15062	this.OnClickRow = function(e)
15063	{
15064		if(!e)
15065			var e = window.event;
15066		if(!e.ctrlKey)
15067			return;
15068		var obj = (e.target? e.target : (e.srcElement? e.srcElement : null));
15069		if(!obj)
15070			return;
15071		if(!obj.parentNode.cells)
15072			return;
15073		var checkbox = obj.parentNode.cells[0].childNodes[0];
15074		if(checkbox && checkbox.tagName && checkbox.tagName.toUpperCase() == "INPUT" && checkbox.type.toUpperCase() == "CHECKBOX" && !checkbox.disabled)
15075		{
15076			checkbox.checked = !checkbox.checked;
15077			_this.SelectRow(checkbox);
15078		}
15079		_this.EnableActions();
15080	}
15081
15082	this.SelectAllRows = function(checkbox)
15083	{
15084		var tbl = checkbox.parentNode.parentNode.parentNode.parentNode;
15085		var bChecked = checkbox.checked;
15086		var i;
15087		var n = tbl.rows.length;
15088		for(i=2; i<n; i++)
15089		{
15090			var box = tbl.rows[i].cells[0].childNodes[0];
15091			if(box && box.tagName && box.tagName.toUpperCase() == 'INPUT' && box.type.toUpperCase() == "CHECKBOX")
15092			{
15093				if(box.checked != bChecked && !box.disabled)
15094				{
15095					box.checked = bChecked;
15096					this.SelectRow(box);
15097				}
15098			}
15099		}
15100		this.EnableActions();
15101	}
15102
15103	this.EnableActions = function()
15104	{
15105		var form = document.forms['form_'+this.table_id];
15106		if(!form) return;
15107
15108		var bEnabled = this.IsActionEnabled();
15109		var bEnabledEdit = this.IsActionEnabled('edit');
15110
15111		if(form.apply) form.apply.disabled = !bEnabled;
15112		var b = document.getElementById('action_edit_button');
15113		if(b) b.className = 'context-button icon action-edit-button'+(bEnabledEdit? '':'-dis');
15114		b = document.getElementById('action_delete_button');
15115		if(b) b.className = 'context-button icon action-delete-button'+(bEnabled? '':'-dis');
15116	}
15117
15118	this.IsActionEnabled = function(action)
15119	{
15120		var form = document.forms['form_'+this.table_id];
15121		if(!form) return;
15122
15123		var bChecked = false;
15124		var span = document.getElementById(this.table_id+'_selected_span');
15125		if(span && parseInt(span.innerHTML)>0)
15126			bChecked = true;
15127
15128		if(action == 'edit')
15129			return !(form.action_target && form.action_target.checked) && bChecked;
15130		else
15131			return (form.action_target && form.action_target.checked) || bChecked;
15132	}
15133
15134	this.SetActiveResult = function(callback, url)
15135	{
15136		CHttpRequest.Action = function(result)
15137		{
15138			CloseWaitWindow();
15139			_this.Destroy(false);
15140			document.getElementById(_this.table_id+"_result_div").innerHTML = result;
15141			_this.InitTable();
15142			jsAdminChain.AddItems(_this.table_id+"_navchain_div");
15143			if(callback)
15144				callback(url);
15145		}
15146	}
15147
15148	this.GetAdminList = function(url, callback)
15149	{
15150		ShowWaitWindow();
15151
15152		var re = new RegExp('&mode=list&table_id='+escape(_this.table_id), 'g');
15153		url = url.replace(re, '');
15154
15155		var link = document.getElementById('navchain-link');
15156		if(link)
15157			link.href = url;
15158
15159		if(url.indexOf('?')>=0)
15160			url += '&mode=list&table_id='+escape(_this.table_id);
15161		else
15162			url += '?&mode=list&table_id='+escape(_this.table_id);
15163
15164		_this.SetActiveResult(callback, url);
15165		CHttpRequest.Send(url);
15166	}
15167
15168	this.Sort = function(url, bCheckCtrl, args)
15169	{
15170		if(bCheckCtrl == true)
15171		{
15172			var e = null, bControl = false;
15173			if(args.length > 0)
15174				e = args[0];
15175			if(!e)
15176				e = window.event;
15177			if(e)
15178				bControl = e.ctrlKey;
15179			url += (bControl? 'desc':'asc');
15180		}
15181		this.GetAdminList(url);
15182	}
15183
15184	this.PostAdminList = function(url)
15185	{
15186		if(url.indexOf('?')>=0)
15187			url += '&mode=frame&table_id='+escape(this.table_id);
15188		else
15189			url += '?mode=frame&table_id='+escape(this.table_id);
15190
15191		var frm = document.getElementById('form_'+this.table_id);
15192
15193		try{frm.action.act.parentNode.removeChild(frm.action);}catch(e){}
15194
15195		frm.action = url;
15196		frm.onsubmit();
15197		frm.submit();
15198	}
15199
15200	this.ShowSettings = function(url)
15201	{
15202		if(document.getElementById("settings_float_div"))
15203			return;
15204
15205		CHttpRequest.Action = function(result)
15206		{
15207			CloseWaitWindow();
15208
15209			if(result == '')
15210				return;
15211
15212			var div = document.body.appendChild(document.createElement("DIV"));
15213			div.id = "settings_float_div";
15214			div.className = "settings-float-form";
15215			div.style.position = 'absolute';
15216			div.style.zIndex = 1000;
15217			div.innerHTML = result;
15218
15219			var left = parseInt(document.body.scrollLeft + document.body.clientWidth/2 - div.offsetWidth/2);
15220			var top = parseInt(document.body.scrollTop + document.body.clientHeight/2 - div.offsetHeight/2);
15221			jsFloatDiv.Show(div, left, top);
15222
15223			jsUtils.addEvent(document, "keypress", _this.SettingsOnKeyPress);
15224		}
15225		ShowWaitWindow();
15226		CHttpRequest.Send(url);
15227	}
15228
15229	this.CloseSettings =  function()
15230	{
15231		jsUtils.removeEvent(document, "keypress", _this.SettingsOnKeyPress);
15232		var div = document.getElementById("settings_float_div");
15233		jsFloatDiv.Close(div);
15234		div.parentNode.removeChild(div);
15235	}
15236
15237	this.SettingsOnKeyPress = function(e)
15238	{
15239		if(!e) e = window.event
15240		if(!e) return;
15241		if(e.keyCode == 27)
15242			_this.CloseSettings();
15243	}
15244
15245	this.SaveSettings =  function()
15246	{
15247		ShowWaitWindow();
15248
15249		var sCols='', sBy='', sOrder='', sPageSize='';
15250
15251		var oSelect = document.list_settings.selected_columns;
15252		var n = oSelect.length;
15253		for(var i=0; i<n; i++)
15254			sCols += (sCols != ''? ',':'')+oSelect[i].value;
15255
15256		oSelect = document.list_settings.order_field;
15257		if(oSelect)
15258			sBy = oSelect[oSelect.selectedIndex].value;
15259
15260		oSelect = document.list_settings.order_direction;
15261		if(oSelect)
15262			sOrder = oSelect[oSelect.selectedIndex].value;
15263
15264		oSelect = document.list_settings.nav_page_size;
15265		sPageSize = oSelect[oSelect.selectedIndex].value;
15266
15267		var bCommon = (document.list_settings.set_default && document.list_settings.set_default.checked);
15268
15269		jsUserOptions.SaveOption('list', this.table_id, 'columns', sCols, bCommon);
15270		jsUserOptions.SaveOption('list', this.table_id, 'by', sBy, bCommon);
15271		jsUserOptions.SaveOption('list', this.table_id, 'order', sOrder, bCommon);
15272		jsUserOptions.SaveOption('list', this.table_id, 'page_size', sPageSize, bCommon);
15273
15274		var url = window.location.href;
15275		jsUserOptions.SendData(function(){_this.GetAdminList(url, _this.CloseSettings);});
15276	}
15277
15278	this.DeleteSettings = function(bCommon)
15279	{
15280		ShowWaitWindow();
15281		var url = window.location.href;
15282		jsUserOptions.DeleteOption('list', this.table_id, bCommon, function(){_this.GetAdminList(url, _this.CloseSettings);});
15283	}
15284}
15285
15286/************************************************/
15287
15288function TabControl(name, unique_name, aTabs)
15289{
15290	var _this = this;
15291	this.name = name;
15292	this.unique_name = unique_name;
15293	this.aTabs = aTabs;
15294	this.aTabsDisabled = {};
15295	this.bExpandTabs = false;
15296
15297	this.AUTOSAVE = null;
15298
15299	var auto_lnk = BX(this.name + '_autosave_link');
15300	if (auto_lnk)
15301	{
15302		auto_lnk.title = BX.message('AUTOSAVE_T');
15303		BX.addCustomEvent('onAutoSavePrepare', function (ob, h) {
15304			BX.bind(auto_lnk, 'click', BX.proxy(ob.Save, ob));
15305		});
15306		BX.addCustomEvent('onAutoSave', function() {
15307			auto_lnk.className = 'context-button bx-core-autosave bx-core-autosave-saving';
15308		});
15309		BX.addCustomEvent('onAutoSaveFinished', function(ob, t) {
15310			t = parseInt(t);
15311			if (!isNaN(t))
15312			{
15313				setTimeout(function() {
15314					auto_lnk.className = 'context-button bx-core-autosave bx-core-autosave-ready';
15315				}, 1000);
15316				auto_lnk.title = BX.message('AUTOSAVE_L').replace('#DATE#', BX.formatDate(new Date(t * 1000)));
15317			}
15318		});
15319		BX.addCustomEvent('onAutoSaveInit', function() {
15320			auto_lnk.className = 'context-button bx-core-autosave bx-core-autosave-edited';
15321		});
15322	}
15323
15324
15325	this.NextTab = function()
15326	{
15327		var SelectedTab = BX.findChild(document, {'className': 'tab-selected'}, true );
15328		//let's cut "tab_" and take tab name or tab_cont_
15329		if(SelectedTab)
15330			var CurrentTab=SelectedTab.id.substr(4);
15331		else
15332		{
15333			var SelectedTab = BX.findChild(document, {'className': 'tab-container-selected'}, true );
15334			var CurrentTab=SelectedTab.id.substr(9);
15335		}
15336
15337		var NextTab="";
15338
15339		for(var i=0; i<this.aTabs.length; i++)
15340			{
15341				if(CurrentTab==this.aTabs[i]["DIV"])
15342				{
15343					if(i>=(this.aTabs.length-1))
15344						NextTab=this.aTabs[0];
15345					else
15346						NextTab=this.aTabs[i+1];
15347				}
15348			}
15349
15350		if(NextTab["DIV"])
15351			this.SelectTab(NextTab["DIV"]);
15352	}
15353
15354
15355	this.SelectTab = function(tab_id)
15356	{
15357		var div = document.getElementById(tab_id);
15358		if(div.style.display != 'none')
15359			return;
15360
15361		for (var i = 0, cnt = this.aTabs.length; i < cnt; i++)
15362		{
15363			var tab = document.getElementById(this.aTabs[i]["DIV"])
15364			if(tab.style.display != 'none')
15365			{
15366				this.ShowTab(this.aTabs[i]["DIV"], false);
15367				tab.style.display = 'none';
15368				break;
15369			}
15370		}
15371
15372		this.ShowTab(tab_id, true);
15373		div.style.display = 'block';
15374
15375		document.getElementById(this.name+'_active_tab').value = tab_id;
15376
15377		for (var i = 0, cnt = this.aTabs.length; i < cnt; i++)
15378			if(this.aTabs[i]["DIV"] == tab_id)
15379			{
15380				this.aTabs[i]["_ACTIVE"] = true;
15381				if(this.aTabs[i]["ONSELECT"])
15382					eval(this.aTabs[i]["ONSELECT"]);
15383				break;
15384			}
15385	}
15386
15387	this.ShowTab = function(tab_id, on)
15388	{
15389		var sel = (on? '-selected':'');
15390		try{
15391		document.getElementById('tab_cont_'+tab_id).className = 'tab-container'+sel;
15392		document.getElementById('tab_left_'+tab_id).className = 'tab-left'+sel;
15393		document.getElementById('tab_'+tab_id).className = 'tab'+sel;
15394		if(tab_id != this.aTabs[this.aTabs.length-1]["DIV"])
15395			document.getElementById('tab_right_'+tab_id).className = 'tab-right'+sel;
15396		else
15397			document.getElementById('tab_right_'+tab_id).className = 'tab-right-last'+sel;
15398		}catch(e){}
15399	}
15400
15401	this.HoverTab = function(tab_id, on)
15402	{
15403		var tab = document.getElementById('tab_'+tab_id);
15404		if(tab.className == 'tab-selected')
15405			return;
15406
15407		document.getElementById('tab_left_'+tab_id).className = (on? 'tab-left-hover':'tab-left');
15408		tab.className = (on? 'tab-hover':'tab');
15409		var tab_right = document.getElementById('tab_right_'+tab_id);
15410		if(tab_id != this.aTabs[this.aTabs.length-1]["DIV"])
15411			tab_right.className = (on? 'tab-right-hover':'tab-right');
15412		else
15413			tab_right.className = (on? 'tab-right-last-hover':'tab-right-last');
15414	}
15415
15416	this.InitEditTables = function()
15417	{
15418		for(var tab = 0, cnt = this.aTabs.length; tab < cnt; tab++)
15419		{
15420			var div = document.getElementById(this.aTabs[tab]["DIV"]);
15421			var tbl = jsUtils.FindChildObject(div.firstChild, 'table', 'edit-table');
15422			if(!tbl)
15423			{
15424				var tbl = jsUtils.FindChildObject(div, 'table', 'edit-table');
15425				if (!tbl)
15426					continue;
15427			}
15428
15429			var n = tbl.rows.length;
15430			for(var i=0; i<n; i++)
15431				if(tbl.rows[i].cells.length > 1)
15432					tbl.rows[i].cells[0].className = 'field-name';
15433		}
15434	}
15435
15436	this.DisableTab = function(tab_id)
15437	{
15438		this.aTabsDisabled[tab_id] = true;
15439		this.ShowDisabledTab(tab_id, true);
15440		if(this.bExpandTabs)
15441		{
15442			var div = document.getElementById(tab_id);
15443			div.style.display = 'none';
15444		}
15445	}
15446
15447	this.EnableTab = function(tab_id)
15448	{
15449		this.aTabsDisabled[tab_id] = false;
15450		this.ShowDisabledTab(tab_id, this.bExpandTabs);
15451		if(this.bExpandTabs)
15452		{
15453			var div = document.getElementById(tab_id);
15454			div.style.display = 'block';
15455		}
15456	}
15457
15458	this.ShowDisabledTab = function(tab_id, disabled)
15459	{
15460		var tab = document.getElementById('tab_cont_'+tab_id);
15461		if(disabled)
15462		{
15463			tab.className = 'tab-container-disabled';
15464			tab.onclick = null;
15465			tab.onmouseover = null;
15466			tab.onmouseout = null;
15467		}
15468		else
15469		{
15470			tab.className = 'tab-container';
15471			tab.onclick = function(){_this.SelectTab(tab_id);};
15472			tab.onmouseover = function(){_this.HoverTab(tab_id, true);};
15473			tab.onmouseout = function(){_this.HoverTab(tab_id, false);};
15474		}
15475	}
15476
15477	this.Destroy = function()
15478	{
15479		//for(var i in this.aTabs)
15480		for(var i = 0, cnt = this.aTabs.length; i < cnt; i++)
15481		{
15482			var tab = document.getElementById('tab_cont_'+this.aTabs[i]["DIV"]);
15483			if (!tab)
15484				continue;
15485			tab.onclick = null;
15486			tab.onmouseover = null;
15487			tab.onmouseout = null;
15488		}
15489		_this = null;
15490	}
15491
15492	this.ToggleTabs = function()
15493	{
15494		this.bExpandTabs = !this.bExpandTabs;
15495
15496		var a = document.getElementById(this.name+'_expand_link');
15497		a.title = (this.bExpandTabs? phpVars.messCollapseTabs : phpVars.messExpandTabs);
15498		a.className = (this.bExpandTabs? a.className.replace(/\s*down/ig, ' up') : a.className.replace(/\s*up/ig, ' down'));
15499
15500		for(var i in this.aTabs)
15501		{
15502			var tab_id = this.aTabs[i]["DIV"];
15503			this.ShowTab(tab_id, false);
15504			this.ShowDisabledTab(tab_id, (this.bExpandTabs || this.aTabsDisabled[tab_id]));
15505			var div = document.getElementById(tab_id);
15506			div.style.display = (this.bExpandTabs && !this.aTabsDisabled[tab_id]? 'block':'none');
15507			if(i > 0)
15508			{
15509				var tbl = jsUtils.FindChildObject(div.firstChild, 'table', 'edit-tab-title');
15510				if(this.bExpandTabs)
15511				{
15512					try{
15513						tbl.rows[0].style.display = 'table-row';
15514					}
15515					catch(e){
15516						tbl.rows[0].style.display = 'block';
15517					}
15518				}
15519				else
15520					tbl.rows[0].style.display = 'none';
15521			}
15522		}
15523		if(!this.bExpandTabs)
15524		{
15525			this.ShowTab(this.aTabs[0]["DIV"], true);
15526			var div = document.getElementById(this.aTabs[0]["DIV"]);
15527			div.style.display = 'block';
15528		}
15529		jsUserOptions.SaveOption('edit', this.unique_name, 'expand', (this.bExpandTabs? 'on': 'off'));
15530
15531		jsUtils.onCustomEvent('OnToggleTabs');
15532	}
15533
15534	this.ShowWarnings = function(form_name, warnings)
15535	{
15536		var form = document.forms[form_name];
15537		if(!form)
15538			return;
15539		for(var i in warnings)
15540		{
15541			var e = form.elements[warnings[i]['name']];
15542			if(!e)
15543				continue;
15544
15545			var type = (e.type? e.type.toLowerCase():'');
15546			var bBefore = false;
15547			if(e.length > 1 && type != 'select-one' && type != 'select-multiple')
15548			{
15549				e = e[0];
15550				bBefore = true;
15551			}
15552			if(type == 'textarea' || type == 'select-multiple')
15553				bBefore = true;
15554
15555			var td = e.parentNode;
15556			var img;
15557			if(bBefore)
15558			{
15559				img = td.insertBefore(new Image(), e);
15560				td.insertBefore(document.createElement("BR"), e);
15561			}
15562			else
15563			{
15564				img = td.insertBefore(new Image(), e.nextSibling);
15565				img.hspace = 2;
15566				img.vspace = 2;
15567				img.style.verticalAlign = 'bottom';
15568			}
15569			img.src = '/bitrix/themes/'+phpVars.ADMIN_THEME_ID+'/images/icon_warn.gif';
15570			img.title = warnings[i]['title'];
15571		}
15572	}
15573
15574	this.ShowSettings = function(url)
15575	{
15576		if(document.getElementById("settings_float_div"))
15577			return;
15578
15579		CHttpRequest.Action = function(result)
15580		{
15581			CloseWaitWindow();
15582
15583			if(result == '')
15584				return;
15585
15586			var div = document.body.appendChild(document.createElement("DIV"));
15587			div.id = "settings_float_div";
15588			div.className = "settings-float-form";
15589			div.style.position = 'absolute';
15590			div.style.zIndex = 1000;
15591			div.innerHTML = result;
15592
15593			var left = parseInt(document.body.scrollLeft + document.body.clientWidth/2 - div.offsetWidth/2);
15594			var top = parseInt(document.body.scrollTop + document.body.clientHeight/2 - div.offsetHeight/2);
15595			jsFloatDiv.Show(div, left, top);
15596
15597			jsUtils.addEvent(document, "keypress", _this.SettingsOnKeyPress);
15598		}
15599		ShowWaitWindow();
15600		CHttpRequest.Send(url);
15601	}
15602
15603	this.CloseSettings =  function()
15604	{
15605		jsUtils.removeEvent(document, "keypress", _this.SettingsOnKeyPress);
15606		var div = document.getElementById("settings_float_div");
15607		jsFloatDiv.Close(div);
15608		div.parentNode.removeChild(div);
15609	}
15610
15611	this.SettingsOnKeyPress = function(e)
15612	{
15613		if(!e) e = window.event
15614		if(!e) return;
15615		if(e.keyCode == 27)
15616			_this.CloseSettings();
15617	}
15618
15619	this.SaveSettings =  function()
15620	{
15621		ShowWaitWindow();
15622
15623		var sTabs='', s='';
15624
15625		var oFieldsSelect;
15626		var oSelect = document.getElementById('selected_tabs');
15627		if(oSelect)
15628		{
15629			var k = oSelect.length;
15630			for(var i=0; i<k; i++)
15631			{
15632				s = oSelect[i].value + '--#--' + oSelect[i].text;
15633				oFieldsSelect = document.getElementById('selected_fields[' + oSelect[i].value + ']');
15634				if(oFieldsSelect)
15635				{
15636					var n = oFieldsSelect.length;
15637					for(var j=0; j<n; j++)
15638					{
15639						s += '--,--' + oFieldsSelect[j].value + '--#--' + jsUtils.trim(oFieldsSelect[j].text);
15640					}
15641				}
15642				sTabs += s + '--;--';
15643			}
15644		}
15645
15646		var bCommon = (document.form_settings.set_default && document.form_settings.set_default.checked);
15647
15648		var request = new JCHttpRequest;
15649		request.Action = function () {BX.reload()};
15650
15651		var sParam = '';
15652		sParam += '&p[0][c]=form';
15653		sParam += '&p[0][n]='+encodeURIComponent(this.name);
15654		if(bCommon)
15655			sParam += '&p[0][d]=Y';
15656		sParam += '&p[0][v][tabs]=' + encodeURIComponent(sTabs);
15657
15658		var options_url = '/bitrix/admin/user_options.php?lang='+phpVars.LANGUAGE_ID+'&sessid='+phpVars.bitrix_sessid;
15659		options_url += '&action=delete&c=form&n='+this.name+'_disabled';
15660
15661		request.Post(options_url, sParam);
15662	}
15663
15664	this.DeleteSettings = function(bCommon)
15665	{
15666		ShowWaitWindow();
15667		jsUserOptions.DeleteOption('form', this.name, bCommon, function () {BX.reload()});
15668	}
15669
15670	this.DisableSettings = function()
15671	{
15672		var request = new JCHttpRequest;
15673		request.Action = function () {BX.reload()};
15674		var sParam = '';
15675		sParam += '&p[0][c]=form';
15676		sParam += '&p[0][n]='+encodeURIComponent(this.name+'_disabled');
15677		sParam += '&p[0][v][disabled]=Y';
15678		request.Send('/bitrix/admin/user_options.php?lang=' + phpVars.LANGUAGE_ID + sParam + '&sessid='+phpVars.bitrix_sessid);
15679	}
15680
15681	this.EnableSettings = function()
15682	{
15683		var request = new JCHttpRequest;
15684		request.Action = function () {BX.reload()};
15685		var sParam = '';
15686		sParam += '&c=form';
15687		sParam += '&n='+encodeURIComponent(this.name)+'_disabled';
15688		sParam += '&action=delete';
15689		request.Send('/bitrix/admin/user_options.php?lang=' + phpVars.LANGUAGE_ID + sParam + '&sessid='+phpVars.bitrix_sessid);
15690	}
15691}
15692
15693/************************************************/
15694
15695function ViewTabControl(aTabs)
15696{
15697	var _this = this;
15698	this.aTabs = aTabs;
15699
15700	this.SelectTab = function(tab_id)
15701	{
15702		var div = document.getElementById(tab_id);
15703		if(div.style.display != 'none')
15704			return;
15705
15706		for(var i in this.aTabs)
15707		{
15708			var tab_div = document.getElementById(this.aTabs[i]["DIV"]);
15709			if(tab_div.style.display != 'none')
15710			{
15711				var tab = document.getElementById('view_tab_'+this.aTabs[i]["DIV"]);
15712				tab.innerHTML = this.aTabs[i]["HTML"];
15713				tab.className = 'view-tab';
15714				this.ToggleDelimiter(tab, true);
15715				tab_div.style.display = 'none';
15716				break;
15717			}
15718		}
15719
15720		var active_tab = document.getElementById('view_tab_'+tab_id);
15721		active_tab.className = 'view-tab view-tab-active';
15722		this.ToggleDelimiter(active_tab, false);
15723		div.style.display = 'block';
15724
15725		this.RebuildTabs();
15726
15727		for(var i in this.aTabs)
15728		{
15729			if(this.aTabs[i]["DIV"] == tab_id)
15730			{
15731				this.ReplaceAnchor(this.aTabs[i]);
15732				if(this.aTabs[i]["ONSELECT"])
15733					eval(this.aTabs[i]["ONSELECT"]);
15734				break;
15735			}
15736		}
15737	}
15738
15739	this.ToggleDelimiter = function(tab, on)
15740	{
15741		var d;
15742		if((d = jsUtils.FindNextSibling(tab, 'div')) && d.className.indexOf('view-tab-delimiter') != -1)
15743			d.className = 'view-tab-delimiter'+(on? '':' view-tab-hide-delimiter');
15744		if((d = jsUtils.FindPreviousSibling(tab, 'div')) && d.className.indexOf('view-tab-delimiter') != -1)
15745			d.className = 'view-tab-delimiter'+(on? '':' view-tab-hide-delimiter');
15746	}
15747
15748	this.DisableTab = function(tab_id)
15749	{
15750	}
15751
15752	this.EnableTab = function(tab_id)
15753	{
15754	}
15755
15756	this.ReplaceAnchor = function(tab)
15757	{
15758		var tab_div = document.getElementById('view_tab_'+tab["DIV"]);
15759		tab["HTML"] = tab_div.innerHTML;
15760		var a = jsUtils.FindChildObject(tab_div, "a");
15761		tab_div.innerHTML = a.innerHTML;
15762	}
15763
15764	this.RebuildTabs = function()
15765	{
15766		var container = jsUtils.FindParentObject(document.getElementById('view_tab_'+_this.aTabs[0]["DIV"]), "div");
15767		var aPos = [0];
15768		var selectedIndex = -1;
15769		var prevTop = -1;
15770		var last;
15771		var n = container.childNodes.length;
15772		for(var i=0; i<n; i++)
15773		{
15774			var div = container.childNodes[i];
15775			if(!div.id)
15776				continue;
15777
15778			if(prevTop > -1 && div.offsetTop > prevTop)
15779				aPos[aPos.length] = i;
15780			prevTop = div.offsetTop;
15781
15782			if(selectedIndex == -1 && div.className.indexOf('view-tab-active') != -1)
15783				selectedIndex = aPos.length-1;
15784			last = div;
15785		}
15786
15787		if(selectedIndex < aPos.length && selectedIndex > -1)
15788		{
15789			var aDiv = new Array();
15790			var div = container.childNodes[aPos[selectedIndex]];
15791			for(var i = aPos[selectedIndex]; i<aPos[selectedIndex+1]; i++)
15792			{
15793				aDiv[aDiv.length] = div;
15794				div = div.nextSibling;
15795			}
15796			if(aDiv.length > 0)
15797			{
15798				for(var i in aDiv)
15799					container.removeChild(aDiv[i]);
15800
15801				while(last.nextSibling)
15802				{
15803					last = last.nextSibling;
15804					if(last.tagName && last.tagName.toUpperCase() == 'BR' && last.className && last.className == 'tab-break')
15805						break;
15806				}
15807
15808				var br = document.createElement("BR");
15809				br.style.clear='both';
15810				container.insertBefore(br, last);
15811
15812				for(var i in aDiv)
15813				{
15814					if(aDiv[i].tagName && aDiv[i].tagName.toUpperCase() == 'BR')
15815						continue;
15816					container.insertBefore(aDiv[i], last);
15817				}
15818			}
15819		}
15820	}
15821
15822	this.Init = function()
15823	{
15824		if(this.aTabs.length == 0)
15825			return;
15826		for(var i in this.aTabs)
15827		{
15828			var div = document.getElementById(this.aTabs[i]["DIV"]);
15829			if(div.style.display != 'none')
15830			{
15831				this.ReplaceAnchor(this.aTabs[i]);
15832				this.ToggleDelimiter(document.getElementById('view_tab_'+this.aTabs[i]["DIV"]), false);
15833				break;
15834			}
15835		}
15836		setTimeout(this.RebuildTabs, 10);
15837		window.onresize = this.RebuildTabs;
15838	}
15839
15840	this.Init();
15841}
15842
15843/************************************************/
15844
15845var jsAdminChain =
15846{
15847	_chain: '',
15848
15849	AddItems: function(divId)
15850	{
15851		var main_chain = document.getElementById("main_navchain");
15852		if(!main_chain)
15853			return;
15854
15855		if(this._chain == '')
15856			this._chain = main_chain.innerHTML;
15857		else
15858			main_chain.innerHTML = this._chain;
15859
15860		var div = document.getElementById(divId);
15861		if(!div)
15862			return;
15863
15864		main_chain.innerHTML += '<span class="adm-navchain-delimiter"></span>';
15865		main_chain.innerHTML += div.innerHTML;
15866	}
15867}
15868
15869/************************************************/
15870
15871function JCHttpRequest()
15872{
15873	this.Action = null; //function(result){}
15874
15875	this._OnDataReady = function(result)
15876	{
15877		if(this.Action)
15878			this.Action(result);
15879	}
15880
15881	this._CreateHttpObject = function()
15882	{
15883		var obj = null;
15884		if(window.XMLHttpRequest)
15885		{
15886			try {obj = new XMLHttpRequest();} catch(e){}
15887		}
15888        else if(window.ActiveXObject)
15889        {
15890            try {obj = new ActiveXObject("Microsoft.XMLHTTP");} catch(e){}
15891            if(!obj)
15892            	try {obj = new ActiveXObject("Msxml2.XMLHTTP");} catch (e){}
15893        }
15894        return obj;
15895	}
15896
15897	this._SetHandler = function(httpRequest)
15898	{
15899		var _this = this;
15900		httpRequest.onreadystatechange = function()
15901		{
15902			if(httpRequest.readyState == 4)
15903			{
15904//				try
15905				{
15906					var s = httpRequest.responseText;
15907					var code = [];
15908					var start, end;
15909					while((start = s.indexOf('<script>')) != -1)
15910					{
15911						var end = s.indexOf('</script>', start);
15912						if(end == -1)
15913							break;
15914
15915						code[code.length] = s.substr(start+8, end-start-8);
15916						s = s.substr(0, start) + s.substr(end+9);
15917					}
15918					_this._OnDataReady(s);
15919
15920					for(var i = 0, cnt = code.length; i < cnt; i++)
15921						if(code[i] != '')
15922							jsUtils.EvalGlobal(code[i]);
15923				}
15924/*
15925				catch (e)
15926				{
15927					var w = window.open("about:blank");
15928					w.document.write(httpRequest.responseText);
15929					w.document.close();
15930				}
15931*/
15932			}
15933		}
15934	}
15935
15936	this.Send = function(url)
15937	{
15938		var httpRequest = this._CreateHttpObject();
15939		if(httpRequest)
15940		{
15941			httpRequest.open("GET", url, true);
15942			this._SetHandler(httpRequest);
15943			return httpRequest.send("");
15944  		}
15945	}
15946
15947	this.Post = function(url, data)
15948	{
15949		var httpRequest = this._CreateHttpObject();
15950		if(httpRequest)
15951		{
15952			httpRequest.open("POST", url, true);
15953			this._SetHandler(httpRequest);
15954			httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
15955			return httpRequest.send(data);
15956  		}
15957	}
15958}
15959var CHttpRequest = new JCHttpRequest();
15960
15961/************************************************/
15962
15963/***** DEPRECATED! Use BX.userOptions from core_ajax.js **********/
15964function JCUserOptions()
15965{
15966	var _this = this;
15967	this.options = null;
15968	this.bSend = false;
15969	this.request = new JCHttpRequest();
15970
15971	this.GetParams = function()
15972	{
15973		if (BX && BX.userOptions)
15974		{
15975			_this.GetParams = BX.userOptions.__get;
15976			return _this.GetParams.apply(BX.userOptions, arguments);
15977		}
15978
15979		var sParam = '';
15980		var n = -1;
15981		var prevParam = '';
15982		for(var i in _this.options)
15983		{
15984			var aOpt = _this.options[i];
15985			if(prevParam != aOpt[0]+'.'+aOpt[1])
15986			{
15987				n++;
15988				sParam += '&p['+n+'][c]='+encodeURIComponent(aOpt[0]);
15989				sParam += '&p['+n+'][n]='+encodeURIComponent(aOpt[1]);
15990				if(aOpt[4] == true)
15991					sParam += '&p['+n+'][d]=Y';
15992				prevParam = aOpt[0]+'.'+aOpt[1];
15993			}
15994			sParam += '&p['+n+'][v]['+encodeURIComponent(aOpt[2])+']='+encodeURIComponent(aOpt[3]);
15995		}
15996
15997		return sParam.substr(1);
15998	}
15999
16000	this.SaveOption = function(sCategory, sName, sValName, sVal, bCommon)
16001	{
16002		if (BX && BX.userOptions)
16003		{
16004			_this.SaveOption = BX.userOptions.save;
16005			return _this.SaveOption.apply(BX.userOptions, arguments);
16006		}
16007
16008		if(!this.options)
16009			this.options = new Object();
16010
16011		if(bCommon != true)
16012			bCommon = false;
16013		this.options[sCategory+'.'+sName+'.'+sValName] = [sCategory, sName, sValName, sVal, bCommon];
16014
16015		var sParam = this.GetParams();
16016		if(sParam != '')
16017			document.cookie = phpVars.cookiePrefix+"_LAST_SETTINGS=" + sParam + "&sessid="+phpVars.bitrix_sessid+"; expires=Thu, 31 Dec 2020 23:59:59 GMT; path=/;";
16018
16019		if(!this.bSend)
16020		{
16021			this.bSend = true;
16022			setTimeout(function(){_this.SendData(null)}, 5000);
16023		}
16024	}
16025
16026	this.SendData = function(callback)
16027	{
16028		if (BX && BX.userOptions)
16029		{
16030			_this.SendData = BX.userOptions.send;
16031			return _this.SendData.apply(BX.userOptions, arguments);
16032		}
16033
16034		var sParam = _this.GetParams();
16035		_this.options = null;
16036		_this.bSend = false;
16037		if(sParam != '')
16038		{
16039			document.cookie = phpVars.cookiePrefix+"_LAST_SETTINGS=; path=/;";
16040			_this.request.Action = callback;
16041			_this.request.Send('/bitrix/admin/user_options.php?'+sParam+'&sessid='+phpVars.bitrix_sessid);
16042		}
16043	}
16044
16045	this.DeleteOption = function(sCategory, sName, bCommon, callback)
16046	{
16047		if (BX && BX.userOptions)
16048		{
16049			_this.DeleteOption = BX.userOptions.del;
16050			return _this.DeleteOption.apply(BX.userOptions, arguments);
16051		}
16052
16053		_this.request.Action = callback;
16054		_this.request.Send('/bitrix/admin/user_options.php?action=delete&c='+sCategory+'&n='+sName+(bCommon == true? '&common=Y':'')+'&sessid='+phpVars.bitrix_sessid);
16055	}
16056}
16057var jsUserOptions = new JCUserOptions();
16058
16059/************************************************/
16060
16061function JCPanel()
16062{
16063	var _this = this;
16064
16065	this.FixPanel = function()
16066	{
16067		var a = document.getElementById('admin_panel_fix_link');
16068		var panel = document.getElementById('bx_top_panel_container');
16069		var backDiv = document.getElementById('bx_top_panel_back');
16070		var bFixed = (panel.style.position == 'fixed' || panel.style.position == 'absolute');
16071		var bIE = jsUtils.IsIE();
16072		if(bIE)
16073		{
16074			try{panel.style.removeExpression("top");} catch(e) {bIE = false;}
16075		}
16076		if(bFixed)
16077		{
16078			a.title = phpVars.messPanelFixOn;
16079			a.className = 'fix-link fix-on';
16080			panel.style.position = '';
16081			backDiv.style.display = 'none';
16082			if(bIE)
16083			{
16084				panel.style.removeExpression("top");
16085				panel.style.removeExpression("left");
16086				panel.style.removeExpression("width");
16087				panel.style.width = '100%';
16088
16089				var frame = document.getElementById("admin_panel_frame");
16090				if(frame)
16091					frame.style.visibility = 'hidden';
16092			}
16093		}
16094		else
16095		{
16096			this.ShowOn();
16097			if(bIE)
16098			{
16099				var frame = document.getElementById("admin_panel_frame");
16100				if(frame)
16101					frame.style.visibility = 'visible';
16102				else
16103					this.CreateFrame(panel);
16104			}
16105		}
16106		jsUserOptions.SaveOption('admin_panel', 'settings', 'fix', (bFixed? 'off':'on'));
16107	}
16108
16109	this.ShowOn = function()
16110	{
16111		var a = document.getElementById('admin_panel_fix_link');
16112		var panel = document.getElementById('bx_top_panel_container');
16113		var backDiv = document.getElementById('bx_top_panel_back');
16114		var bIE = jsUtils.IsIE();
16115		if(bIE)
16116		{
16117			try{panel.style.setExpression("top", "0");} catch(e) {bIE = false;}
16118		}
16119
16120		a.title = phpVars.messPanelFixOff;
16121		a.className = 'fix-link fix-off';
16122		panel.style.position = (bIE? 'absolute':'fixed');
16123		panel.style.left = '0px';
16124		panel.style.top = '0px';
16125		panel.style.zIndex = '1000';
16126		if(bIE)
16127		{
16128			if(document.body.currentStyle.backgroundImage == 'none')
16129			{
16130				document.body.style.backgroundImage = "url(/bitrix/images/1.gif)";
16131				document.body.style.backgroundAttachment = "fixed";
16132				document.body.style.backgroundRepeat = "no-repeat";
16133			}
16134			panel.style.setExpression("top", "eval((document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop)");
16135			panel.style.setExpression("left", "eval((document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft)");
16136			panel.style.setExpression("width", "eval((document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth)");
16137		}
16138		backDiv.style.height = panel.offsetHeight+'px';
16139		backDiv.style.display = 'block';
16140	}
16141
16142	this.FixOn = function()
16143	{
16144		this.ShowOn();
16145		jsUtils.addEvent(window, "load", this.AdjustBackDiv);
16146	}
16147
16148	this.AdjustBackDiv = function()
16149	{
16150		var panel = document.getElementById('bx_top_panel_container');
16151		var backDiv = document.getElementById('bx_top_panel_back');
16152
16153		var bIE = jsUtils.IsIE();
16154		if(bIE)
16155		{
16156			try{backDiv.style.setExpression("height", "0");} catch(e) {bIE = false;}
16157		}
16158
16159		backDiv.style.height = panel.offsetHeight+'px';
16160
16161		if(bIE)
16162			_this.CreateFrame(panel);
16163	}
16164
16165	this.CreateFrame = function(panel)
16166	{
16167		var frame = document.createElement("IFRAME");
16168		frame.src = "javascript:void(0)";
16169		frame.id = "admin_panel_frame";
16170		frame.style.position = 'absolute';
16171		frame.style.overflow = 'hidden';
16172		frame.style.zIndex = parseInt(panel.currentStyle.zIndex)-1;
16173		frame.style.height = panel.offsetHeight + "px";
16174		document.body.appendChild(frame);
16175		frame.style.setExpression("top", "eval(document.body.scrollTop)");
16176		frame.style.setExpression("left", "eval(document.body.scrollLeft)");
16177		frame.style.setExpression("width", "eval(document.body.clientWidth)");
16178		return frame;
16179	}
16180
16181	this.IsFixed = function()
16182	{
16183		var panel = document.getElementById('bx_top_panel_container');
16184		return (panel && (panel.style.position == 'fixed' || panel.style.position == 'absolute'));
16185	}
16186
16187	this.DisplayPanel = function(el)
16188	{
16189		var div = document.getElementById('bx_top_panel_splitter');
16190		if(div.style.display == 'none')
16191		{
16192			div.style.display = 'block';
16193			el.className = 'splitterknob';
16194			el.title = phpVars.messPanelCollapse;
16195			jsUserOptions.SaveOption('admin_panel', 'settings', 'collapsed', 'off');
16196		}
16197		else
16198		{
16199			div.style.display = 'none';
16200			el.className = 'splitterknob splitterknobdown';
16201			el.title = phpVars.messPanelExpand;
16202			jsUserOptions.SaveOption('admin_panel', 'settings', 'collapsed', 'on');
16203		}
16204		var panel = document.getElementById('bx_top_panel_container');
16205		var backDiv = document.getElementById('bx_top_panel_back');
16206		backDiv.style.height = panel.offsetHeight+'px';
16207		var frame = document.getElementById("admin_panel_frame");
16208		if(frame)
16209			frame.style.height = panel.offsetHeight + "px";
16210	}
16211}
16212var jsPanel = new JCPanel();
16213
16214//***************************************************
16215
16216function JCDebugWindow()
16217{
16218	var _this = this;
16219	this.div_id = 'BX_DEBUG_WINDOW';
16220	this.div_current = null;
16221	this.div_detail_current = null;
16222
16223	this.Show = function(info_id)
16224	{
16225		var div = document.getElementById(this.div_id);
16226		if(div)
16227		{
16228			div.style.display = 'block';
16229			var info_div = document.getElementById(info_id);
16230			if(info_div)
16231			{
16232				if(this.div_current)
16233					this.div_current.style.display = 'none';
16234
16235				info_div.style.display = 'block';
16236				this.div_current = info_div;
16237
16238				this.ShowDetails(info_id+'_1');
16239			}
16240
16241			//var left = parseInt(document.body.scrollLeft + document.body.clientWidth/2 - div.offsetWidth/2);
16242			//var top = parseInt(document.body.scrollTop + document.body.clientHeight/2 - div.offsetHeight/2);
16243
16244			var windowSize = jsUtils.GetWindowSize();
16245
16246			var left = parseInt(windowSize["scrollLeft"] + windowSize["innerWidth"]/2 - div.offsetWidth/2);
16247			var top = parseInt(windowSize["scrollTop"] + windowSize["innerHeight"]/2 - div.offsetHeight/2);
16248
16249			jsFloatDiv.Show(div, left, top);
16250			jsUtils.addEvent(document, "keypress", this.OnKeyPress);
16251		}
16252	}
16253
16254	this.Close = function()
16255	{
16256		jsUtils.removeEvent(document, "keypress", this.OnKeyPress);
16257		var div = document.getElementById(this.div_id);
16258		jsFloatDiv.Close(div);
16259		div.style.display = 'none';
16260	}
16261
16262	this.OnKeyPress = function(e)
16263	{
16264		if(!e) e = window.event
16265		if(!e) return;
16266		if(e.keyCode == 27)
16267			_this.Close();
16268	}
16269
16270	this.ShowDetails = function(div_id)
16271	{
16272		var div = document.getElementById(div_id);
16273		if(div)
16274		{
16275			if(this.div_detail_current)
16276				this.div_detail_current.style.display = 'none';
16277
16278			div.style.display = 'block';
16279			this.div_detail_current = div;
16280		}
16281	}
16282}
16283var jsDebugWindow = new JCDebugWindow();
16284
16285//***************************************************
16286
16287function ImgShw(ID, width, height, alt)
16288{
16289	var scroll = "no";
16290	var top=0, left=0;
16291	if(width > screen.width-10 || height > screen.height-28) scroll = "yes";
16292	if(height < screen.height-28) top = Math.floor((screen.height - height)/2-14);
16293	if(width < screen.width-10) left = Math.floor((screen.width - width)/2-5);
16294	width = Math.min(width, screen.width-10);
16295	height = Math.min(height, screen.height-28);
16296	var wnd = window.open("","","scrollbars="+scroll+",resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
16297	wnd.document.write(
16298		"<html><head>"+
16299		"<"+"script type=\"text/javascript\">"+
16300		"function KeyPress()"+
16301		"{"+
16302		"	if(window.event.keyCode == 27) "+
16303		"		window.close();"+
16304		"}"+
16305		"</"+"script>"+
16306		"<title></title></head>"+
16307		"<body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onKeyPress=\"KeyPress()\">"+
16308		"<img src=\""+ID+"\" border=\"0\" alt=\""+alt+"\" />"+
16309		"</body></html>"
16310	);
16311	wnd.document.close();
16312}
16313
16314
16315var WizardWindow = {
16316
16317	iframe : null,
16318	messLoading : phpVars.messLoading,
16319	currentDialog : null,
16320	currentFrame : null,
16321	isClosed : false,
16322	frameLoaded : false,
16323	//dialogs : {},
16324
16325	Open : function(wizardName, sessid)
16326	{
16327		/*if (this.dialogs[wizardName])
16328		{
16329			this.currentDialog = this.dialogs[wizardName].dialog;
16330			this.currentFrame = this.dialogs[wizardName].frame;
16331			this.currentDialog.Show();
16332			return;
16333		}*/
16334
16335		this.currentDialog = new BX.CWizardDialog({
16336			'width':'700',
16337			'height':'400',
16338			resizable: false
16339		});
16340		this.isClosed = false;
16341		this.frameLoaded = false;
16342
16343		BX.addCustomEvent(this.currentDialog, "onBeforeWindowClose", BX.proxy(this.onBeforeWindowClose, this));
16344
16345		var iframeID = Math.random();
16346		this.currentDialog.SetContent('<iframe class="content" style="background-color: transparent; height:400px;" allowtransparency="true" scrolling="no" id="wizard_iframe_' + iframeID + '" width="100%" src="/bitrix/admin/wizard_install.php?lang='+phpVars.LANGUAGE_ID+'&wizardName='+wizardName+'&bxsender=admin_wizard_dialog&sessid='+sessid+'" frameborder="0"></iframe>');
16347		this.currentDialog.Show();
16348
16349		setTimeout(BX.proxy(function() { if (!this.frameLoaded) {this.ShowWaitWindow();} }, this), 400);
16350		this.currentFrame = BX("wizard_iframe_" + iframeID);
16351		BX.bind(this.currentFrame, "load", BX.proxy(this.OnFrameLoad, this));
16352
16353		//this.dialogs[wizardName] = { dialog : this.currentDialog, frame : this.currentFrame };
16354	},
16355
16356	OnFrameLoad : function()
16357	{
16358		this.frameLoaded = true;
16359		this.HideWaitWindow();
16360
16361		var iframeWindow = this.currentFrame.contentWindow;
16362
16363		var iframeDocument = null;
16364		if (this.currentFrame.contentDocument)
16365			iframeDocument = this.currentFrame.contentDocument;
16366		else
16367			iframeDocument = this.currentFrame.contentWindow.document;
16368
16369		if(iframeWindow.focus)
16370			iframeWindow.focus();
16371		else
16372			iframeDocument.body.focus();
16373	},
16374
16375	Close : function()
16376	{
16377		if (this.currentDialog)
16378		{
16379			this.isClosed = true;
16380			this.currentDialog.Close(true);
16381		}
16382	},
16383
16384	ShowWaitWindow : function()
16385	{
16386		if (this.currentDialog && BX.type.isDomNode(this.currentDialog.PARTS.CONTENT))
16387		{
16388			var waiter = document.createElement("DIV");
16389			waiter.id = "__bx_wait_window";
16390			waiter.className = "";
16391			waiter.style.position = "absolute";
16392			waiter.style.left = "40%";
16393			waiter.style.top = "40%";
16394			waiter.style.zIndex = "3000";
16395			waiter.style.padding = "15px 10px 15px 35px";
16396			waiter.style.width = "auto";
16397			waiter.style.fontSize = "12px";
16398			waiter.style.borderRadius = "4px";
16399			waiter.style.boxShadow = "0 0 10px 1px #dfdfdf";
16400			waiter.style.border = "1px solid #DCE7ED";
16401			waiter.style.lineHeight = "9px";
16402			waiter.style.background = "#fff url(/bitrix/panel/main/images/waiter-white.gif) 3px center no-repeat";
16403			waiter.innerHTML = this.messLoading;
16404
16405			this.currentDialog.PARTS.CONTENT.appendChild(waiter);
16406		}
16407	},
16408
16409	HideWaitWindow : function()
16410	{
16411		var waiter = BX("__bx_wait_window");
16412		if (waiter && waiter.parentNode)
16413			waiter.parentNode.removeChild(waiter);
16414	},
16415
16416	onBeforeWindowClose : function(dialog)
16417	{
16418		if (this.isClosed === false)
16419		{
16420			dialog.denyClose = !confirm(BX.message("ADMIN_WIZARD_EXIT_ALERT"));
16421		}
16422	}
16423};
16424
16425//************************************************************
16426
16427function JCStartMenu()
16428{
16429	var menuStart = null;
16430	var request = new JCHttpRequest();
16431	var _this = this;
16432
16433	this.EvalMenu = function(result)
16434	{
16435		if(jsUtils.trim(result).length == 0)
16436			return;
16437
16438		var menuItems;
16439        try
16440        {
16441		    eval(result); // menuItems={'styles':[], 'items':[]}
16442        }
16443        catch(e)
16444        {
16445        }
16446
16447		if(!menuItems)
16448			return false;
16449
16450		//Applying styles
16451		var head = document.getElementsByTagName("HEAD");
16452		if(head && head[0])
16453		{
16454			var style = document.createElement("STYLE");
16455			head[0].appendChild(style);
16456			if(jsUtils.IsIE())
16457				document.styleSheets[document.styleSheets.length-1].cssText = menuItems['styles'];
16458			else
16459				style.appendChild(document.createTextNode(menuItems['styles']));
16460		}
16461		return menuItems;
16462	}
16463
16464	this.ShowStartMenu = function(button, back_url)
16465	{
16466		var dPos = {'left':0, 'top':0, 'right':0, 'bottom':0};
16467		if(!menuStart || !menuStart.menuItems)
16468		{
16469			request.Action = function(result)
16470			{
16471				var menuItems = _this.EvalMenu(result);
16472				if(menuItems)
16473				{
16474					//show menu
16475					menuStart.PopupHide();
16476					menuStart.ShowMenu(button, menuItems['items'], jsPanel.IsFixed(), dPos);
16477				}
16478			}
16479			//create menu
16480			menuStart = new PopupMenu('panel_start_menu');
16481			menuStart.Create(1100);
16482			menuStart.ShowMenu(button, [{
16483				'TEXT':phpVars.messMenuLoading,
16484				'TITLE':phpVars.messMenuLoadingTitle,
16485				'ICONCLASS':'loading',
16486				'AUTOHIDE':false}], jsPanel.IsFixed(), dPos);
16487			request.Send('/bitrix/admin/get_start_menu.php?lang='+phpVars.LANGUAGE_ID+(back_url? '&back_url_pub='+encodeURIComponent(back_url):'')+'&sessid='+phpVars.bitrix_sessid);
16488		}
16489		else
16490		{
16491			menuStart.ShowMenu(button, null, jsPanel.IsFixed(), dPos);
16492		}
16493	}
16494
16495	this.PreloadMenu = function(back_url)
16496	{
16497		if(!menuStart)
16498		{
16499			request.Action = function(result)
16500			{
16501				var menuItems = _this.EvalMenu(result);
16502				if(menuItems)
16503				{
16504					//show menu
16505					menuStart.SetItems(menuItems['items']);
16506					menuStart.BuildItems();
16507				}
16508			}
16509			//create menu
16510			menuStart = new PopupMenu('panel_start_menu');
16511			menuStart.Create(1100);
16512			request.Send('/bitrix/admin/get_start_menu.php?lang='+phpVars.LANGUAGE_ID+(back_url? '&back_url_pub='+encodeURIComponent(back_url):'')+'&sessid='+phpVars.bitrix_sessid);
16513		}
16514	}
16515
16516	this.OpenDynMenu = function(menu, module_id, items_id, back_url)
16517	{
16518		request.Action = function(result)
16519		{
16520			if(jsUtils.trim(result).length == 0)
16521				return;
16522
16523			var menuItems;
16524			eval(result); // menuItems={'items':[]}
16525
16526			if(menu && menuItems)
16527			{
16528				var bVisible = menu.IsVisible();
16529				menu.PopupHide();
16530				menu.SetItems(menuItems['items']);
16531				menu.BuildItems();
16532				menu.parentMenu.ShowSubmenu(menu.parentItem, false, !bVisible);
16533			}
16534		}
16535		request.Send('/bitrix/admin/get_start_menu.php?mode=dynamic&lang='+phpVars.LANGUAGE_ID+'&admin_mnu_module_id='+encodeURIComponent(module_id)+'&admin_mnu_menu_id='+encodeURIComponent(items_id)+(back_url? '&back_url_pub='+encodeURIComponent(back_url):'')+'&sessid='+phpVars.bitrix_sessid);
16536	}
16537
16538	this.OpenURL = function(item, arguments, url, back_url)
16539	{
16540		var itemInfo = menuStart.GetItemInfo(item);
16541		if(itemInfo)
16542		{
16543			request.Action = function(result){}
16544			request.Send('/bitrix/admin/get_start_menu.php?mode=save_recent&url='+encodeURIComponent(url)+'&text='+encodeURIComponent(itemInfo['TEXT'])+'&title='+encodeURIComponent(itemInfo['TITLE'])+'&icon='+itemInfo['ICON']+'&sessid='+phpVars.bitrix_sessid);
16545		}
16546		if(back_url)
16547			url += (url.indexOf('?')>=0? '&':'?')+'back_url_pub='+encodeURIComponent(back_url);
16548		jsUtils.Redirect(arguments, url);
16549	}
16550}
16551var jsStartMenu = new JCStartMenu();
16552
16553//************************************************************
16554//Admin edit form functions
16555
16556function OnAdd(id)
16557{
16558	var frm=document.form_settings;
16559	if(id == 'tabs_add')
16560	{
16561		var oSelect = document.getElementById('selected_tabs');
16562		if(oSelect)
16563		{
16564			var name = prompt(arFormEditMess.admin_lib_sett_tab_prompt, arFormEditMess.admin_lib_sett_tab_default_name);
16565			if(name && name.length > 0)
16566			{
16567				var n = oSelect.length;
16568				var c = 0;
16569				var found = true;
16570				while(found)
16571				{
16572					c++;
16573					found = false;
16574					for(var i=0; i<n; i++)
16575						if(oSelect[i].value == 'cedit'+c)
16576							found = true;
16577				}
16578				jsSelectUtils.addNewOption('selected_tabs', 'cedit'+c, name, false);
16579				var td = document.getElementById('selected_fields');
16580				var newSelect = document.createElement('SPAN');
16581				td.appendChild(newSelect);
16582				newSelect.innerHTML = '<select style="display:none" class="select" name="selected_fields[cedit' + c + ']" id="selected_fields[cedit' + c + ']" size="12" multiple onchange="Sync();"></select>';
16583				jsSelectUtils.selectOption('selected_tabs', 'cedit'+c);
16584			}
16585		}
16586	}
16587	if(id == 'tabs_copy')
16588	{
16589		var oSelectFrom = document.getElementById('available_tabs');
16590		var oSelectTo = document.getElementById('selected_tabs');
16591		if(oSelectFrom && oSelectTo)
16592		{
16593			var n = oSelectFrom.length;
16594			var k = oSelectTo.length;
16595			var c = 0;
16596			for(var i=0; i<n; i++)
16597				if(oSelectFrom[i].selected)
16598				{
16599					var found = false;
16600					for(var j=0; j<k; j++)
16601						if(oSelectTo[j].value == oSelectFrom[i].value)
16602							found = true;
16603					if(!found)
16604					{
16605						var td = document.getElementById('selected_fields');
16606						var newSelect = document.createElement('SPAN');
16607						var newID = 'selected_fields[' + oSelectFrom[i].value + ']';
16608						td.appendChild(newSelect);
16609						newSelect.innerHTML = '<select style="display:none" class="select" name="' + newID + '" id="' + newID + '" size="12" multiple onchange="Sync();"></select>';
16610
16611						jsSelectUtils.addNewOption('selected_tabs', oSelectFrom[i].value, oSelectFrom[i].text, false);
16612						jsSelectUtils.selectAllOptions('available_fields');
16613						jsSelectUtils.addSelectedOptions(document.getElementById('available_fields'), newID);
16614
16615						jsSelectUtils.selectOption('selected_tabs', oSelectFrom[i].value);
16616
16617					}
16618				}
16619		}
16620	}
16621	if(id == 'fields_add')
16622	{
16623		var oSelect = document.getElementById('selected_tabs');
16624		var prefix = '';
16625		if(oSelect)
16626		{
16627			for(var i = 0; i < oSelect.length; i++)
16628				if(oSelect[i].selected)
16629					prefix = oSelect[i].value;
16630		}
16631
16632		oSelect = GetFieldsActiveSelect();
16633		if(oSelect)
16634		{
16635			var name = prompt(arFormEditMess.admin_lib_sett_sec_prompt, arFormEditMess.admin_lib_sett_sec_default_name);
16636			if(name && name.length > 0)
16637			{
16638				var n = oSelect.length;
16639				var c = 0;
16640				var found = true;
16641				while(found)
16642				{
16643					c++;
16644					found = false;
16645					for(var i=0; i<n; i++)
16646						if(oSelect[i].value == prefix+'_csection'+c)
16647							found = true;
16648				}
16649				jsSelectUtils.addNewOption(oSelect.id, prefix+'_csection'+c, '--'+name, false);
16650				jsSelectUtils.selectOption(oSelect.id, prefix+'_csection'+c);
16651			}
16652		}
16653	}
16654	if(id == 'fields_copy')
16655	{
16656		var oSelectFrom = document.getElementById('available_fields');
16657		var oSelectTo = GetFieldsActiveSelect();
16658		if(oSelectFrom && oSelectTo && !oSelectTo.disabled)
16659		{
16660			//find last selected item in selected_fields
16661			var i, last = oSelectTo.length - 1;
16662			for(i = 0; i < oSelectTo.length; i++)
16663			{
16664				if(oSelectTo[i].selected)
16665					last = i;
16666			}
16667			//Delete all after last selected
16668			var tail = new Array;
16669			for(i = oSelectTo.length - 1; i > last; i--)
16670			{
16671				var newoption = new Option(oSelectTo[i].text, oSelectTo[i].value, false, false);
16672				newoption.innerHTML = oSelectTo[i].innerHTML;
16673				tail[tail.length] = newoption;
16674				oSelectTo.remove(i);
16675			}
16676			//Deselect all selected_fields
16677			for(i = 0; i < oSelectTo.length; i++)
16678				if(oSelectTo[i].selected)
16679					oSelectTo[i].selected = false;
16680			//Add new options
16681			var sel_count = 0, sel_value = '';
16682			for(i = 0; i < oSelectFrom.length; i++)
16683			{
16684				if(oSelectFrom[i].selected)
16685				{
16686					jsSelectUtils.addNewOption(oSelectTo.id, oSelectFrom[i].value, oSelectFrom[i].text, false);
16687					oSelectTo[oSelectTo.length - 1].selected = true;
16688					sel_count++;
16689					if(i < (oSelectFrom.length - 1))
16690						sel_value = oSelectFrom[i+1].value;
16691					else
16692						sel_value = '';
16693//					else if(i > 0)
16694//							sel_value = oSelectFrom[i-1].value;
16695				}
16696			}
16697			//Append selected_fields tail
16698			var n = oSelectTo.length;
16699			for(i = tail.length - 1; i >= 0; i--)
16700			{
16701				oSelectTo[n] = tail[i];
16702				n++;
16703			}
16704			if((sel_count == 1) && sel_value)
16705				jsSelectUtils.selectOption(oSelectFrom.id, sel_value);
16706		}
16707	}
16708	Sync();
16709}
16710function OnDelete(id)
16711{
16712	if(id == 'tabs_delete')
16713	{
16714		var selected_tabs = document.getElementById('selected_tabs');
16715		for(var i = 0; i < selected_tabs.length; i++)
16716		{
16717			if(selected_tabs[i].selected)
16718			{
16719				var selected_fields = document.getElementById('selected_fields[' + selected_tabs[i].value + ']');
16720				var p = selected_fields.parentNode;
16721				p.removeChild(selected_fields);
16722			}
16723		}
16724
16725		jsSelectUtils.deleteSelectedOptions(selected_tabs.id);
16726		//For Opera deselect options
16727		jsSelectUtils.selectOption(selected_tabs.id, '');
16728	}
16729	if(id == 'fields_delete')
16730	{
16731		var selected_fields = GetFieldsActiveSelect();
16732		if(selected_fields)
16733		{
16734			jsSelectUtils.deleteSelectedOptions(selected_fields.id);
16735			//For Opera deselect options
16736			jsSelectUtils.selectOption(selected_fields.id, '');
16737		}
16738	}
16739	Sync();
16740}
16741
16742
16743function Sync()
16744{
16745	var i,j,n,found;
16746	var available_tabs = document.getElementById('available_tabs');
16747	var available_fields = document.getElementById('available_fields');
16748	var selected_tabs = document.getElementById('selected_tabs');
16749
16750	//1 available_tabs
16751	//1.1 Save selection
16752	var available_tabs_selection = '';
16753	for(i = 0; i < available_tabs.length; i++)
16754		if(available_tabs[i].selected)
16755			available_tabs_selection = available_tabs[i].value;
16756	//2 available_fields
16757	//2.1 Save selection
16758	var available_fields_selection = new Object;
16759	for(i = 0; i < available_fields.length; i++)
16760	{
16761		if(available_fields[i].selected)
16762			available_fields_selection[available_fields[i].value] = available_fields[i].value;
16763	}
16764	//2.2 Clear list
16765	jsSelectUtils.selectAllOptions(available_fields.id);
16766	jsSelectUtils.deleteSelectedOptions(available_fields.id);
16767	//2.3 Fill list with fields missed
16768	if(available_tabs_selection)
16769	{
16770		var all_selected_fields = new Object;
16771		for(i = 0; i < selected_tabs.length; i++)
16772		{
16773			var selected_fields = document.getElementById('selected_fields[' + selected_tabs[i].value + ']');
16774			for(j = 0; j < selected_fields.length; j++)
16775				all_selected_fields[selected_fields[j].value] = selected_fields[j].value;
16776		}
16777		n = 0;
16778		for(available_field in arSystemTabsFields[available_tabs_selection])
16779		{
16780			if(!all_selected_fields[available_field])
16781			{
16782				var newoption = new Option(arSystemFields[available_field], available_field, false, false);
16783				available_fields.options[n] = newoption;
16784				available_fields.options[n].innerHTML = arSystemFields[available_field];
16785				n++;
16786			}
16787		}
16788		//2.4 Set selection
16789		for(i = 0; i < available_fields.length; i++)
16790			if(available_fields_selection[available_fields[i].value])
16791				available_fields[i].selected = true;
16792	}
16793
16794	//3 selected_tabs
16795
16796	//4 selected_fields
16797	found = false;
16798	for(i = 0; i < selected_tabs.length; i++)
16799	{
16800		var selected_fields = document.getElementById('selected_fields[' + selected_tabs[i].value + ']');
16801		if(selected_tabs[i].selected)
16802		{
16803			selected_fields.style.display = 'block';
16804			found = true;
16805		}
16806		else
16807		{
16808			selected_fields.style.display = 'none';
16809		}
16810	}
16811	if(found)
16812		document.getElementById('selected_fields[undef]').style.display = 'none';
16813	else
16814		document.getElementById('selected_fields[undef]').style.display = 'block';
16815
16816	//5 disable and enable buttons
16817	//5.0 calculate selections counters
16818	var selected_tabs_count = 0;
16819	for(i = 0; i < selected_tabs.length; i++)
16820		if(selected_tabs[i].selected)
16821			selected_tabs_count++;
16822	var available_tabs_count = 0;
16823	for(i = 0; i < available_tabs.length; i++)
16824		if(available_tabs[i].selected)
16825			available_tabs_count++;
16826	//tabs_delete enabled if selected_tabs have selection
16827	document.getElementById('tabs_delete').disabled = selected_tabs_count <= 0;
16828	//tabs_copy enabled if available_tabs have selection and this selection does not exists in
16829	//		selected fields
16830	if(available_tabs_count <= 0)
16831	{
16832		document.getElementById('tabs_copy').disabled = true;
16833	}
16834	else
16835	{
16836		found = false;
16837		for(i = 0; i < selected_tabs.length; i++)
16838			if(selected_tabs[i].value == available_tabs_selection)
16839				found = true;
16840		document.getElementById('tabs_copy').disabled = found;
16841	}
16842	//tabs_up enabled if selected_tabs have selection
16843	document.getElementById('tabs_up').disabled = selected_tabs_count <= 0;
16844	//tabs_down enabled if selected_tabs have selection
16845	document.getElementById('tabs_down').disabled = selected_tabs_count <= 0;
16846	//tabs_rename enabled if selected_tabs have one item selected
16847	document.getElementById('tabs_rename').disabled = selected_tabs_count != 1;
16848	//tabs_add always selected
16849	document.getElementById('tabs_add').disabled = false;
16850
16851	var selected_fields_count = 0;
16852	for(i = 0; i < selected_tabs.length; i++)
16853	{
16854		if(selected_tabs[i].selected)
16855		{
16856			var selected_fields = document.getElementById('selected_fields[' + selected_tabs[i].value + ']');
16857			for(j = 0; j < selected_fields.length; j++)
16858				if(selected_fields[j].selected)
16859					selected_fields_count++;
16860		}
16861	}
16862	var available_fields_count = 0;
16863	for(i = 0; i < available_fields.length; i++)
16864		if(available_fields[i].selected)
16865			available_fields_count++;
16866	//fields_delete enabled if selected_fields have selection
16867	document.getElementById('fields_delete').disabled = selected_fields_count <= 0;
16868	//fields_copy enabled if available_fields have selection and at least one tab selected
16869	document.getElementById('fields_copy').disabled = available_fields_count <= 0 || selected_tabs_count <= 0;
16870	//fields_up enabled if selected_fields have selection
16871	document.getElementById('fields_up').disabled = selected_fields_count <= 0;
16872	//fields_down enabled if selected_fields have selection
16873	document.getElementById('fields_down').disabled = selected_fields_count <= 0;
16874	//fields_rename enabled if selected_fields have one item selected
16875	document.getElementById('fields_rename').disabled = selected_fields_count != 1;
16876	//fields_add enabled if selected_tabs have one item selected
16877	document.getElementById('fields_add').disabled = selected_tabs_count != 1;
16878
16879	var arFields = new Object;
16880	for(var name in arSystemFields)
16881		arFields[name] = arSystemFields[name];
16882	for(i = 0; i < selected_tabs.length; i++)
16883	{
16884		selected_fields = document.getElementById('selected_fields[' + selected_tabs[i].value + ']');
16885		for(j = 0; j < selected_fields.length; j++)
16886			delete arFields[selected_fields[j].value];
16887	}
16888	var save_button = document.getElementById('save_settings');
16889	save_button.disabled = false;
16890	for(var name in arFields)
16891	{
16892		if(arFields[name].substring(0,1) == "*")
16893			save_button.disabled = true;
16894	}
16895}
16896
16897function SyncAvailableFields()
16898{
16899	var oSelect = document.getElementById('available_tabs');
16900	if(oSelect)
16901	{
16902		var k = oSelect.length;
16903		for(var i=0; i<k; i++)
16904		{
16905			oFieldsSelect = document.getElementById('available_fields');
16906			if(oFieldsSelect)
16907			{
16908				jsSelectUtils.selectAllOptions(oFieldsSelect.id);
16909				jsSelectUtils.deleteSelectedOptions(oFieldsSelect.id);
16910				if(oSelect[i].selected)
16911				{
16912					var n = 0;
16913					for(var field_id in arSystemTabsFields[oSelect[i].value])
16914					{
16915						var newoption = new Option(arSystemFields[field_id], field_id, false, false);
16916						oFieldsSelect.options[n]=newoption;
16917						oFieldsSelect.options[n].innerHTML = arSystemFields[field_id];
16918						n++;
16919					}
16920				}
16921			}
16922		}
16923	}
16924}
16925
16926function GetFieldsActiveSelect()
16927{
16928	var oFieldsSelect;
16929	var oSelect = document.getElementById('selected_tabs');
16930	if(oSelect)
16931	{
16932		var k = oSelect.length;
16933		for(var i=0; i<k; i++)
16934		{
16935			oFieldsSelect = document.getElementById('selected_fields[' + oSelect[i].value + ']');
16936			if(oFieldsSelect && oFieldsSelect.style.display == 'block')
16937				return oFieldsSelect;
16938		}
16939	}
16940	return false;
16941}
16942
16943function OnRename(id)
16944{
16945	var frm=document.form_settings;
16946	if(id == 'tabs_rename')
16947	{
16948		var oSelect = document.getElementById('selected_tabs');
16949		if(oSelect)
16950		{
16951			var n = oSelect.length;
16952			var c = 0;
16953			var choice = '';
16954			for(var i=0; i<n; i++)
16955			{
16956				if(oSelect[i].selected)
16957				{
16958					c++;
16959					if(!choice)
16960						choice = oSelect[i].text;
16961				}
16962			}
16963			if(c == 1)
16964			{
16965				var name = prompt(arFormEditMess.admin_lib_sett_tab_rename, choice);
16966				if(name && name.length > 0)
16967				{
16968					for(var i=0; i<n; i++)
16969						if(oSelect[i].selected)
16970						{
16971							oSelect[i].text = name;
16972							break;
16973						}
16974				}
16975			}
16976		}
16977	}
16978	if(id == 'fields_rename')
16979	{
16980		var oSelect = GetFieldsActiveSelect();
16981		if(oSelect)
16982		{
16983			var n = oSelect.length;
16984			var c = 0;
16985			var choice = '';
16986			for(var i=0; i<n; i++)
16987			{
16988				if(oSelect[i].selected)
16989				{
16990					c++;
16991					if(!choice)
16992						choice = oSelect[i].innerHTML;
16993				}
16994			}
16995			if(c == 1)
16996			{
16997				var prefix = '';
16998				if(choice.substring(0, 2) == '--')
16999				{
17000					choice = choice.substring(2);
17001					prefix = '--';
17002				}
17003				else
17004				{
17005					if(choice.substring(0, 1) == '*')
17006					{
17007						choice = choice.substring(1);
17008						prefix = '*';
17009					}
17010					else
17011					{
17012						if(choice.substring(0, 12) == '&nbsp;&nbsp;')
17013						{
17014							choice = choice.substring(12);
17015							prefix = '&nbsp;&nbsp;';
17016						}
17017						else
17018						{
17019							while(choice.substring(0, 2) == '\xA0\xA0' || choice.substring(0, 2) == '\xC2\xA0')
17020							{
17021								choice = choice.substring(2);
17022								prefix = '&nbsp;&nbsp;';
17023							}
17024						}
17025					}
17026				}
17027				var name = prompt(arFormEditMess.admin_lib_sett_sec_rename, choice);
17028				if(name && name.length > 0)
17029				{
17030					for(var i=0; i<n; i++)
17031						if(oSelect[i].selected)
17032						{
17033							if(prefix == '&nbsp;&nbsp;')
17034							{
17035								oSelect[i].text = name;
17036								oSelect[i].innerHTML = '&nbsp;&nbsp;' + oSelect[i].innerHTML;
17037							}
17038							else
17039							{
17040								oSelect[i].text = prefix + name;
17041							}
17042							break;
17043						}
17044				}
17045			}
17046		}
17047	}
17048}
17049function FieldsUpAndDown(direction)
17050{
17051	var oSelect = GetFieldsActiveSelect();
17052	if(oSelect)
17053	{
17054		if(direction == 'up')
17055			jsSelectUtils.moveOptionsUp(oSelect);
17056		else
17057			jsSelectUtils.moveOptionsDown(oSelect);
17058	}
17059}
17060
17061/* End */
17062;
17063; /* Start:/bitrix/js/main/popup_menu.js*/
17064function PopupMenu(id, zIndex, dxShadow)
17065{
17066	var _this = this;
17067	this.menu_id = id;
17068	this.controlDiv = null;
17069	this.zIndex = 100;
17070	this.dxShadow = 3;
17071	this.menuItems = null;
17072	this.submenus = [];
17073	this.bDoHide = false;
17074	this.parentItem = null;
17075	this.parentMenu = null;
17076	this.submenuIndex = null;
17077	this.bHasSubmenus = false;
17078
17079	this.OnClose = null;
17080
17081	if(!isNaN(zIndex))
17082		this.zIndex = zIndex;
17083	if(!isNaN(dxShadow))
17084		this.dxShadow = dxShadow;
17085
17086	this.Create = function(zIndex, dxShadow)
17087	{
17088		if(!isNaN(zIndex))
17089			this.zIndex = zIndex;
17090		if(!isNaN(dxShadow))
17091			this.dxShadow = dxShadow;
17092
17093		var div = document.createElement("DIV");
17094		div.id = this.menu_id;
17095		div.className = "bx-popup-menu";
17096		div.style.position = 'absolute';
17097		div.style.zIndex = this.zIndex;
17098		div.style.left = '-1000px';
17099		div.style.top = '-1000px';
17100		div.style.visibility = 'hidden';
17101		div.onclick = _this.PreventDefault;
17102		document.body.appendChild(div);
17103
17104		div.innerHTML =
17105			'<table cellpadding="0" cellspacing="0" border="0">'+
17106			'<tr><td class="popupmenu">'+
17107			'<table cellpadding="0" cellspacing="0" border="0" id="'+this.menu_id+'_items">'+
17108			'<tr><td></td></tr>'+
17109			'</table>'+
17110			'</td></tr>'+
17111			'</table>';
17112	}
17113
17114	this.ClearItemsStyle = function()
17115	{
17116		var tbl = document.getElementById(this.menu_id+'_items');
17117		for(var i=0; i<tbl.rows.length; i++)
17118		{
17119			var div = jsUtils.FindChildObject(tbl.rows[i].cells[0], "div");
17120			if(div && div.className.indexOf('popupitemover') != -1)
17121			{
17122				div.className = div.className.replace(/\s*popupitemover/i, '');
17123				break;
17124			}
17125		}
17126	}
17127
17128	this.PopupShow = function(pos)
17129	{
17130		var div = document.getElementById(this.menu_id);
17131		if(!div)
17132		{
17133			this.BuildItems();
17134			div = document.getElementById(this.menu_id);
17135		}
17136
17137		this.ClearItemsStyle();
17138
17139		setTimeout(function(){jsUtils.addEvent(document, "click", _this.CheckClick)}, 10);
17140		jsUtils.addEvent(document, "keypress", _this.OnKeyPress);
17141
17142		var w = div.offsetWidth;
17143		var h = div.offsetHeight;
17144		pos = jsUtils.AlignToPos(pos, w, h);
17145
17146		div.style.width = w + 'px';
17147		div.style.visibility = 'visible';
17148
17149		jsFloatDiv.Show(div, pos["left"], pos["top"], this.dxShadow, false);
17150
17151		div.ondrag = jsUtils.False;
17152		div.onselectstart = jsUtils.False;
17153		div.style.MozUserSelect = 'none';
17154	}
17155
17156	this.PopupHide = function()
17157	{
17158		for(var i = 0, length = this.submenus.length; i < length; i++)
17159			if(this.submenus[i] && this.submenus[i].IsVisible())
17160				this.submenus[i].PopupHide();
17161
17162		if(this.parentMenu)
17163			this.parentMenu.submenuIndex = null;
17164
17165		var div = document.getElementById(this.menu_id);
17166		if(div)
17167		{
17168			jsFloatDiv.Close(div);
17169			div.style.visibility = 'hidden';
17170		}
17171
17172		if(this.OnClose)
17173			this.OnClose();
17174
17175		this.controlDiv = null;
17176		jsUtils.removeEvent(document, "click", _this.CheckClick);
17177		jsUtils.removeEvent(document, "keypress", _this.OnKeyPress);
17178	}
17179
17180	this.CheckClick = function(e)
17181	{
17182		for(var i = 0, length = _this.submenus.length; i < length; i++)
17183			if(_this.submenus[i] && !_this.submenus[i].CheckClick(e))
17184				return false;
17185
17186		var div = document.getElementById(_this.menu_id);
17187		if(!div)
17188			return true;
17189
17190		if (div.style.visibility != 'visible')
17191			return true;
17192
17193		var arScroll = jsUtils.GetWindowScrollPos();
17194		var x = e.clientX + arScroll.scrollLeft;
17195		var y = e.clientY + arScroll.scrollTop;
17196
17197		/*menu region*/
17198		var posLeft = parseInt(div.style.left);
17199		var posTop = parseInt(div.style.top);
17200		var posRight = posLeft + parseInt(div.offsetWidth);
17201		var posBottom = posTop + parseInt(div.offsetHeight);
17202		if(x >= posLeft && x <= posRight && y >= posTop && y <= posBottom)
17203			return false;
17204
17205		if(_this.controlDiv)
17206		{
17207			var pos = jsUtils.GetRealPos(_this.controlDiv);
17208			if(x >= pos['left'] && x <= pos['right'] && y >= pos['top'] && y <= pos['bottom'])
17209				return false;
17210		}
17211		_this.PopupHide();
17212		return true;
17213	}
17214
17215	this.OnKeyPress = function(e)
17216	{
17217		if(!e) e = window.event
17218		if(!e) return;
17219		if(e.keyCode == 27)
17220			_this.PopupHide();
17221	}
17222
17223	this.PreventDefault = function(e)
17224	{
17225		if(!e) e = window.event;
17226		if(e.stopPropagation)
17227		{
17228			e.preventDefault();
17229			e.stopPropagation();
17230		}
17231		else
17232		{
17233			e.cancelBubble = true;
17234			e.returnValue = false;
17235		}
17236		return false;
17237	}
17238
17239	this.GetItemIndex = function(item)
17240	{
17241		var item_id = _this.menu_id+'_item_';
17242		var item_index = parseInt(item.id.substr(item_id.length));
17243		return item_index;
17244	}
17245
17246	this.ShowSubmenu = function(item, bMouseOver, bDontShow)
17247	{
17248		if(!item)
17249			item = this;
17250		var item_index = _this.GetItemIndex(item);
17251
17252		if(bMouseOver == true)
17253		{
17254			if(!_this.menuItems[item_index]["__time"])
17255				return;
17256			var dxTime = (new Date()).valueOf() - _this.menuItems[item_index]["__time"];
17257			if(dxTime < 500)
17258				return;
17259		}
17260
17261		var menu;
17262		if(!_this.submenus[item_index])
17263		{
17264			menu = new PopupMenu(_this.menu_id+'_sub_'+item_index);
17265			menu.Create(_this.zIndex+10, _this.dxShadow);
17266			menu.SetItems(_this.menuItems[item_index].MENU);
17267			menu.BuildItems();
17268			menu.parentItem = document.getElementById(_this.menu_id+'_item_'+item_index);
17269			menu.parentMenu = _this;
17270			menu.OnClose = function()
17271			{
17272				jsUtils.addEvent(document, "keypress", _this.OnKeyPress);
17273			}
17274			_this.submenus[item_index] = menu;
17275
17276			if(_this.menuItems[item_index].ONMENUPOPUP)
17277				eval(_this.menuItems[item_index].ONMENUPOPUP);
17278		}
17279		else
17280			menu = _this.submenus[item_index];
17281
17282		_this.submenuIndex = item_index;
17283
17284		if(menu.IsVisible() || bDontShow == true)
17285			return;
17286
17287		var item_pos = jsUtils.GetRealPos(item);
17288		var menu_pos = jsUtils.GetRealPos(document.getElementById(_this.menu_id));
17289		var pos = {'left': menu_pos["right"]-1, 'right': menu_pos["left"]+1, 'top': item_pos["bottom"]+1, 'bottom': item_pos["top"]};
17290
17291		jsUtils.removeEvent(document, "keypress", _this.OnKeyPress);
17292		menu.controlDiv = item;
17293		menu.PopupShow(pos);
17294	}
17295
17296	this.OnSubmenuMouseOver = function()
17297	{
17298		_this.OnItemMouseOver(this);
17299
17300		var item_index = _this.GetItemIndex(this);
17301		if(!_this.menuItems[item_index]["__time"])
17302			_this.menuItems[item_index]["__time"] = (new Date()).valueOf();
17303
17304		var div = this;
17305		setTimeout(function(){_this.ShowSubmenu(div, true)}, 550);
17306	}
17307
17308	this.OnItemMouseOver = function(item)
17309	{
17310		if(_this.bHasSubmenus)
17311			_this.ClearItemsStyle();
17312
17313		var div = (item? item:this);
17314		div.className="popupitem popupitemover";
17315
17316		if(_this.parentItem)
17317		{
17318			_this.bDoHide = false;
17319			if(_this.parentItem.className != "popupitem popupitemover")
17320			{
17321				_this.parentMenu.ClearItemsStyle();
17322				_this.parentItem.className = "popupitem popupitemover";
17323			}
17324		}
17325
17326		if(_this.submenuIndex != null)
17327		{
17328			var item_index = _this.GetItemIndex(div);
17329			if(_this.submenuIndex != item_index && _this.submenus[_this.submenuIndex])
17330			{
17331				_this.submenus[_this.submenuIndex].bDoHide = true;
17332				setTimeout(function(){_this.HideSubmenu()}, 500);
17333			}
17334		}
17335	}
17336
17337	this.OnSubmenuMouseOut = function()
17338	{
17339		var item_index = _this.GetItemIndex(this);
17340		_this.menuItems[item_index]["__time"] = null;
17341	}
17342
17343	this.OnItemMouseOut = function()
17344	{
17345		this.className="popupitem";
17346	}
17347
17348	this.HideSubmenu = function()
17349	{
17350		if(_this.submenuIndex == null)
17351			return;
17352		if(_this.submenus[_this.submenuIndex].bDoHide != true)
17353			return;
17354		_this.submenus[_this.submenuIndex].PopupHide();
17355	}
17356
17357	this.SetItems = function(items)
17358	{
17359		this.menuItems = items;
17360		this.submenus = [];
17361	}
17362
17363	this.SetItemIcon = function(item_id, icon)
17364	{
17365		if(typeof(item_id) == 'string' || item_id instanceof String)
17366		{
17367			for(var i in this.menuItems)
17368			{
17369				if(this.menuItems[i].ID && this.menuItems[i].ID == item_id)
17370				{
17371					this.menuItems[i].ICONCLASS = icon;
17372					var item_td = document.getElementById(item_id);
17373					if(item_td)
17374					{
17375						var div = jsUtils.FindChildObject(item_td, "div");
17376						if(div)
17377							div.className = "icon "+icon;
17378					}
17379					break;
17380				}
17381			}
17382		}
17383		else
17384		{
17385			var div = jsUtils.FindChildObject(jsUtils.FindChildObject(item_id, "td", "gutter", true), "div");
17386			if(div)
17387			{
17388				this.menuItems[this.GetItemIndex(item_id)].ICONCLASS = icon;
17389				div.className = "icon "+icon;
17390			}
17391		}
17392	}
17393
17394	this.SetAllItemsIcon = function(icon)
17395	{
17396		for(var i=0, n=this.menuItems.length; i < n; i++)
17397		{
17398			var item = document.getElementById(this.menu_id+'_item_'+i);
17399			var div = jsUtils.FindChildObject(jsUtils.FindChildObject(item, "td", "gutter", true), "div");
17400			if(div)
17401			{
17402				this.menuItems[i].ICONCLASS = icon;
17403				div.className = "icon "+icon;
17404			}
17405		}
17406	}
17407
17408	this.BuildItems = function()
17409	{
17410		var items = this.menuItems;
17411		if(!items || items.length == 0)
17412			return;
17413
17414		var div = document.getElementById(this.menu_id);
17415		if(!div)
17416		{
17417			this.Create();
17418			div = document.getElementById(this.menu_id);
17419		}
17420		div.style.left='-1000px';
17421		div.style.top='-1000px';
17422		div.style.width='auto';
17423
17424		this.bHasSubmenus = false;
17425		var tbl = document.getElementById(this.menu_id+'_items');
17426		while(tbl.rows.length>0)
17427			tbl.deleteRow(0);
17428
17429		var n = items.length;
17430		for(var i=0; i<n; i++)
17431		{
17432			var row = tbl.insertRow(-1);
17433			var cell = row.insertCell(-1);
17434			if(items[i]['CLASS'])
17435				row.className = items[i]['CLASS'];
17436			if(items[i]['SEPARATOR'])
17437			{
17438				cell.innerHTML = '<div class="popupseparator"><div class="empty"></div></div>';
17439			}
17440			else
17441			{
17442				var s =
17443					'<div id="'+this.menu_id+'_item_'+i+'" class="popupitem"'+(items[i]['DISABLED']!=true && items[i]['ONCLICK']? ' '+(items[i]['MENU']? 'ondblclick':'onclick')+'="'+jsUtils.htmlspecialchars(items[i]['ONCLICK'])+'"':'')+'>'+
17444					'	<div style="width:100%;"><table style="width:100% !important" cellpadding="0" cellspacing="0" border="0" dir="ltr">'+
17445					'		<tr>'+
17446					'			<td class="gutter"'+(items[i]['ID']? ' id="'+items[i]['ID']+'"' : '')+'><div class="icon'+(items[i]['ICONCLASS']? ' '+items[i]['ICONCLASS']:'')+'"'+(items[i]['IMAGE']? ' style="background-image:url('+items[i]['IMAGE']+');"':'')+'></div></td>'+
17447					'			<td class="item'+(items[i]['DISABLED'] == true? ' disabled' : '')+(items[i]['DEFAULT'] == true? ' default' : '')+'"'+(items[i]["TITLE"]? ' title="'+items[i]["TITLE"]+'"' : '')+'>'+items[i]['TEXT']+'</td>';
17448				if(items[i]['MENU'])
17449					s += '<td class="arrow"></td>';
17450
17451				s +=
17452					'		</tr>'+
17453					'	</table></div></div>';
17454				cell.innerHTML = s;
17455				if(items[i]['DISABLED']!=true)
17456				{
17457					var item_div = jsUtils.FindChildObject(cell, "div");
17458					if(items[i]['MENU'])
17459					{
17460						item_div.onclick = function(){_this.ShowSubmenu(this)};
17461						item_div.onmouseover = _this.OnSubmenuMouseOver;
17462						item_div.onmouseout = _this.OnSubmenuMouseOut;
17463						this.bHasSubmenus = true;
17464					}
17465					else
17466					{
17467						item_div.onmouseover = function(){_this.OnItemMouseOver(this)};
17468						item_div.onmouseout = _this.OnItemMouseOut;
17469						if(items[i]['ONCLICK'] && (items[i]['AUTOHIDE'] == null || items[i]['AUTOHIDE'] == true))
17470							jsUtils.addEvent(item_div, "click",	function(){_this.PopupHide();});
17471					}
17472				}
17473				items[i]['__id'] = this.menu_id+'_item_'+i;
17474			}
17475		}
17476
17477		div.style.width = tbl.parentNode.offsetWidth;
17478	}
17479
17480
17481	this.GetItemInfo = function(item)
17482	{
17483		var td = jsUtils.FindChildObject(item, "td", "item", true);
17484		if(td)
17485		{
17486			var icon = '';
17487			var icon_div = jsUtils.FindChildObject(jsUtils.FindChildObject(item, "td", "gutter", true), "div");
17488			//<div class="icon class">
17489			if(icon_div.className.length > 5)
17490				icon = icon_div.className.substr(5);
17491			return {'TEXT': td.innerHTML, 'TITLE':td.title, 'ICON':icon};
17492		}
17493		return null;
17494	}
17495
17496	this.GetMenuByItemId = function(item_id)
17497	{
17498		for(var i = 0, length = this.menuItems.length; i < length; i++)
17499			if(this.menuItems[i]['__id'] && this.menuItems[i]['__id'] == item_id)
17500				return this;
17501
17502		var menu;
17503
17504		for(var i = 0, length = this.submenus.length; i < length; i++)
17505			if(this.submenus[i] && (menu = this.submenus[i].GetMenuByItemId(item_id)) != false)
17506				return menu;
17507
17508		return false;
17509	}
17510
17511	this.IsVisible = function()
17512	{
17513		var div = document.getElementById(this.menu_id);
17514		if(div)
17515			return (div.style.visibility != 'hidden');
17516		return false;
17517	}
17518
17519	this.ShowMenu = function(control, items, bFixed, dPos, userFunc)
17520	{
17521		if(this.controlDiv == control)
17522		{
17523			this.PopupHide();
17524		}
17525		else
17526		{
17527			if(this.IsVisible())
17528				this.PopupHide();
17529
17530			if(items)
17531			{
17532				this.SetItems(items);
17533				this.BuildItems();
17534			}
17535
17536			control.className += ' pressed bx-pressed';
17537			var pos = window.BX ? BX.pos(control) : jsUtils.GetRealPos(control);
17538			if(dPos)
17539			{
17540				pos["left"] += dPos["left"];
17541				pos["right"] += dPos["right"];
17542				pos["top"] += dPos["top"];
17543				pos["bottom"] += dPos["bottom"];
17544			}
17545			else
17546				pos["bottom"]+= 2;
17547
17548			if(bFixed == true && !jsUtils.IsIE())
17549			{
17550				var arScroll = jsUtils.GetWindowScrollPos();
17551				pos["top"] += arScroll.scrollTop;
17552				pos["bottom"] += arScroll.scrollTop;
17553				pos["left"] += arScroll.scrollLeft;
17554				pos["right"] += arScroll.scrollLeft;
17555			}
17556
17557			this.controlDiv = control;
17558			this.OnClose = function()
17559			{
17560				control.className = control.className.replace(/\s*pressed bx-pressed/ig, "");
17561				if(userFunc)
17562					userFunc();
17563			}
17564			this.PopupShow(pos);
17565		}
17566	}
17567}
17568
17569/* End */
17570;
17571; /* Start:/bitrix/js/main/admin_search.js*/
17572function JCAdminTitleSearch(arParams)
17573{
17574	var _this = this;
17575
17576	this.arParams = {
17577		'AJAX_PAGE': arParams.AJAX_PAGE,
17578		'CONTAINER_ID': arParams.CONTAINER_ID,
17579		'INPUT_ID': arParams.INPUT_ID,
17580		'MIN_QUERY_LEN': parseInt(arParams.MIN_QUERY_LEN)
17581	};
17582	if(arParams.WAIT_IMAGE)
17583		this.arParams.WAIT_IMAGE = arParams.WAIT_IMAGE;
17584	if(arParams.MIN_QUERY_LEN <= 0)
17585		arParams.MIN_QUERY_LEN = 1;
17586
17587	this.cache = [];
17588	this.cache_key = null;
17589
17590	this.startText = '';
17591	this.currentRow = -1;
17592	this.RESULT = null;
17593	this.CONTAINER = null;
17594	this.INPUT = null;
17595	this.WAIT = null;
17596
17597	this.Hide = function()
17598	{
17599		_this.RESULT.style.display = 'none';
17600		_this.RESULT.innerHTML = '';
17601		_this.currentRow = -1;
17602		_this.UnSelectAll();
17603		BX.removeClass(_this.INPUT.parentNode,'adm-header-search-block-active-popup');
17604	};
17605
17606	this.ShowResult = function(result)
17607	{
17608		var pos = BX.pos(_this.CONTAINER);
17609		pos.width = pos.right - pos.left;
17610		_this.RESULT.style.position = 'absolute';
17611		_this.RESULT.style.top = '4px';//(pos.bottom + 2) - 46  + 'px';
17612		_this.RESULT.style.left = (pos.left - 7) + 'px';
17613		_this.RESULT.style.width = (pos.width + 14)+ 'px';
17614		//_this.RESULT.style.zIndex = _this.CONTAINER.style.zIndex - 1;
17615		if(result != null)
17616			_this.RESULT.innerHTML = result;
17617
17618		if(_this.RESULT.innerHTML.length > 0)
17619		{
17620			_this.RESULT.style.display = 'block';
17621			BX.addClass(_this.INPUT.parentNode,'adm-header-search-block-active-popup');
17622		}
17623		else
17624			this.Hide();
17625
17626	};
17627
17628	this.onKeyPress = function(keyCode)
17629	{
17630		var tbl = BX.findChild(_this.RESULT, {'tag':'table','class':'adm-search-result'}, true);
17631		if(!tbl)
17632			return false;
17633
17634		var cnt = tbl.rows.length;
17635
17636		switch (keyCode)
17637		{
17638		case 27: // escape key - close search div
17639			_this.Hide();
17640		return true;
17641
17642		case 40: // down key - navigate down on search results
17643			if(_this.RESULT.style.display == 'none')
17644				_this.RESULT.style.display = 'block';
17645
17646			var first = -1;
17647			for(var i = 0; i < cnt; i++)
17648			{
17649				if(first == -1)
17650					first = i;
17651
17652				if(_this.currentRow < i)
17653				{
17654					_this.currentRow = i;
17655					break;
17656				}
17657				else if(tbl.rows[i].className == 'adm-search-selected')
17658				{
17659					tbl.rows[i].className = '';
17660				}
17661			}
17662
17663			if(i == cnt && _this.currentRow != i)
17664				_this.currentRow = first;
17665
17666			tbl.rows[_this.currentRow].className = 'adm-search-selected';
17667		return true;
17668
17669		case 38: // up key - navigate up on search results
17670			if(_this.RESULT.style.display == 'none')
17671				_this.RESULT.style.display = 'block';
17672
17673			var last = -1;
17674			for(var i = cnt-1; i >= 0; i--)
17675			{
17676				if(last == -1)
17677					last = i;
17678
17679				if(_this.currentRow > i)
17680				{
17681					_this.currentRow = i;
17682					break;
17683				}
17684				else if(tbl.rows[i].className == 'adm-search-selected')
17685				{
17686					tbl.rows[i].className = '';
17687				}
17688			}
17689
17690			if(i < 0)
17691				_this.currentRow = last;
17692
17693			tbl.rows[_this.currentRow].className = 'adm-search-selected';
17694		return true;
17695
17696		case 13: // enter key - choose current search result
17697			if(_this.RESULT.style.display == 'block')
17698			{
17699				for(var i = 0; i < cnt; i++)
17700				{
17701					if(_this.currentRow == i)
17702					{
17703						if(!BX.findChild(tbl.rows[i], {'class':'adm-search-separator'}, true))
17704						{
17705							var a = BX.findChild(tbl.rows[i], {'tag':'a'}, true);
17706							if(a)
17707							{
17708								window.location = a.href;
17709								return true;
17710							}
17711						}
17712					}
17713				}
17714			}
17715		return false;
17716		}
17717
17718		return false;
17719	};
17720
17721	this.onTimeout = function()
17722	{
17723		if(_this.INPUT.value != _this.oldValue && _this.INPUT.value != _this.startText)
17724		{
17725			if(_this.INPUT.value.length >= _this.arParams.MIN_QUERY_LEN)
17726			{
17727				_this.oldValue = _this.INPUT.value;
17728				_this.cache_key = _this.arParams.INPUT_ID + '|' + _this.INPUT.value;
17729				if(_this.cache[_this.cache_key] == null)
17730				{
17731					if(_this.WAIT)
17732					{
17733						var pos = BX.pos(_this.INPUT);
17734						var height = (pos.bottom - pos.top)-2;
17735						_this.WAIT.style.top = (pos.top+1) + 'px';
17736						_this.WAIT.style.height = height + 'px';
17737						_this.WAIT.style.width = height + 'px';
17738						_this.WAIT.style.left = (pos.right - height + 2) + 'px';
17739						_this.WAIT.style.display = 'block';
17740					}
17741
17742					BX.ajax.post(
17743						_this.arParams.AJAX_PAGE,
17744						{
17745							'ajax_call':'y',
17746							'INPUT_ID':_this.arParams.INPUT_ID,
17747							'q':_this.INPUT.value
17748						},
17749						function(result)
17750						{
17751							_this.cache[_this.cache_key] = result;
17752							_this.ShowResult(result);
17753							_this.currentRow = -1;
17754							_this.EnableMouseEvents();
17755							if(_this.WAIT)
17756								_this.WAIT.style.display = 'none';
17757							setTimeout(_this.onTimeout, 500);
17758						}
17759					);
17760				}
17761				else
17762				{
17763					_this.ShowResult(_this.cache[_this.cache_key]);
17764					_this.currentRow = -1;
17765					_this.EnableMouseEvents();
17766					setTimeout(_this.onTimeout, 500);
17767				}
17768			}
17769			else
17770			{
17771				_this.Hide();
17772				setTimeout(_this.onTimeout, 500);
17773			}
17774		}
17775		else
17776		{
17777			setTimeout(_this.onTimeout, 500);
17778		}
17779	}
17780
17781	this.UnSelectAll = function()
17782	{
17783		var tbl = BX.findChild(_this.RESULT, {'tag':'table','class':'adm-search-result'}, true);
17784		if(tbl)
17785		{
17786			var cnt = tbl.rows.length;
17787			for(var i = 0; i < cnt; i++)
17788				tbl.rows[i].className = '';
17789		}
17790	};
17791
17792	this.EnableMouseEvents = function()
17793	{
17794		var tbl = BX.findChild(_this.RESULT, {'tag':'table','class':'adm-search-result'}, true);
17795		if(tbl)
17796		{
17797			var cnt = tbl.rows.length;
17798			for(var i = 0; i < cnt; i++)
17799			{
17800				tbl.rows[i].id = 'row_' + i;
17801				tbl.rows[i].onmouseover = function (e) {
17802					if(_this.currentRow != this.id.substr(4))
17803					{
17804						_this.UnSelectAll();
17805						this.className = 'adm-search-selected';
17806						_this.currentRow = this.id.substr(4);
17807					}
17808				};
17809				tbl.rows[i].onmouseout = function (e) {
17810					this.className = '';
17811					_this.currentRow = -1;
17812				};
17813			}
17814		}
17815	};
17816
17817	this.onFocusLost = function(hide)
17818	{
17819		setTimeout(function(){_this.Hide();}, 250);
17820	};
17821
17822	this.onFocusGain = function()
17823	{
17824		if(_this.RESULT.innerHTML.length)
17825			_this.ShowResult();
17826	};
17827
17828	this.onKeyDown = function(e)
17829	{
17830		if(!e)
17831			e = window.event;
17832
17833		if (_this.RESULT.style.display == 'block')
17834		{
17835			if(_this.onKeyPress(e.keyCode))
17836				return BX.PreventDefault(e);
17837		}
17838	};
17839
17840	this.Init = function()
17841	{
17842		this.CONTAINER = document.getElementById(this.arParams.CONTAINER_ID);
17843		this.RESULT = document.getElementById("bx-panel").appendChild(document.createElement("DIV"));
17844		this.RESULT.className = 'adm-search-result-wrap';
17845		this.RESULT.style.display = 'none';
17846
17847		this.INPUT = document.getElementById(this.arParams.INPUT_ID);
17848		this.startText = this.oldValue = this.INPUT.value;
17849		BX.bind(this.INPUT, 'focus', function() {_this.onFocusGain()});
17850		BX.bind(this.INPUT, 'blur', function() {_this.onFocusLost()});
17851		BX.bind(window, 'resize', function() {_this.onFocusGain()});
17852
17853		if(BX.browser.IsSafari() || BX.browser.IsIE())
17854			this.INPUT.onkeydown = this.onKeyDown;
17855		else
17856			this.INPUT.onkeypress = this.onKeyDown;
17857
17858		if(this.arParams.WAIT_IMAGE)
17859		{
17860			this.WAIT = document.body.appendChild(document.createElement("DIV"));
17861			this.WAIT.style.backgroundImage = "url('" + this.arParams.WAIT_IMAGE + "')";
17862			if(!BX.browser.IsIE())
17863				this.WAIT.style.backgroundRepeat = 'none';
17864			this.WAIT.style.display = 'none';
17865			this.WAIT.style.position = 'absolute';
17866			this.WAIT.style.zIndex = '1100';
17867		}
17868
17869		setTimeout(this.onTimeout, 500);
17870	};
17871
17872	BX.ready(function (){_this.Init(arParams)});
17873}
17874
17875/* End */
17876;
17877; /* Start:/bitrix/js/main/hot_keys.js*/
17878
17879if(!BXHotKeys)
17880{
17881
17882	function CBXHotKeys()
17883	{
17884		var _this = this;
17885		var idxKS = 0;
17886		var idxCode = 1;
17887		var idxCodeId = 2;
17888		var idxName = 3;
17889		var idxHKId = 4;
17890		var arServSymb = { 8: 'Back Space',9: 'Tab',13: 'Enter',16: 'Shift',17: 'Ctrl',18: 'Alt',19: 'Pause',
17891						20: 'Caps Lock',27: 'ESC',32: 'Space bar',33: 'Page Up',34: 'Page Down',35: 'End',36: 'Home',
17892						37: 'Left',38: 'Up',39: 'Right',40: 'Down',45: 'Insert',46: 'Delete',96: '0 (ext)',97: '1 (ext)',
17893						98: '2 (ext)',99: '3 (ext)',100: '4 (ext)',101: '5 (ext)',102: '6 (ext)',105: '9 (ext)',106: '* (ext)',
17894						107: '+ (ext)',104: '8 (ext)',103: '7 (ext)',110: '. (ext)',111: '/ (ext)',112: 'F1',113: 'F2',114: 'F3',
17895						115: 'F4',116: 'F5',117: 'F6',118: 'F7',119: 'F8',120: 'F9',121: 'F10',122: 'F11',123: 'F12',144: 'Num Lock',
17896						186: ';',188: ',',190: '.',191: '/',192: '`',219: '[',220: '|',221: ']',222: "'",189: '-',187: '+',145: 'Scrol Lock' };
17897		var bxHotKeyCode=0;
17898		var inputKeyCode=0;
17899		var inputDopString="";
17900
17901		this.ArrHKCode=[];
17902		this.MesNotAssign="";
17903		this.MesClToChange="";
17904		this.MesClean="";
17905		this.MesBusy="";
17906		this.MesClose="";
17907		this.MesSettings="";
17908		this.MesDefault="";
17909		this.MesDelAll="";
17910		this.MesDelete="";
17911		this.MesDelConfirm="";
17912		this.MesDefaultConfirm="";
17913		this.MesExport="";
17914		this.MesExpFalse="";
17915		this.MesImport="";
17916		this.MesImpFalse="";
17917		this.MesImpSuc="";
17918		this.MesImpHeader="";
17919		this.MesFileEmpty="";
17920		this.MesChooseFile="";
17921		this.uid="";
17922		this.deleting = false;
17923
17924
17925
17926		this.Init = function()
17927		{
17928			this.Register();
17929		};
17930
17931		// keysString: Ctrl+Alt+Shift+KeyCode
17932		this.UpdateKS = function(codeId, keysString)
17933		{
17934			for(var i=0; i<this.ArrHKCode.length; i++)
17935				if(this.ArrHKCode[i][idxCodeId]==codeId)
17936				{
17937					this.ArrHKCode[i][idxKS]=keysString;
17938					return true;
17939				}
17940		};
17941
17942		this.UpdateHk = function(codeId, hkId)
17943		{
17944			for(var i=0; i<this.ArrHKCode.length; i++)
17945				if(this.ArrHKCode[i][idxCodeId]==codeId)
17946				{
17947					this.ArrHKCode[i][idxHKId]=hkId;
17948					return i;
17949				}
17950
17951			return (-1);
17952		};
17953
17954		this.Add = function(keysString, execCode, codeId, name, hkId)
17955		{
17956			for(var i=0; i<this.ArrHKCode.length; i++)
17957				if(this.ArrHKCode[i][idxCodeId]==codeId)
17958					return false;
17959
17960			return this.ArrHKCode.push([String(keysString),String(execCode),codeId,String(name),hkId]);
17961		};
17962
17963		// keysString: Ctrl+Alt+Shift+KeyCode
17964		this.GetExCode = function(keysString)
17965		{
17966			var ret="";
17967			if(keysString)
17968				for(var i=0; i<this.ArrHKCode.length; i++)
17969					if (this.ArrHKCode[i][idxKS]==keysString)
17970					{
17971						if(ret)
17972							ret+=" ";
17973
17974						ret+=this.ArrHKCode[i][idxCode];
17975					}
17976
17977			return ret;
17978		};
17979
17980		this.MakeKeyString = function(Event)
17981		{
17982			this.inputDopString = (Event.ctrlKey ? 'Ctrl+':'') + (Event.altKey ? 'Alt+':'') + (Event.shiftKey ? 'Shift+':'');
17983			this.inputKeyCode = Event.keyCode;
17984
17985			if(!this.inputKeyCode)
17986				this.inputKeyCode = Event.charCode;
17987
17988			return this.inputDopString + this.inputKeyCode;
17989		};
17990
17991		this.ShowMenu = function()
17992		{
17993			var menu = 	'<table class="bx-hk-settings-toolbar" cellspacing="0" cellpadding="0" border="0">'+
17994						'<tr><td class="bx-left"><div class="bx-hk-settings-empty"></div></td>'+
17995						'<td class="bx-content">'+
17996						'<a class="bx-context-button" hidefocus="true" href="javascript:void(0)" onclick="BXHotKeys.Import();">'+
17997						'<span class="bx-context-button-icon btn-import"></span>'+
17998						'<span class="bx-context-button-text">'+this.MesImport+'</span>'+
17999						'</a>'+
18000						'<a class="bx-context-button" hidefocus="true" href="javascript:void(0)" onclick="BXHotKeys.Export();">'+
18001						'<span class="bx-context-button-icon btn-export"></span>'+
18002						'<span class="bx-context-button-text">'+this.MesExport+'</span>'+
18003						'</a>'+
18004						'<a class="bx-context-button" hidefocus="true" href="javascript:void(0)" onclick="if(confirm(BXHotKeys.MesDelConfirm)) BXHotKeys.DelAll();">'+
18005						'<span class="bx-context-button-icon btn-delall"></span>'+
18006						'<span class="bx-context-button-text">'+this.MesDelAll+'</span>'+
18007						'</a>'+
18008						'<a class="bx-context-button" hidefocus="true" href="javascript:void(0)" onclick="if(confirm(BXHotKeys.MesDefaultConfirm)) { BXHotKeys.DelAll(); BXHotKeys.SetDefault(); }">'+
18009						'<span class="bx-context-button-icon btn-default"></span>'+
18010						'<span class="bx-context-button-text">'+this.MesDefault+'</span>'+
18011						'</a></td>'+
18012						'<td class="bx-right"><div class="bx-hk-settings-empty"></div></td></tr>'+
18013						'</table>';
18014			return menu;
18015		}
18016
18017		this.ShowSettings = function()
18018		{
18019			var formText ='<table width="100%" id="tbl_hk_settings">';
18020			var keyStr="";
18021			var editStr="";
18022
18023			for(var i=0; i<this.ArrHKCode.length; i++)
18024			{
18025				if(this.ArrHKCode[i][idxKS])
18026					keyStr=this.PrintKSAsChar(this.ArrHKCode[i][idxKS]);
18027				else
18028					keyStr=this.MesNotAssign;
18029
18030				if(this.ArrHKCode[i][idxCode])
18031					editStr = "<td width='30%' id='hotkeys-float-form-"+this.ArrHKCode[i][idxCodeId]+"'><a href='javascript:void(0)' onclick='BXHotKeys.SubstInput("+this.ArrHKCode[i][idxCodeId]+", "+
18032							this.ArrHKCode[i][idxHKId]+", \""+this.ArrHKCode[i][idxKS]+"\");' title='"+this.MesClToChange+"' class='bx-hk-settings'>"+keyStr+"</a></td><td width='10%' align='right' id='hotkeys-float-form-del-"+this.ArrHKCode[i][idxCodeId]+"'><a href='javascript:void(0)' onclick='BXHotKeys.DeleteBase("+
18033							this.ArrHKCode[i][idxCodeId]+","+this.ArrHKCode[i][idxHKId]+");' class='hk-delete-icon' title='"+this.MesDelete+"'></a></td>";
18034				else
18035					editStr ="<td width='30%'>&nbsp;</td><td width='10%'>&nbsp</td>";
18036
18037				formText+="<tr class = 'bx-hk-settings-row'><td width='60%'>"+this.ArrHKCode[i][idxName]+"</td>"+editStr+"</tr>";
18038			}
18039
18040			formText+='</table>';
18041
18042			var btnClose = new BX.CWindowButton({
18043				'title': this.MesClose,
18044				'action': function() { this.parentWindow.Close(); }
18045			});
18046
18047			var obWnd = new BX.CDialog({
18048							title: this.MesSettings,
18049							content: formText,
18050							buttons: [btnClose],
18051							width: 500,
18052							height: 400,
18053							resizable: false
18054						});
18055
18056			this.tblSettParent=BX("tbl_hk_settings").parentNode;
18057			BX.addCustomEvent(obWnd, 'onWindowClose', function(obWnd) {
18058																		obWnd.DIV.parentNode.removeChild(obWnd.DIV);
18059																		_this.Register();
18060																	});
18061
18062			//some customization to standart BX.CDialog
18063			var hk_menu_div = document.createElement("div");
18064			hk_menu_div.className = "bx-hk-settings-toolbar";
18065			hk_menu_div.innerHTML = this.ShowMenu();
18066
18067			var dialog_head = BX.findChild(obWnd.DIV, {attribute: {'class': 'bx-core-adm-dialog-content'}}, true );
18068
18069			if(dialog_head)
18070			{
18071				dialog_head.appendChild(hk_menu_div);
18072				BX.findChild(obWnd.DIV, {attribute: {'class': 'bx-core-adm-dialog-content'}}, true ).style.marginTop="37px";
18073			}
18074			else // ie quirck mode
18075			{
18076				this.hk_getElementsByClass("bx-core-adm-dialog-head")[0].appendChild(hk_menu_div);
18077				this.hk_getElementsByClass("bx-hk-settings-toolbar",obWnd.DIV,"div")[0].style.width = "480px";
18078			}
18079
18080			obWnd.Show();
18081
18082			this.Unregister();
18083		};
18084
18085		this.hk_getElementsByClass = function(className, node, tag)
18086		{
18087			var node = node || document,
18088			tag = tag || '*',
18089			list = node.getElementsByTagName(tag),
18090			length = list.length,
18091			result = [], i,j;
18092			for(i = 0; i < length; i++)
18093			{
18094				if(list[i].className == className)
18095				{
18096					result.push(list[i])
18097					break;
18098				}
18099			}
18100			return result
18101		}
18102
18103		this.DelAll = function()
18104		{
18105			_this.deleting = true;
18106
18107			for(var i=0; i<this.ArrHKCode.length; i++)
18108			{
18109				_this.UpdateKS(this.ArrHKCode[i][idxCodeId],"");
18110				_this.UpdateHk(this.ArrHKCode[i][idxCodeId],0);
18111				_this.SubstAnch(this.ArrHKCode[i][idxCodeId], 0,"");
18112				_this.SubstDel(this.ArrHKCode[i][idxCodeId],0);
18113			}
18114
18115			var request = new JCHttpRequest;
18116			var options_url = '/bitrix/admin/hot_keys_act.php?hkaction=delete_all';
18117			var sParam = "&sessid="+phpVars.bitrix_sessid;
18118			request.Action = function (result)
18119			{
18120				_this.deleting = false;
18121			}
18122
18123			request.Post(options_url, sParam);
18124		}
18125
18126		this.Register = function()
18127		{
18128			try //reautorization gives unstable error
18129			{
18130				jsUtils.addEvent(document, 'keypress', _this.KeyPressHandler);
18131				jsUtils.addEvent(document, 'keydown', _this.KeyDownHandler);
18132			}
18133			catch (e)
18134			{
18135				//nothing
18136			}
18137		}
18138
18139		this.Unregister = function()
18140		{
18141			jsUtils.removeEvent(document, 'keypress', _this.KeyPressHandler);
18142			jsUtils.removeEvent(document, 'keydown', _this.KeyDownHandler);
18143		}
18144
18145		this.SetDefault = function()
18146		{
18147			var request = new JCHttpRequest;
18148			var options_url = '/bitrix/admin/hot_keys_act.php?hkaction=set_default';
18149			var sParam = "&sessid="+phpVars.bitrix_sessid;
18150
18151			request.Action = function (strDefHK)
18152			{
18153				if(strDefHK)
18154				{
18155					if(!strDefHK)
18156						return false;
18157
18158					var arHK=[];
18159					var row="";
18160					var arStrHK=strDefHK.split(";;");
18161
18162					for(var i=0; i<arStrHK.length; i++)
18163					{
18164						arHK=arStrHK[i].split("::");
18165						row=_this.UpdateHk(arHK[0],arHK[1]);
18166						if (row>=0)
18167						{
18168							_this.UpdateKS(arHK[0],arHK[2]);
18169							_this.SubstAnch(arHK[0],arHK[1],arHK[2]);
18170							_this.SubstDel(arHK[0],arHK[1]);
18171						}
18172					}
18173				}
18174			}
18175
18176			//waiting while deleting hot-keys
18177			waiter =
18178				{
18179					func: function()
18180					{
18181						if (!(this.deleting))
18182						{
18183							request.Post(options_url, sParam);
18184							clearInterval(intervalID);
18185						}
18186					}
18187				}
18188			intervalID = window.setInterval(function(){ waiter.func.call(waiter) }, 1000);
18189		}
18190
18191		this.IsKeysBusy = function(strKeyString,code_id)
18192		{
18193			for(var i=0; i<this.ArrHKCode.length; i++)
18194				if (this.ArrHKCode[i][idxKS]==strKeyString && this.ArrHKCode[i][idxCodeId]!=code_id)
18195					return true;
18196
18197			return false;
18198		}
18199
18200		this.SubstInput = function(code_id, hk_id, keysString)
18201		{
18202
18203			var td = document.getElementById('hotkeys-float-form-'+code_id);
18204
18205			if(!td)
18206				return false;
18207
18208			td.innerHTML='';
18209			td.innerHTML = '<input type="text" class="adm-input" name="HUMAN_KEYS_STRING" size="10" maxlength="30" value="'+this.PrintKSAsChar(keysString)+'" id="HKeysString" autocomplete="off">'+
18210							'<input type="hidden" name="KEYS_STRING" value="'+keysString+'" id="KeysString">';
18211
18212			var inpHKString = document.getElementById("HKeysString");
18213			var inpKString = document.getElementById("KeysString");
18214
18215			inpHKString .onkeydown  = _this.SetInput;
18216			inpHKString .onkeypress = _this.SetInput;
18217			inpHKString .onkeyup = function ()
18218			{
18219				ShowWaitWindow();
18220
18221				inpHKString .onblur ="";
18222
18223				if(_this.IsKeysBusy(inpKString.value,code_id))
18224					if(!confirm(_this.MesBusy))
18225					{
18226						_this.SubstAnch(code_id, hk_id, keysString);
18227						return false;
18228					}
18229
18230
18231				_this.bxHotKeyCode=0;
18232
18233				_this.UpdateKS(code_id,inpKString.value);
18234
18235				if(hk_id)
18236				{
18237					_this.UpdateHk(code_id,hk_id);
18238					_this.UpdateBase(hk_id,inpKString.value);
18239				}
18240				else
18241					_this.AddBase(code_id,inpKString.value);
18242
18243				_this.SubstAnch(code_id, hk_id, inpKString.value);
18244
18245				CloseWaitWindow();
18246			}
18247
18248			inpHKString.focus();
18249
18250			inpHKString.onblur = function ()
18251			{
18252				_this.SubstAnch(code_id, hk_id, keysString);
18253			}
18254		}
18255
18256		this.SubstAnch = function(code_id, hk_id, keysString)
18257		{
18258			var td = document.getElementById('hotkeys-float-form-'+code_id);
18259			if(td)
18260				td.innerHTML = "<a href='javascript:void(0)' onclick='BXHotKeys.SubstInput("+code_id+", "+hk_id+", \""+keysString+"\");' title='"+this.MesClToChange+"' class='bx-hk-settings'>"+(keysString ? this.PrintKSAsChar(keysString) : this.MesNotAssign)+"</a>";
18261		}
18262
18263		this.SubstDel = function(code_id, hk_id)
18264		{
18265			var td = document.getElementById('hotkeys-float-form-del-'+code_id);
18266			if (td)
18267				td.innerHTML = "<a href='javascript:void(0)' onclick='BXHotKeys.DeleteBase("+code_id+","+hk_id+");' class='hk-delete-icon' title='"+this.MesDelete+"'></a>";
18268		}
18269
18270
18271		this.AddBase = function(code_id,keysString)
18272		{
18273			var request = new JCHttpRequest;
18274			var options_url = '/bitrix/admin/hot_keys_act.php?hkaction=add';
18275			var sParam = "&KEYS_STRING="+encodeURIComponent(keysString)+"&CODE_ID="+code_id+"&USER_ID="+_this.uid+"&sessid="+phpVars.bitrix_sessid;
18276			request.Action = function (hk_id)
18277			{
18278				if(hk_id && (hk_id == Number(hk_id)))
18279				{
18280					var row =_this.UpdateHk(code_id,hk_id);
18281					if (row>=0)
18282					{
18283						_this.SubstAnch(code_id, hk_id,keysString);
18284						_this.SubstDel(code_id, hk_id);
18285					}
18286				}
18287			}
18288			request.Post(options_url, sParam);
18289		}
18290
18291		this.Export = function()
18292		{
18293			window.open("/bitrix/admin/hot_keys_act.php?hkaction=export&sessid="+phpVars.bitrix_sessid);
18294		}
18295
18296		this.OnFileInputChange = function(ob)
18297		{
18298			fileName = ob.value;
18299			fileName = fileName.replace(/\\/g, '/');
18300			fileName = fileName.substr(fileName.lastIndexOf("/")+1);
18301
18302			if(ob.parentNode.childNodes[0].textContent)
18303				ob.parentNode.childNodes[0].textContent = fileName;
18304			else
18305				ob.parentNode.childNodes[0].innerText = fileName;
18306		}
18307
18308		this.Import = function()
18309		{
18310			var formText = 	'<form action="/bitr
18310ix/admin/hot_keys_act.php?hkaction=import" method="post" enctype="multipart/form-data" target="upload_iframe" id="hk_import_form" name="hk_import_form">'+
18311							'<input type="hidden" name="sessid" value="'+BX.bitrix_sessid()+'">'+
18312							'<span class="adm-input-file"><span>'+this.MesChooseFile+'</span><input type="file" name="bx_hk_filename" id="bx_hk_filename" class="adm-designed-file" onchange="BXHotKeys.OnFileInputChange(this);"></span>'+
18313							'</form>'+
18314							'<iframe id="upload_iframe" name="upload_iframe" style="display:none"></iframe>';
18315
18316			var btnClose = new BX.CWindowButton({
18317				'title': this.MesClose,
18318				'action': function() { this.parentWindow.Close(); }
18319			});
18320
18321			var btnImport = new BX.CWindowButton({
18322				'title': this.MesImport,
18323				'action': function()
18324									{
18325										if(!BX('bx_hk_filename').value)
18326										{
18327											alert(_this.MesFileEmpty);
18328											return;
18329										}
18330
18331										BX('hk_import_form').submit();
18332										ShowWaitWindow();
18333									}
18334			});
18335
18336
18337			var impWnd = new BX.CDialog({
18338							title: this.MesImpHeader,
18339							content: formText,
18340							buttons: [btnImport,btnClose],
18341							width: 300,
18342							height: 60,
18343							resizable: false
18344						});
18345
18346			impWnd.Show();
18347
18348		}
18349
18350		this.OnImportResponse = function(hkNum)
18351		{
18352			if(hkNum)
18353				alert(_this.MesImpSuc+hkNum);
18354			else
18355				alert(_this.MesImpFalse);
18356
18357			BX.reload();
18358		}
18359
18360		this.UpdateBase = function(hk_id, keysString)
18361		{
18362			var request = new JCHttpRequest;
18363			var options_url = '/bitrix/admin/hot_keys_act.php?hkaction=update';
18364			var sParam = "&KEYS_STRING="+encodeURIComponent(keysString)+"&ID="+hk_id+"&sessid="+phpVars.bitrix_sessid;
18365			request.Post(options_url, sParam);
18366		}
18367
18368		this.DeleteBase = function(code_id, hk_id)
18369		{
18370			if(hk_id)
18371			{
18372				var request = new JCHttpRequest;
18373				var options_url = '/bitrix/admin/hot_keys_act.php?hkaction=delete';
18374				var sParam = "&ID="+hk_id+"&sessid="+phpVars.bitrix_sessid;
18375				request.Post(options_url, sParam);
18376				_this.UpdateKS(code_id,"");
18377				_this.UpdateHk(code_id,0);
18378				_this.SubstAnch(code_id, 0,"");
18379				_this.SubstDel(code_id,0);
18380			}
18381		}
18382
18383		this.PrintKSAsChar = function(strKeysString)
18384		{
18385			if(!strKeysString)
18386				return "";
18387
18388			var lastPlus = strKeysString.lastIndexOf("+");
18389			if(lastPlus)
18390			{
18391				var charCode = strKeysString.substr(lastPlus+1,strKeysString.length - (lastPlus+1));
18392				var preChar = strKeysString.substr(0,lastPlus+1);
18393				if(charCode==16 || charCode==17 || charCode==18)
18394					return preChar.substr(0,preChar.length-1);
18395			}
18396			else
18397			{
18398				var charCode = strKeysString;
18399				var preChar = "";
18400			}
18401
18402			var codeSymb=arServSymb[charCode];
18403			if(!codeSymb)
18404				codeSymb = String.fromCharCode(charCode);
18405
18406			return preChar+codeSymb;
18407		}
18408
18409		this.SetInput = function(e)
18410		{
18411			e = e || event;
18412
18413			var inputDopString = (e.ctrlKey ? 'Ctrl+':'') + (e.altKey ? 'Alt+':'') + (e.shiftKey ? 'Shift+':'');
18414
18415			if(e.keyCode && e.type!="keypress")
18416				_this.bxHotKeyCode = e.keyCode;
18417
18418			var charCode;
18419			if(e.charCode==undefined)
18420				charCode = e.which;
18421			else
18422				charCode = e.charCode;
18423
18424			if (charCode && (!_this.bxHotKeyCode || _this.bxHotKeyCode==17 || _this.bxHotKeyCode==18 || _this.bxHotKeyCode==16 || _this.bxHotKeyCode==224))
18425				_this.bxHotKeyCode = charCode;
18426
18427			document.getElementById("KeysString").value = inputDopString + _this.bxHotKeyCode;
18428			document.getElementById("HKeysString").value = _this.PrintKSAsChar(document.getElementById("KeysString").value);
18429			return false;
18430		}
18431
18432		//Key-handlers
18433		this.KeyPressHandler = function(e)
18434		{
18435			e = e || event;
18436
18437			if(e.charCode > 256)
18438			{
18439				var ExCode=_this.GetExCode(_this.MakeKeyString(e));
18440
18441				if (ExCode)
18442					eval(ExCode);
18443			}
18444		}
18445
18446		this.KeyDownHandler = function(e)
18447		{
18448			e = e || event;
18449
18450			var ExCode=_this.GetExCode(_this.MakeKeyString(e));
18451
18452			if (ExCode)
18453				eval(ExCode);
18454		}
18455	}
18456
18457	var BXHotKeys = new CBXHotKeys;
18458	BXHotKeys.Init();
18459	window.BXHotKeys = BXHotKeys;
18460}
18461
18462/* End */
18463;
18464; /* Start:/bitrix/js/main/public_tools.js*/
18465function JCPopup(arParams)
18466{
18467	if (!arParams) arParams = {};
18468	this.suffix = arParams.suffix ? '_' + arParams.suffix.toString().toLowerCase() : '';
18469	this.div_id = 'bx_popup_form_div' + this.suffix;
18470	this.overlay_id = 'bx_popup_overlay' + this.suffix;
18471	this.form_name = 'bx-popup-form' + this.suffix;
18472	this.class_name = 'bx-popup-form';
18473	this.url = '';
18474	this.zIndex = arParams.zIndex || 1020;
18475	this.arParams = null;
18476	this.bDenyClose = false;
18477	this.bDenyEscKey = false;
18478	this.__arRuntimeResize = {};
18479	this.bodyOverflow = "";
18480	this.currentScroll = 0;
18481	this.div = null;
18482	this.div_inner = null;
18483	this.x = 0;
18484	this.y = 0;
18485	this.error_dy = null;
18486	this.arAdditionalResize = [];
18487	this.onClose = [];
18488
18489	var _this = this;
18490	// Event handlers
18491	window['JCPopup_OnKeyPress' + this.suffix] = function(e){_this.__OnKeyPress(e)};
18492	window['JCPopup_OverlayResize' + this.suffix] = function(e){_this.OverlayResize(e)};
18493	window['JCPopup_AjaxAction' + this.suffix] = function(result) {_this.AjaxAction(result);};
18494	window['JCPopup_AjaxPostAction' + this.suffix] = function(result) {_this.__AjaxPostAction(result);};
18495	window['JCPopup_stopResize' + this.suffix] = function(e) {_this.stopResize(e);};
18496	window['JCPopup_startResize' + this.suffix] = function(e) {_this.startResize(e);};
18497	window['JCPopup_doResize' + this.suffix] = function(e) {_this.doResize(e);};
18498
18499	jsExtLoader.jsPopup_name = 'jsPopup' + this.suffix;
18500}
18501
18502JCPopup.prototype.addOnClose = function(func)
18503{
18504	this.onClose[this.onClose.length] = func;
18505}
18506
18507JCPopup.prototype.addAdditionalResize = function(id)
18508{
18509	this.arAdditionalResize[this.arAdditionalResize.length] = document.getElementById(id);
18510};
18511
18512JCPopup.prototype.clearAdditionalResize = function()
18513{
18514	this.arAdditionalResize = [];
18515};
18516
18517JCPopup.prototype.DenyClose = function(bDeny)
18518{
18519	if (bDeny !== false)
18520		bDeny = true;
18521	this.bDenyClose = bDeny;
18522
18523	if (!this.obSaveButton)
18524	{
18525		this.obSaveButton = document.getElementById('btn_popup_save' + this.suffix);
18526		this.obCloseButton = document.getElementById('btn_popup_close'  + this.suffix);
18527		this.obCancelButton = document.getElementById('btn_popup_cancel' + this.suffix);
18528	}
18529
18530	if (this.obSaveButton) this.obSaveButton.disabled = bDeny;
18531	if (this.obCloseButton) this.obCloseButton.disabled = bDeny;
18532	if (this.obCancelButton) this.obCancelButton.disabled = bDeny;
18533};
18534
18535JCPopup.prototype.AllowClose = function()
18536{
18537	this.DenyClose(false);
18538};
18539
18540JCPopup.prototype.__OnKeyPress = function(e)
18541{
18542	if(this.bDenyEscKey) return;
18543	if (!e) e = window.event
18544	if (!e) return;
18545	if (this.bDenyClose) return;
18546	if (e.keyCode == 27)
18547	{
18548		jsUtils.removeEvent(document, "keypress", window['JCPopup_OnKeyPress' + this.suffix]);
18549		this.CloseDialog();
18550	}
18551};
18552
18553JCPopup.prototype.AjaxAction = function(result)
18554{
18555	CloseWaitWindow();
18556	if (this.suffix)
18557		jsPopup.bDenyClose = true;
18558	var div = document.body.appendChild(document.createElement("DIV"));
18559	div.id = this.div_id;
18560	div.className = this.class_name;
18561	div.style.position = 'absolute';
18562	div.style.zIndex = this.zIndex;
18563
18564	div.innerHTML = result;
18565
18566	if (null != this.arParams.height)
18567		div.style.height = this.arParams.height + 'px';
18568	if (null != this.arParams.width)
18569		div.style.width = this.arParams.width + 'px';
18570
18571	var windowSize = jsUtils.GetWindowInnerSize();
18572	var windowScroll = jsUtils.GetWindowScrollPos();
18573
18574	var left = parseInt(windowScroll.scrollLeft + windowSize.innerWidth / 2 - div.offsetWidth / 2);
18575	var top = parseInt(windowScroll.scrollTop + windowSize.innerHeight / 2 - div.offsetHeight / 2);
18576
18577	jsFloatDiv.Show(div, left, top, 5, true);
18578	jsUtils.addEvent(document, "keypress", window['JCPopup_OnKeyPress' + this.suffix]);
18579
18580	this.div = div;
18581	this.div_inner = document.getElementById('bx_popup_content' + this.suffix);
18582	if(this.div_inner)
18583	{
18584		if(this.div.style.width)
18585			this.div_inner.style.width = parseInt(parseInt(this.div.style.width) - 12) + 'px';
18586		if(this.div.style.height)
18587		{
18588			var aDivId = ['bx_popup_title', 'bx_popup_description_container', 'bx_popup_buttons'];
18589			var h=0;
18590			for(var i=0; i < aDivId.length; i++)
18591			{
18592				var dv = document.getElementById(aDivId[i] + this.suffix);
18593				if(dv)
18594					h += dv.offsetHeight;
18595			}
18596			this.div_inner.style.height = parseInt(parseInt(this.div.style.height) - h - 16) + 'px';
18597		}
18598	}
18599
18600	var _this = this;
18601	setTimeout(function() {_this.AdjustShadow();}, 10);
18602	if (this.arParams.resize && null != this.div && null != this.div_inner)
18603		this.createResizer();
18604	return div;
18605};
18606
18607JCPopup.prototype.__AjaxPostAction = function(result)
18608{
18609	CloseWaitWindow();
18610	if (this.suffix)
18611		jsPopup.bDenyClose = true;
18612	this.div.innerHTML = result;
18613	this.div_inner = document.getElementById('bx_popup_content' + this.suffix);
18614	this.AdjustShadow();
18615	if (this.arParams.resize && null != this.div && null != this.div_inner)
18616		this.createResizer();
18617};
18618
18619JCPopup.prototype.ShowDialog = function(url, arParams)
18620{
18621	if (document.getElementById(this.div_id))
18622		this.CloseDialog();
18623
18624	if (!arParams) arParams = {};
18625	if (null == arParams.resize) arParams.resize = true;
18626	if (!arParams.min_width) arParams.min_width = 250;
18627	if (!arParams.min_height) arParams.min_height = 200;
18628
18629	var pos = url.indexOf('?');
18630	if (pos == -1)
18631		url += "?mode=public";
18632	else
18633		url = url.substring(0, pos) + "?mode=public&" + url.substring(pos+1);
18634
18635	this.check_url = pos == -1 ? url : url.substring(0, pos);
18636
18637	if (arParams.resize && null != this.__arRuntimeResize[this.check_url])
18638	{
18639		arParams.width = this.__arRuntimeResize[this.check_url].width;
18640		arParams.height = this.__arRuntimeResize[this.check_url].height;
18641		var ipos = url.indexOf('bxpiheight');
18642		if (ipos == -1)
18643			url += (pos == -1 ? '?' : '&') + 'bxpiheight=' + this.__arRuntimeResize[this.check_url].iheight;
18644		else
18645			url = url.substring(0, ipos) + 'bxpiheight=' + this.__arRuntimeResize[this.check_url].iheight;
18646	}
18647
18648	this.url = url;
18649	this.arParams = arParams;
18650	this.CreateOverlay();
18651	jsExtLoader.onajaxfinish = window['JCPopup_AjaxAction' + this.suffix];
18652	if(arParams['postData'])
18653		jsExtLoader.startPost(url, arParams['postData']);
18654	else
18655		jsExtLoader.start(url);
18656};
18657
18658JCPopup.prototype.RemoveOverlay = function()
18659{
18660	//var overlay = document.getElementById(this.overlay_id);
18661	if (this.overlay)
18662		this.overlay.parentNode.removeChild(this.overlay);
18663	jsUtils.removeEvent(window, "resize", window['JCPopup_OverlayResize' + this.suffix]);
18664};
18665
18666JCPopup.prototype.OverlayResize = function()
18667{
18668	//var overlay = document.getElementById(this.overlay_id);
18669	if (!this.overlay)
18670		return;
18671	var windowSize = jsUtils.GetWindowScrollSize();
18672	this.overlay.style.width = windowSize.scrollWidth + "px";
18673};
18674
18675JCPopup.prototype.CreateOverlay = function()
18676{
18677	var opacity = new COpacity();
18678	if (!opacity.GetOpacityProperty())
18679		return;
18680	//Create overlay
18681	this.overlay = document.body.appendChild(document.createElement("DIV"));
18682	this.overlay.className = "bx-popup-overlay";
18683	this.overlay.id = this.overlay_id;
18684	this.overlay.style.zIndex = this.zIndex - 5;
18685
18686	var windowSize = jsUtils.GetWindowScrollSize();
18687
18688	this.overlay.style.width = windowSize.scrollWidth + "px";
18689	this.overlay.style.height = windowSize.scrollHeight + "px";
18690
18691	jsUtils.addEvent(window, "resize", window['JCPopup_OverlayResize' + this.suffix]);
18692};
18693
18694JCPopup.prototype.CloseDialog = function()
18695{
18696	jsUtils.onCustomEvent('OnBeforeCloseDialog', this.suffix);
18697
18698	for(var i=0; i<this.onClose.length; i++)
18699		this.onClose[i]();
18700
18701	if (this.bDenyClose)
18702		return false;
18703	if (this.suffix)
18704		jsPopup.bDenyClose = false;
18705	jsUtils.removeEvent(document, "keypress", window['JCPopup_OnKeyPress' + this.suffix]);
18706	var div = document.getElementById(this.div_id);
18707	if (!div)
18708		return;
18709	jsFloatDiv.Close(div);
18710	div.parentNode.removeChild(div);
18711	this.clearAdditionalResize();
18712	this.RemoveOverlay();
18713
18714	return true;
18715};
18716
18717JCPopup.prototype.GetParameters = function(form_name)
18718{
18719	if (null == form_name)
18720		var form = document.forms[this.form_name];
18721	else
18722		var form = document.forms[form_name];
18723
18724	if(!form)
18725		return "";
18726
18727	var i, s = "";
18728	var n = form.elements.length;
18729
18730	var delim = '';
18731	for(i=0; i<n; i++)
18732	{
18733		if (s != '') delim = '&';
18734		var el = form.elements[i];
18735		if (el.disabled)
18736			continue;
18737
18738		switch(el.type.toLowerCase())
18739		{
18740			case 'text':
18741			case 'textarea':
18742			case 'password':
18743			case 'hidden':
18744				if (null == form_name && el.name.substr(el.name.length-4) == '_alt' && form.elements[el.name.substr(0, el.name.length-4)])
18745					break;
18746				s += delim + el.name + '=' + encodeURIComponent(el.value);
18747				break;
18748			case 'radio':
18749				if(el.checked)
18750					s += delim + el.name + '=' + encodeURIComponent(el.value);
18751				break;
18752			case 'checkbox':
18753				s += delim + el.name + '=' + encodeURIComponent(el.checked ? 'Y':'N');
18754				break;
18755			case 'select-one':
18756				var val = "";
18757				if (null == form_name && form.elements[el.name + '_alt'] && el.selectedIndex == 0)
18758					val = form.elements[el.name+'_alt'].value;
18759				else
18760					val = el.value;
18761				s += delim + el.name + '=' + encodeURIComponent(val);
18762				break;
18763			case 'select-multiple':
18764				var j, bAdded = false;
18765				var l = el.options.length;
18766				for (j=0; j<l; j++)
18767				{
18768					if (el.options[j].selected)
18769					{
18770						s += delim + el.name + '=' + encodeURIComponent(el.options[j].value);
18771						bAdded = true;
18772					}
18773				}
18774				if (!bAdded)
18775					s += delim + el.name + '=';
18776				break;
18777			default:
18778				break;
18779		}
18780	}
18781
18782	if (null != this.arParams && this.arParams.resize && this.div_inner)
18783	{
18784		var inner_width = parseInt(this.div_inner.style.width);
18785		var inner_height = parseInt(this.div_inner.style.height);
18786
18787		if (inner_width > 0)
18788			s += '&bxpiwidth=' + inner_width;
18789		if (inner_height > 0)
18790			s += '&bxpiheight=' + inner_height;
18791	}
18792
18793	return s;
18794};
18795
18796JCPopup.prototype.PostParameters = function(params)
18797{
18798	var _this = this;
18799	jsExtLoader.onajaxfinish = window['JCPopup_AjaxPostAction' + this.suffix];
18800	ShowWaitWindow();
18801	var url = this.url;
18802	if (null != params)
18803	{
18804		index = url.indexOf('?')
18805		if (index == -1)
18806			url += '?' + params;
18807		else
18808			url = url.substring(0, index) + '?' + params + "&" + url.substring(index+1);
18809	}
18810
18811	jsExtLoader.startPost(url, this.GetParameters());
18812};
18813
18814JCPopup.prototype.AdjustShadow = function()
18815{
18816	if (this.div)
18817		jsFloatDiv.AdjustShadow(this.div);
18818};
18819
18820JCPopup.prototype.HideShadow = function()
18821{
18822	if (this.div)
18823		jsFloatDiv.HideShadow(this.div);
18824};
18825
18826JCPopup.prototype.UnhideShadow = function()
18827{
18828	if (this.div)
18829		jsFloatDiv.UnhideShadow(this.div);
18830};
18831
18832JCPopup.prototype.DragPanel = function(event, td)
18833{
18834	var div = jsUtils.FindParentObject(td, 'div');
18835	div.style.left = div.offsetLeft+'px';
18836	div.style.top = div.offsetTop+'px';
18837	jsFloatDiv.StartDrag(event, div);
18838};
18839
18840// ************* resizers ************* //
18841JCPopup.prototype.createResizer = function()
18842{
18843	this.diff_x = null;
18844	this.diff_y = null;
18845	this.arPos = jsUtils.GetRealPos(this.div);
18846	var zIndex = parseInt(jsUtils.GetStyleValue(this.div, jsUtils.IsIE() ? 'zIndex' : 'z-index')) + 1;
18847	this.obResizer = document.createElement('DIV');
18848	this.obResizer.className = 'bxresizer';
18849	this.obResizer.style.position = 'absolute';
18850	this.obResizer.style.zIndex = zIndex;
18851	this.obResizer.onmousedown = window['JCPopup_startResize' + this.suffix];
18852	//this.obResizer.onmousedown = this.startResize;
18853	this.div.appendChild(this.obResizer);
18854};
18855
18856JCPopup.prototype.startResize = function (e)
18857{
18858	if(!e) e = window.event;
18859
18860	this.wndSize = jsUtils.GetWindowScrollPos();
18861	this.wndSize.innerWidth = jsUtils.GetWindowInnerSize().innerWidth;
18862
18863	this.x = e.clientX + this.wndSize.scrollLeft;
18864	this.y = e.clientY + this.wndSize.scrollTop;
18865	this.obDescr = document.getElementById('bx_popup_description_container' + this.suffix);
18866	if (jsUtils.IsIE())
18867	{
18868		this.arPos = this.div.getBoundingClientRect();
18869		this.arPos =
18870		{
18871			left: this.arPos.left + this.wndSize.scrollLeft,
18872			top: this.arPos.top + this.wndSize.scrollTop,
18873			right: this.arPos.right + this.wndSize.scrollLeft,
18874			bottom: this.arPos.bottom + this.wndSize.scrollTop
18875		}
18876		this.arPosInner = this.div_inner.getBoundingClientRect();
18877		this.arPosInner = {
18878			left: this.arPosInner.left + this.wndSize.scrollLeft,
18879			top: this.arPosInner.top + this.wndSize.scrollTop,
18880			right: this.arPosInner.right + this.wndSize.scrollLeft,
18881			bottom: this.arPosInner.bottom + this.wndSize.scrollTop
18882		}
18883	}
18884	else
18885	{
18886		this.arPos = jsUtils.GetRealPos(this.div);
18887		this.arPosInner = jsUtils.GetRealPos(this.div_inner);
18888	}
18889
18890	document.onmouseup = window['JCPopup_stopResize' + this.suffix];
18891	jsUtils.addEvent(document, "mousemove", window['JCPopup_doResize' + this.suffix]);
18892
18893	if(document.body.setCapture)
18894		document.body.setCapture();
18895
18896	var b = document.body;
18897	b.ondrag = jsUtils.False;
18898	b.onselectstart = jsUtils.False;
18899	b.style.MozUserSelect = this.div.style.MozUserSelect = 'none';
18900	b.style.cursor = this.obResizer.style.cursor;
18901
18902	this.HideShadow();
18903};
18904
18905JCPopup.prototype.doResize = function(e)
18906{
18907	if(!e) e = window.event;
18908	var x = e.clientX + this.wndSize.scrollLeft;
18909	var y = e.clientY + this.wndSize.scrollTop;
18910
18911	if(this.x == x && this.y == y || x > this.wndSize.innerWidth + this.wndSize.scrollLeft - 10)
18912		return;
18913
18914	this.Resize(x, y);
18915	this.x = x;
18916	this.y = y;
18917};
18918
18919JCPopup.prototype.Resize = function(x, y)
18920{
18921	if (null == this.diff_x)
18922	{
18923		this.diff_x = this.div.offsetWidth - this.div_inner.offsetWidth;
18924		this.diff_y = this.div.offsetHeight - this.div_inner.offsetHeight;
18925
18926		if (this.arAdditionalResize.length > 0)
18927		{
18928			for (var i = 0, cnt = this.arAdditionalResize.length; i < cnt; i++)
18929			{
18930				if (null != this.arAdditionalResize[i])
18931				{
18932					var borderX = jsUtils.IsOpera() ? 0 :
18933						parseInt(jsUtils.GetStyleValue(
18934							this.arAdditionalResize[i], jsUtils.IsIE() ? 'borderLeftWidth' : 'border-left-width'
18935						)) +
18936						parseInt(jsUtils.GetStyleValue(
18937							this.arAdditionalResize[i], jsUtils.IsIE() ? 'borderRightWidth' : 'border-right-width'
18938						));
18939
18940					var borderY = jsUtils.IsOpera() || jsUtils.IsIE() ? 0 :
18941						parseInt(jsUtils.GetStyleValue(this.arAdditionalResize[i], 'border-top-width')) +
18942						parseInt(jsUtils.GetStyleValue(this.arAdditionalResize[i], 'border-bottom-width'));
18943
18944					this.arAdditionalResize[i].diff_x = this.div.offsetWidth - this.arAdditionalResize[i].offsetWidth + borderX;
18945					this.arAdditionalResize[i].diff_y = this.div.offsetHeight - this.arAdditionalResize[i].offsetHeight + borderY;
18946				}
18947			}
18948		}
18949	}
18950	var new_width = x - this.arPos.left;
18951	var new_height = y - this.arPos.top;
18952	var dx = new_width - this.div.offsetWidth;
18953	//var dy = y - this.y;
18954
18955	if (null != this.obDescr)
18956		var descrHeight = this.obDescr.offsetHeight;
18957
18958	var bResizeX = false;
18959	if (new_width > this.arParams.min_width)
18960	{
18961		bResizeX = true;
18962		this.div.style.width = new_width + 'px';
18963		this.div_inner.style.width = (new_width - this.diff_x) + 'px';
18964	}
18965
18966	if (null != this.obDescr)
18967		var dy = this.obDescr.offsetHeight - descrHeight;
18968	else
18969		var dy = 0;
18970
18971	this.diff_y += dy;
18972	var bResizeY = false;
18973	if (new_height > this.arParams.min_height)
18974	{
18975		bResizeY = true;
18976		this.div_inner.style.height = (new_height - this.diff_y) + 'px';
18977		this.div.style.height = new_height + 'px';
18978	}
18979
18980	if (this.arAdditionalResize.length > 0)
18981	{
18982		for (var i = 0, cnt = this.arAdditionalResize.length; i < cnt; i++)
18983		{
18984			if (null != this.arAdditionalResize[i])
18985			{
18986				if (bResizeY) this.arAdditionalResize[i].style.height = (new_height - this.arAdditionalResize[i].diff_y) + 'px';
18987				if (bResizeX) this.arAdditionalResize[i].style.width = (new_width - this.arAdditionalResize[i].diff_x) + 'px';
18988			}
18989		}
18990	}
18991	if (jsUtils.IsIE())
18992		this.AdjustShadow();
18993};
18994
18995JCPopup.prototype.stopResize = function ()
18996{
18997	if(document.body.releaseCapture)
18998		document.body.releaseCapture();
18999
19000	jsUtils.removeEvent(document, "mousemove", window['JCPopup_doResize' + this.suffix]);
19001
19002	document.onmouseup = null;
19003
19004	var b = document.body;
19005	b.ondrag = null;
19006	b.onselectstart = null;
19007	b.style.MozUserSelect = this.div.style.MozUserSelect = '';
19008	b.style.cursor = '';
19009
19010	this.UnhideShadow();
19011	this.AdjustShadow();
19012	this.SavePosition();
19013};
19014
19015JCPopup.prototype.SavePosition = function()
19016{
19017	var arPos = {
19018		width: parseInt(this.div.style.width),
19019		height: parseInt(this.div.style.height),
19020		iheight: parseInt(this.div_inner.style.height)
19021	};
19022
19023	if (null != this.error_dy)
19024		arPos.iheight += this.error_dy;
19025
19026	jsUserOptions.SaveOption('jsPopup' + this.suffix, 'size_' + this.check_url, 'width', arPos.width);
19027	jsUserOptions.SaveOption('jsPopup' + this.suffix, 'size_' + this.check_url, 'height', arPos.height);
19028	jsUserOptions.SaveOption('jsPopup' + this.suffix, 'size_' + this.check_url, 'iheight', arPos.iheight);
19029
19030	for (var i = 0, cnt = this.arAdditionalResize.length; i < cnt; i++)
19031	{
19032		if (null != this.arAdditionalResize[i] && null != this.arAdditionalResize[i].BXResizeCacheID)
19033		{
19034			jsUserOptions.SaveOption('jsPopup' + this.suffix, 'size_' + this.check_url, this.arAdditionalResize[i].BXResizeCacheID + '_height', parseInt(this.arAdditionalResize[i].style.height));
19035			jsUserOptions.SaveOption('jsPopup' + this.suffix, 'size_' + this.check_url, this.arAdditionalResize[i].BXResizeCacheID + '_width', parseInt(this.arAdditionalResize[i].style.width));
19036		}
19037	}
19038	this.__arRuntimeResize[this.check_url] = arPos;
19039};
19040
19041JCPopup.prototype.IncludePrepare = function()
19042{
19043	var obFrame = window.frames.editor;
19044	if (null == obFrame)
19045		return false;
19046	var obSrcForm = obFrame.document.forms.inner_form;
19047	var obDestForm = document.forms[this.form_name];
19048	if (null == obSrcForm || null == obDestForm)
19049		return false;
19050	obDestForm.include_data.value = obSrcForm.filesrc_pub.value;
19051	return true;
19052};
19053
19054JCPopup.prototype.ShowError = function(error_text)
19055{
19056	CloseWaitWindow();
19057	this.AllowClose();
19058
19059	this.obDescr = document.getElementById('bx_popup_description_container' + this.suffix);
19060	if (null != this.obDescr)
19061	{
19062		var descrHeight = this.obDescr.offsetHeight;
19063		var obError = document.getElementById('bx_popup_description_error' + this.suffix);
19064		if (!obError)
19065		{
19066			obError = document.createElement('P');
19067			obError.id = 'bx_popup_description_error' + this.suffix;
19068			this.obDescr.firstChild.appendChild(obError);
19069		}
19070		obError.innerHTML = '<font class="errortext">' + error_text + '</font>';
19071		if (this.obDescr.offsetHeight != descrHeight)
19072		{
19073			this.error_dy = this.obDescr.offsetHeight - descrHeight;
19074			if (this.div_inner)
19075				this.div_inner.style.height = (parseInt(jsUtils.GetStyleValue(this.div_inner, 'height')) - this.error_dy) + 'px';
19076		}
19077	}
19078	else
19079		alert(error_text);
19080};
19081
19082function JCComponentUtils()
19083{
19084}
19085
19086JCComponentUtils.prototype.ClearCache = function(params)
19087{
19088	CHttpRequest.Action = function(result){window.location = window.location.href;};
19089	ShowWaitWindow();
19090	CHttpRequest.Send('/bitrix/admin/clear_component_cache.php?' + params);
19091};
19092
19093JCComponentUtils.prototype.EnableComponent = function(params)
19094{
19095	CHttpRequest.Action = function(result){window.location = window.location.href;};
19096	ShowWaitWindow();
19097	CHttpRequest.Send('/bitrix/admin/enable_component.php?' + params);
19098};
19099
19100function COpacity(element)
19101{
19102	this.element = element;
19103	this.opacityProperty = this.GetOpacityProperty();
19104
19105	this.startOpacity = null;
19106	this.finishOpacity = null;
19107	this.delay = 30;
19108
19109	this.currentOpacity = null;
19110	this.fadingTimeoutID = null;
19111}
19112
19113
19114COpacity.prototype.SetElementOpacity = function(opacity)
19115{
19116	if (!this.opacityProperty)
19117		return false;
19118
19119	if (this.opacityProperty == "filter")
19120	{
19121		opacity = opacity * 100;
19122		var alphaFilter = this.element.filters['DXImageTransform.Microsoft.alpha'] || this.element.filters.alpha;
19123		if (alphaFilter)
19124			alphaFilter.opacity = opacity;
19125		else
19126			this.element.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+opacity+")";
19127	}
19128	else
19129		this.element.style[this.opacityProperty] = opacity;
19130
19131	return true;
19132}
19133
19134COpacity.prototype.GetOpacityProperty = function()
19135{
19136	var m;
19137	if (typeof document.body.style.opacity == 'string')
19138		return 'opacity';
19139	else if (typeof document.body.style.MozOpacity == 'string')
19140		return 'MozOpacity';
19141	else if (typeof document.body.style.KhtmlOpacity == 'string')
19142		return 'KhtmlOpacity';
19143	else if (document.body.filters && (m = navigator.appVersion.match(/MSIE ([\d.]+)/)) && m[1] >=5.5)
19144		return 'filter';
19145
19146	return false;
19147}
19148
19149COpacity.prototype.Fading = function(startOpacity, finishOpacity, callback)
19150{
19151	if (!this.opacityProperty)
19152		return;
19153
19154	this.startOpacity = startOpacity;
19155	this.finishOpacity = finishOpacity;
19156	this.currentOpacity = this.startOpacity;
19157
19158	if (this.fadingTimeoutID)
19159		clearInterval(this.fadingTimeoutID);
19160
19161	var _this = this;
19162	this.fadingTimeoutID = setInterval(function () {_this.Run(callback)}, this.delay);
19163}
19164
19165COpacity.prototype.Run = function(callback)
19166{
19167	this.currentOpacity = Math.round((this.currentOpacity + 0.1*(this.finishOpacity - this.startOpacity > 0 ? 1: -1) )*10) / 10;
19168	this.SetElementOpacity(this.currentOpacity);
19169
19170	if (this.currentOpacity == this.startOpacity || this.currentOpacity == this.finishOpacity)
19171	{
19172		clearInterval(this.fadingTimeoutID);
19173		if (typeof(callback) == "function")
19174			callback(this);
19175	}
19176}
19177
19178COpacity.prototype.Undo = function()
19179{
19180}
19181
19182// this object can be used to load any pages with huge scripts structure via AJAX
19183var jsExtLoader = {
19184	obContainer: null,
19185	obContainerInner: null,
19186	jsPopup_name: 'jsPopup',
19187	url: '',
19188
19189	httpRequest: null,
19190	httpRequest2: null, // for Opera bug fix
19191
19192	obTemporary: null,
19193
19194	onajaxfinish: null,
19195
19196	obFrame: null,
19197
19198	start: function(url)
19199	{
19200		this.url = url;
19201
19202		this.obContainer = null;
19203
19204		ShowWaitWindow();
19205
19206		this.httpRequest = this._CreateHttpObject();
19207		this.httpRequest.onreadystatechange = jsExtLoader.stepOne;
19208
19209		this.httpRequest.open("GET", this.url, true);
19210		this.httpRequest.send("");
19211	},
19212
19213	startPost: function(url, data)
19214	{
19215		this.url = url;
19216		this.obContainer = null;
19217
19218		ShowWaitWindow();
19219
19220		this.httpRequest = this._CreateHttpObject();
19221		this.httpRequest.onreadystatechange = jsExtLoader.stepOne;
19222
19223		this.httpRequest.open("POST", this.url, true);
19224		this.httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
19225		this.httpRequest.send(data);
19226	},
19227
19228	post: function(form_name)
19229	{
19230		var obForm = document.forms[form_name];
19231		if (null == obForm)
19232			return;
19233
19234		if (null == this.obFrame)
19235		{
19236			if (jsUtils.IsIE())
19237				this.obFrame = document.createElement('<iframe src="javascript:void(0)" name="frame_' + form_name + '">');
19238			else
19239			{
19240				this.obFrame = document.createElement('IFRAME');
19241				this.obFrame.name = 'frame_' + form_name;
19242				this.obFrame.src = 'javascript:void(0)';
19243			}
19244
19245			this.obFrame.style.display = 'none';
19246
19247			document.body.appendChild(this.obFrame);
19248		}
19249
19250		obForm.target = this.obFrame.name;
19251
19252		if (obForm.action.length <= 0)
19253			obForm.action = this.url;
19254
19255		window[jsExtLoader.jsPopup_name].DenyClose();
19256		ShowWaitWindow();
19257
19258		obForm.save.click();
19259
19260		if (false === obForm.BXReturnValue)
19261		{
19262			window[jsExtLoader.jsPopup_name].AllowClose();
19263			CloseWaitWindow();
19264		}
19265
19266		obForm.BXReturnValue = true;
19267	},
19268
19269	urlencode: function(s)
19270	{
19271		return escape(s).replace(new RegExp('\\+','g'), '%2B');
19272	},
19273
19274	__prepareOnload: function()
19275	{
19276		this.obTemporary = window.onload;
19277		window.onload = null;
19278	},
19279
19280	__runOnload: function()
19281	{
19282		if (window.onload) window.onload();
19283		window.onload = this.obTemporary;
19284		this.obTemporary = null;
19285	},
19286
19287	stepOne: function()
19288	{
19289		if (jsExtLoader.httpRequest.readyState == 4)
19290		{
19291			var content = jsExtLoader.httpRequest.responseText;
19292			var arCode = [];
19293			var matchScript;
19294
19295			var regexp = new RegExp('<script([^>]*)>', 'i');
19296			var regexp1 = new RegExp('src=["\']([^"\']+)["\']', 'i');
19297
19298			while ((matchScript = content.match(regexp)) !== null)
19299			{
19300				var end = content.search('<\/script>', 'i');
19301				if (end == -1)
19302					break;
19303
19304				var bRunFirst = matchScript[1].indexOf('bxrunfirst') != '-1';
19305
19306				var matchSrc;
19307				if ((matchSrc = matchScript[1].match(regexp1)) !== null)
19308					arCode[arCode.length] = {"bRunFirst": bRunFirst, "isInternal": false, "JS": matchSrc[1]};
19309				else
19310				{
19311					var start = matchScript.index + matchScript[0].length;
19312					var js = content.substr(start, end-start);
19313
19314					if (false && arCode.length > 0 && arCode[arCode.length - 1].isInternal && arCode[arCode.length - 1].bRunFirst == bRunFirst)
19315						arCode[arCode.length - 1].JS += "\r\n\r\n" + js;
19316					else
19317						arCode[arCode.length] = {"bRunFirst": bRunFirst, "isInternal": true, "JS": js};
19318				}
19319
19320				content = content.substr(0, matchScript.index) + content.substr(end+9);
19321			}
19322
19323			jsExtLoader.__prepareOnload();
19324			jsExtLoader.processResult(content, arCode);
19325			CloseWaitWindow();
19326			jsExtLoader.__runOnload();
19327		}
19328	},
19329
19330	EvalGlobal: function(script)
19331	{
19332		if (window.execScript)
19333			window.execScript(script, 'javascript');
19334		else if (jsUtils.IsSafari())
19335			window.setTimeout(script, 0);
19336		else
19337			window.eval(script);
19338	},
19339
19340	arLoadedScripts: [],
19341
19342	__isScriptLoaded: function (script_src)
19343	{
19344		for (var i=0; i<jsExtLoader.arLoadedScripts.length; i++)
19345			if (jsExtLoader.arLoadedScripts[i] == script_src) return true;
19346		return false;
19347	},
19348
19349	// evaluate external script
19350	EvalExternal: function(script_src)
19351	{
19352		if (/\/bitrix\/js\/main\/public_tools.js$/i.test(script_src)) return; // sorry guys, i cannot execute myself :-)
19353		if (jsExtLoader.__isScriptLoaded(script_src)) return;
19354
19355		jsExtLoader.arLoadedScripts.push(script_src);
19356
19357		if (script_src.substring(0, 8) != '/bitrix/')
19358			script_src = '/bitrix/admin/' + script_src;
19359
19360		// fix Opera bug with combining syncronous and asynchronuos requests using one XHR object.
19361		if (jsUtils.IsOpera())
19362		{
19363			if (null == this.httpRequest2)
19364				this.httpRequest2 = this._CreateHttpObject();
19365
19366			var httpRequest = this.httpRequest2;
19367		}
19368		else
19369		{
19370			var httpRequest = this.httpRequest;
19371		}
19372
19373		httpRequest.onreadystatechange = function (str) {};
19374		httpRequest.open("GET", script_src, false);
19375		httpRequest.send("");
19376
19377		var s = httpRequest.responseText;
19378
19379		httpRequest = null;
19380
19381		try
19382		{
19383			this.EvalGlobal(s);
19384		}
19385		catch(e)
19386		{
19387			//alert('script_src: ' + script_src + '<pre>' + s + '</pre>');
19388		}
19389	},
19390
19391	processResult: function(content, arCode)
19392	{
19393		//Javascript
19394		jsExtLoader.processScripts(arCode, true);
19395
19396		if (null == jsExtLoader.obContainer)
19397			jsExtLoader.obContainer = jsExtLoader.onajaxfinish(content);
19398		else
19399			jsExtLoader.obContainer.innerHTML = content;
19400
19401		//Javascript
19402		jsExtLoader.processScripts(arCode, false);
19403	},
19404
19405	processScripts: function(arCode, bRunFirst)
19406	{
19407		for (var i = 0, length = arCode.length; i < length; i++)
19408		{
19409			if (arCode[i].bRunFirst != bRunFirst)
19410				continue;
19411
19412			if (arCode[i].isInternal)
19413			{
19414				arCode[i].JS = arCode[i].JS.replace('<!--', '');
19415				jsExtLoader.EvalGlobal(arCode[i].JS);
19416			}
19417			else
19418			{
19419				jsExtLoader.EvalExternal(arCode[i].JS);
19420			}
19421		}
19422	},
19423
19424	_CreateHttpObject: function()
19425	{
19426		var obj = null;
19427		if(window.XMLHttpRequest)
19428		{
19429			try {obj = new XMLHttpRequest();} catch(e){}
19430		}
19431		else if(window.ActiveXObject)
19432		{
19433			try {obj = new ActiveXObject("Microsoft.XMLHTTP");} catch(e){}
19434			if(!obj)
19435				try {obj = new ActiveXObject("Msxml2.XMLHTTP");} catch (e){}
19436		}
19437		return obj;
19438	}
19439}
19440
19441/*
19442public jsAdminStyle - external CSS manager
19443*/
19444
19445var jsAdminStyle = {
19446
19447	arCSS: {},
19448	bInited: false,
19449
19450	httpRequest: null,
19451
19452	Init: function()
19453	{
19454		var arStyles = document.getElementsByTagName('LINK');
19455		if (arStyles.length > 0)
19456		{
19457			for (var i = 0; i<arStyles.length; i++)
19458			{
19459				if (arStyles[i].href)
19460				{
19461					var filename = arStyles[i].href;
19462					var pos = filename.indexOf('://');
19463					if (pos != -1)
19464						filename = filename.substr(filename.indexOf('/', pos + 3));
19465
19466					arStyles[i].bxajaxflag = false;
19467					this.arCSS[filename] = arStyles[i];
19468				}
19469			}
19470		}
19471
19472		this.bInited = true;
19473	},
19474
19475	Load: function(filename)
19476	{
19477		if (!this.bInited) this.Init();
19478
19479		if (null != this.arCSS[filename])
19480		{
19481			this.arCSS[filename].disabled = false;
19482			return;
19483		}
19484
19485		var link = document.createElement("STYLE");
19486		link.type = 'text/css';
19487
19488		var head = document.getElementsByTagName("HEAD")[0];
19489		head.insertBefore(link, head.firstChild);
19490		//head.appendChild(link);
19491
19492		if (jsUtils.IsIE())
19493		{
19494			link.styleSheet.addImport(filename);
19495		}
19496		else
19497		{
19498			try
19499			{
19500				if (null == this.httpRequest)
19501					this.httpRequest = jsExtLoader._CreateHttpObject();
19502
19503				this.httpRequest.onreadystatechange = null;
19504
19505				this.httpRequest.open("GET", filename, false); // make *synchronous* request for css source
19506				this.httpRequest.send("");
19507
19508				var s = this.httpRequest.responseText;
19509
19510				// convert relative resourse paths in css to absolute. current path to css will be lost.
19511				var pos = filename.lastIndexOf('/');
19512				if (pos != -1)
19513				{
19514					var dirname = filename.substring(0, pos);
19515					s = s.replace(/url\(([^\/\\].*?)\)/gi, 'url(' + dirname + '/$1)');
19516				}
19517
19518				link.appendChild(document.createTextNode(s));
19519			}
19520			catch (e) {}
19521		}
19522	},
19523
19524	Unload: function(filename)
19525	{
19526		if (!this.bInited) this.Init();
19527
19528		if (null != this.arCSS[filename])
19529		{
19530			this.arCSS[filename].disabled = true;
19531		}
19532	},
19533
19534	UnloadAll: function()
19535	{
19536		if (!this.bInited) this.Init();
19537		else
19538			for (var i in this.arCSS)
19539			{
19540				if (this.arCSS[i].bxajaxflag)
19541					this.Unload(i);
19542			}
19543	}
19544}
19545
19546// for compatibility with IE 5.0 browser
19547if (![].pop)
19548{
19549	Array.prototype.pop = function()
19550	{
19551		if (this.length <= 0) return false;
19552		var element = this[this.length-1];
19553		delete this[this.length-1];
19554		this.length--;
19555		return element;
19556	}
19557
19558	Array.prototype.shift = function()
19559	{
19560		if (this.length <= 0) return false;
19561		var tmp = this.reverse();
19562		var element = tmp.pop();
19563		this.prototype = tmp.reverse();
19564		return element;
19565	}
19566
19567	Array.prototype.push = function(element)
19568	{
19569		this[this.length] = element;
19570	}
19571}
19572//************************************************************
19573
19574function jsWizard()
19575{
19576	this.currentStep = null;
19577	this.firstStep = null;
19578
19579	this.arSteps = {};
19580
19581	this.nextButtonID = "btn_popup_next";
19582	this.prevButtonID = "btn_popup_prev";
19583	this.finishButtonID = "btn_popup_finish";
19584
19585	this.arButtons = {};
19586}
19587
19588jsWizard.prototype.AddStep = function(stepID, arButtons)
19589{
19590	var element = document.getElementById(stepID);
19591	if (!element)
19592		return;
19593
19594	if (typeof(arButtons) != "object")
19595		arButtons = {};
19596
19597	this.arSteps[stepID] = {"element": element};
19598
19599	//Actions
19600	for (var button in arButtons)
19601		this.arSteps[stepID][button] = arButtons[button];
19602
19603	if (this.firstStep === null)
19604		this.firstStep = stepID;
19605}
19606
19607jsWizard.prototype.SetCurrentStep = function(stepID)
19608{
19609	this.currentStep = stepID;
19610}
19611
19612jsWizard.prototype.SetFirstStep = function(stepID)
19613{
19614	this.firstStep = stepID;
19615}
19616
19617jsWizard.prototype.SetNextButtonID = function(buttonID)
19618{
19619	this.nextButtonID = buttonID;
19620}
19621
19622jsWizard.prototype.SetPrevButtonID = function(buttonID)
19623{
19624	this.prevButtonID = buttonID;
19625}
19626
19627jsWizard.prototype.SetFinishButtonID = function(buttonID)
19628{
19629	this.finishButtonID = buttonID;
19630}
19631
19632jsWizard.prototype.SetCancelButtonID = function(buttonID)
19633{
19634	this.cancelButtonID = buttonID;
19635}
19636
19637
19638jsWizard.prototype.SetButtonDisabled = function(button, disabled)
19639{
19640	if (this.arButtons[button])
19641		this.arButtons[button].disabled = disabled;
19642}
19643
19644jsWizard.prototype.IsStepExists = function(stepID)
19645{
19646	if (this.arSteps[stepID])
19647		return true;
19648	else
19649		return false;
19650}
19651
19652jsWizard.prototype.Display = function()
19653{
19654	if (this.firstStep === null)
19655		return;
19656
19657	this.currentStep = this.firstStep;
19658
19659	var _this = this;
19660	var arButtons = {"next" : this.nextButtonID, "prev" : this.prevButtonID, "finish" : this.finishButtonID};
19661	for (var button in arButtons)
19662	{
19663		var buttonElement = document.getElementById(arButtons[button]);
19664		if (buttonElement && buttonElement.tagName == "INPUT")
19665		{
19666			buttonElement.buttonID = button;
19667			buttonElement.onclick = function() {_this._OnButtonClick(this.buttonID)};
19668			this.arButtons[button] = buttonElement;
19669		}
19670		else
19671			this.arButtons[button] = null;
19672	}
19673
19674	this._OnStepShow();
19675}
19676
19677jsWizard.prototype._OnButtonClick = function(button)
19678{
19679	if (this.arSteps[this.currentStep] )
19680	{
19681		var callback = this.arSteps[this.currentStep]["on" + button];
19682		if (callback && typeof(callback) == "function")
19683		{
19684			if (callback(this) === false)
19685				return;
19686		}
19687	}
19688
19689	if (!this.arSteps[this.currentStep])
19690	{
19691		if (!this.arSteps[this.firstStep])
19692			return;
19693
19694		this.currentStep = this.firstStep;
19695	}
19696	else if (this.arSteps[this.currentStep][button])
19697		this.currentStep = this.arSteps[this.currentStep][button];
19698
19699	this._OnStepShow();
19700}
19701
19702jsWizard.prototype._OnStepShow = function()
19703{
19704	//Display current step and hide others steps
19705	for (var stepID in this.arSteps)
19706		this.arSteps[stepID].element.style.display = (stepID == this.currentStep ? "" : "none");
19707
19708	//Activate and disable buttons
19709	for (var button in this.arButtons)
19710	{
19711		if (this.arButtons[button])
19712		{
19713			var stepID = this.arSteps[this.currentStep][button];
19714			this.arButtons[button].disabled = (stepID && this.arSteps[stepID] ? false : true);
19715		}
19716	}
19717
19718	//Execute onshow function
19719	if (this.arSteps[this.currentStep])
19720	{
19721		var callback = this.arSteps[this.currentStep]["onshow"];
19722		if (callback && typeof(callback) == "function")
19723			callback(this);
19724	}
19725}
19726
19727var jsPopup = new JCPopup();
19728var jsComponentUtils = new JCComponentUtils();
19729
19730/* End */
19731;

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.