Ext.override(Ext.Element, {
	unselectable : function() {
		this.dom.unselectable = "on";
		return this.swallowEvent("selectstart", true).applyStyles(
				"-moz-user-select:none;-khtml-user-select:none;").addClass(
				"x-unselectable")
	},
	swallowEvent : function(a, b) {
		var d = this;
		function c(f) {
			f.stopPropagation();
			if (b) {
				f.preventDefault()
			}
		}
		if (Ext.isArray(a)) {
			Ext.each(a, function(f) {
				d.on(f, c)
			});
			return d
		}
		d.on(a, c);
		return d
	},
	applyStyles : function(a) {
		Ext.DomHelper.applyStyles(this.dom, a);
		return this
	}
});
String.prototype.trim = function() {
	var a = /^\s+|\s+$/g;
	return function() {
		return this.replace(a, "")
	}
}();
Ext.ns("beez");
beez.Ajax = {
	conn : new Ext.data.Connection({
		method : "POST",
		timeout : 10000
	}),
	request : function(a) {
		var d = a.success;
		var b = a.failure;
		var c = a.scope;
		if (d) {
			a.success = function(f, g) {
				try {
					var h = Ext.decode(f.responseText);
					if (!h.error) {
						d.call(c, h);
						return
					}
				} catch (i) {
					alert(i)
				}
				g.failure(f, g)
			}
		}
		a.failure = function(f, g) {
			if (b) {
				b.apply(c, arguments)
			} else {
				try {
					var h = Ext.decode(f.responseText);
					if (h.error) {
						var i = h.error;
						alert("發生錯誤 (" + i.code + ")\n" + i.message);
						return
					} else {
						alert("發生錯誤\n" + f.responseText)
					}
				} catch (i) {
					console.error(i);
					alert("發生錯誤\n" + i);
					return
				}
			}
		};
		this.conn.request(a)
	}
};
Ext.ns("beez.util");
beez.util.StringUtils = {
	substitute : function(a, b) {
		return a.replace(/\${([^,\}]+),?([^\}]+)?\}/g, function(c, d, f) {
			d = d.trim();
			var e = b[d];
			if (e !== null && e !== undefined) {
				if (f) {
					console.error("Error to do the formatting for ", f, d, e)
				}
				return e
			} else {
				console.error('"' + d + '" is not in the input map.');
				return ""
			}
		})
	}
};
beez.CatererIntro = function(a) {
	this.number = a.number;
	this.thumbIdPrefix = a.thumbIdPrefix;
	this.contentIdPrefix = a.contentIdPrefix;
	this.time = a.time || 10000;
	for ( var b = 0; b < this.number; b++) {
		var c = Ext.fly(this.thumbIdPrefix + "-" + b);
		c.on("mouseenter", this.onMouseEnter, this, {
			index : b
		});
		c.on("mouseleave", this.onMouseLeave, this)
	}
	if (this.number > 0) {
		this.select(Math.floor(Math.random() * this.number))
	}
};
Ext
		.override(
				beez.CatererIntro,
				{
					overCls : "home-c-thumb-selected",
					onMouseEnter : function(b, c, a) {
						if (this.currentIndex !== a.index) {
							this.select(a.index, true)
						}
					},
					onMouseLeave : function() {
						this.autoNext()
					},
					select : function(b, d) {
						for ( var c = 0; c < this.number; c++) {
							if (c != b) {
								var e = Ext.fly(this.thumbIdPrefix + "-" + c);
								e.removeClass(this.overCls);
								var a = e.down(".mask-black", true);
								if (a) {
									a.style.display = ""
								} else {
									e.createChild({
										name : "mask",
										tag : "div",
										cls : "mask-black",
										style : {
											height : e.getHeight() + "px",
											width : e.getWidth() + "px"
										}
									}, null, true)
								}
								Ext.getDom(this.contentIdPrefix + "-" + c).style.display = "none"
							} else {
								var e = Ext.fly(this.thumbIdPrefix + "-" + c);
								e.addClass(this.overCls);
								var a = e.down(".mask-black", true);
								if (a) {
									a.style.display = "none"
								}
								Ext.getDom(this.contentIdPrefix + "-" + c).style.display = ""
							}
						}
						this.currentIndex = b;
						if (!d) {
							this.autoNext()
						} else {
							clearTimeout(this.timeoutId)
						}
					},
					autoNext : function() {
						clearTimeout(this.timeoutId);
						var a = (this.currentIndex + 1) % this.number;
						this.timeoutId = this.select.defer(this.time, this,
								[ a ])
					}
				});
