function fireDOMContentLoaded() {
	initSuggest();
	initMenus();

	document.getElementById('logo').onclick = function(){
		document.location.href = location.pathname;
	}

	var sideBtn = document.getElementById('sideBarButton'), side = document.getElementById('sideBar');
	if(sideBtn){
		sideBtn.onclick = function(){
			var mod = side.style.display.toLowerCase();
			if(mod == 'none'){
				side.style.display = '';
				sideBtn.className = 'sideBarButton';
			} else {
				side.style.display = 'none';
				sideBtn.className = ' sideBarButton-collapsed';
			}
		}

		function showrelated(){
			if(document.body.offsetWidth < 1150){
				document.getElementById('rand-info').style.display = 'none';
			} else {
				document.getElementById('rand-info').style.display = 'block';
			}
			if(document.body.offsetWidth < 1002){
				side.style.display = 'none';
				sideBtn.style.display = 'none';
			}else {
				side.style.display = 'block';
				sideBtn.style.display = 'block';
			}
		}

		showrelated();
		window.onresize = showrelated;
	} else {
		setTimeout(function(){document.getElementById('word').focus();}, 500);
	}
}

function stopPropagation(a) {
	a = a.browserEvent || a;
	if (a.stopPropagation) a.stopPropagation();
	else a.cancelBubble = true
}

function addEvent(a, b, c, d) {
	if (a.addEventListener) a.addEventListener(b, c, d);
	else a.attachEvent && a.attachEvent("on" + b, c)
}

if (document.addEventListener){
	document.addEventListener("DOMContentLoaded", fireDOMContentLoaded, false);
}else{
	var timer = setInterval(function() {
		try {
			document.body.doScroll("left");
			fireDOMContentLoaded();
			window.clearInterval(timer)
		} catch(a) {}
	});
}

function initMenus() {
	setMenu("main-link", "main-list", 0, 0);
	setMenu("more-link", "more-list", 0, 0)
}

function initSuggest() {
	if (xlfqs) {
		window.aa = new xlfqs.Autocomplete("word", "aa");
		var otips = document.getElementById("otips");
		xlfqs.events.listen(otips, "click", xlfqs.bind(window.aa.pressPoint, window.aa));
		xlfqs.events.listen(otips, "mouseover", xlfqs.bind(window.aa.removeBoxBlur, window.aa));
		xlfqs.events.listen(otips, "mouseout", xlfqs.bind(window.aa.revertBoxBlur, window.aa))
	}
}

function setMenu(a, b, c, d) {
	var f = document.getElementById(a), e = document.getElementById(b);
	function h(g) {
		if (e.style.display == "block") e.style.display = "none";
		else {
			var i = f.offsetLeft + c,
			j = f.offsetTop + f.offsetHeight + d;
			e.style.ZIndex = "1000";
			e.style.left = i + "px";
			e.style.top = j + "px";
			e.style.display = "block"
		}
		stopPropagation(g)
	}
	function k(g) {
		e.style.display = "none"
	}
	f.href = "javascript:void(0)";
	addEvent(document, "click", k);
	addEvent(f, "click", h)
}
var senders = [],
senderIndex = 0;

function sendRequest(a) {
	var b = Math.random(),
	c = new Image;
	c.src = a + "&_=" + b;
	if (senderIndex >= 50) senderIndex = 0;
	senders[senderIndex++] = c
}

