var core_inits = [];

function extend(Child, Parent) {
    var F = function() { }
    F.prototype = Parent.prototype;
    Child.prototype = new F();
    Child.prototype.constructor = Child;
    Child.superclass = Parent.prototype ;   
}
function Redirect(url)
{
	this.document.location.replace(url);
}
function isNumber(x) {
						return (typeof x == "number" || x instanceof Number) && isFinite(x);
					}
function cClass(elm,cls)
{
	if (elm) {
		if (elm.className!=cls) elm.className = cls;
	}
}
function init_params(obj,params)
{
	for (var i in params)
	{
		child[i] = params[i];
	}
}
function make_extend(child,parent)
{
	for(var i in parent)
	{
		child[i] = parent[i];
	}
	return parent;
}
function include(scripturl)
{
	var s  = Core.New('SCRIPT');
		s.language 	= 'javascript';
		s.src		= scripturl;
	Core.B().appendChild(s);
}
function initHTML(c)
{
	c.initHTML_();
}
function CoreObject()
{
	this.worldCont = null;
	var ua=navigator.userAgent.toLowerCase();
	this.isOpera=ua.indexOf("opera")>-1;
	this.isSafari=(/webkit|khtml/).test(ua);
	this.isSafari3=this.isSafari&&ua.indexOf("webkit/5")!=-1;
	this.isIE=!this.isOpera&&ua.indexOf("msie")>-1;
	this.isIE5=!this.isOpera&&ua.indexOf("msie 5")>-1;
	this.isIE6=!this.isOpera&&ua.indexOf("msie 6")>-1;
	this.isIE7=!this.isOpera&&ua.indexOf("msie 7")>-1;
	this.isIE8=!this.isOpera&&ua.indexOf("msie 8")>-1;
	this.isGecko=!this.isSafari&&ua.indexOf("gecko")>-1;
	this.isGecko3=!this.isSafari&&ua.indexOf("rv:1.9")>-1;
	this.isWindows=(ua.indexOf("windows")!=-1||ua.indexOf("win32")!=-1);
	this.isMac=(ua.indexOf("macintosh")!=-1||ua.indexOf("mac os x")!=-1);
	this.isChrome = (ua.indexOf('chrome')!=-1);
	this.isAir=(ua.indexOf("adobeair")!=-1);
	this.isLinux=(ua.indexOf("linux")!=-1);
	this.isSecure=window.location.href.toLowerCase().indexOf("https")===0;
	this.isMSIE = this.isIE;
	this.xmlhttps = new Array();
	this.toolTipObject = null;
	this.toolTipTarget = null;
	this.xmlhttps = new Array();
	this.isRun = true;
	this.Refreshers = new Array();
	this.zIndexMax = 1000001;
	this.cashImages = new Array();
	this.ObjectsStore = new Array();
	this.DebugWin = null;
	this.DebugMsg = true;
	this.uid_counter = 0;
	this.isInit = false;
	
	try {
		this.window = window.self;
		this.document = this.window.document;
	} catch (e) {}
	this.onImageLoadCB = [];
	this.resizeCB = [];
	
	this.Factories = [];
	this.Factory = function (name,cfnc)
	{
		this.Factories[name] = cfnc;
	}
	this.onImageLoad = function ( cb ) {
		_$.onImageLoadCB.push ( cb );
	}
	this.onResize = function ( cb ) {
		_$.resizeCB.push ( cb );
	}
	this.onResizeCall = function (e)
	{
		if (_$.resizeCB.length>0)
		{
			for(var i=0;i<_$.resizeCB.length;i++)
			{
				_$.resizeCB[i]();
			}
			for(var i=0;i<_$.resizeCB.length;i++)
			{
				_$.resizeCB[i]();
			}
		}
	}
	this.window.onResize = function (e) {
		_$.onResizeCall(e);
	}
	this.winLastW = 0;
	this.winLastH = 0;
	this.winRB = null;
	this.onResizeDo = 0;
	this.onResizeCatch = function ()
	{
		var _nw = (_$.isChrome) ? _$.$('xbody').w() : _$.winRB.X();
		var _nh = (_$.isChrome) ? _$.$('xbody').h() : _$.winRB.Y();
		if ((_$.winLastW!=_nw) || (_$.winLastH!=_nh))
		{
			_$.winLastW = _nw;
			_$.winLastH = _nh;
			if (_$.onResizeDo ) _$.delT( _$.onResizeDo );
			_$.onResizeDo = _$.setT( _$.onResizeCall , 100);
		}
		_$.setT( _$.onResizeCatch, 100 );
	}
	this.onResizeInit = function () {
		_$.winRB = _$.New('DIV', {
			s_position: 'absolute',
			s_left: '99%',
			s_top: '99%',
			s_width: '1px',
			s_height: '1px'
		} );
		_$.$('xbody').a(_$.winRB);
		_$.winRB.toTop();
		_$.onResizeCatch();
		_$.setT(_$.onResizeCall,500);
		_$.onImageLoadResize();
	}
	this.onImageLoadResize = function ()
	{
		var img = document.getElementsByTagName ('IMG');
		var c = 0;
		while (img[c]) {
			if (!img[c].complete) {
				_$.setT( _$.onImageLoadResize, 100 );
				return false;
			}
			c++;
		}
		_$.onResizeCall();
		if (_$.onImageLoadCB.length>0)
		{
			_$.FEach(_$.onImageLoadCB, function (fnc) { fnc(); } );
		}
	}
	this.POSTRec = function(url,post)
	{
		var form = _$.New('FORM', {
				action : url,
				method : 'post' } );
		this.FEach(post, function (elm) {
			form.a(_$.New('INPUT', {
				type : 'text',
				name : elm[0],
				value : elm[1] } )
				);
		} );
		this.$('xbody').a(form);
		form.submit();
		return true;
	}
	this.setRng = function(r) 
	{
		var s;
		if (!_$.isIE) {
			s = _$.getSelection();

			if (s) {
				s.removeAllRanges();
				s.addRange(r);
			}
		} else {
			try {
				r.select();
			} catch (ex) {}
		}
	}
	this.prew = function(n)
	{
		var p = n.parentNode;
		if (p.childNodes && (p.childNodes.length>1))
		{
			for(var i=0;i<p.childNodes.length-1;i++)
			{
				if ((i==0) && (p.childNodes.item(i)==n)) return false;
				if (p.childNodes.item(i+1)==n) return p.childNodes.item(i);
			}
		}
		return false;
	}
	this.next = function(n)
	{
		var p = n.parentNode;
		if (!p) return false;
		if (p.childNodes)
		{
			for(var i=0;i<p.childNodes.length;i++)
			{
				if ((i==0) && (p.childNodes.item(i)==n)) {
					return (p.childNodes.length>1) ? p.childNodes.item(i+1) : false;
				}
				if ((i>0) && (p.childNodes.item(i-1)==n)) return p.childNodes.item(i);
			}
		}
		return false;
	}
	this.setSelection = function(n)
	{
		var r;
		
		if (_$.isIE) {
			try {
				var b = window.document.body;
				r = b.createTextRange();
				if (n) {
					r.moveToElementText(n);
				} else {
					r.collapse();
				}
				r.select();
			} catch (ex) {}
		} else {
			c=true;
			if (c) {
				if (n)
				{
					var fn = _this.prew(n);
					var ln = _this.next(n);
					r = window.document.createRange();
					if ((fn) && (ln) && (ln.nodeValue)) 
					{
						r.setStart(fn, 0);
						r.setEnd(ln, ln.nodeValue.length);
					} else
						r.selectNode(n);
				} else r = window.document.createRange();
			}
			_$.setRng(r);
		}
	}
	this.getRng = function()
	{
		var s = _$.getSelection(), r;
		try {
			if (s) {
				r = s.rangeCount > 0 ? s.getRangeAt(0) : (s.createRange ? s.createRange() : window.document.createRange());
			}
		} catch (ex) {}

		if (!r)
			r = _$.isIE ? window.document.body.createTextRange() : window.document.createRange();
		return r;
	}
	
	this.getSelection = function ()
	{
		if (_$.isIE)
		{
			return window.document.selection;
		} else {
			return window.getSelection();
		}
	}
	
	this.setI = function(func,time)
	{
		return window.setInterval(func,time);
	}
	this.setT = function(func,time)
	{
		return window.setTimeout(func,time);
	}
	this.delI = function(id)
	{
		return window.self.clearInterval(id);
	}
	this.delT = function(id)
	{
		return window.self.clearInterval(id);
	}
	this.SetDebug = function(dwin)
	{
		this.DebugWin = dwin;
	}
	this.DebugOn = function ()
	{
		this.DegugWin = window.open('../core/debuger.php');
	}
	this.DebugDump = function(obj)
	{
		var msg = '';
		for(var i in obj)
		{
			msg = msg + "<BR>" + i + ":" + obj[i];
		}
		Core.DebugAdd(msg);
	}
	this.DebugAdd = function(msg)
	{
		if (Core.DebugWin)
		{
			try {
				Core.DebugWin.AddMsg(msg);
			} catch (e) {}
		}
	}
	this.CI_onLoad = function(elm , func) {
		var cOnLoadCI = 0;
		if (this.OS_Get('CI_LoadCI')) cOnLoadCI = this.OS_Get('CI_LoadCI');
		cOnLoadCI++;
		this.OS_Add('CI_LoadCI_E'+cOnLoadCI,elm);
		this.OS_Add('CI_LoadCI_C'+cOnLoadCI,func)
		this.OS_Add('CI_LoadCI_F'+cOnLoadCI, function (cit) {
			if (_$.OS_Get('CI_LoadCI_E'+cit).complete) {
				window.clearInterval(_$.OS_Get('CI_LoadCI_I'+cit));
				_$.OS_Get('CI_LoadCI_C'+cit)(_$.OS_Get('CI_LoadCI_E'+cit));
				_$.OS_Del('CI_LoadCI_I'+cit);
				_$.OS_Del('CI_LoadCI_F'+cit);
				_$.OS_Del('CI_LoadCI_E'+cit);
			}
		} );
		this.OS_Add('CI_LoadCI_I'+cOnLoadCI, window.setInterval("_$.OS_Get('CI_LoadCI_F"+ cOnLoadCI + "')(" + cOnLoadCI + ");",100));		
		this.OS_Add('CI_LoadCI',cOnLoadCI);
	}
	this.CI_LoadCount = function()
	{
		var i;
		var ii=0;
		var tc=0;
		for (i in this.cashImages)
		{
			if (this.cashImages[i])
			{
				tc++;
				if (this.cashImages[i].complete)
				{
					ii++;
				} else {
					if (_$.$('img_debug'))
					{
						_$.$('img_debug').a(_$.New('DIV', { innerHTML : _$.cashImages[i].src } ) );
					}
				}
			}
		}
		var rv = tc-ii;
		if (rv==1) rv=0;
		return rv;
	}
	this.CI_Get =  function(id)
	{
		if (this.cashImages[id]) return this.cashImages[id];
	}
	this.CI_Add = function(imgname,id)
	{
		if (!this.cashImages[id])
		{
			var ni = new Image();
			ni.src = imgname;
			this.cashImages[id] = ni;
		}
	}
	this.OS_Add = function(sid,obj)
	{
		this.ObjectsStore[sid] = obj;
		return obj;
	}
	this.OS_Del = function(sid)
	{
		this.ObjectsStore[sid] = null;
	}
	this.OS_Chk = function(sid)
	{
		if (this.ObjectsStore[sid]) return true;
		return false;
	}
	this.OS_New = function(id,createfunc)
	{
		if (this.ObjectsStore) if (this.ObjectsStore[id]) return this.ObjectsStore[id];
		if (this.ObjectsStore)
		{
			this.ObjectsStore[id] = createfunc();
			return this.ObjectsStore[id];
		}
		return null;
	}
	this.OS_Or = function(id,olternate)
	{
		if (this.ObjectsStore) {
			if (this.ObjectsStore[id]) return this.ObjectsStore[id];
			this.ObjectsStore[id] = olternate;
			return this.ObjectsStore[id];
		}
		return null;
	}
	this.OS_Get = function(id)
	{
		if (this.ObjectsStore) if (this.ObjectsStore[id]!=undefined) return this.ObjectsStore[id];
		return null;
	}
	this.R = function(obj,cb)
	{
		this.Refreshers.push( new Array(obj,cb));
	}
	this.R_ = function(obj,cb)
	{
		var tr = new Array();
		for(var i in this.Refreshers)
			if ((this.Refreshers[i][0]!=obj) && (this.Refreshers[i][1]!=cb))
				tr.push(this.Refreshers[i]);
		this.Refreshers = tr;
	}
	this.UpdateRefreshers = function()
	{
		for(var i in this.Refreshers) 
		{	
			var cb = this.Refreshers[i][1];
			var ob = this.Refreshers[i][0];
			try {
				cb(ob);
			} catch (e) {}
		}
	}
	this.MaxZOrder = function(cont,cmax)
	{
		this.zIndexMax++;
		return this.zIndexMax;
	}
	this.Text = function(t)
	{
		return this.document.createTextNode(t);
	}
	this.New = function(tag,params)
	{
		var obj = this.MakeFW(document.createElement(tag));
		if (tag=='IFRAME')
		{
			obj.cWindow = function ()
			{
				return this.contentWindow;
			}
			obj.cDocument = function ()
			{
				if (_$.isGecko)
				{
					return this.contentDocument;
				} else {
					return this.cWindow().document;
				}
			}
		}
		if (params)
		{
			for (var i in params.events)
			{
				obj.e(i,params.events[i]);
			}
			for (var i in params)
			{
				if (i=='css')
				{
					_$.uid_counter++;
					var css_name = "fxLib_css_"+MSTicker.ticks()+'_'+_$.uid_counter;
					var css = "."+css_name+" {";
						css = css + params[i] + " }";
					if (!_$.isIE) {
						_$.WriteCSS(css);
					} else {
						var csss = params[i].split(";");
						_$.FEach(csss, function (prm) {
							var prp = prm.split(":");
							try {
								obj.style[Effects.ccs2js(prp[0])] = prp[1];
							} catch (e) {}
						} );
					}
					obj.className = css_name;
				} else {
					if (i.substr(0,4)=='css_')
					{
						try {
							if (!obj.css_styles) obj.css_styles = new Array();
							var i2 = i.substr(4);
							obj.css_styles[i2] = params[i];
						} catch (e) {}
					}
					if (i.substr(0,2)=='s_') 
					{
						try {
							var i2 = i.substr(2);
							i2 = Effects.ccs2js(i2);
							obj.style[i2] = params[i];
						} catch (e) {}
					} else  {
						if (tag=='IMG' && i=='src')
						{
							var src = new String(params[i]);
							if (src.substr(params[i].length-3,3)=='png')
							{
								if (_$.isIE) {
									obj[i] = '<!BASEURL!>/js/blank.gif';
									obj.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + params[i] + "', sizingMethod=scale)";
									obj.pngImage = true;
								} else {
									obj[i] = params[i];
									obj.setAttribute(i,params[i]);
								}
							} else {
								obj[i] = params[i];
								obj.setAttribute(i,params[i]);
							}
						} else {
							obj[i] = params[i];
							obj.setAttribute(i,params[i]);
						}
					}
				}
			}
		}
		return obj;
	}
	this.XBODY = function () { return this.MakeFW(this.worldCont); }
	
	this.B = function()
	{
		if (document.documentElement)
			return this.MakeFW(document.documentElement); else
			return this.MakeFW(document.body);
	},
	this.V = function(val)
	{
		return val;
	},
	this.FindF = function(parent,tag)
	{
		if (typeof(parent) == 'string') parent=this.$(parent);
		for(var i=0;i<parent.childNodes.length;i++)
		{
			if (parent.childNodes[i].nodeName==tag) return parent.childNodes[i];
		}
		return null;
	},
	this.FindN = function(parent,first,tag)
	{
		if (typeof(parent) == 'string') parent=this.$(parent);
		var b=false;
		for(var i=0;i<parent.childNodes.length;i++)
		{
			if (parent.childNodes[i] == first) b=true;
			if ((parent.childNodes[i].nodeName==tag) && b) return parent.childNodes[i];
		}
		return null;
	}
	this.ChildOf = function(elm_in,parent)
	{
		elm_in = _$.MakeFW(elm_in);
		parent = _$.MakeFW(parent);
		
		var a = [];
		var eq = false;
		_$.DOM_4All(a,parent,function(elm) { return _$.MakeFW(elm); } );
		_$.FEach(a,function(elm) {
			if (elm_in.uid==elm.uid) eq = true;
		} );
		return eq;
		if (elm.uid==parent.uid) return true;
		var p = parent;
		var e = elm;
		do {
			if (e.parentNode) 
			{
				if (_$.MakeFW(e.parentNode).uid == p.uid) return true;
			}
		} while (e = _$.MakeFW(e.parentNode));
		return false;
	}
	this.ChildOfClass = function(elm,className)
	{
		if (elm.className==className) return true;
		var p = className;
		var e = elm;
		do {
			if (e.parentNode) 
			{
				if (e.parentNode.className == p) return true;
			}
		} while (e = e.parentNode);
		return false;
	}
	this.ChildOfID = function(elm,id)
	{
		if (elm.id==id) return true;
		var p = id;
		var e = elm;
		do {
			if (e.parentNode) 
			{
				if (e.parentNode.id == p) return true;
			}
		} while (e = e.parentNode);
		return false;
	}
	this.FEach = function(arr,func)
	{
		if (arr && arr.length>0) for (var i=0;i<arr.length;i++) { func(arr[i]); }
	}
	this.FEachK = function(arr,func)
	{
		if (arr && arr.length>0) for (var i in arr) { func(i,arr[i]); }
	}
	this.DOM_4All_level = function (arr,p,func,level)
	{
		if (!p) return false;
		if (p.childNodes.length>0)
		{
			for(var i = 0;i<p.childNodes.length;i++)
			{
				if (p.childNodes.item(i))
				{
					if (func(_$.MakeFW(p.childNodes.item(i)))) arr.push(_$.MakeFW(p.childNodes.item(i)));
					if (p.childNodes.item(i))
					{
						if (p.childNodes.item(i).childNodes) {
							if (level>1) {
								if (p.childNodes.item(i).childNodes.length>0) Core.DOM_4All_level(arr,p.childNodes.item(i),func, (level-1));
							}
						}
					}
				}
			}
		}
	}
	this.DOM_4All = function(arr,p,func)
	{
		if (!p) return false;
		if (p.childNodes.length>0)
		{
			for(var i = 0;i<p.childNodes.length;i++)
			{
				if (p.childNodes.item(i))
				{
					if (func(_$.MakeFW(p.childNodes.item(i)))) arr.push(_$.MakeFW(p.childNodes.item(i)));
					if (p.childNodes.item(i))
					{
						if (p.childNodes.item(i).childNodes) {
							if (p.childNodes.item(i).childNodes.length>0) Core.DOM_4All(arr,p.childNodes.item(i),func);
						}
					}
				}
			}
		}
	}
	this.$if = function(condition,tf,ff)
	{
		if (condition) { alert(1); return tf();}
		alert(2);
		return ff();
	}
	this.$ = function(id)
	{
		if (id instanceof Object) return this.MakeFW(id);
		if (id instanceof Array)
		{
			var rv=new Array();
			for(e in id)
			{
				var o = this.MakeFW(document.getElementById(id[e]));
				rv.push(o);
			}
			return rv;
		} else {
			return this.MakeFW(document.getElementById(id));
		}
	},
	this.AJAX_StatusCheck = function()
	{
		var cl = 0;
		if (Core.xmlhttps)
		{
			if (Core.xmlhttps.length)
			{
				cl = Core.xmlhttps.length;
				if (Core.xmlhttps.length>0)
				{
					for (i=0;i<Core.xmlhttps.length;i++)
					{
						if  ((Core.xmlhttps[i].readyState == 4) || (Core.xmlhttps[i].nostatus)) cl--;
					}
				}
			}
		}
		var ic = Core.CI_LoadCount();
		
		cl=cl+ic;
		
		if (cl==0) { if (Core.$('bgload')) { Core.$("bgload").style.display='none'; } }
		if (ic==0) {
			if (Core.$('imgload')) Core.$('imgload').style.display='none';
		} else {
			if (Core.$('imgload'))
			{
				Core.$('imgload').innerHTML = "Загрузка изображений:"+ ic;
				Core.$('imgload').style.display='block';
			}
		}
	},
	this.BodyHeight = function ()
	{
		return Math.max(document.compatMode != 'CSS1Compat' ? document.body.scrollHeight : document.documentElement.scrollHeight, this.getViewportHeight());
	}
	this.getViewportHeight = function() {
		return ((document.compatMode || this.isIE) && !this.isOpera) ? (document.compatMode == 'CSS1Compat') ? document.documentElement.clientHeight : document.body.clientHeight : (document.parentWindow || document.defaultView).innerHeight;
	}
	this.Get_Free_xmlhttp = function()
	{
		var i=0;
		var n_xmlhttp;
		
		for (i=0;i<this.xmlhttps.length;i++)
		{
			if (this.xmlhttps[i])
			{
				if (this.xmlhttps[i].readyState==4) {
				}
			}
		}
		if(window.XMLHttpRequest){
			n_xmlhttp=new XMLHttpRequest();
		} else if(window.ActiveXObject){
			try{
				n_xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				try{
					n_xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e){ }
			}
		}
		
		this.xmlhttps.push(n_xmlhttp);
		return n_xmlhttp;
	},
	
	this.Ajax_POST_RequestCB = function(url,postvars,callback,status)
	{
		if (this.$('bgload') && (!status)) this.$('bgload').style.display='block';
		var xmlhttp;
		xmlhttp = this.Get_Free_xmlhttp();
		if (!xmlhttp) {
			return false;
		}
		var post = "";
		var ii = 1;
		for(v in postvars) {
			post += encodeURIComponent(v) + "=" + encodeURIComponent(postvars[v]);
			if (ii!=(postvars.length-1)) post = post+ "&";
			ii++;
		}
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState==4) {
				Core.AJAX_StatusCheck();
				
				if(Core.isRun) if (callback) callback(xmlhttp.responseText);
			}
		}
		xmlhttp.open('POST',url,true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-Length", post.length);
		xmlhttp.send(post);
		return true;
	},
	this.GetPage = function(url)
	{
		_$.$('bgload')._show();
		this.GET(url,this.GetPageCallBack);
	}
	this.GetPageCallBack = function(rv)
	{
		var a = [];
		_$.DOM_4All(a,_$.$('xbody'), function (elm) { return true; } );
		_$.FEach(a, function (elm) {
			try {
				if (elm.gA('id')!='bgload') {
					_$.$('xbody').d(elm);
				}
			} catch (e) {}
		} );
		try {
			eval(rv);
			_$.$('bgload')._hide();
		} catch (e) { alert(e.message); }
	}
	this.POST = function(url,postvars,callback,status) { _$.Ajax_POST_RequestCB(url,postvars,callback,status); }
	this.Ajax_POST_Request = function(url,postvars,status)
	{
		return this.Ajax_POST_RequestCB(url,postvars,null,status);
	}
	this.AjaxCB = function(r) {
		if (r) {
			try {
				eval(r);
			} catch (e) { 
				alert(e.message);
			}
		}
	}
	this.GET = function(url,callback,status) { _$.Ajax_GET_RequestCB(url,callback,status); }
	this.Ajax_GET_RequestCB = function(url,callback,status)
	{
		if (this.$('bgload') && (!status)) this.$('bgload').style.display='block';
		var xmlhttp;
		xmlhttp = this.Get_Free_xmlhttp();
		if(!xmlhttp) {
			return false;
		}
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState==4) {
				Core.AJAX_StatusCheck();
				if (Core.isRun) if (callback) callback(xmlhttp.responseText);
			}
		}
		xmlhttp.open('GET',url,true);
		xmlhttp.send(null);
		return true;
	},
	this.Ajax_GET_Request = function(url,status)
	{
		return this.Ajax_GET_RequestCB(url,null,status);
	},
	this.HideTooltip = function()
	{
		if (Core.$('OC_TOOLTIP')) Core.$('OC_TOOLTIP').style.display='none';
	}
	this.PopupTooltip2 = function (targetobj,tt_obj,tt_cont,x_o,y_o,msg)
	{
		this.toolTipTarget = targetobj;
		if (tt_obj && tt_cont)
		{
			tt_cont.innerHTML =msg;
			tt_obj.style.left = this.getLeftPos(targetobj) + x_o +'px';
			tt_obj.style.top =  this.getTopPos(targetobj) + y_o + 'px';
			tt_obj.style.display = 'block';
		
			_$.OS_Add('TOOLTIP2_OBJECT',tt_obj);
			function HideTooltip()
			{
				_$.OS_Get('TOOLTIP2_OBJECT').style.display='none';
				if (Core.toolTipTarget)
				{
					Core.removeHandler(Core.toolTipTarget,"mouseout",HideTooltip);
				}
			}
			this.addHandler(targetobj,"mouseout",HideTooltip);
		}
	},
	this.PopupTooltip = function (targetobj,xoffset,yoffset,msg)
	{
		this.toolTipTarget = targetobj;
		if (this.toolTipObject == null)
		{
			this.toolTipObject = _$.New("DIV");
			this.toolTipObject.id='OC_TOOLTIP';
			with (this.toolTipObject)
			{
				className = 'tooltip';
				this.worldCont.appendChild(this.toolTipObject);
				style.position = 'absolute';
				style.zIndex = 9000000;
				style.left = this.getLeftPos(targetobj) + xoffset + 'px';
				style.top =  this.getTopPos(targetobj) + yoffset + 'px';
				appendChild(document.createTextNode(msg));
				//innerHTML = msg;
				style.display = 'block';
				style.visibility = 'visible';
			}
			
		} else {
			this.toolTipObject.innerHTML =msg;
			this.toolTipObject.style.left = this.getLeftPos(targetobj) + xoffset + 'px';
			this.toolTipObject.style.top =  this.getTopPos(targetobj) + yoffset + 'px';
			this.toolTipObject.style.display = 'block';
		}
		if ((this.toolTipObject.X()+this.toolTipObject.w()) > _$.$('xbody').w())
		{
			this.toolTipObject.style.left = _$.$('xbody').w() - this.toolTipObject.w() - 10;
		}
		if ((this.toolTipObject.Y()+this.toolTipObject.h()) > _$.$('xbody').h())
		{
			this.toolTipObject.style.top = this.getTopPos(targetobj) - this.toolTipObject.h();
		}
		function HideTooltip()
		{
			Core.$('OC_TOOLTIP').style.display='none';
			if (Core.toolTipTarget)
			{
				Core.removeHandler(Core.toolTipTarget,"mouseout",HideTooltip);
			}
		}
		this.addHandler(targetobj,"mouseout",HideTooltip);
	}
	this.SetScrollY = function(nWal)
	{
		try {
			if (this.isIE)
			{
				window.document.body.scrollTop = nWal;
			} else {
				window.scrollY = nWal;
			}
		} catch (e) {
			alert('SetScrollY - ' + e.message);
		}
		return true;
	}
	this.WindowSY = function()
	{
		var rv = "";
		if (this.isIE)
		{
			rv = window.document.body.scrollTop;
		} else {
			rv = window.scrollY;
		}
		return rv;
	}
	this.WindowHeight = function()
	{
		var hh=0;
		if (window.innerHeight) {
			hh = window.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			hh = document.documentElement.clientHeight;
		} else if (document.body) {
			hh = document.body.clientHeight;
		} 
		return hh;
	}
	this.WindowWidth = function()
	{
		var ww=0;
		if (window.innerWidth) {
			ww = window.innerWidth;
		} else if (document.documentElement && document.documentElement.clientWidth) {
			ww = document.documentElement.clientWidth;
		} else if (document.body) {
			ww = document.body.clientWidth;
		} 
		return ww;
	}
	this.getTopPos = function(inputObj)
	{		
		if (typeof(inputObj) == 'string') inputObj = this.$(inputObj);
		if (inputObj)
		{
			var offsetTop = 0;
		    do {
				if (inputObj.offsetTop) 
					offsetTop  += inputObj.offsetTop;
		    } while (inputObj = inputObj.offsetParent);
		    return offsetTop;
		}
	}
	this.getLeftPos = function(inputObj)
	{
		if (typeof(inputObj) == 'string') inputObj = this.$(inputObj);
		if (inputObj)
		{
			var offsetLeft = 0;
		    do {
				if (inputObj.offsetLeft) 
					offsetLeft  += inputObj.offsetLeft;
		    } while (inputObj = inputObj.offsetParent);
		    return offsetLeft;
		}
	}
	this.addHandler = function(object, event, handler, useCapture) { 
		if (object instanceof Array)
		{
			for(var i in object)
			{
				this.addHandler(object[i],event,handler, useCapture ? useCapture : false);
			}
		} else {
			if (typeof(object) == 'string') object=Core.$(object);
			if (object)
			{
				if (!object.fxLib) object = _$.MakeFW(object);
				if (!object.events[event])
				{
					object.events[event] = new Array();
				}
				object.events[event].push(handler);
				if (object.addEventListener) { 
					object.addEventListener(event, handler, useCapture ? useCapture : false); 
				} else if (object.attachEvent) { 
					object.attachEvent('on' + event, handler); 
				} else alert("Add handler is not supported"); 
			}
		}
	},
	this.removeHandler = function(object, event, handler) { 
		if (object instanceof Array)
		{
			for (var i in object)
			{
				this.removeHandler(object[i],event,handler);
			}
		} else {
			if (typeof(object) == 'string') object=Core.$(object);
			if (object)
			{
				if (object.removeEventListener) { 
					object.removeEventListener(event, handler, false); 
				} else if (object.detachEvent) { 
					object.detachEvent('on' + event, handler); 
				} else alert("Remove handler is not supported"); 
			}
		}
	}
	this.Init = function()
	{
		this.worldCont=this.$('xbody');
		if (Core.isIE) window.document.execCommand("BackgroundImageCache", false, true);
		this.FEach( core_inits, function (fnc) { fnc(); } );
		this.isInit = true;
	}
	this.WriteCSS = function(css)
	{
		try {
			var err = this.cash_css_temp;
		} catch (e) {
			this.cash_css_temp = new Array();
			
		}
		var style = this.New('STYLE', {
							tyle:'text/css'
							});
		style.a(this.document.createTextNode(css));
		this.$('xbody').a(style);
	}
	this.W = function(id)
	{
		var obj = id;
		if (typeof(id) == 'string') obj = this.$(id);
		if (obj)
		{
			if (obj.offsetWidth) return obj.offsetWidth;
			if (obj.style)
			{
				if (obj.style.width) return parseInt(obj.style.width);
			}
		}
	}
	this.H = function(id)
	{
		var obj = id;
		if (typeof(id) == 'string') obj = this.$(id);
		if (obj)
		{
			if (obj.offsetHeight) return obj.offsetHeight;
			if (obj.style)
			{
				if (obj.style.height) return parseInt(obj.style.height);
			}
		}
	}
	this.X = function(id)
	{
		return this.getLeftPos(id);
	}
	this.Y = function(id)
	{
		return this.getTopPos(id);
	}
	this.Rect = function(id)
	{
		if (id instanceof Array)
		{
			var rv = new Array();
			for (var i in id)
			{
				if (typeof(id[i])=='string') id[i] = this.$(id[i]);
				var nr = new Rect(this.X(id[i]),this.Y(id[i]),this.W(id[i]),this.H(id[i]));
				rv.push(nr);
			}
			return rv;
		} else {
			if (typeof(id) == 'string') id = this.$(id);
			var nr = new Rect(this.X(id),this.Y(id),this.W(id),this.H(id));
			return nr;
		}
	}
	this.Event = function(e)
	{
		var r = window.event;
		if (!r) r = e;
		if (r)
		{
			r.kCode = (_$.isIE) ? e.keyCode : e.which;
			if (r.type.match(/DOMMouseScroll|mousewheel/)){
				r.wheel = (r.wheelDelta) ? r.wheelDelta / 120 : -(r.detail || 0) / 3;
			}
			if (r.target == undefined) 
			{
				if (r.srcElement) r.target = r.srcElement;
				if (r.currentTarget) r.target =r.currentTarget;
			} 
			var rr = Core.Rect(r.target);
			this.MakeFW(r.target);
			if (r.pageX == undefined) r.pageX = r.clientX;
			if (r.pageY == undefined) r.pageY = r.clientY;
			r.Stop = function () {
				if (_$.isIE) {
					this.cancelBubble = true;
				} else {
					this.stopPropagation();
				}
			}
			r.NewTarget = (_$.isIE) ? r.toElement : r.relatedTarget;
			r.OX = r.pageX - rr.x;
			r.OY = r.pageY - rr.y;
		
			return r;
		}
	}
	this.elmFromPoint = function(x,y)
	{
		var elms = [];
		if (this.isIE)
		{
			var inputObj = document.elementFromPoint(x,y);
			if (inputObj)
			{
				do {
					elms.push(_$.MakeFW(inputObj));
				} while (inputObj = inputObj.offsetParent);
			}
		} else {
			_$.DOM_4All(elms,_$.B(),function (e) {
				e = _$.MakeFW(e);
				if (e.fxLib != undefined)
				{
					if ((e.X()<x) && (e.Y()<y) && ((e.X()+e.w())>x) && ((e.Y()+e.h())>y)) return true;
				}
			} );
		}
		return elms;
	}
	this.MakeFW = function(obj)
	{
		var _core = this;
		
		if (obj)
			{
			if (obj.fxLib == undefined)
			{
				try {
					obj.fxLib = '1.2.2';
				} catch (e) { return obj; }
				var n_uid='fxLib_'+MSTicker.ticks() + '_' + _core.uid_counter;
				try {
					var b_isWinDoc = false;
					if (_$.isIE || _$.isOpera || _$.isChrome || _$.isSafari)
					{
						if (_$.isChrome)
						{
							try {
								if (obj.document) b_isWinDoc = true;
							} catch (e) {}
							try {
								if (obj.location) b_isWinDoc = true;
							} catch (e) {}
						} else {
							if ((obj==_$.window) || (obj==_$.document)) b_isWinDoc = true;
						}
					} else {
						if ((obj instanceof Document) || (obj instanceof Window)) b_isWinDoc = true; 
					}
				} catch (e) { alert( e.message); }
				
				obj.uid = n_uid;
				
				_core.uid_counter++;
				obj.events = new Array();
				obj.attr = [];
				obj.e_rall = function(etype)
				{
					if (this.events)
					{
						if (this.events[etype])
						{
							if (this.events[etype].length>0)
							{
								var i=0;
								for (i=0;i<this.events[etype].length;i++)
								{
									this.r(etype,this.events[etype][i]);
								}
							}
							this.events[etype] = new Array();
						}
					}
					return this;
				}
				obj.Float = function(val)
				{
					if (_$.isIE)
					{
						if (val)
						{
							this.style.styleFloat = val;
							return this;
						} else {
							return this.style.styleFloat;
						}
					} else {
						if (val)
						{
							this.style.cssFloat = val;
							return this;
						} else {
							return this.style.cssFloat;
						}
					}
				}
				obj.pngFix = function ()
				{
					if (this.nodeName=='IMG')
					{
						var src = new String(this.src);
						if (src.substr(src.length-3,3)=='png')
						{
							if (_$.isIE) {
								var _w = this.w();
								var _h = this.h();
								
								this.style.width = _w+'px';
								this.style.height = _h+'px';
								this.src = '/js/blank.gif';
								this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod=scale)";
							}
						}
					}
				}
				obj.put = function (id)
				{
					if (_$.$(id))
					{
						_$.$(id).a(this);
					}
					this.fire('fx_put');
					return this;
				}
				obj.aS = function(atr,val)
				{
					this.attr[atr] = val;
					return this;
				}
				obj.aG = function(atr)
				{
					return this.attr[atr];
				}
				obj.sA = function(atr,val)
				{
					obj.setAttribute(atr,val);
					return this;
				}
				obj.gA = function(atr)
				{
					return obj.getAttribute(atr);
				}
				if (!b_isWinDoc)
				{
					obj.$ = function(id)
					{
						var arr = new Array();
						var new_obj = null;
						_$.DOM_4All(arr,this,function(elm) {
							if (elm.id)
							{
								if (elm.id==id && !new_obj) {
									new_obj = _$.MakeFW(elm);
									return true;
								}
							}
						} );
						return new_obj;
					}
				}
				if (!b_isWinDoc)
				{
					obj.parent = null;
					obj.parent = function()
					{
						return _$.MakeFW(this.parentNode);
					}
				}
				obj.classAdd = function (newClass)
				{
					if (obj.className.indexOf(newClass)==-1)
					{
						obj.className = obj.className + ' ' + newClass;
					}
					return this;
				}
				obj.classReplace = function (newClass, oldClass)
				{
					if (obj.className.indexOf(oldClass)!=-1)
					{	
						var o_c = obj.className;
						var n_c = o_c.replace(oldClass,newClass);
						obj.className = n_c;
					} else {
						if(obj.className.indexOf(newClass)==-1) {
							obj.className = obj.className + ' ' + newClass;
						}
					}
					return this;
				}
				try {
					obj.clear = function () 
					{
						var _elm = [];
						_$.DOM_4All(_elm, obj, function (e) { return true; } );
						_$.FEach( _elm , function (elm) {
							try {
								obj.d(elm);
							} catch (e) {}
						} );
						return this;
					}
				} catch (e) {}
				obj.classExs = function (cls_name)
				{
					if (obj.className.indexOf(cls_name)!=-1)
					{
						return true;
					} else {
						return false;
					}
				}
				obj.childOf = function(prnt)
				{
					return _$.ChildOf(obj,prnt);
				}
				obj.fire = function(eventname,prm)
				{
					if (eventname.substr(0,3)=='fx_') {
						_$.FEach(this.events[eventname],function(func) { func(prm); } );
						return this;
					}
					if (this.fireEvent)
					{
						var event = eventname;
						if (event.substr(0,2)!='on') event='on'+event;
						return this.fireEvent(event,prm);
					} else {
						_$.FEach(this.events[eventname],function(func) { func(prm); } );
					}
					return this;
					if (this.fireEvent)
					{
						var event = eventname;
						if (event.substr(0,2)!='on') event='on'+event;
						return this.fireEvent(event,prm);
					} else {
					    var eventTypes = { 
								resize : ['HTMLEvents',1,0],
								scroll : ['HTMLEvents',1,0],
								focusin : ['HTMLEvents',0,0],
								focusout : ['HTMLEvents',0,0],
								gainselection : ['HTMLEvents',1,0],
								loseselection : ['HTMLEvents',1,0],
								activate : ['HTMLEvents',1,1],
								load : ['HTMLEvents',0,0],
								unload : ['HTMLEvents',0,0],
								abort : ['HTMLEvents',1,0],
								error : ['HTMLEvents',1,0],
								select : ['HTMLEvents',1,0],
								change : ['HTMLEvents',1,0],
								submit : ['HTMLEvents',1,1],
								reset : ['HTMLEvents',1,0],
								focus : ['HTMLEvents',0,0],
								blur : ['HTMLEvents',0,0],
								dblclick : ['MouseEvents',1,1],
								click : ['MouseEvents',1,1],
								mousedown : ['MouseEvents',1,1],
								mouseup : ['MouseEvents',1,1],
								mouseover : ['MouseEvents',1,1],
								mousemove : ['MouseEvents',1,0],
								mouseout : ['MouseEvents',1,0],
								keypress : ['KeyEvents',1,1],
								keydown : ['KeyEvents',1,1],
								keyup : ['KeyEvents',1,1],
								DOMSubtreeModified : ['MutationEvents',1,0],
								DOMNodeInserted : ['MutationEvents',1,0],
								DOMNodeRemoved : ['MutationEvents',1,0],
								DOMNodeRemovedFromDocument : ['MutationEvents',0,0],
								DOMNodeInsertedIntoDocument : ['MutationEvents',0,0],
								DOMAttrModified : ['MutationEvents',1,0],
								DOMCharacterDataModified : ['MutationEvents',1,0]
										};
						alert(1);
						if (!eventTypes[event]) return false;
						try {
							var evt = document.createEvent(eventTypes[event][0]);
							evt.initEvent(event,eventTypes[event][1],eventTypes[event][2]);
							return this.dispatchEvent(evt);
						} catch (e) {
							/**/
							alert('ec');
							if (this.events[eventname])
							{
								this.events[eventname]();
							}
						}
					}
				}
					
				obj.position = function(v)
					{
						this.style.position = v;
						return this;
					}
				obj.opacity = function(v)
					{
						Effects.setOpacity(this,v);
						return this;
					}
				obj.resize = function(w,h)
					{
						try {
							this.style.width = w + 'px';
							this.style.height = h + 'px';
							this.fire('fx_resize');
							return this;
						} catch (e) {
							this.fire('fx_resize');
							return this;
						}
					}
				obj.move = function(x,y)
					{
						try {
							this.style.left = x + 'px';
							this.style.top = y + 'px';
						} catch (e) {}
						this.fire('fx_move');
						return this;
					}
				obj._show = function()
					{
						this.style.display = 'block';
						this.style.visibility = 'visible';
						this.fire('fx_show');
						return this;
					}
				obj._hide = function()
					{
						this.style.display = 'none';
						this.style.visibility = 'hidden';
						this.fire('fx_hide');
						return this;
					}
				obj.e = function(event,func,pp)
					{
						_core.addHandler(this,event,func,pp);
						return this;
					}
					obj.event = obj.e;
				obj.r = function(event,func)
					{
						_core.removeHandler(this,event,func);
						return this;
					}
					obj.del_event = obj.r;
				obj.cX = function(c)
					{
						if (c)
						{
							return this.X() - _$.$(c).X();
						} else 
							if (this.parentNode) {
								return this.X() - _$.X(this.parentNode);
							} else return _$.X(this);
					}
				obj.cY = function(c)
					{
						if (c)
						{
							return this.Y() - _$.$(c).Y();
						} else 
							if (this.parentNode) {
								return this.Y() - _$.Y(this.parentNode);
							} else return _$.Y(this);
					}
				obj.X = function()
					{
						return _core.X(this);
					}
				obj.Y = function()
					{
						return _core.Y(this);
					}
				obj.w = function()
					{
						return _core.W(this);
					}
				obj.h = function()
					{
						return _core.H(this);
					}
				obj.a = function(child)
					{
						if (child) {
							try {
								child.parent = this;
							} catch (e) {}
							try {
								this.appendChild(child);
							} catch (e) { }
							return this;
						}
					}
					obj.append = obj.a;
				obj.d = function(child)
					{
						try {
							if (child) child.parent = null;
							return this.removeChild(child);
						} catch (e) {}
					}
					obj.remove = obj.r;
				obj.i_before = function(element)
					{
						if (element.parentNode) element.parentNode.insertBefore(obj, element);
						return this;
					}
				obj.i_after = function(element)
					{
						if (!element.parentNode) return this;
						var next = obj.nextSibling;
						(next) ? obj.parentNode.insertBefore(obj, next) : element.parentNode.appendChild(obj);
						return this;
					}
				obj.i_bottom = function(element)
					{
						element.appendChild(obj);
						return this;
					}
				obj.i_top = function(element)
					{
						var first = element.firstChild;
						(first) ? element.insertBefore(obj, first) : element.appendChild(obj);
						return this;
					}
				obj.c = function()
					{
						return this.childNodes;
					}
					obj.childs = obj.c;
				obj.prew = function()
					{
						return _$.prew(this);
					}
				obj.next = function()
					{
						return _$.next(this);
					}
				obj.clone = function()
					{
						var n_obj = this.cloneNode(true);
						n_obj.fxLib = undefined;
						n_obj = _$.MakeFW(n_obj);
						this.fire("fx_clone");
						return n_obj;
					}
				obj.toTop = function ()
					{
						obj.style.zIndex = _$.MaxZOrder();
						return this;
					}
				obj.nop = function () { return this; }
				obj.rfp = function (func) { func(); return this; }
				obj.RunFunc = obj.rfp;
				obj.f= function (name) {
					if (_$.Factories[name]) _$.Factories[name](this);
					return this;
				}
				obj.factory = obj.f;
			}
		}
		return obj;
	}
}

