	/**
	 * Сокращение document.getElementById()
	 */
	function gE(el)
	{ return document.getElementById(el); }
	
	/**
	 * Сокращение document.getElementsByName()
	 */
	function gN(el)
	{ return document.getElementsByName(el); }
	
	/**
	 * Проверка правельности написания mail-адресса
	 */
	function IsEmail(str)
	{
		var re_1 = /^([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4}))$/i;
		return (Trim(str).length && Trim(str).match(re_1))?true:false;
	}

	/**
	 * Проверка что переданная переменная явл integer-переменной
	 */
	function IsInt(v)
	{ return parseInt(v).toString()===v.toString(); }
	
	/**
	 * Перевод в integer
	 */
	function ToInt(v)
	{ return (v*1); }
	
	/**
	 * Добавить функцию к функции onLoad для body
	 */
	function AddLoadEvent(func)
	{
		var oldonload = window.onload;
		if (typeof window.onload != 'function')
			window.onload = func;
		else
		{
			window.onload = function()
			{
				oldonload();
				func();
			}
		}
	}
	
	/**
	 * AJAX-ом обращается к _url и результат работы скрипта вставляет в oInsertTo при помощи innerHTML
	 */
	function InnerToFromAjax(_url, oInsertTo)
	{
		var oAjax;

		if (window.XMLHttpRequest)
		{
			oAjax = new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			try 
			{
				oAjax = new ActiveXObject('Msxml2.XMLHTTP');
			} catch (e){}
			try 
			{
				oAjax = new ActiveXObject('Microsoft.XMLHTTP');
			} catch (e){}
		}

		if (oAjax)
		{
			oAjax.onreadystatechange = function()
			{
				if (oAjax.readyState == 4 && oAjax.status == 200) 
				{
					var sContent = oAjax.responseText;
					oInsertTo.innerHTML = sContent;
				}
			};
			oAjax.open("POST", _url, true);
			oAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			oAjax.send('is_ajax=1');
		}
		else
		{
			alert("AJAX not init!");
		}
	}
	
	/**
	 * AJAX-ом обращается к _url и результат работы скрипта показывает как alert-сообщение
	 */
	function AlertFromAjax(_url)
	{
		var oAjax;

		if (window.XMLHttpRequest)
		{
			oAjax = new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			try 
			{
				oAjax = new ActiveXObject('Msxml2.XMLHTTP');
			} catch (e){}
			try 
			{
				oAjax = new ActiveXObject('Microsoft.XMLHTTP');
			} catch (e){}
		}

		if (oAjax)
		{
			oAjax.onreadystatechange = function()
			{
				if (oAjax.readyState == 4 && oAjax.status == 200) 
				{
					alert( oAjax.responseText );
				}
			};
			oAjax.open("POST", _url, true);
			oAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			oAjax.send('is_ajax=1');
		}
		else
		{
			alert("AJAX not init!");
		}
	}
	
	/**
	 * AJAX-ом обращается к _url и результат работы скрипта вставляет в oInsertTo при помощи value
	 */
	function SetValueFromAjax(_url, obj)
	{
		var oAjax;

		if (window.XMLHttpRequest)
		{
			oAjax = new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			try 
			{
				oAjax = new ActiveXObject('Msxml2.XMLHTTP');
			} catch (e){}
			try 
			{
				oAjax = new ActiveXObject('Microsoft.XMLHTTP');
			} catch (e){}
		}

		if (oAjax)
		{
			oAjax.onreadystatechange = function()
			{
				if (oAjax.readyState == 4 && oAjax.status == 200) 
				{
					obj.value 		= oAjax.responseText;
				}
			};
			oAjax.open("POST", _url, true);
			oAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			oAjax.send('is_ajax=1');
		}
		else
		{
			alert("AJAX not init!");
		}
	}
	
	/**
	 * Получает список элементов по их классу
	 */
	function GetElementsByClass(searchClass, node, tag)
	{
		var classElements = new Array();
		if ( node == null )
		{
			node = document;
		}
		
		if ( tag == null )
		{
			tag = '*';
		}
		
		var els = node.getElementsByTagName(tag);
		var elsLen = els.length;
		var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
		for (i = 0, j = 0; i < elsLen; i++) 
		{
			if ( pattern.test(els[i].className) ) 
			{
				classElements[j] = els[i];
				j++;
			}
		}
		
		return classElements;
	}
	
	/**
	 * Возвращает длинну строки
	 */
	function StrLen(string) 
	{
		var str = string+'';
		var i = 0, chr = '', lgth = 0;
	 
		var getWholeChar = function (str, i) 
		{
			var code = str.charCodeAt(i);
			var next = '', prev = '';
			if (0xD800 <= code && code <= 0xDBFF) 
			{
				if (str.length <= (i+1))  
				{
					throw 'High surrogate without following low surrogate';
				}
				next = str.charCodeAt(i+1);
				if (0xDC00 > next || next > 0xDFFF) 
				{
					throw 'High surrogate without following low surrogate';
				}
				return str[i]+str[i+1];
			}
			else if (0xDC00 <= code && code <= 0xDFFF) {
				if (i === 0) 
				{
					throw 'Low surrogate without preceding high surrogate';
				}
				prev = str.charCodeAt(i-1);
				if (0xD800 > prev || prev > 0xDBFF) 
				{
					throw 'Low surrogate without preceding high surrogate';
				}
				return false;
			}
			return str[i];
		};
	 
		for (i=0, lgth=0; i < str.length; i++) 
		{
			if ((chr = getWholeChar(str, i)) === false) 
			{
				continue;
			}
			lgth++;
		}
		return lgth;
	}
	
	/**
	 * define константы (как в php)
	 */
	define = 
	(
		function()
		{
			function toString(name, value)
			{
				return  "const " + name + "=" + (/^(null|true|false|(\+|\-)?\d+(\.\d+)?)$/.test(value = String(value)) ? value : '"' + replace(value) + '"')
			};
			
			var define, replace;
			try
			{
				eval("const e=1");
				replace = function(value)
				{
					var replace = {"\x08":"b","\x0A":"\\n","\x0B":"v","\x0C":"f","\x0D":"\\r",'"':'"',"\\":"\\"};
					return  value.replace(/\x08|[\x0A-\x0D]|"|\\/g, function(value){return  "\\"+replace[value]})
				};
				
				define = function(name, value)
				{
					var script = document.createElement("script");
					script.type = "text/javascript";
					script.appendChild(document.createTextNode(toString(name, value)));
					document.documentElement.appendChild(script);
					document.documentElement.removeChild(script);
				}
			}
			catch(e)
			{
				replace = function(value)
				{
					var replace = {"\x0A":"\\n", "\x0D":"\\r"};
					return  value.replace(/"/g, '""').replace(/\n|\r/g, function(value){return replace[value]})
				};
				
				define = this.execScript ?	function(name, value){execScript(toString(name, value), "VBScript");} :	function(name, value){eval(toString(name, value).substring(6));}
			};
			return  define;
		}
	)();
	
	/**
	 * Проверка была ли контанта define (как php)
	 */
	function defined(constantName )  
	{
		return (typeof window[constantName] !== 'undefined');
	}
	
	/**
	 * Аналог функции file() в php
	 */
	function File(url) 
	{
		var req = null;
		try 
		{
			req = new ActiveXObject("Msxml2.XMLHTTP"); 
		}
		catch(e) 
		{
			try 
			{
				req = new ActiveXObject("Microsoft.XMLHTTP"); 
			}
			catch(e) 
			{
				try { req = new XMLHttpRequest(); } catch(e) {}
			}
		}
		if (req == null)
			throw new Error('XMLHttpRequest not supported');
	 
		req.open("GET", url, false);
		req.send(null);
	 
		return req.responseText.split('\n');
	}
	
	/**
	 * Аналог функции file_get_contents() в php
	 */
	function FileGetContents(url)
	{
		var req = null;
		try 
		{
			req = new ActiveXObject("Msxml2.XMLHTTP"); 
		}
		catch (e)
		{
			try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
				try { req = new XMLHttpRequest(); } catch(e) {}
			}
		}
		if (req == null) throw new Error('XMLHttpRequest not supported');
	 
		req.open("GET", url, false);
		req.send(null);
	 
		return req.responseText;
	}
	
	function FileGetContentsPOSTPars(url, pars)
	{
		var req = null;
		try 
		{
			req = new ActiveXObject("Msxml2.XMLHTTP"); 
		}
		catch (e)
		{
			try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
				try { req = new XMLHttpRequest(); } catch(e) {}
			}
		}
		if (req == null) throw new Error('XMLHttpRequest not supported');
	 
		req.open("POST", url, false);
		req.send('is_ajax=1');
	 
		return req.responseText;
	}
	
	/**
	 * Возвращает позицию по X элемента относительно окна
	 */
	function GetX(el)
	{
		var left = 0;
		do
		{
			left += el.offsetLeft || 0;																	
			el 	 =  el.offsetParent;
		} while (el);
		return left+(window.ie6||window.ie7?1:0);
	}
	
	/**
	 * Возвращает позицию по Y элемента относительно окна
	 */
	function GetY(el)
	{
		var top = 0;
		do
		{
			top += el.offsetTop || 0;
			el 	=  el.offsetParent;
		} while (el);
		return top+(window.ie6||window.ie7?1:0);
	}