if (typeof $WH == "undefined") {
	$WH = {
		wowheadRemote: true
	}
}
if (typeof $WowheadPower == "undefined") {
	var $WowheadPower = new
	function () {
		var V = $WH.wowheadRemote;
		var z = {
			applyto: 3
		},
			t = document.getElementsByTagName("head")[0],
			H = false,
			i, P, T, K, v, Z, N, L, k = 0,
			ae = false,
			O = {},
			j = {},
			A = {},
			I = {},
			U = {},
			ag = {},
			g = {},
			f = {},
			Y = 1,
			C = 1,
			S = 0,
			Q = 1,
			l = 2,
			w = 3,
			R = 4,
			x = 1,
			n = 2,
			E = 3,
			J = 5,
			y = 6,
			q = 10,
			ab = 16,
			m = 100,
			s = 15,
			G = 15,
			D = {
				loading: "Loading...",
				noresponse: "No response from server :(",
				achievementcomplete: "Achievement earned by $1 on $2/$3/$4"
			},
			u = {
				1: [O, "npc", "NPC"],
				2: [j, "object", "Object"],
				3: [A, "item", "Item"],
				5: [I, "quest", "Quest"],
				6: [U, "spell", "Spell"],
				10: [ag, "achievement", "Achievement"],
				16: [g, "statistic", "Statistic"],
				100: [f, "profile", "Profile"]
			},
			e = {
				0: "enus",
				2: "frfr",
				3: "dede",
				6: "eses",
				7: "ruru",
				ptr: "ptr",
				beta: "beta"
			},
			c = {
				wotlk: "www"
			};
		if (V) {
			var b = {
				getId: function () {
					return 0
				},
				getName: function () {
					return "enus"
				}
			}
		}
		if (H) {} else {
			c.ptr = "www"
		}
		function aa() {
			if (V) {
				var ah = document.createElement("script");
				ah.src = "http://static.wowhead.com/js/basic.js?5";
				t.appendChild(ah)
			} else {
				W()
			}
		}
		function W() {
			if (ae) {
				return
			}
			ae = true;
			$WH.aE(document, "mouseover", B)
		}
		this.init = function () {
			if (V) {
				$WH.ae(t, $WH.ce("link", {
					type: "text/css",
					href: "http://static.wowhead.com/css/basic.css?5",
					rel: "stylesheet"
				}))
			}
			W()
		};

		function r(ah) {
			var ai = $WH.g_getCursorPos(ah);
			N = ai.x;
			L = ai.y
		}
		function ad(au, ap) {
			if (au.nodeName != "A" && au.nodeName != "AREA") {
				return -2323
			}
			if (!au.href.length) {
				return
			}
			if (au.rel && au.rel.indexOf("np") != -1) {
				return
			}
			var am, al, aj, ai, an = {};
			v = an;
			var ah = function (av, ax, aw) {
				if (ax == "buff" || ax == "sock") {
					an[ax] = true
				} else {
					if (ax == "rand" || ax == "ench" || ax == "lvl" || ax == "c") {
						an[ax] = parseInt(aw)
					} else {
						if (ax == "gems" || ax == "pcs") {
							an[ax] = aw.split(":")
						} else {
							if (ax == "who" || ax == "domain") {
								an[ax] = aw
							} else {
								if (ax == "when") {
									an[ax] = new Date(parseInt(aw))
								}
							}
						}
					}
				}
			};
			if (z.applyto & 1) {
				al = 2;
				aj = 3;
				if (au.href.indexOf("http://") == 0) {
					am = 1;
					ai = au.href.match(/^http:\/\/(.+?)?\.?wowhead\.com\/\??(item|quest|spell|achievement|statistic|npc|object)=([0-9]+)/);
					if (ai == null) {
						ai = au.href.match(/^http:\/\/(.+?)?\.?wowhead\.com\/\??(profile)=([^&#]+)/)
					}
					C = 0
				} else {
					ai = au.href.match(/()\??(item|quest|spell|achievement|statistic|npc|object)=([0-9]+)/);
					if (ai == null) {
						ai = au.href.match(/()\??(profile)=([^&#]+)/)
					}
					C = 1
				}
			}
			if (ai == null && au.rel && (z.applyto & 2)) {
				am = 0;
				al = 1;
				aj = 2;
				ai = au.rel.match(/(item|quest|spell|achievement|statistic|npc|object).?([0-9]+)/);
				if (ai == null) {
					ai = au.rel.match(/(profile).?([^&#]+)/)
				}
				C = 1
			}
			au.href.replace(/([a-zA-Z]+)=?([a-zA-Z0-9:-]*)/g, ah);
			if (au.rel) {
				au.rel.replace(/([a-zA-Z]+)=?([a-zA-Z0-9:-]*)/g, ah)
			}
			if (an.gems && an.gems.length > 0) {
				var ao;
				for (ao = Math.min(3, an.gems.length - 1); ao >= 0; --ao) {
					if (parseInt(an.gems[ao])) {
						break
					}
				}++ao;
				if (ao == 0) {
					delete an.gems
				} else {
					if (ao < an.gems.length) {
						an.gems = an.gems.slice(0, ao)
					}
				}
			}
			if (ai) {
				var at, ak = "www";
				Z = au;
				if (an.domain) {
					ak = an.domain
				} else {
					if (am && ai[am]) {
						ak = ai[am]
					}
				}
				if (c[ak]) {
					ak = c[ak]
				}
				at = $WH.g_getLocaleFromDomain(ak);
				if (ak == "ptr") {
					at = "ptr"
				} else {
					if (ak == "beta" || ak == "cata") {
						at = "beta"
					}
				}
				K = ak;
				if (au.href.indexOf("#") != -1 && document.location.href.indexOf(ai[al] + "=" + ai[aj]) != -1) {
					return
				}
				k = ((au.parentNode.className.indexOf("icon") == 0 && au.parentNode.nodeName == "DIV") ? 1 : 0);
				if (!au.onmouseout) {
					if (k == 0) {
						au.onmousemove = a
					}
					au.onmouseout = ac
				}
				r(ap);
				var ar = $WH.g_getIdFromTypeName(ai[al]),
					aq = ai[aj];
				F(ar, aq, at, an)
			}
		}
		function B(aj) {
			aj = $WH.$E(aj);
			var ai = aj._target;
			var ah = 0;
			while (ai != null && ah < 5 && ad(ai, aj) == -2323) {
				ai = ai.parentNode;
				++ah
			}
		}
		function a(ah) {
			ah = $WH.$E(ah);
			r(ah);
			$WH.Tooltip.move(N, L, 0, 0, s, G)
		}
		function ac() {
			i = null;
			Z = null;
			$WH.Tooltip.hide()
		}
		function X(ah) {
			return (v && v.buff ? "buff_" : "tooltip_") + e[ah]
		}
		function o(ai, ak, aj) {
			var ah = u[ai][0];
			if (ah[ak] == null) {
				ah[ak] = {}
			}
			if (ah[ak].status == null) {
				ah[ak].status = {}
			}
			if (ah[ak].status[aj] == null) {
				ah[ak].status[aj] = S
			}
		}
		function F(ai, am, ak, al) {
			if (!al) {
				al = {}
			}
			var aj = h(am, al);
			i = ai;
			P = aj;
			T = ak;
			v = al;
			o(ai, aj, ak);
			var ah = u[ai][0];
			if (ah[aj].status[ak] == R || ah[aj].status[ak] == w) {
				af(ah[aj][X(ak)], ah[aj].icon)
			} else {
				if (ah[aj].status[ak] == Q) {
					af(D.loading)
				} else {
					d(ai, am, ak, null, al)
				}
			}
		}
		function d(aq, al, ar, aj, am) {
			var ah = h(al, am);
			var ao = u[aq][0];
			if (ao[ah].status[ar] != S && ao[ah].status[ar] != l) {
				return
			}
			ao[ah].status[ar] = Q;
			if (!aj) {
				ao[ah].timer = setTimeout(function () {
					p.apply(this, [aq, ah, ar])
				}, 333)
			}
			var ak = "";
			for (var an in am) {
				if (an != "rand" && an != "ench" && an != "gems" && an != "sock") {
					continue
				}
				if (typeof am[an] == "object") {
					ak += "&" + an + "=" + am[an].join(":")
				} else {
					if (an == "sock") {
						ak += "&sock"
					} else {
						ak += "&" + an + "=" + am[an]
					}
				}
			}
			var ap = $WH.g_getDomainFromLocale(ar);
			if (ar == "ptr") {
				ap = "ptr"
			} else {
				if (ar == "beta") {
					ap = "cata"
				}
			}
			var ai = "";
			if (typeof g_dev == "undefined" || !g_dev) {
				ai += "http://" + ap + ".wowhead.com"
			} else {
				if (window.location.hostname.indexOf("dev.wowhead.com") != -1) {
					if (ap != "www" && window.location.hostname.indexOf(ap) != 0) {
						ai += "http://" + ap + "." + window.location.hostname
					}
				}
			}
			ai += "/" + u[aq][1] + "=" + al + "&power" + ak;
			$WH.g_ajaxIshRequest(ai)
		}
		function af(ak, al) {
			if (Z && Z._fixTooltip) {
				ak = Z._fixTooltip(ak, i, P, Z)
			}
			var am = false;
			if (!ak) {
				ak = u[i][2] + " not found :(";
				al = "inv_misc_questionmark";
				am = true
			} else {
				if (v != null) {
					if (v.pcs && v.pcs.length) {
						var an = P.match(/^(\d+)/);
						an = an[1];
						var ao = 0;
						for (var aj = 0, ai = v.pcs.length; aj < ai; ++aj) {
							var ah;
							if (ah = ak.match(new RegExp("<span><!--si([0-9]+:)*" + v.pcs[aj] + '(:[0-9]+)*--><a href="/??item=(\\d+)">(.+?)</a></span>'))) {
								ak = ak.replace(ah[0], '<span class="q8"><!--si' + v.pcs[aj] + '--><a href="/item=' + ah[3] + '">' + (($WH.isset("g_items") && g_items[v.pcs[aj]]) ? g_items[v.pcs[aj]]["name_" + e[T]] : ah[4]) + "</a></span>");
								++ao
							}
						}
						if (ao > 0) {
							ak = ak.replace("(0/", "(" + ao + "/");
							ak = ak.replace(new RegExp("<span>\\(([0-" + ao + "])\\)", "g"), '<span class="q2">($1)')
						}
					}
					if (v.lvl) {
						ak = $WH.g_setTooltipLevel(ak, v.lvl, v.buff)
					}
					if (v.who && v.when) {
						ak = ak.replace("<table><tr><td><br />", '<table><tr><td><br /><span class="q2">' + $WH.sprintf(D.achievementcomplete, v.who, v.when.getMonth() + 1, v.when.getDate(), v.when.getFullYear()) + "</span><br /><br />");
						ak = ak.replace(/class="q0"/g, 'class="r3"')
					}
				}
			}
			if (k == 1) {
				$WH.Tooltip.setIcon(null);
				$WH.Tooltip.show(Z, ak)
			} else {
				$WH.Tooltip.setIcon(al);
				$WH.Tooltip.showAtXY(ak, N, L, s, G)
			}
			if (V && $WH.Tooltip.logo) {
				$WH.Tooltip.logo.style.display = (C ? "block" : "none")
			}
		}
		function p(ai, ak, aj) {
			if (i == ai && P == ak && T == aj) {
				af(D.loading);
				var ah = u[ai][0];
				ah[ak].timer = setTimeout(function () {
					M.apply(this, [ai, ak, aj])
				}, 3850)
			}
		}
		function M(ai, ak, aj) {
			var ah = u[ai][0];
			ah[ak].status[aj] = l;
			if (i == ai && P == ak && T == aj) {
				af(D.noresponse)
			}
		}
		function h(ai, ah) {
			return ai + (ah.rand ? "r" + ah.rand : "") + (ah.ench ? "e" + ah.ench : "") + (ah.gems ? "g" + ah.gems.join(",") : "") + (ah.sock ? "s" : "")
		}
		this.register = function (aj, al, ak, ai) {
			var ah = u[aj][0];
			o(aj, al, ak);
			if (ah[al].timer) {
				clearTimeout(ah[al].timer);
				ah[al].timer = null
			}
			$WH.cO(ah[al], ai);
			if (ah[al].status[ak] == Q) {
				if (ah[al][X(ak)]) {
					ah[al].status[ak] = R
				} else {
					ah[al].status[ak] = w
				}
			}
			if (i == aj && al == P && T == ak) {
				af(ah[al][X(ak)], ah[al].icon)
			}
		};
		this.registerNpc = function (aj, ai, ah) {
			this.register(x, aj, ai, ah)
		};
		this.registerObject = function (aj, ai, ah) {
			this.register(n, aj, ai, ah)
		};
		this.registerItem = function (aj, ai, ah) {
			this.register(E, aj, ai, ah)
		};
		this.registerQuest = function (aj, ai, ah) {
			this.register(J, aj, ai, ah)
		};
		this.registerSpell = function (aj, ai, ah) {
			this.register(y, aj, ai, ah)
		};
		this.registerAchievement = function (aj, ai, ah) {
			this.register(q, aj, ai, ah)
		};
		this.registerStatistic = function (aj, ai, ah) {
			this.register(ab, aj, ai, ah)
		};
		this.registerProfile = function (aj, ai, ah) {
			this.register(m, aj, ai, ah)
		};
		this.request = function (ah, al, aj, ak) {
			if (!ak) {
				ak = {}
			}
			var ai = h(al, ak);
			o(ah, ai, aj);
			d(ah, al, aj, 1, ak)
		};
		this.requestItem = function (ai, ah) {
			this.request(E, ai, b.getId(), ah)
		};
		this.requestSpell = function (ah) {
			this.request(y, ah, b.getId())
		};
		this.getStatus = function (ai, ak, aj) {
			var ah = u[ai][0];
			if (ah[ak] != null) {
				return ah[ak].status[aj]
			} else {
				return S
			}
		};
		this.getItemStatus = function (ai, ah) {
			this.getStatus(E, ai, ah)
		};
		this.getSpellStatus = function (ai, ah) {
			this.getStatus(y, ai, ah)
		};
		if (V) {
			this.set = function (ah) {
				$WH.cO(z, ah)
			};
			this.showTooltip = function (aj, ah, ai) {
				r(aj);
				af(ah, ai)
			};
			this.hideTooltip = function () {
				$WH.Tooltip.hide()
			};
			this.moveTooltip = function (ah) {
				a(ah)
			}
		}
		aa()
	}
};
