var uagent=navigator.userAgent.toLowerCase(),
	VARS=
{
	browser:
	{
		safari:(uagent.indexOf('safari')!=-1 || navigator.vendor=="Apple Computer, Inc." || uagent.indexOf('konqueror')!=-1 || uagent.indexOf('khtml')!=-1),
		opera:uagent.indexOf('opera')!=-1,
		ie:(uagent.indexOf('msie')!=-1 && !this.opera && !this.safari),
		mozilla:navigator.product=='Gecko'
	},
	st:0,
	p:0,
	f:0,
	t:0,

	cookie_domain:"eleanor-cms.ru",
	cookie_path:"/",
	cookie_prefix:"CP",
	cookie_time:360*86400,

	base_url:"",
	img_url:"",
	md5_check:"",

	new_pms:0,

	CancelBubble:function(e)
	{
		e=e ? e : window.event;
		e.cancelBubble=true;
		e.returnValue=false;
		if(e.preventDefault)
			e.preventDefault();
		if(e.stopPropagation)
			e.stopPropagation();
		return e;
	}
},
	FORUM=
{
	lang:[],
	Lang:function(arr,a)
	{
		if(typeof arr=="string")
		{
			var ret=typeof this.lang[arr]=="undefined" ? "" : this.lang[arr],
				f=false;

			a=a || [];
			for(var i in a)
				ret=ret.replace("{"+i+"}",a[i]);
			return ret;
		}
		else
			for(var i in arr)
				this.lang[i]=arr[i];
	},
	Go:function(url,full)
	{
		url=url.replace(/&amp;/g,'&');
		window.location.href=full ? url : VARS.base_url+url;
		return false;
	},
	//Установка и удаление кук
	SetCookie:function(name,value,ctime)
	{
		var data=new Date();
		data.setTime(data.getTime()+(ctime ? ctime : VARS.cookie_time)*1000);
		document.cookie=VARS.cookie_prefix+name+"="+escape(value)+';expires='+data.toGMTString()+";domain="+VARS.cookie_domain+";path="+VARS.cookie_path;
	},
	GetCookie:function(name)
	{
		var res;
		if(res=document.cookie.match(new RegExp(VARS.cookie_prefix+name+"=([^;]+)","i")))
			return res[1];
		return false;
	},
	PageJump:function(url,total,per_page)
	{
		var pages=Math.ceil(total/per_page),
			user_page=prompt(this.Lang("page_jump"),1);
		if(user_page>0)
		{
			if(user_page<1)
				user_page=1;
			if(user_page>pages)
				user_page=pages;
			return this.Go(url+(user_page==1 ? "" : "&st="+(user_page-1)*per_page),false);
		}
		return false;
	},
	ToggleCategory:function(id,show)
	{
		var saved=[],
			clean=[];
		if(tmp=this.GetCookie('collapseprefs'))
			saved=tmp.split(",");
		for(i=0;i<saved.length;i++)
			if(saved[i]!=id && saved[i])
				clean[clean.length]=saved[i];
		if(show)
		{
			clean[clean.length]=id;
			$("#fo_"+id).hide();
			$("#fc_"+id).show();
		}
		else
		{
			$("#fc_"+id).hide();
			$("#fo_"+id).show();
		}
		this.SetCookie('collapseprefs',clean.join(','));
		return false;
	},

	//Forums
	WhoPosted:function(tid)
	{
		window.open(ipb_var_base_url+"act=stats&do=who&t="+tid,"WhoPosted","toolbar=no,scrollbars=yes,resizable=yes,width=230,height=300");
		return false;
	}
},
	TOPIC=
{
	ignored:[],
	DoIgnoredPost:function(p)
	{
		this.ignored[p]=$("#post-main-"+p).html();
		$("#post-main-"+p).empty().append("#post-ignore-"+p);
	},
	ShowIgnoredPost:function(p)
	{
		if(this.ignored[p])
			$("#post-main-"+p).html(this.ignored[p]);
		return false;
	},
	MultiQuote:function(p,obj)
	{
		var sels=[],
			tmp;
		if(tmp=FORUM.GetCookie('mqtids'))
			sels=tmp.split(",");
		for(var i in sels)
			if(sels[i]==p)
				delete sels[i];
		obj=$(obj).find("img:first");
		if(obj.attr("alt")=="+")
		{
			sels.push(p);
			obj.attr({"src":VARS.img_url+"p_mq_remove.gif","alt":"-","title":"-"});
		}
		else
			obj.attr({"src":VARS.img_url+"p_mq_add.gif","alt":"-","title":"-"});
		FORUM.SetCookie("mqtids",sels.join(','));
		return false;
	},
	CheckModerDelete:function(obj)
	{
		if($(obj).find("select:first").val()=="delete")
			return confirm(CORE.Lang("suredelete_posts"));
		return true;
	},
	LinkToPost:function(pid)
	{
		var temp=prompt(FORUM.Lang("link_to_post"),ipb_var_base_url+"act=findpost&pid="+pid);
		return false;
	},
	MarkPost:function(p)
	{
		var sels=[],
			tmp;
		if(tmp=$("#fmodposts").find("input[name=selectedpids]:first").val())
			sels=tmp.split(",");
		tmp=false;
		for(var i in sels)
			if(sels[i]==p)
			{
				delete sels[i];
				tmp=true;
			}
		if(tmp)
			$("#img"+p).attr("src",VARS.img_url+"topic_unselected.gif");
		else
		{
			sels.push(p);
			$("#img"+p).attr("src",VARS.img_url+"topic_selected.gif");
		}
		tmp=sels.join(',');
		FORUM.SetCookie('modpids',tmp);
		$("#fmodposts").find("input[name=selectedpids]:first").val(tmp).end().find("input[type=submit]:first").val(FORUM.Lang("f_go_posts",[sels.length]))
		return false;
	},
	EditPost:function(pid)
	{
		var obj=$('#post-'+pid);
		if(!obj.get(0).old_html)
			obj.get(0).old_html=obj.html();
		MENU.Close(false,true);
		$('#loading-layer').show();
		$.post(
				'index.php',
				{
					'act':'xmlout',
					'do':'post-edit',
					'p':pid,
					'md5check':ipb_md5_check
				},
				function(result)
				{
					$('#loading-layer').hide();
					if(result['error'])
						alert(result['error']);
					else
					{
						obj.html(result['html']);
						obj.find("form:first").submit(function(){return false});
					}
				},
				"json"
		);
		return false;
	},
	CancelPost:function(pid)
	{
		var obj=$('#post-'+pid);
		obj.html(obj.get(0).old_html);
	},
	SavePost:function(pid,Ed)
	{
		var obj=$('#post-'+pid),arr={};
		obj.find("input").each(function(){
			if(this.type=="submit" || this.type=="reset")
				return;
			arr[this.name]=$(this).val();
		});
		arr["Post"]=Ed.GetText();
		arr["act"]='xmlout';
		arr["do"]='post-save';
		arr["p"]=pid;
		arr["md5check"]=ipb_md5_check;
		$('#loading-layer').show();
		$.post(
				'index.php',
				arr,
				function(result)
				{
					$('#loading-layer').hide();
					if(result['error'])
						alert(result['error']);
					else
						obj.html(result['html']);
					obj.get(0).old_html=false;
					try{hljs.initHighlighting();}catch(e){};
					try{TopicTip.CheckAll();}catch(e){};
				},
				"json"
		);
		return false;
	},
	PasteNick:function(nick)
	{
		var editor=false;
		if(typeof OPost!="undefined")
			editor=OPost;
		else if(typeof Qr!="undefined")
			editor=Qr;
		if(!nick || !editor)
			return false;
		$('#qr_open').show();
		editor.SetSelectedText(editor.visual ? '<b>'+nick+'</b>, ' : '[b]'+nick+'[/b], ');
		return false;
	},
	QQuote:function(name,date,pid)
	{
		var editor=false;
		if(typeof OPost!="undefined")
			editor=OPost;
		else if(typeof Qr!="undefined")
			editor=Qr;
		var txt='';
		if(document.getSelection)
			txt=document.getSelection();
		else if (document.selection)
			txt=document.selection.createRange().text;
		txt="\n"+$.trim(txt)+"\n";
		if(!txt || !editor)
			return false;
		if(editor.visual)
			txt=txt.replace(/\n/g,"<br />\n");
		$('#qr_open').show();
		if(txt)
			editor.SetSelectedText('[quote name='+name+' date='+date+' p='+pid+']'+txt+'[/quote]');
		return false;
	},
	DeletePost:function()
	{
		if(confirm(FORUM.Lang("post_del_1")))
			return true;
		alert(FORUM.Lang("post_del_2"));
		return false;
	}
},
	TopicTip=
{
	//Настройки
	opacity:0.9,//Прозначность
	time_to_show:800,//Время в мс до показа подсказки
	time_to_hide:400,//Время в мс до показа подсказки
	wnd_padding:5,//Отступ подсказки от края окна
	post_height:250,//Высота поля текста

	dont_tips:FORUM.GetCookie('dont_topic_tip'),

	showed:false,
	p:0,
	tip_div:'',
	tip_iframe:'',
	timer_show:false,
	timer_hide:false,
	cache:{},
	topics_read:{},
	last_obj:'',
	CheckAll:function()
	{
		if(this.dont_tips)
			return;
		var th=this;

		//Create topic tip popup container
		if(!this.tip_div)
			this.tip_div=$('<div>').mouseenter(function(){
				if(th.timer_hide)
					clearTimeout(th.timer_hide);
			}).mouseleave(function(){
					th.HideTip();
			}).addClass('topictip').css({'z-index':1000,'opacity':this.opacity,'display':'none'}).appendTo(document.body);

		//Workaround for IE bug which shows select boxes and other windows GUI over divs. SHOW IFRAME
		if(VARS.browser.ie && !this.tip_iframe)
			this.tip_iframe=$('<iframe>').addClass('iframeshim').attr({'src':'javascript::','scroling':'no','frameborder':'no'}).css({'position':'absolute','z-index':999}).appendTo(document.body);

		//Check all document links
		$(document.links).each(function(){
			th.TipLink(this);
		});
	},
	TipLink:function(link)
	{
		if
		(
			//Pass link?
			link.name=='nopreview' || link.have_tip ||
			//Link contains image?
			link.innerHTML.match(/<img/i) ||
			//Topic view mode links?
			link.href.match(/mode=(threaded|linear|linearplus)/i) ||
			//<< & >> topics links
			link.href.match(/view=(old|new)/i) ||
			//Not a link, onclick
			link.onclick ||
			//Stop words
			link.href.match(/(#topicoptions)/i) ||
			//Ссылки не нашего домена
			link.href.match(/^[a-z]{1,5}:\/\//) && link.href.indexOf(window.location.protocol+'//'+document.domain)!=0 ||
			link.href.indexOf('/go.php?')!=-1 ||
			//Pages links
			link.parentNode.className=='minipagelink' || link.parentNode.className=='pagelink' || link.parentNode.className=='minipagelinklast' || link.parentNode.className=='pagelinklast'
		)
			return;
		var href=link.href.replace(/&amp;/gi,'&');
		var span=$('<span>');
		var span_obj=span.get(0)
		span_obj.params={
			't':0,
			'p':0,
			'do':0
		};

		if(m=href.match(/showtopic=\d+&(?:p|pid)=(\d+)/))
		{
			span_obj.params['p']=m[1];
			span_obj.params['do']='post';
		}
		else if(m=href.match(/findpost&(?:p|pid)=(\d+)/))
		{
			span_obj.params['p']=m[1];
			span_obj.params['do']='post';
		}
		else if(m=href.match(/showtopic=(\d+)&view=(getlastpost|getnewpost)/))
		{
			span_obj.params['t']=m[1];
			span_obj.params['do']=m[2]=='getlastpost' ? 'last' : 'newpost';
		}
		else if(m=href.match(/showtopic=(\d+)/))
		{
			span_obj.params['t']=m[1];
			span_obj.params['do']='topic';
		}
		else
			return;

		span_obj.params['obj']=span_obj;

		var th=this;
		span.mouseover(function(){
			th.EvShowTip(this.params);
		}).click(function(e){
			th.EvShowTip(this.params,e);
		}).mouseleave(function(e){
			th.EvHideTip(e);
		}).css('cursor','pointer').text(' [?]').insertAfter(link);

		link.have_tip=1;
	},
	EvShowTip:function(params,e)
	{
		if(this.timer_hide)
		{
			clearTimeout(this.timer_hide);
			this.timer_hide=false;
			this.showed=false;
		}

		if(this.timer_show)
		{
			clearTimeout(this.timer_show);
			this.timer_show=false;
			this.showed=false;
		}
		var th=this;
		this.timer_show=setTimeout(function()
			{
				th.ShowTip(params,e);
				th.showed=true;
			},
			this.time_to_show
		);
	},
	EvHideTip:function(e)
	{
		if(this.timer_hide)
		{
			clearTimeout(this.timer_hide);
			this.timer_hide=false;
		}

		if(this.timer_show)
		{
			clearTimeout(this.timer_show);
			this.timer_show=false;
		}
		var th=this;
		this.timer_hide=setTimeout(function()
			{
				th.HideTip(e);
				th.showed=false;
			},
			this.time_to_hide
		);
	},
	ShowTip:function(params,e)
	{
		if(params['p']==-1)
		{
			alert(FORUM.Lang('access_denied'));
			return;
		}
		var cached;
		if(cached=this.LoadFromCache(params))
		{
			this.tip_div.html(cached);
			if(this.topics_read[params['t']])
				$('#tip_mark_'+params['t']).hide();

			try{hljs.initHighlighting()}catch(e){}
			this.ShowTipDiv(e,params);
			return;
		}

		var tip_msg=document.getElementById('tip_msg_'+params['t']);
		if(tip_msg)
			$(tip_msg).html(FORUM.Lang("loading_title"));
		else
			this.tip_div.html('<div style="margin:3px">'+FORUM.Lang("loading_title")+'</div>');

		this.ShowTipDiv(e,params);

		var th=this;
		$.get(
			VARS.base_url,
			{
				'act':'xmlout',
				'do':'topic-tip',
				't':params['t'],
				'p':params['p'],
				'todo':params['do']
			},
			function(result)
			{
				if(result=='error')
				{
					th.HideTip(e);
					params['obj'].params['p']=-1;
					alert(FORUM.Lang('access_denied'));
					return;
				}
				if(!result)
				{
					th.HideTip(e);
					params['obj'].params['p']=-1;
					alert(result);
					return;
				}
				if(result['p'])
				{
					if(params['do']=='topic' || params['do']=='first' || !result['prev'])
						th.SaveToCache(result['p'],'',{'do':'first','p':'0','t':result['t']});
					else if(params['do']=='last' || !result['next'])
						th.SaveToCache(result['p'],'',{'do':'last','p':'0','t':result['t']});
					if(params['obj'] && !params['obj'].params['p'])
					{
						params['obj'].params['p']=result['p'];
						params['obj'].params['do']='post';
					}
					th.SaveToCache(result['p'],result['text'],params);
					if(params['do']=='prev')
						th.SaveToCache(th.p,'',{'do':'next','p':result['p'],'t':result['t']});
					else if(params['do']=='next')
						th.SaveToCache(th.p,'',{'do':'prev','p':result['p'],'t':result['t']});
					th.p=result['p'];
				}
				th.tip_div.html(result['text']);
				if(result['t'] && params['obj'])
					params['obj'].params['t']=result['t'];
				th.ShowTipDiv(e,params);
				try{hljs.initHighlighting()}catch(e){};
			},
			"json"
		);
		return false;
	},
	HideTip:function(e)
	{
		if(VARS.browser.ie && this.tip_iframe)
			this.tip_iframe.hide();
		this.tip_div.hide();
	},
	SaveToCache:function(p,content,params)
	{
		if(!p || typeof content=='undefined')
			return false;
		if(content)
			this.cache[p]=content;
		if(typeof params!='undefined' && params['do']!='post')
			this.cache[params['do']+params['t']+params['p']]=p;
		return true;
	},
	LoadFromCache:function(params)
	{
		var p=params['p'];
		if(!p || params['do']!='post')
			p=this.cache[params['do']+params['t']+params['p']];
		if(!p || typeof this.cache[p]=='undefined')
			return false;
		this.p=p;
		return this.cache[p];
	},
	ShowTipDiv:function(e,params)
	{
		var left,top,span_height=10;
		if(!params['obj'] && this.last_obj)
			params['obj']=this.last_obj;
		if(this.showed)
		{
			left=this.tip_div.position().left;
			top=this.tip_div.position().top;
			span_height=-1;
		}
		else
		{
			if(params['obj'])
			{
				this.last_obj=params['obj'];
				left=$(params['obj']).position().left;
				top=$(params['obj']).position().top;
				span_height=$(params['obj']).height();
			}
			else
			{
				e=e ? e : window.event;
				e.cancelBubble = true;
				e.returnValue = false;
				if(e.preventDefault)
					e.preventDefault();
				if(e.stopPropagation)
					e.stopPropagation();

				left=$(params['obj']).position().clientX;
				top=$(params['obj']).position().clientY;
			}
		}

		//Show menu DIV.. but keep it underneath
		this.tip_div.show().css('z-index',-1);

		var post_tip_div=document.getElementById('post-tip-div');
		if(post_tip_div)
		{
			post_tip_div=$(post_tip_div);
			if(post_tip_div.height()>this.post_height)
				post_tip_div.height(this.post_height+'px');
		}

		var width=this.tip_div.width(),
			height=this.tip_div.height(),
			window_height=is_ie ? document_body.clientHeight : window.innerHeight,
			window_scroll=is_ie ? document_body.scrollTop : window.scrollY;
		if((left+width)>=$(document).width()-this.wnd_padding)
			left=$(document).width()-width-this.wnd_padding;
		if((top-window_scroll+span_height+height+1)>=window_height-this.wnd_padding)
		{
			top-=height+1;
			// Firefox bump
			if(VARS.browser.mozilla)
				top-=5;
		}
		else
			top=top+span_height+1;

		this.tip_div.css({'left':left+"px",'top':top+"px",'z-index':1000});

		//Workaround for IE bug which shows select boxes and other windows GUI over divs. SHOW IFRAME
		if(VARS.browser.msie && this.tip_iframe)
		{
			this.tip_iframe.width(parseInt(this.tip_div.width())+'px').height(parseInt(this.tip_div.height())+'px')
			.css({'left':left+"px",'top':top+"px",'z-index':999}).show();
		}
	},
	MarkRead:function(t)
	{
		var mark=$('#tip_mark_'+t).html(FORUM.Lang("loading_title"));
		var th=this;
		$.get(
			VARS.base_url,
			{
				'act':'xmlout',
				'do':'topic-tip',
				't':t,
				'todo':'mark-read'
			},
			function(content)
			{
				if(content=='error')
				{
					th.HideTip(t);
					alert(FORUM.Lang('access_denied'));
					return;
				}
				//Set topics cookie
				th.topics_read[t]=true;

				//Delete "go new posts" image
				$('#topic-'+t+'-new_posts').hide();

				//Change topic folder icon
				try
				{
					var fimgs=$('#tid-folder-'+t+' img').each(function(){
						if(this.src.match(/style_images\/[^\/]+\/f_/))
							this.src=this.src.replace('.gif','_no.gif').replace('_dot_no','_no_dot').replace('_no_no','_no');
					});
				}
				catch(e){};

				mark.html(FORUM.Lang('marked'));
			}
		);
		return false;
	}
},
	MENU=
{
	registered:[],
	cur:-1,
	item:"<img src=\""+VARS.img_url+"menu_item.gif\" alt=\"\" />",
	action:"<img src=\""+VARS.img_url+"menu_item2.gif\" alt=\"\" />",

	Register:function(id,menu,open_cb,close_cb,etype)
	{
		this.registered[this.registered.length]=new Menu(id,menu||id+"_menu",etype=="over" ? "over" : "click",open_cb||false,close_cb||false);
	},
	Close:function(e,force)
	{
		try
		{
			if(typeof this.registered[this.cur]=="undefined"||e.button==2||e.button==3)
				return
		}
		catch(ex){}
		if(!e)
			e=window.event;
		if(e && !force)
		{
			var target=e.target||e.srcElement;
			while(target)
			{
				if(target==this.registered[this.cur].menu_obj.get(0))
					return;
				target=target.parentNode;
			}
		}
		if(this.cur>=0)
			this.registered[this.cur].Close()
	},
	Build:function(id,arr)
	{
		var div=$("<div>").addClass("popupmenu").hide();
		if(typeof arr=="string")
			div.html(arr);
		else if(arr.length)
			for(var i in arr)
				div.append($("<div>").addClass((arr.length==i+1) ? "popupmenu-item-last" : "popupmenu-item").html(arr[i]));
		$(id).parent().append(div);
		this.Register(id,div);
	}
}

function Menu(id,menu,etype,open_cb,close_cb)
{
	var th=this,
		cid=MENU.registered.length;
	this.Click=function(e)
	{
		if(MENU.cur==cid)
			th.Close();
		else
			th.Open();
		VARS.CancelBubble(e);
	}

	this.Open=function()
	{
		if(MENU.cur==cid)
			return false;
		if(MENU.cur>=0)
			MENU.registered[MENU.cur].Close()
		MENU.cur=cid;
		var pos=th.obj.position(),
			left_px=pos.left;
		th.menu_obj.show();
		var width=this.menu_obj.outerWidth();

		if(left_px+width>=$(document).width())
			left_px-=width-th.obj.outerWidth();

		th.menu_obj.css({'left':left_px+"px",'top':pos.top+th.obj.outerHeight()+"px"})
		if(open_cb)
			open_cb(th);
	}

	this.Close=function()
	{
		if(th.menu_obj)
			th.menu_obj.hide();
		if(MENU.cur==cid)
			MENU.cur=-1;
		if(close_cb)
			close_cb(th);
	}

	this.Hover=function()
	{
		if(MENU.cur>=0 && MENU.cur!=cid)
			th.Open();
	}

	this.obj=$(id).css("cursor","pointer");
	this.obj.get(0).unselectable=true;

	this.menu_obj=$(menu).hide().css({"position":"absolute","left":"0px","top":"0px","z-index":100});

	if(etype=='over')
		this.obj.mouseover(this.Click);
	else
	{
		this.obj.click(this.Click);
		this.obj.mouseover(function(e){
			th.Hover();
		});
	}
}

/*!
 * jquery.event.drag - v 2.0.0
 * Copyright (c) 2010 Three Dub Media - http://threedubmedia.com
 * Open Source MIT License - http://threedubmedia.com/code/license
 */
(function(f){f.fn.drag=function(b,a,d){var e=typeof b=="string"?b:"",k=f.isFunction(b)?b:f.isFunction(a)?a:null;if(e.indexOf("drag")!==0)e="drag"+e;d=(b==k?a:d)||{};return k?this.bind(e,d,k):this.trigger(e)};var i=f.event,h=i.special,c=h.drag={defaults:{which:1,distance:0,not:":input",handle:null,relative:false,drop:true,click:false},datakey:"dragdata",livekey:"livedrag",add:function(b){var a=f.data(this,c.datakey),d=b.data||{};a.related+=1;if(!a.live&&b.selector){a.live=true;i.add(this,"draginit."+ c.livekey,c.delegate)}f.each(c.defaults,function(e){if(d[e]!==undefined)a[e]=d[e]})},remove:function(){f.data(this,c.datakey).related-=1},setup:function(){if(!f.data(this,c.datakey)){var b=f.extend({related:0},c.defaults);f.data(this,c.datakey,b);i.add(this,"mousedown",c.init,b);this.attachEvent&&this.attachEvent("ondragstart",c.dontstart)}},teardown:function(){if(!f.data(this,c.datakey).related){f.removeData(this,c.datakey);i.remove(this,"mousedown",c.init);i.remove(this,"draginit",c.delegate);c.textselect(true); this.detachEvent&&this.detachEvent("ondragstart",c.dontstart)}},init:function(b){var a=b.data,d;if(!(a.which>0&&b.which!=a.which))if(!f(b.target).is(a.not))if(!(a.handle&&!f(b.target).closest(a.handle,b.currentTarget).length)){a.propagates=1;a.interactions=[c.interaction(this,a)];a.target=b.target;a.pageX=b.pageX;a.pageY=b.pageY;a.dragging=null;d=c.hijack(b,"draginit",a);if(a.propagates){if((d=c.flatten(d))&&d.length){a.interactions=[];f.each(d,function(){a.interactions.push(c.interaction(this,a))})}a.propagates= a.interactions.length;a.drop!==false&&h.drop&&h.drop.handler(b,a);c.textselect(false);i.add(document,"mousemove mouseup",c.handler,a);return false}}},interaction:function(b,a){return{drag:b,callback:new c.callback,droppable:[],offset:f(b)[a.relative?"position":"offset"]()||{top:0,left:0}}},handler:function(b){var a=b.data;switch(b.type){case !a.dragging&&"mousemove":if(Math.pow(b.pageX-a.pageX,2)+Math.pow(b.pageY-a.pageY,2)<Math.pow(a.distance,2))break;b.target=a.target;c.hijack(b,"dragstart",a); if(a.propagates)a.dragging=true;case "mousemove":if(a.dragging){c.hijack(b,"drag",a);if(a.propagates){a.drop!==false&&h.drop&&h.drop.handler(b,a);break}b.type="mouseup"}case "mouseup":i.remove(document,"mousemove mouseup",c.handler);if(a.dragging){a.drop!==false&&h.drop&&h.drop.handler(b,a);c.hijack(b,"dragend",a)}c.textselect(true);if(a.click===false&&a.dragging){jQuery.event.triggered=true;setTimeout(function(){jQuery.event.triggered=false},20);a.dragging=false}break}},delegate:function(b){var a= [],d,e=f.data(this,"events")||{};f.each(e.live||[],function(k,j){if(j.preType.indexOf("drag")===0)if(d=f(b.target).closest(j.selector,b.currentTarget)[0]){i.add(d,j.origType+"."+c.livekey,j.origHandler,j.data);f.inArray(d,a)<0&&a.push(d)}});if(!a.length)return false;return f(a).bind("dragend."+c.livekey,function(){i.remove(this,"."+c.livekey)})},hijack:function(b,a,d,e,k){if(d){var j={event:b.originalEvent,type:b.type},n=a.indexOf("drop")?"drag":"drop",l,o=e||0,g,m;e=!isNaN(e)?e:d.interactions.length; b.type=a;b.originalEvent=null;d.results=[];do if(g=d.interactions[o])if(!(a!=="dragend"&&g.cancelled)){m=c.properties(b,d,g);g.results=[];f(k||g[n]||d.droppable).each(function(q,p){l=(m.target=p)?i.handle.call(p,b,m):null;if(l===false){if(n=="drag"){g.cancelled=true;d.propagates-=1}if(a=="drop")g[n][q]=null}else if(a=="dropinit")g.droppable.push(c.element(l)||p);if(a=="dragstart")g.proxy=f(c.element(l)||g.drag)[0];g.results.push(l);delete b.result;if(a!=="dropinit")return l});d.results[o]=c.flatten(g.results); if(a=="dropinit")g.droppable=c.flatten(g.droppable);a=="dragstart"&&!g.cancelled&&m.update()}while(++o<e);b.type=j.type;b.originalEvent=j.event;return c.flatten(d.results)}},properties:function(b,a,d){var e=d.callback;e.drag=d.drag;e.proxy=d.proxy||d.drag;e.startX=a.pageX;e.startY=a.pageY;e.deltaX=b.pageX-a.pageX;e.deltaY=b.pageY-a.pageY;e.originalX=d.offset.left;e.originalY=d.offset.top;e.offsetX=b.pageX-(a.pageX-e.originalX);e.offsetY=b.pageY-(a.pageY-e.originalY);e.drop=c.flatten((d.drop||[]).slice()); e.available=c.flatten((d.droppable||[]).slice());return e},element:function(b){if(b&&(b.jquery||b.nodeType==1))return b},flatten:function(b){return f.map(b,function(a){return a&&a.jquery?f.makeArray(a):a&&a.length?c.flatten(a):a})},textselect:function(b){f(document)[b?"unbind":"bind"]("selectstart",c.dontstart).attr("unselectable",b?"off":"on").css("MozUserSelect",b?"":"none")},dontstart:function(){return false},callback:function(){}};c.callback.prototype={update:function(){h.drop&&this.available.length&& f.each(this.available,function(b){h.drop.locate(this,b)})}};h.draginit=h.dragstart=h.dragend=c})(jQuery);
//End jquery.event.drag - v 2.0.0

$(document).ready(function(){
	TopicTip.CheckAll();

/*	$('.drag').drag(function( ev, dd ){
		$( this ).css({
			top: dd.offsetY,
			left: dd.offsetX
		});
	},{ handle:".handle" });*/
}).click(function(e){
	MENU.Close(e);
})