var Core = new CoreObject();
document.Core = Core;
var _$ = Core;
setInterval(Core.AJAX_StatusCheck,100);
var MSTicker = {
	ticks : function() 
	{
		var d = new Date();
		return (d.getHours() * 360 + d.getMinutes()*60 + d.getSeconds())*1000 + d.getMilliseconds();
	}
}
function Effect(id,speed)
{
	this.speed = speed;
	this.cb = null;
	this.cbp = null;
	this.next = new Array;
	this.SCB = function (cb,cbp)
	{
		this.cb = cb;
		this.cbp = cbp;
		return this;
	}
	if (typeof(id) == 'string')
	{
		this.target = Core.$(id);
	} else {
		this.target = id;
	}
	this.type = 0;	/*
				0 -  Ничаго )
				1 - Opacity		//Изменение прозрачности
				2 - Move		//Перемещение
				3 - ResizeH		//Изменение Высоты
				4 - ResizeW		//Изменение ширины
				5 - ResizeWH	//Изменение ширины высоты
				6 - Morph		//Плавное изменение одного свойства ксс
				7 - Toggle
					*/
	this.lastRefresh = MSTicker.ticks();	/*Последнее обновление*/
	/*
	Вспомогательные параметры
	*/
	this.p1 = 0;
	this.p2 = 0;
	this.p3 = 0;
	this.p4 = 0;
	this.p5 = 0;
	this.end = true;
	this.n = function(eff)
	{
		this.next.push(eff);
		return this;
	}
	this.ToggleHide = function()
	{
		if (this.target)
		{
			var v = parseInt(this.target.style.marginTop);
			if (!this.target.style.marginTop) return this.Toggle();
			if (v>=0) 
			{
				return this.Toggle();
			} else {
				this.type=0;
			}
		}
		this.end = true;
		this.lastRefresh = MSTicker.ticks();
		return this;
	}
	this.ToggleShow  = function()
	{
		if (this.target)
		{
			var v = parseInt(this.target.style.marginTop);
			if (!this.target.style.marginTop) return this.Toggle();
			if (v<=0) 
			{
				return this.Toggle();
			} else {
				this.type=0;
			}
		}
		this.end = true;
		this.lastRefresh = MSTicker.ticks();
		return this;
	}
	this.Toggle = function()
	{
		this.type = 7;
		if (this.target)
		{
			var v = parseInt(this.target.style.marginTop);
			if (v<0) 
			{
				this.p2 = 1;
				this.p3 = v;
			} else {
				this.p2 = 2;
				this.p3 = Core.H(this.target);
			}
		}
		this.end = false;
		this.lastRefresh = MSTicker.ticks();
		return this;
	}
	this.ResizeWH = function (w_f,h_f,w_t,h_t)
	{
		this.type = 5;
		this.p1 = w_f;
		this.p2 = h_f;
		this.p3 = w_t;
		this.p4 = h_t;
		this.lastRefresh = MSTicker.ticks();
		this.end = false;
		return this;
	}
	this.ResizeW = function(w_from,w_to)
	{
		this.type = 4;
		this.p1 = w_from;
		this.p2 = w_to;
		this.lastRefresh = MSTicker.ticks();
		this.end = false;
		return this;
	}
	this.ResizeH = function(h_from,h_to)
	{
		this.type = 3;
		this.p1 =h_from;
		this.p2 =h_to;
		this.lastRefresh = MSTicker.ticks();
		this.end = false;
		return this;
	}
	this.Move = function(x_to,y_to,x_f,y_f)
	{
		this.type = 2;
		this.p1 = x_to;
		this.p2 = y_to;
		if (!x_f && (x_f!=0)) this.p3 = Core.X(this.target); else this.p3=x_f;
		if (!y_f && (y_f!=0)) this.p4 = Core.Y(this.target); else this.p4=y_f;
		this.lastRefresh = MSTicker.ticks();
		this.end = false;
		return this;
	}
	this.Opacity = function(value_from,value_to)
	{
		this.type=1;
		this.p1 = value_from;
		this.p2 = value_to;
		this.lastRefresh = MSTicker.ticks();
		this.end = false;
		return this;
	}
	this.Morph = function(style,from,to,eds,usestatic)
	{
		if (style=='opacity')
		{
			return this.Opacity(from,to);
		} else {
			this.type = 6;
			this.p1 = Effects.ccs2js(style);
			if (eds) this.p5 = eds; else this.p5="";
			if (typeof(to)=='string' && to.substr(0,1)=='#')
			{
				if (usestatic)
					if(this.target.style[this.p1]) from=this.target.style[this.p1];
				this.p2 = Effects.splitRGB(from);
				this.p3 = Effects.splitRGB(to);
				this.p4 = 0;
			} else {
				if (usestatic)
					if (this.target.style[this.p1]) from = parseFloat(this.target.style[this.p1]);
				this.p2 = from;
				this.p3 = to;
				this.p4 = 1;
			}
			this.lastRefresh = MSTicker.ticks();
			this.end = false;
			return this;
		}
	}
}