beez.Album = function(a, c, b) {
	this.idPrefix = a;
	this.tabIdPrefix = c;
	this.albumNames = b
};
Ext.override(beez.Album, {
	show : function(d) {
		d = this.idPrefix + d;
		var e = this.albumNames;
		for ( var c = 0; c < e.length; c++) {
			var b = e[c];
			var g = Ext.get(this.tabIdPrefix + b);
			var a = this.idPrefix + b;
			var f = Ext.getDom(a);
			if (f) {
				if (d == a) {
					f.style.display = "";
					g.addClass("album-tab-selected")
				} else {
					f.style.display = "none";
					g.removeClass("album-tab-selected")
				}
			}
		}
	}
});
beez.AlbumPage = function(c, a, b) {
	this.thumbIdPrefix = c;
	this.imageCt = Ext.get(a);
	this.photoNum = b;
	this.currentIndex = 0;
	this.currentImage = this.imageCt.dom.firstChild
};
Ext.override(beez.AlbumPage, {
	show : function(a) {
		if (this.lock) {
			return

		}
		var c = Ext.getDom(this.thumbIdPrefix + a);
		if (c) {
			if (this.currentImage) {
				Ext.fly(this.currentImage).remove()
			}
			var d = Ext.getDom(this.thumbIdPrefix + this.currentIndex);
			if (d) {
				var b = d.firstChild;
				if (b) {
					Ext.fly(b).removeClass("cat-album-thumb-selected")
				}
			}
			var e = c.firstChild;
			if (e) {
				Ext.fly(e).addClass("cat-album-thumb-selected")
			}
			this.currentImage = this.imageCt.createChild({
				tag : "a",
				target : "_new",
				href : c.href,
				children : {
					tag : "img",
					src : c.href,
					alt : "",
					cls : "cat-album-img"
				}
			}, null, true);
			this.currentIndex = a
		}
	},
	next : function() {
		var a = this.currentIndex + 1;
		if (a >= this.photoNum) {
			a = 0
		}
		this.show(a)
	},
	previous : function() {
		var a = this.currentIndex - 1;
		if (a < 0) {
			a = this.photoNum - 1
		}
		this.show(a)
	}
});
beez.ImageLinkPreviewer = function(e) {
	var b = Ext.fly(e).query("a");
	for ( var c = 0, a = b.length; c < a; c++) {
		var d = b[c];
		if (!this.isImageLink(d)) {
			continue
		}
		d = Ext.fly(d);
		d.on("mouseenter", this.onMouseOver, this);
		d.on("mouseleave", this.onMouseOut, this);
		d.on("click", this.onClick, this)
	}
	Ext.getBody().on("click", this.destroyCurrent, this);
	this.timeout = []
};
Ext.override(beez.ImageLinkPreviewer, {
	onMouseOver : function(a, c) {
		var c = a.getTarget("a", 5);
		if (c && this.isImageLink(c)) {
			var b = c.getAttribute("state");
			if (!b || b == "hide") {
				this.showTimeout = this.showPreview.defer(300, this, [ c ]);
				c.setAttribute("state", "showing")
			} else {
				if (b != "showing") {
					this.showPreview(c)
				}
			}
		}
	},
	onMouseOut : function(a, c) {
		var c = a.getTarget("a", 5);
		if (c && this.isImageLink(c)) {
			var b = c.getAttribute("state");
			if (b == "show") {
				this.hideTimeout = this.hidePreview.defer(1500, this, [ c ]);
				c.setAttribute("state", "countdown")
			} else {
				if (b == "showing") {
					clearTimeout(this.showTimeout);
					c.setAttribute("state", "hide")
				}
			}
		}
	},
	onClick : function(b, c) {
		var c = b.getTarget("a", 5);
		if (c) {
			var a = window.open(c.href)
		}
		b.stopEvent()
	},
	showPreview : function(d) {
		var c = d.getAttribute("state");
		if (c == "showing") {
			if (d != this.currentTarget) {
				this.destroyCurrent()
			}
			this.currentTarget = d;
			var a = document.createElement("div");
			a.innerHTML = '<img src="' + d.href
					+ '" alt="" style="width: 400px"/>';
			a.className = "img-preview-wrap";
			targetEl = Ext.fly(d);
			var b = targetEl.getOffsetsTo(document.body);
			a.style.left = b[0] + "px";
			a.style.top = b[1] + d.offsetHeight + "px";
			d.appendChild(a);
			d.setAttribute("state", "show")
		} else {
			if (c == "countdown") {
				clearTimeout(this.hideTimeout);
				d.setAttribute("state", "show")
			}
		}
	},
	hidePreview : function(b) {
		if (b.getAttribute("state") != "countdown") {
			return

		}
		var a = b.lastChild;
		if (a && a.tagName == "DIV") {
			Ext.fly(a).hide({
				duration : 0.5,
				callback : this.doHidePreview,
				scope : this
			})
		}
		b.setAttribute("state", "hiding")
	},
	doHidePreview : function(b) {
		var c = Ext.getDom(b);
		if (!c) {
			return
		}
		var a = c.parentNode;
		if (!a) {
			return
		}
		Ext.fly(b).remove();
		a.setAttribute("state", "hide");
		this.currentTarget = null
	},
	destroyCurrent : function() {
		if (!this.currentTarget) {
			return

		}
		var a = this.currentTarget.lastChild;
		if (a && a.tagName == "DIV") {
			clearTimeout(this.hideTimeout);
			this.doHidePreview(a)
		}
	},
	isImageLink : function(b) {
		if (b.tagName == "A" && b.href) {
			var a = b.href.substr(b.href.length - 4).toLowerCase();
			if (a == ".jpg" || a == ".png" || a == ".gif" || a == ".bmp") {
				return true
			}
		}
		return false
	}
});
beez.Tooltip = function() {
};
Ext
		.override(
				beez.Tooltip,
				{
					showBy : function(e, c, h) {
						h = h || "r";
						e = Ext.get(e);
						if (!this.rendered) {
							this.render()
						}
						var f = e.getOffsetsTo(document.body);
						var a = f[0];
						var g = f[1];
						switch (h) {
						case "t":
							g -= this.dom.offsetHeight;
							break;
						case "l":
							a -= this.dom.offsetsetWidth;
							break;
						case "r":
							a += e.getWidth();
							break;
						case "b":
							g += e.getHeight();
							break
						}
						this.dom.style.left = a + "px";
						this.dom.style.top = g + "px";
						var d = Ext.get(this.dom);
						var b = d.child(".tooltip-mm", true);
						b.innerHTML = c;
						(function() {
							var i = (d.child(".tooltip-ml", true).offsetWidth - 36);
							if (i > 0) {
								d.child(".tooltip-tm", true).style.width = i
										+ "px";
								d.child(".tooltip-bm", true).style.width = i
										+ "px"
							}
						}).defer(100)
					},
					close : function() {
						Ext.fly(this.dom).remove();
						delete this.dom
					},
					render : function(a) {
						a = Ext.getDom(a || document.body);
						var b = this.dom = document.createElement("div");
						b.className = "tooltip-wrap";
						b.innerHTML = '<div class="tooltip-tl"><div class="tooltip-tr"><div class="tooltip-tm"></div></div></div><div class="tooltip-ml"><div class="tooltip-mr"><div class="tooltip-mm">'
								+ this.content
								+ '</div></div></div><div class="tooltip-bl"><div class="tooltip-br"><div class="tooltip-bm"></div></div></div>';
						a.appendChild(b);
						this.rendered = true
					}
				});
