// 首页搜索
function cancelBubble(e){
	e = e?e:window.event;
	e.cancelBubble = true;
}
var contextPath='';
var searchMenu={
	init:function(path){
		if(path!=undefined) contextPath=path;
		try{
			document.getElementById("searchmenu").innerHTML="<a href=\"#\" onclick=\"searchMenu.to(0);return false;\">游戏搜索</a>"
				+"<a href=\"#\" onclick=\"searchMenu.to(1);return false;\">玩家搜索</a>"
				+"<a href=\"#\" onclick=\"searchMenu.to(2);return false;\">网站资讯</a>";
//				+"<a href=\"#\" onclick=\"searchMenu.to(3);return false;\">论坛帖子</a>";
		}catch(e){}
		var tempFunc = document.onclick;
		document.onclick = function(){
			if (typeof (tempFunc) == "function"){
				try{
					tempFunc();
				} catch(e){}
			}
			try{document.getElementById("searchmenu").style.display="none";}catch(e){}
		}
	},
	click:function(e){
		cancelBubble(e);
		if(document.getElementById("searchmenu").style.display==""){
			document.getElementById("searchmenu").style.display="none";
		}else{
			document.getElementById("searchmenu").style.display=""
		}
	},
	to:function(type){
		var searchWord = document.getElementById("searchWord").value.replace(/(^\s*)|(\s*$)/g,"");
		if(searchWord.length<1) {
			alert('请输入您要查找的值');
			return false;
		}
		searchWord=encodeURIComponent(searchWord);
		switch(type){
			case 0:
				window.open(contextPath+"/hall/gameInfo.do?method=searchGameInfo&typeSelect=0&keyword="+searchWord);
				break;
			case 1:
				window.open(contextPath+"/show/userfriend.do?checkType=exact&keyword="+searchWord);
				break;
			case 2:
				window.open(contextPath+"/news/news.do?method=secrchArticle&keyword="+searchWord);
				break;
			case 3:
				window.open(contextPath+"/bbs/bbs.do?method=searchBbsByOption&key="+searchWord);
				break;
		}
		return null;
	}
}