function FXP(prop,from,to,dur,eds)
{
	this.prop = prop;
	this.from = from;
	this.to = to;
	this.dur = dur;
	this.eds = eds;
}

function EffectsObject()
{
	this.Effects = new Array();
	this.splitRGB = function (color)
	{
		var rgb = color.replace(/[# ]/g,"").replace(/^(.)(.)(.)$/,'$1$1$2$2$3$3').match(/.{2}/g); 
		for (var i=0;  i<3; i++) rgb[i] = parseInt(rgb[i], 16);
		return {'r':rgb[0],'g':rgb[1],'b':rgb[2]};
	}
	this.ccs2js = function (prop)
	{
		var i; 
		while ((i=prop.indexOf("-"))!=-1) 
			prop = prop.substr(0, i) + prop.substr(i+1,1).toUpperCase() + prop.substr(i+2);	
		return prop;
	}
	this.addMorphPack = function(el,pack)
	{
		if (el)
		{
			if (pack instanceof Array)
			{
				for (var i in pack)
				{
					this.add(new Effect(el,pack[i].dur).Morph(pack[i].prop,pack[i].from,pack[i].to,pack[i].eds));
				}
			}
		}
		return this;
	}
	this.checkOverlap = function(eff)
	{
		if (this.Effects.length==0) return eff;
		for (var i in this.Effects)
			with(this.Effects[i]) {
				if(!this.Effects[i].end) if (this.Effects[i].target==eff.target) {
					var d = (MSTicker.ticks()+1) - this.Effects[i].lastRefresh;
					if (this.Effects[i].type==eff.type)
					{
						end=true;
						switch (type)
						{
							case 0 :
								break;
							case 1 :	/*/Opacity*/
								var x = (this.Effects[i].p2 - this.Effects[i].p1) / this.Effects[i].speed * d;
								eff.p1 = this.Effects[i].p1 + x;
								break;
							case 2 :	/*/Move*/
								var d_x = (this.Effects[i].p1 - this.Effects[i].p3) / this.Effects[i].speed * d;
								var d_y = (this.Effects[i].p2 - this.Effects[i].p4) / this.Effects[i].speed * d;
								eff.p3 = this.Effects[i].p3 + d_x;
								eff.p4 = this.Effects[i].p4 + d_y;
								break;
							case 3 :	/*/ResizeH*/
								var d_h = (this.Effects[i].p2 - this.Effects[i].p1) / this.Effects[i].speed * d;
								eff.p1 = this.Effects[i].p1+d_h;
								break;
							case 4 :	/*/ResizeW*/
								var d_w = (this.Effects[i].p2 - this.Effects[i].p1) / this.Effects[i].speed * d;
								eff.p1 = (this.Effects[i].p1 + d_w);
								break;
							case 5 :	/*/ResizeWH*/
								var dd_w = (this.Effects[i].p3 - this.Effects[i].p1) / this.Effects[i].speed * d;
								var dd_h = (this.Effects[i].p4 - this.Effects[i].p2) / this.Effects[i].speed * d;
								eff.p1 = (this.Effects[i].p1 + dd_w);
								eff.p2 = (this.Effects[i].p2 + dd_h);
								break;
							case 6 :	/*/Morph*/
								if (this.Effects[i].p1==eff.p1)
								{
									if (this.Effects[i].p4==1)
									{
										/*/Number morph*/
										var d_c = (this.Effects[i].p3 - this.Effects[i].p2) / this.Effects[i].speed * d;
										/*/alert(d_c);*/
										eff.p2 = Math.floor( this.Effects[i].p2 + d_c )
									} else {
										/*/Color morph*/
										var d_c = d/(this.Effects[i].speed/100)/100;
										var startPercent = 1 -d_c;
										var finishPercent = d_c;
										var aRGBStart = this.Effects[i].p2;
										var aRGBFinish = eff.p3;
										eff.p2['r'] = Math.floor(aRGBStart['r'] * startPercent + aRGBFinish['r'] * finishPercent);
										eff.p2['g'] = Math.floor(aRGBStart['g'] * startPercent + aRGBFinish['g'] * finishPercent);
										eff.p2['b'] = Math.floor(aRGBStart['b'] * startPercent + aRGBFinish['b'] * finishPercent);
									}
									this.Effects[i].end = true;
								} else {
									this.Effects[i].end = false;
								}
								break;
							case 7 : 	/*/Toggle\*/
								
								break;
							
						}
						/*/end = true;*/
					}
				}
			}
		return eff;
	}
	this.add = function(eff)
	{
		eff = this.checkOverlap(eff);
		eff.end = false;
		eff.lastRefresh = MSTicker.ticks();
		this.Effects.push(eff);
		return this;
	}
	this.setElementOpacity = function(elem, nOpacity)
	{
		var opacityProp = this.getOpacityProperty();

		if (!elem || !opacityProp) return;
		nOpacity = parseFloat(nOpacity) * 100;
		if (opacityProp=="filter")
		{
			try {
				if (elem.filters)
				{
					var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
					if (oAlpha) {
						oAlpha.opacity = nOpacity;
					} else {
						elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";
					}
				} else {
					elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";
				}
			} catch (e) {
				//elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";
				//ie 8
				elem.setAttribute("style","-ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")'");
			}
		} else {
			var props = ['MozOpacity', 'KhtmlOpacity', 'opacity'];
			for (var i in props) {
				if (typeof elem.style[props[i]] == 'string') {
					elem.style[props[i]] = nOpacity;
					return;
				}
			}
		}
	}

	this.getOpacityProperty =function()
	{
		if (typeof document.body.style.opacity == 'string')
			return 'opacity';
		else if (typeof document.body.style.MozOpacity == 'string')
			return 'MozOpacity';
		else if (typeof document.body.style.KhtmlOpacity == 'string')
			return 'KhtmlOpacity';
		else if (_$.isIE)
			return 'filter';
		return false;
	}
	this.setOpacity = function(elem, nOpacity) {
		if (typeof elem == 'string') elem = Core.$(elem);
		if (_$.isIE8)
		{
			return this.setElementOpacity(elem,nOpacity);
		} else {
			var props = ['MozOpacity', 'KhtmlOpacity', 'opacity'];
			for (var i in props) {
				if (typeof elem.style[props[i]] == 'string') {
					elem.style[props[i]] = nOpacity;
					return;
				}
			}
			/*/ IE 6+*/
			try {
				/*/alert(nOpacity);*/
				nOpacity = 100 * parseFloat(nOpacity);
				var oAlpha;
				if ((oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha)) 
				{
					
					oAlpha.opacity = nOpacity;
					/*/alert(oAlpha.opacity);*/
				} 
				else 
				{
					/*alert(elem.runtimeStyle.filter);
					obj.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + params[i] + "', sizingMethod=scale)";*/
					elem.runtimeStyle.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";
				}
				
				elem.style.backgroundColor = '#FFFFFF';
				elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";
			} catch (e) {
				/*/alert(' IE <= 5.5 OR Opera < 9 OR another browser. Do nothing');*/
			}
		}
	}
	this.Refresh = function ()
	{
		Core.UpdateRefreshers();
		var nel = new Array();
		for (var i = 0 ; i< this.Effects.length ; i++)
		{
			if (this.Effects[i])
			{
				var e = this.Effects[i];
				if (!e.end)
				{
					var d = (MSTicker.ticks()+1) - e.lastRefresh;
					/*/alert(d);*/
					if (d>=e.speed)
					{
						e.end = true;
						if (e.next)
						{
							for (var i in e.next)
							{
								e.next[i].lastRefresh = MSTicker.ticks();
								nel.push(e.next[i]);
							}
						}
						switch (e.type)
						{
							case 0 : break;
							case 1 :
								this.setOpacity(e.target,e.p2);
								break;
							case 2 :
								e.target.style.left=e.p1 + 'px';
								e.target.style.top=e.p2 + 'px';
								break;
							case 3 : 
								e.target.style.height = e.p2 + 'px';
								break;
							case 4 : 
								e.target.style.width = e.p2 + 'px';
								break;
							case 5 : 
								e.target.style.width = e.p3 + 'px';
								e.target.style.height = e.p4 + 'px';
								break;
							case 6 :
								if (e.p4==1)
								{
									e.target.style[e.p1] = e.p3 + e.p5;
								} else {
									e.target.style[e.p1] = 'rgb('+ 
										Math.floor(e.p3['r']) + ','+
										Math.floor(e.p3['g']) + ','+
										Math.floor(e.p3['b']) +')';
								}
								break;
							case 7 :
								if (e.p2 == 1)
								{
									e.target.style.marginTop = '0px';
								} else {
									e.target.style.marginTop = -e.p3 +'px';
								}
						}
						if (e.cb)
						{
							if (e.cbp) {
								e.cb(e.cbp);
							} else {
								e.cb();
							}
						}
					} else {
						switch (e.type)
						{
							case 0 :
								break;
							case 1 :	/*/Opacity*/
								var x = (e.p2 - e.p1) / e.speed * d;
								this.setOpacity(e.target, e.p1 + x);
								if ((e.p1+x)!=0) 
								{
									e.target.style.display='block';
									e.target.style.visibility = "inherit";
								}
								break;
							case 2 :	/*/Move*/
								var d_x = (e.p1 - e.p3) / e.speed * d;
								var d_y = (e.p2 - e.p4) / e.speed * d;
								e.target.style.left = parseInt(e.p3 + d_x) + 'px';
								e.target.style.top = parseInt(e.p4 + d_y) + 'px';
								break;
							case 3 :	/*/ResizeH*/
								var d_h = (e.p2 - e.p1) / e.speed * d;
								e.target.style.height = (e.p1 + d_h) +'px';
								break;
							case 4 :	/*/ResizeW*/
								var d_w = (e.p2 - e.p1) / e.speed * d;
								e.target.style.width = (e.p1 + d_w) + 'px';
								break;
							case 5 :	/*/ResizeWH*/
								var dd_w = (e.p3 - e.p1) / e.speed * d;
								var dd_h = (e.p4 - e.p2) / e.speed * d;
								e.target.style.width = (e.p1 + dd_w) + 'px';
								e.target.style.height = (e.p2 + dd_h) + 'px';
								break;
							case 6 :	/*/Morph*/
								
								if (e.p4==1)
								{
									/*/Number morph*/
									var d_c = (e.p3 - e.p2) / e.speed * d;
									/*/alert(d_c);*/
									e.target.style[e.p1] = Math.floor( e.p2 + d_c ) + e.p5;
								} else {
									/*/Color morph*/
									var d_c = d/(e.speed/100)/100;
									var startPercent = 1 -d_c;
									var finishPercent = d_c;
									var aRGBStart = e.p2;
									var aRGBFinish = e.p3;
								    e.target.style[e.p1] = 'rgb('+ 
										Math.floor( aRGBStart['r'] * startPercent + aRGBFinish['r'] * finishPercent ) + ','+
										Math.floor( aRGBStart['g'] * startPercent + aRGBFinish['g'] * finishPercent ) + ','+
										Math.floor( aRGBStart['b'] * startPercent + aRGBFinish['b'] * finishPercent ) +')';
								}
								break;
							case 7 : 	/*/Toggle\*/
								if (e.p2 == 1)
								{
									var t_h = e.p3 / e.speed * d;
									e.target.style.marginTop = e.p3 - parseInt(t_h) + 'px';
									/*/alert('1=' + e.target.style.marginTop);*/
								} else {
									var t_h = e.p3 / e.speed * d;
									e.target.style.marginTop = -parseInt(t_h) + 'px';
									/*/alert(t_h);// + 'px';
									//alert('2=' + e.target.style.marginTop)*/
								}
								break;
						}
					}
					if (!e.end) nel.push(e);
				}
			}
		}
		this.Effects = nel;
	}
}
function Rect(x,y,w,h)
{
	this.x = x;
	this.y = y;
	this.w = w;
	this.h = h;
	/*/Проверяет текущий квадрат с переданым на предмет вхождения исходного в данный*/
	this.Intersect = function (r)
	{
		var bf = false;
		if ((this.x>r.x) && (this.x<(r.x+r.w)) && (this.y>r.y) && (this.y<(r.y+r.h))) return true;
		
		return false;
	}
	/*Проверяет нахождение точки внутри квадрата*/
	this.PointIn = function (x,y)
	{
		if ((this.x<x) && ((this.x+this.w)>x) && (this.y<y) && ((this.y+this.h)>y)) return true;
		return false;
	}
}
function DragDrop(d,b,cb,container) {
	var dd = this;
	this.container = container;
	this.drogable = d;
	this.CallBack = cb;
	this.StartXOffset = 0;
	this.StartYOffset = 0;
	this.bases = b;
	this.lastbase = null;
	this.IsDrag = false;
	this.lastpos = "";
	this.lastevent = null;
	this.CheckContainer = function()
	{
		if (this.container)
		{
			var c = _$.Rect(this.container);
			var d = _$.Rect(this.drogable);
			if (d.x<c.x) d.x = c.x;
			if (d.y<c.y) d.y = c.y;
			if (d.x+d.w>c.x+c.w) d.x=c.x+c.w-d.w;
			if (d.y+d.h>c.y+c.h) d.y=c.y+c.h-d.h;
			this.drogable.style.left = d.x +'px';
			this.drogable.style.top = d.y + 'px';
		}
	}
	this.Drag_Begin = function(evt)
	{
		if (dd)
		{
			var e = _$.Event(evt);
			var trg = _$.MakeFW(e.target);
			if (trg.uid!=dd.drogable.uid) {
				trg = _$.MakeFW(trg.parentNode);
				if (trg.uid!=dd.drogable.uid) return false;
			}
			dd.IsDrag = true;
			dd.StartXOffset = e.OX;
			dd.StartYOffset = e.OY;
			dd.lastbase = null;
			dd.drogable.style.zIndex = _$.MaxZOrder();
			dd.lastpos = dd.drogable.style.position;
			dd.drogable.style.position = 'absolute';
			dd.drogable.style.left = e.pageX -  dd.StartXOffset + 'px';
			dd.drogable.style.top = e.pageY -  dd.StartYOffset + 'px';
			if (dd.CallBack) dd.CallBack(dd,'begin',null);
			
		}
		if (e.stopPropagation)
			e.stopPropagation(); else e.cancelBubble=true;
		
		_$.B().e('mousemove',dd.Draging);
		_$.B().e('mouseup',dd.Drop);
		return false;
	}
	this.Draging = function(evt)
	{
		if (dd)
		{
			if (dd.IsDrag)
			{
				_$.setSelection(null);
				var e = _$.Event(evt);
				dd.lastevent = e;
				dd.drogable.style.left = e.pageX -  dd.StartXOffset + 'px';
				dd.drogable.style.top = e.pageY -  dd.StartYOffset + 'px';
				
				dd.CheckBase(false);
				dd.CheckContainer();
				if (dd.CallBack) dd.CallBack(dd,'move',null);
			}
		}
	}
	this.CheckBase = function (isdrop)
	{
		var d = new Rect(_$.X(dd.drogable),_$.Y(dd.drogable),_$.W(dd.drogable),_$.H(dd.drogable));
		var ok = false;
		var bfind = false;
		var elms = _$.elmFromPoint(dd.lastevent.pageX,dd.lastevent.pageY);
		var cbase = null;
		
		_$.FEach(elms, function (elm) {
			_$.FEach(dd.bases,function (elm2) {
				if ((elm2.uid==elm.uid) && (elm2.uid!=dd.drogable.uid)) {
					cbase=elm2;
				}
			} );
		} );
		if (cbase) 
		{
				//var b = new Rect(_$.X(cbase),_$.Y(cbase),_$.W(cbase),_$.H(cbase));
				//var cIn = b.PointIn(dd.lastevent.pageX,dd.lastevent.pageY);
				//if (d.Intersect(b)) {
					if (isdrop)
					{
						ok = true;
						bfind = true;
						if (dd.CallBack) dd.CallBack(dd,'drop',cbase);
						return true;
					} else {
						ok = true;
						bfind = true;
						if (dd.lastbase!=cbase)
						{
							if (dd.CallBack) dd.CallBack(dd,'over',cbase);
							dd.lastbase = cbase;
						} else {
							if (dd.CallBack) dd.CallBack(dd,'overmove',cbase);
						}
					}
				//}
		}
		if (!ok && dd.lastbase) {
			if (dd.CallBack) dd.CallBack(dd,'leave',dd.lastbase);
			dd.lastbase = null;
		}
		if (ok) return true;
	}
	this.Drop = function(evt)
	{
		/*/var dd = this.getAttribute('DragDrop');*/
		if (dd)
		{
			if (dd.IsDrag)
			{
				dd.Draging(evt);
				
				dd.IsDrag=false;
				if (!dd.CheckBase(true))
				{
					if (dd.CallBack) dd.CallBack(dd,'drop',null);
				}
				dd.drogable.style.position = dd.lastpos;
				_$.B().r('mousemove',dd.Draging);
				_$.B().r('mouseup',dd.Drop);
			}
		}
	}
	this.drogable.e('mousedown',this.Drag_Begin);
	this.drogable.e('mousemove',this.Draging);
	this.drogable.e('mouseup',this.Drop);
}
function Scroll(cont,butt,cb)
{
	var thisScroll = this;
	this.Callback = cb;
	this.cont = cont;
	this.butt = butt;
	this.Max = 100;
	this.Min = 0;
	this.Value = 0;
	this.Vertical = false;
	this.CalcValue = function()
	{
		var c = Core.Rect(this.cont);
		var b = Core.Rect(this.butt);
		var v = 0;
		if (this.Vertical)
		{
			v = this.Min + parseInt((b.y-c.y) / ((c.h-b.h) / (this.Max - this.Min)));
		} else {
			v = this.Min + parseInt((b.x-c.x) / ((c.w-b.w) / (this.Max - this.Min)));
		}
		if (v<this.Min) v =this.Min;
		if (v>this.Max) v =this.Max;
		this.Value = v;
	}
	this.dcallback = function(dd,e,base)
	{
		switch(e)
		{
			case "overmove":
				thisScroll.CalcValue();
				if (thisScroll.Callback) thisScroll.Callback(thisScroll);
				break;
		}
	}
	this.FixScroller = function()
	{
		if (!thisScroll.drag.IsDrag)
		{
			if (thisScroll.Value<thisScroll.Min) thisScroll.Value=thisScroll.Min;
			if (thisScroll.Value>thisScroll.Max) thisScroll.Value=thisScroll.Max;
			var c = Core.Rect(thisScroll.cont);
			var b = Core.Rect(thisScroll.butt);
			/*/alert(c);*/
			if (thisScroll.Vertical)
			{
				thisScroll.butt.style.top = c.y + (c.h-b.h) / (thisScroll.Max-thisScroll.Min)*(thisScroll.Value-thisScroll.Min);
				thisScroll.butt.style.left = c.x;
			} else {
				thisScroll.butt.style.top = c.y;
				thisScroll.butt.style.left = c.x + (c.w-b.w) / (thisScroll.Max-thisScroll.Min)*(thisScroll.Value-thisScroll.Min);
			}
		}
	}
	window.setInterval(this.FixScroller,10);
	this.drag = new DragDrop(this.butt,this.cont,this.dcallback,this.cont);
	
}

function domReady( f ) {
    if ( domReady.done ) {
		domReady.done = false;
		return f();
	}

    if ( domReady.timer ) {
        domReady.ready.push( f );
    } else {
        if (window.addEventListener)
            window.addEventListener('load',isDOMReady, false);
        else if (window.attachEvent)
            window.attachEvent('onload',isDOMReady);

        domReady.ready = [ f ];
        domReady.timer = setInterval( isDOMReady, 13 );
    }
}

function isDOMReady(){
    if ( domReady.done ) return false;

    if ( document && document.getElementsByTagName && document.getElementById && document.body ) {
        clearInterval( domReady.timer );
        domReady.timer = null;
		domReady.done = true;
		try {
			for ( var i = 0; i < domReady.ready.length; i++ )
			{
			
				domReady.ready[i]();
			}
		} catch (e) {}
        domReady.ready = null;
        
    }
}

DOMReady = function(func){
	var already = false;
 
	ready = function () {
		if (!already) {
			func();
			already = true;
		}
	};
	try {/*/opera, firefox*/
		document.addEventListener("DOMContentLoaded", ready, false);
	} 
	catch (e) { /*/ie*/
		timer = setInterval(function(){
			if (/loaded|complete/.test(document.readyState)) {
				clearInterval(timer);
				ready();
			}
		}, 10);
	}
 
 
	window.onload = function(){
		ready();
	};
};
DOMReady2 = function(frm,func){
	var already = false;
 
	ready = function () {
		if (!already) {
			func();
			already = true;
		}
	};
	try {/*/opera, firefox*/
		frm.contentDocument.addEventListener("DOMContentLoaded", ready, false);
	} 
	catch (e) { /*/ie*/
		timer = setInterval(function(){
			if (/loaded|complete/.test(document.readyState)) {
				clearInterval(timer);
				ready();
			}
		}, 10);
	}
 
 
	window.onload = function(){
		ready();
	};
};
function DOMReady3(func){
	var already = false;
	var timer = null;
	ready = function () {
		if (!already) {
			if (document && document.getElementsByTagName && document.getElementById && document.body)
			{
				func();
				window.clearInterval( timer );
				already = true;
			}
		}
	};
	//timer = window.setInterval( ready , 10);
	
	try {//opera, firefox
		document.addEventListener("DOMContentLoaded", ready, false);
		document.addEventListener('load', ready,false);
	} 
	catch (e) { //ie
		timer = setInterval(function(){
			if (/loaded|complete/.test(document.readyState)) {
				clearInterval(timer);
				ready();
			}
		}, 10);
	}
	window.onload = function () { ready (); };
//	_$.MakeFW(window).e('load', function() { ready(); } );
};
String.prototype.replaceAll = function(f,m)
{
	var nString = new String();
	var i;
	for (i=0;i<this.length;i++)
	{
		if (this.substr(i,f.length)==f)
		{
			nString = nString + m;
			i = i + f.length - 1;
		} else {
			nString = nString + this.charAt(i);
		}
	}
	return nString;
}
AB_ = function (params)
{
	var obj = new Array();
	if (params)
	{
		for (var i in params)
		{
			obj[i] = params[i];
		}
	}
	return obj;
}
AB = AB_;
var Effects = new EffectsObject();
window.setInterval("Effects.Refresh()",100);