Ext.ns("beez");
beez.Comments = function(a) {
	this.lastDate = null;
	this.listUrl = "/a/post/listCatererComment/" + a.catererId;
	this.postUrl = "/a/post/postCatererComment";
	this.replyUrl = "/a/post/replyCatererComment";
	this.catererId = a.catererId;
	this.commentFormCt = Ext.getDom(a.commentFormCt);
	this.commentForm = Ext.getDom(a.commentForm);
	this.showMoreBtn = Ext.getDom(a.showMoreBtn)
};
beez.Comments.prototype = {
	commentHtml : '<div class="cat-post-wrap"><div class="cat-post-wrap-inner"><div class="cat-post-body"><div class="cat-post-left"><div class="cat-post-pic" style="background-image: url(${image})"></div><div class="h5">${username}</div></div><div class="cat-post-right"><div><span class="h4">${topic}</span><span class="font-silver" style="margin-left:20px; font-style:italic">${date}</span></div><div style="margin-top:10px">${content}</div></div><div class="clear"></div></div></div></div><div id="replies-${postId}">${replies}</div>'
			+ (up4food.isLoggedIn ? ('<div class="cat-reply-btn" onclick="up4food.comments.showReplyForm(this, ${postId})">回覆</div><div class="cat-reply-wrap" style="display:none"><form method="POST" action="" onsubmit="up4food.comments.postReply(this); return false"><div class="h5 v-spacing-3">回覆:</div><div><textarea id="reply-${postId}" rows="3" name="content" class="form-input"></textarea></div><div class="right"><input type="submit" value="回覆" class="cat-reply-submit-btn" /></div><input type="hidden" name="postId" value="${postId}"/></form></div>')
					: ""),
	replyHtml : '<div class="cat-reply-wrap"><div class="cat-reply-left"><div class="cat-reply-pic" style="background-image: url(${image})"></div><div class="h5">${username}</div></div><div class="cat-reply-right"><div>${content}</div></div><div class="clear"></div></div>',
	render : function(a) {
		this.ct = Ext.getDom(a);
		this.loadComments()
	},
	loadComments : function() {
		this.lock = true;
		beez.Ajax.request({
			url : this.listUrl,
			params : {
				lastDate : this.lastDate
			},
			success : function(a) {
				var b = a.comments;
				this.addComments(b);
				this.showMoreBtn.style.display = (a.hasMore ? "" : "none")
			},
			scope : this
		})
	},
	addComments : function(g) {
		try {
			if (g && g.length > 0) {
				var k = [];
				for ( var d = 0; d < g.length; d++) {
					var f = g[d];
					var h = f.Replies;
					if (h && h.length > 0) {
						var e = [];
						for ( var c = 0; c < h.length; c++) {
							var b = h[c];
							e.push(beez.util.StringUtils.substitute(
									this.replyHtml, {
										date : b.created.substring(0, 16),
										username : b.CreatedBy.displayName,
										content : b.content,
										image : "/img/empty-user.png"
									}))
						}
						h = e.join("")
					}
					k.push(beez.util.StringUtils.substitute(this.commentHtml, {
						date : f.created.substring(0, 16),
						username : f.CreatedBy.displayName,
						topic : f.topic,
						content : f.content,
						replies : h || "",
						postId : f.id,
						image : "/img/empty-user.png"
					}));
					this.lastId = f.id
				}
				var a = document.createElement("div");
				this.ct.appendChild(a);
				a.innerHTML = k.join("")
			}
		} finally {
			this.lock = false
		}
	},
	clearComments : function() {
		this.ct.innerHTML = ""
	},
	addReplies : function(e, d) {
		var b = [];
		for ( var a = 0; a < d.length; a++) {
			var c = d[a];
			b.push(beez.util.StringUtils.substitute(this.replyHtml, {
				date : c.created.substring(0, 16),
				username : c.CreatedBy.displayName,
				image : "/img/empty-user.png",
				content : c.content
			}))
		}
		Ext.getDom("replies-" + e).innerHTML = b.join("")
	},
	clearReplies : function(a) {
		Ext.getDom("replies-" + a).innerHTML = ""
	},
	showCommentForm : function() {
		if (!up4food.isLoggedIn) {
			alert("請先登入")
		} else {
			this.commentFormCt.style.display = "";
			var a = CKEDITOR.replace("comment");
			a.setData("");
			a.focus()
		}
	},
	postComment : function() {
		var a = this.commentForm.topic.value;
		var b = CKEDITOR.instances[this.commentForm.content.id];
		var c = b.getData();
		c.replace(/<p>[\r\n\s]*&nbsp;<\/p>[\r\n\s]*/, "");
		c.replace(/<div .*?firebugversion.*?>.*?<\/div>[\r\n\s]*/, "");
		beez.Ajax.request({
			url : this.postUrl,
			params : {
				catererId : this.catererId,
				topic : a,
				content : c
			},
			success : function(d) {
				b.setData("");
				this.clearComments();
				var e = d.comments;
				this.addComments(e);
				this.showMoreBtn.style.display = (d.hasMore ? "" : "none");
				this.commentFormCt.style.display = "none"
			},
			scope : this
		})
	},
	showReplyForm : function(a, d) {
		a.style.display = "none";
		a.nextSibling.style.display = "";
		var c = "reply-" + d;
		var b = CKEDITOR.replace(c);
		b.setData("");
		b.focus()
	},
	postReply : function(d) {
		var a = d.postId.value;
		var b = CKEDITOR.instances[d.content.id];
		var c = b.getData();
		c.replace(/<p>[\r\n\s]*&nbsp;<\/p>[\r\n\s]*/, "");
		c.replace(/<div .*?firebugversion.*?>.*?<\/div>[\r\n\s]*/, "");
		beez.Ajax.request({
			url : this.replyUrl,
			params : {
				postId : a,
				content : c
			},
			success : function(e) {
				b.setData("");
				this.clearReplies(a);
				var f = e.replies;
				this.addReplies(a, f)
			},
			scope : this
		})
	},
	showMore : function() {
		this.loadComments()
	}
};
Ext.ns("beez.bar");
beez.bar.BarHomeRecommend = function(c) {
	var a = this.pages = [];
	this.ct = Ext.get(c);
	for ( var b = 1; b < arguments.length; b++) {
		var d = arguments[b];
		d.header = Ext.get(d.header);
		d.header.on("click", this.onHeaderClick, this, {
			idx : b - 1
		});
		a.push(d)
	}
	this.showPage(0)
};
Ext.override(beez.bar.BarHomeRecommend, {
	showPage : function(a) {
		var b = this.pages[a];
		if (isNaN(this.currentIndex)) {
		} else {
			this.ct
					.replaceClass("rcd-wrap" + this.currentIndex, "rcd-wrap"
							+ a)
		}
		this.currentIndex = a;
		clearTimeout(this.timeout);
		this.timeout = this.showPage.defer(b.stayInterval, this, [ (a + 1)
				% this.pages.length ])
	},
	onHeaderClick : function(b, c, a) {
		this.showPage(a.idx)
	},
	autoNext : function() {
		clearTimeout(this.timeoutId);
		var a = (this.currentIndex + 1) % this.number;
		this.timeoutId = this.select.defer(this.time, this, [ a ])
	}
});
Ext.ns("beez.action");
beez.action = {
	like : function(a, b) {
		beez.Ajax.request({
			url : "/a/user/like",
			params : {
				id : b,
				type : a
			},
			success : function(c) {
				if (c.html) {
					var d = Ext.getDom("like-" + a + b);
					if (d) {
						d.innerHTML = c.html
					}
				}
			}
		})
	},
	showShareTip : function(d, b) {
		var a;
		switch (b) {
		case "facebook":
			a = '<div class="n4"><img src="/img/icon-fb.png" alt="" class="valign-mid" /> 分享到 Facebook</div><div class="font-silver h-spacing-3">分享這間餐廳到 Facebook</div>';
			break;
		case "twitter":
			a = '<div class="n4"><img src="/img/icon-twit.png" alt="" class="valign-mid" /> 分享到 Twitter</div><div class="font-silver h-spacing-3">分享這間餐廳到 Twitter</div>';
			break;
		case "email":
			a = '<div class="n4"><img src="/img/icon-email.png" alt="" class="valign-mid" /> Email 給朋友</div><div class="font-silver h-spacing-3">Email 這間餐廳給朋友</div>';
			break
		}
		var c = new beez.Tooltip();
		c.showBy(d, a, "b");
		Ext.fly(d).on("mouseleave", c.close, c, {
			single : true
		})
	},
	showLogin : function(d) {
		var a = '<form method="POST" action="/user/login"><table><tr><td>用戶名稱：</td><td><input id="login-name" name="username" size="10" /></td></tr><tr><td>密碼:</td><td><input type="password" name="password" size="10" /><br /></td></tr><tr><td colspan="2">自動登入: <input type="checkbox" name="rememberMe" checked="checked" /></td></tr><tr><td><input type="hidden" name="redirectUrl" value="'
				+ document.URL
				+ '" /><input type="submit" value="登入" /></td></tr></table></form>';
		var c = new beez.Tooltip();
		c.showBy(d, a, "b");
		var b = function(e) {
			if (!e.within(c.dom, false, true)) {
				c.close();
				Ext.getBody().un("click", b)
			}
		};
		setTimeout(function() {
			Ext.getBody().on("click", b);
			Ext.getDom("login-name").focus()
		}, 1)
	},
	shareToFb : function() {
		var a = "http://www.facebook.com/sharer.php?u="
				+ encodeURIComponent(document.URL);
		fbShareWindow = window.open(a, "fbShare",
				"toolbar=0,status=0,width=626,height=436")
	},
	shareToTwitter : function(a) {
		var b = window.open("http://twitter.com/home?status="
				+ encodeURIComponent("[推介餐廳] " + a + ": " + document.URL),
				"twitterShare")
	},
	shareByEmail : function(a) {
		var b = window.open("http://www.up4food.com/toRecommend/?catererId="
				+ a, "emailShare", "toolbar=0,status=0,width=816,height=685")
	},
	showMarkerInfo : function(b) {
		var a = this._data;
		this.openInfoWindowHtml(this._catererInfo(a))
	},
	connectFacebook : function() {
		FB.login(function(a) {
			if (a.session) {
				location.reload()
			} else {
				alert("抱歉，未能連接上facebook")
			}
		}, {
			perms : "offline_access"
		})
	},
	showAdListTooltip : function(c, f) {
		if (f.tagName != "A") {
			return

		}
		var a = f.getAttribute("list");
		var g = f.getAttribute("item");
		if (!g || !a) {
			return
		}
		var e = up4food.adLists[a][g].caterer;
		var b = this._catererInfo(e);
		var d = new beez.Tooltip();
		d.showBy(f, b, "r");
		Ext.fly(f).on("mouseleave", d.close, d, {
			single : true
		})
	},
	popupRRG : function(a, e, d) {
		if (!e) {
			return
		}
		var f = document.getElementById("rrg-from");
		var b = f.value;
		if (!b || b == f.title) {
			alert("請先輸入出發地點");
			return
		}
		b = encodeURI(b);
		a = encodeURI(a);
		var c = "http://www.roadroadguide.com/?ori=" + b + "&dest=" + a
				+ "&destLat=" + e + "&destLng=" + d + "&id=225";
		window
				.open(
						c,
						"rrg",
						"menubar=0,resizable=1,alwaysRaised=yes,scrollbars=yes,toolbar=no,status=yes,width=1000,height=700")
	},
	showEnquiryForm : function(b) {
		var a = "/enquiry/compose" + (b ? "/" + b : "");
		window
				.open(a, "enquiry",
						"height=670,width=698,scrollbars,resizable,location=0,menubar=0,toolbar=0")
	},
	_catererInfo : function(f) {
		var d = '<div class="caterer-info-tip-wrap"><a href="/caterer/'
				+ f.ckey
				+ '"><div class="font-green-b-16" style="margin-bottom: 5px;">'
				+ f.name
				+ '</div><div class="float" style="height:90px; width:70px; overflow:hidden"><img src="'
				+ f.logo
				+ '" alt="" /></div><div class="caterer-info-tip-detail">';
		var a = {
			region : "地區",
			theme : "主題",
			cuisine : "菜式",
			facilities : "設施",
			shortDescription : "簡介"
		};
		for ( var c in a) {
			var b = a[c];
			var e = f[c];
			if (e) {
				if (c == "shortDescription") {
					e = e.substr(0, 50) + " ..."
				}
				d += '<div><span class="b">' + b + "： </span>" + e + "</div>"
			}
		}
		d += '</div><div class="clear" style="height: 1px;"></div></a>';
		return d
	}
};
beez.behavior = {
	tipsInputBox : function(b, a, d) {
		b.value = a;
		b.title = a;
		var c = Ext.fly(b);
		c.addClass(d);
		c.on("focus", function() {
			var e = Ext.fly(b);
			e.removeClass(d);
			b.value = ""
		}, window, {
			single : true
		})
	}
};
beez.topMenu = function(c, e) {
	this.ct = Ext.get(c);
	this.el = e;
	this.k = [];
	for ( var b = 0; b < e.length; b++) {
		var d = e[b];
		this.addMenu(d);
		a = Ext.fly(this.currentMenu);
		a.on("mouseenter", this.onMouseOver, this, {vl: d.value, i: b, n: d.itemid});
		a.on("mouseleave", this.onMouseOut, this, {vl: d.value, i: b, n: d.itemid});
	}
};
Ext.override(beez.topMenu, {
	addMenu : function(d) {
		var a = document.createElement("div");
		a.innerHTML = d.name;
		a.id = d.id;
		a.className = "toolbar-l toolbar-menu";
		this.ct.appendChild(a);
		this.currentMenu = a;
		this.k.push(0);
	},
	onMouseOver : function(a, c, e) {
		if(this.k[e.i] == 0) {
			this.currentTarget = c;
			var d = document.createElement("div");
			d.id = e.n;
			d.className = "toolbar-menu-wrap";
			targetEl = Ext.fly(c);
			var g = targetEl.getOffsetsTo(document.body);
			d.style.left = g[0] + "px";
			d.style.top = g[1] + c.offsetHeight + "px";
			var f = '<table>';
			for(var b in e.vl){
				if(b != 'remove') 
					f += '<tr><td><a href="/caterer/search?query='+e.vl[b]+'">'+b+'</a></td></tr>';
			}
			f += '</table>';
			d.innerHTML = f;
			c.appendChild(d);
			this.k[e.i] = 1;
		} else {
			this.closeAll();
			d = Ext.fly(e.n).applyStyles("display: inline;");
		}
	},
	onMouseOut : function(a, c, e) {
		var b = c.lastChild;
		Ext.fly(b).applyStyles("display: none;");
//		var b = c.lastChild;
//		if (b && b.tagName == "DIV") {
//			Ext.fly(b).hide({
//				duration : 0.5,
//				scope : this
//			});
//		}
	},
	closeAll : function() {
		for ( var b = 0; b < this.el.length; b++) {
			var d = this.el[b];
			Ext.fly(d.itemid).applyStyles("display: none;");
		}
	}
});
