var core = {
	$: function(A) {
		return document.getElementById(A)
	},
	$new: function(A) {
		return document.createElement(A)
	},
	getBody: function() {
		return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement: document.body
	},

	getxy: function(G) {
		var I = G.offsetTop;
		var J = G.offsetLeft;
		var F = G.offsetWidth;
		var H = G.offsetHeight;
		while (G = G.offsetParent) {
			I += G.offsetTop;
			J += G.offsetLeft
		}
		return {
			x: J,
			y: I,
			w: F,
			h: H
		}
	},
	backTip: function(E, D) {
		E = E || 1;
		D = D || 16;
		var B = 0;
		var H = 0;
		var A = 0;
		var G = 0;
		if (document.documentElement) {
			B = document.documentElement.scrollLeft || 0;
			H = document.documentElement.scrollTop || 0
		}
		if (document.body) {
			A = document.body.scrollLeft || 0;
			G = document.body.scrollTop || 0
		}
		var I = Math.max(B, A);
		var F = Math.max(H, G);
		var C = 1 + E;
		return {
			l: I,
			t: F,
			s: C
		}
	}
};
function addEvent(D, A, C, B) {
	if (D) {
		if (D.addEventListener) {
			D[B ? "removeEventListener": "addEventListener"](A, C, false)
		} else {
			if (D.attachEvent) {
				D[B ? "detachEvent": "attachEvent"]("on" + A, C)
			} else {
				D["on" + A] = B ? null: C
			}
		}
	}
	return D
}
var hotTags = function() {
	function A() {
		var F = core.$new("div");
		F.className = "hot-label";
		F.setAttribute("id", "hot-tags");
		document.body.appendChild(F);
		core.$("hot-tags").innerHTML = '<a href="###" onfocus="this.blur()" class="btn-foldhot" id="foldHot"></a><a href="###" onfocus="this.blur()" class="btn-foldtop" id="foldTop"></a><div class="expand-label" id="expandLabel"><a href="###" class="btn-hotclose" id="hotClose"></a><div class="outer"><div class="inner" id="subhot-tags"><a href="/2008">黑刀部落-管巨侠的Blog</a><br><a href="http://www.phpjm.com" target="_blank">PHP加密网</a><br><a href="/rss" target="_blank">聚合中心</a><br><a href="/gyk.htm" target="_blank">管巨侠的秘密</a><br><a href="/onlinetool/" target="_blank">在线工具箱</a><br><a href="http://shop33563805.taobao.com/" target="_blank">黑刀部落淘宝旗舰店</a><br></div></div><a href="#" onfocus="this.blur()" class="btn-expandtop" id="btn-expandtop"></a>';
		hotTags.scrollLayer();
			core.$("foldHot").style.display = "none";
			core.$("foldTop").style.display = "none";
			core.$("expandLabel").style.display = "block";
			core.$("btn-expandtop").style.display = "block";
			hotTags.posLeft(core.$("hot-tags"))
	}
	function D() {
		addEvent(core.$("foldTop"), "click", hotTags.goTop);
		addEvent(core.$("btn-expandtop"), "click", hotTags.goTop);
		if (core.$("hotClose")) {
			core.$("hotClose").onclick = function() {
				B = 1;
				core.$("expandLabel").style.display = "none";
				core.$("btn-expandtop").style.display = "none";
				core.$("foldHot").style.display = "block";
				core.$("foldTop").style.display = "block";
				hotTags.posRight(core.$("hot-tags"))
			}
		}
		if (core.$("foldHot")) {
			core.$("foldHot").onclick = function() {
				B = 0;
				this.style.display = "none";
				core.$("foldTop").style.display = "none";
				core.$("expandLabel").style.display = "block";
				core.$("btn-expandtop").style.display = "block";
				hotTags.posLeft(core.$("hot-tags"))
			}
		}
	}
	return {
		init: function() {
			A();
			D()
		},
		posRight: function(F) {
			F.style.left = "";
			F.style.right = "0px";
			window.onresize = function() {
				F.style.left = "";
				F.style.right = "0px"
			};
			window.onscroll = function() {
				F.style.left = "";
				F.style.right = "0px"
			}
		},
		posLeft: function(F) {
			F.style.left = core.getBody().scrollWidth / 2 + 380 + "px";
			F.style.right = "";
			window.onresize = function() {
				F.style.left = core.getBody().scrollWidth / 2 + 380 + "px";
				F.style.right = ""
			};
			window.onscroll = function() {
				F.style.left = core.getBody().scrollWidth / 2 + 380 + "px";
				F.style.right = ""
			}
		},
		goTop: function() {
			window.scrollTo(0, 0);
			return false
		},
		scrollLayer: function() {
			var H = core.$("hot-tags");
			var J = 240;
			var F = 240;
			var I = 10;
			var K = core.backTip().t;
			K = K - core.getxy(H).y + J;
			K = core.getxy(H).y + K / 10;
			if (K < J) {
				K = J
			}
			if (K != F) {
				H.style.top = K + "px"
			}
			F = K;
			var G = "hotTags.scrollLayer()";
			window.setTimeout(G, I)
		}
	}
}();

addEvent(core.$("btnTop"), "click", hotTags.goTop);

(function() {
	if ($("#content")) {
		hotTags.init()
	}
	$(".btn-expand").toggle(function() {
		$(this).parent(".text-interaction").prev().show();
		$(this).html("收起")
	},
	function() {
		$(this).parent(".text-interaction").prev().hide();
		$(this).html("展开全部")
	});
})();
