
	/**
		Hybrid Library v1.1.0
		© 2010 Алексей Забродин
	*/

	/* Функции для выбора элементов */
	function getElemById(i, p)
	{
		try
		{
			var p = p || document;
			return p.getElementById(i);
		}
		catch(e){}
	}
	function getElemByTag(t, p)
	{
		try
		{
			var p = p || document;
			return p.getElementsByTagName(t);
		}
		catch(e){}
	}
	function $(a, b)
	{
		var o;
		if (typeof(a) == 'string')
		{
			if (!a.search(/^#.+/i))
			{
				if (b)
				{
					o = getElemByTag(b, getElemById(a.replace(/^#/i, '')));
				}
				else
				{
					o = getElemById(a.replace(/^#/i, ''));
				}
			}
			else
			{
				o = getElemByTag(a);
			}
		}
		else
		{
			if (b)
			{
				o = getElemByTag(b, a);
			}
			else
			{
				o = a;
			}
		}
		return o;
	}

	/* Набор инструментов */
	var Tools = {
		hide: function()
		{
			this.o.style.display = 'none';
		},
		show: function()
		{
			this.o.style.display = '';
		},
		style: function(s, o)
		{
			var o = o || this.o;
			for (var i in s)
			{
				o.style[i] = s[i];
			}
		},
		css: function(s)
		{
			if (s)
			{
				if (typeof(s) == 'string')
				{
					this.o.className = s;
				}
				else
				{
					this.style(s);
				}
			}
		},
		event: function(e, l)
		{
			if (this.o.attachEvent)
			{
				this.o.attachEvent('on' + e, l);
			}
			else
			{
				this.o.addEventListener(e, l, false);
			}
		},
		createElement: function(n, s)
		{
			var e = document.createElement(n);
			if (s) this.style(s, e);
			this.o.appendChild(e);
			return e;
		},
		each: function(f)
		{
			for (var i = 0; i < this.o.length; i++)
			{
				f.call(this.o[i], i);
			}
		},
		select: function()
		{
			var r, s;
			if (document.createRange)
			{
				r = document.createRange();
        		r.selectNode(this.o);
        		s = window.getSelection();
        		s.removeAllRanges();
        		s.addRange(r);
			}
			else if (document.selection.createRange)
			{
				r = document.selection.createRange();
				r.moveToElementText(this.o);
				r.select();
			}
		},
		slide: function(s)
		{
			var o = this.o;
			function sh(h, f)
			{
				return function()
				{
					o.style.height = h + 'px';
					if (f) f.call(this, h);
				}
			}
			s = (s - 11) * -1;
			o.style.overflow = 'hidden';
			if (o.style.display == 'none')
			{
				o.style.display = '';
				if (!o.height) o.height = o.clientHeight;
				o.style.height = '1px';
				for (var i = 1; i <= o.height; i++)
				{
					setTimeout(sh(i), i * s);
				}
			}
			else
			{
				if (!o.height) o.height = o.clientHeight;
				for (var i = o.height; i > 0; i--)
				{
   					setTimeout(sh(i, function(h)
       				{
          				if (h == 1) o.style.display = 'none';
          			}), (o.height - i) * s);
       			}
			}
		}
	};
	
	/* Оболочка набора инструментов */
	function _(a, b)
	{
		function f()
		{
			this.o = $(a, b);
		}
		f.prototype = Tools;
		return new f();
	}

	/* Класс для загрузки */
	var Ajax = {
		frame: null,
		onload: null,
		init: function()
		{
			var div = _(document.body).createElement('div', {
				display: 'none'
			});
			div.innerHTML = '<iframe id="_frame_" name="_frame_"></iframe>';
			_('#_frame_').event('load', Ajax.frameOnload);
			Ajax.frame = $('#_frame_');
		},
		frameOnload: function()
		{
			if (Ajax.onload)
			{
				Ajax.onload.call(this, frames['_frame_'].document.body.innerHTML);
				Ajax.onload = null;
			}
		},
		load: function(u, fu)
		{
			Ajax.onload = fu;
			Ajax.frame.src = u;
		},
		submit: function(f, fu)
		{
			Ajax.onload = fu;
			f.setAttribute('target', '_frame_');
			f.submit();
		}
	};

	/* Класс для динамических окон */
	var Box = {
		blind: null,
		container: null,
		init: function()
		{
			Box.blind = _(document.body).createElement('div', {
				backgroundColor: '#000',
				width: '100%',
				height: '100%',
				position: 'absolute',
				top: '0',
				left: '0',
				display: 'none',
				zIndex: '1',
				opacity: '0.7',
				filter: 'alpha(opacity=70)'
			});
			Box.blind.onclick = Box.hide;
			Box.container = _(document.body).createElement('div', {
				position: 'absolute',
				top: '0',
				left: '0',
				display: 'none',
				zIndex: '2'
			});
		},
		show: function(c, nf)
		{
			function fade(e)
			{
				function s(v)
				{
					e.style.opacity = (v / 10);
				}
				function f(v)
				{
					s(v);
					if (v <= 9)
					{
						setTimeout(function()
						{
							f(v + 1);
						}, 28);
					}
				}
				f(0);
			}
			function topBlind()
			{
				Box.blind.style.top = (
					document.documentElement.scrollTop || document.body.scrollTop
				) + 'px';
			}
			function align()
			{
				Box.container.style.top = (document.documentElement.scrollTop || document.body.scrollTop) + 
			    ((document.body.clientHeight / 2) - (Box.container.clientHeight / 2)) + 'px';
			    Box.container.style.left = '0';
			    Box.container.style.left = ((document.body.clientWidth / 2) - (Box.container.clientWidth / 2)) + 'px';
			}
			_(Box.blind).show();
			topBlind();
			_(window).event('scroll', function()
			{
				topBlind();
				align();
			});
			Box.container.innerHTML = c;
			_(Box.container).show();
			align();
			setTimeout(function()
			{
				align();
			}, 1);
			if (!nf) fade(Box.container);
		},
		hide: function()
		{
			_(Box.blind).hide();
			_(Box.container).hide();
		}
	};
	
	/* Класс для работы с вкладками */
	var Tabs = {
		control: null,
		items: null,
		cssHold: null,
		cssSelect: null,
		init: function(o)
		{
			if (o)
			{
				this.control = o.control;
				this.cssHold = o.cssHold;
				this.cssSelect = o.cssSelect;
			}
			if (Tabs.control)
			{
				Tabs.items = new Array();
				_('div').each(function()
				{
					if (/tab,.*/i.test(this.id))
					{
						Tabs.items.push({
							name: this.id.split(', ')[1],
							hold: this.id.split(', ')[2],
							tab: this 
						});
					}
				});
				if (Tabs.items[0])
				{
					$(Tabs.control).innerHTML = '';
					_(Tabs.items).each(function(i)
					{
						var a = _(Tabs.control).createElement('a');
						a.href = 'javascript:;';
						a.innerHTML = this.name;
						if (this.hold)
						{
							a.className = Tabs.cssHold;
						}
						else
						{
							a.onclick = function()
							{
								Tabs.select(i);
								location = '#' + i;
							}
						}
					});
					this.select(location.toString().split('#')[1] || 0);
				}
			}
		},
		select: function(i)
		{
			if (Tabs.items)
			{
				if (!Tabs.items[i].hold)
				{
					_(Tabs.items).each(function()
					{
						_(this.tab).hide();
					});
					setTimeout(function()
					{
						_(Tabs.items[i].tab).show();
					}, 0);
					_(Tabs.control, 'a').each(function(n)
					{
						if (i == n)
						{
							this.className = Tabs.cssSelect;
						}
						else
						{
							if (this.className != Tabs.cssHold)
							{
								this.className = '';
							}
						}
					});
				}
				else
				{
					this.select(0);
				}
			}
		},
		hold: function(n)
		{
			_(Tabs.items).each(function()
			{
				if (this.name == n)
				{
					this.tab.id = 'tab, ' + this.name + ', hold';
				}
			});
			Tabs.init();
		},
		unHold: function(n)
		{
			_(Tabs.items).each(function()
			{
				if (this.name == n)
				{
					this.tab.id = 'tab, ' + this.name;
				}
			});
			Tabs.init();
		}
	}
	
	/* Класс для зебры */
	var Zebra = {
		init: function(i, n, r1, r2, rl)
		{
			_(i, n).each(function(i)
			{
				if (i % 2)
				{
					_(this).css(r1);
				}
				else
				{
					_(this).css(r2);
				}
				if (rl)
				{
					var s = this.style.cssText;
					var c = this.className;
					this.onmouseover = function()
					{
						_(this).css(rl);
					}
					this.onmouseout = function()
					{
						this.style.cssText = s;
						this.className = c;
					}
				}
			});
		}
	};
	
	/* Класс псевдоселектора  */
	var Select = {
		options: null,
		selected: null,
		fieldsName: null,
		init: function(o)
		{
			if (o)
			{
				this.options = o.options;
				this.selected = o.selected;
				this.fieldsName = o.fieldsName;
			}
		},
		initOptions: function()
		{
			if ($(Select.options))
			{
				_(Select.options, 'input').each(function()
				{
					var c = this;
					c.checked = false;
					_(Select.selected, 'input').each(function()
					{
						if (c.value == this.value)
						{
							c.checked = true;
						}
					});
					c.onclick = function()
					{
						if (c.checked)
						{
							Select.add(c.name, c.value);
						}
						else
						{
							Select.remove(c.value);
						}
					};
				});
			}
		},
		add: function(t, v)
		{
			var l = document.createElement('li');
			$(Select.selected).appendChild(l);
			
			var i = document.createElement('input');
			i.type = 'hidden';
			i.name = this.fieldsName;
			i.value = v;
			l.appendChild(i);
			
			var s = document.createElement('span');
			s.innerHTML = t + '&nbsp;&middot;&nbsp;';
			l.appendChild(s);
			
			var a = document.createElement('a');
			a.href = 'javascript:;';
			a.innerHTML = 'Удалить';
			a.selector = this;
			l.appendChild(a);
			a.onclick = function()
			{
				$(Select.selected).removeChild(this.parentNode);
				Select.initOptions();
			}
		},
		remove: function(i)
		{
			_(Select.selected, 'input').each(function()
			{
				if (this.value == i)
				{
					$(Select.selected).removeChild(this.parentNode);
				}
			});
		}
	};
	
	/* Иницыализация */
	_(window).event('load', function()
	{
		Box.init();
		Ajax.init();
	});
