/**
 * @author caojj
 */
//--------------------面切换，如有特殊需要，单独覆盖处理------------------
if (typeof NAVFUN==="undefined") {
	NAVFUN={};
}

WONIUCOMMON = {
	log : function(l) {
		try {
			console.info(l);
		}catch(e){}
	},
	$ : function(id) {
		return document.getElementById(id);
	},
	NAVFUN : function(product) {
		NAVFUN[product]?NAVFUN[product]():this[product]();
//		WONIUCOMMON.NAV.update([product]);
	},
	closeAllList : function(hodePage) {		//hodePage 标示关闭后要新打开的面板，如果将要关闭 和 将要打开是同一个，跳过，避免闪烁的问题
		var hodes = ["","M"];
		for(var i =0;i<hodes.length;i++) {
			if(hodes[i] === hodePage) continue;			
			WONIUCOMMON.$("woniunav_list"+hodes[i]).style.display = "none";			
		}		
		WONIUCOMMON.$("woniunav_userName").className = "selfCenter";
	},
	openList : function(idx) {
		idx=idx||"";
		if (this.timer) {
			clearTimeout(this.timer);
			this.timer = null;
		}

		this.timer = setTimeout(function(){
			WONIUCOMMON.$("woniunav_list"+idx).style.display = "";
			this.timer = null;
		},200);

		this.tikerClose();
	},
	
	tikerClose : function() {
		if (this.closeTimer){
			clearTimeout(this.closeTimer);
			this.closeTimer = null;
		}

		this.closeTimer = setTimeout(function(){
			WONIUCOMMON.closeAllList();
		},2000);

	},
	clearTiker : function() {
		if (this.closeTimer){
			clearTimeout(this.closeTimer);
			this.closeTime = null;
		}		
	},
	
	home : function() {
		var userId = WONIUCOMMON.NAV.User.userId;
		if(!userId) return;
		
		var fun = location.href.match(/woniu\.com\/\d+\.\w+/) ? this.goUrl : this.openUrl;		//如果当前就是空间，当页切换
		
		if (userId) {
			fun("http://hi.woniu.com/$u.home".replace("$u",userId));
		} else {
			//激活
			//alert("未激活");
			fun("http://www.woniu.com/homespace/redirect.html");
		}
	},
	myGame : function() {
		var gUrl = WONIUCOMMON.NAV.getGameHome();
		if (gUrl) {
			this.openUrl(gUrl);
		}
	},
	
	menuMain : function() {
		this.closeAllList("M");
		this.openList('M');
		
		WONIUCOMMON.$("woniunav_userName").className = "selfCenterSe";
	},
	center : function() {
		alert("游戏中心");
	},
	
//	zone : function() {
//		this.closeAllList();
//		this.openList(1);
//	},
//	game : function() {
//		this.closeAllList();
//		this.openList(1);
//	},
	consortia : function() {
		this.goUrl("http://www.woniu.com/apply/");
		//this.closeAllList();
		//this.openList(2);
	},
	channel : function() {
		this.closeAllList("");
		this.openList("");
	},
	
	passport : function() {
		this.openUrl("http://passport.woniu.com/summary.do?method=prepare");
	},
	
	charge : function() {
		this.goUrl("http://res.woniu.com/imprest/imprest_main.html");
	},

	shop : function() {
		this.goUrl("http://shop.woniu.com/");
	},

	jwl : function() {
		this.goUrl("http://jwl.woniu.com/");
	},

	service : function() {
		this.goUrl("http://res.woniu.com/support/support.html");
	},

	bbs : function() {
		this.goUrl("http://club.woniu.com/");
	},

	viewMsg : function() {
		NAVFUN.viewMsg ? NAVFUN.viewMsg() :
			this.goUrl("http://www.woniu.com/personal/showSNSCommunity?app=model/message");
	},
	
	logout : function(_csu) {
		NAVFUN.logout ? NAVFUN.logout() :
			this.goUrl("http://snslogin.woniu.com/login/logout.do?isRedirct=1&targetUrl=&csu=");
	},
	
	goUrl : function(url) {
		location.assign?location.assign(url):setTimeout(function(){location.href=url},10);
	},
	openUrl : function(url) {
		window.open(url);
	}
};

WONIUCOMMON.NAV = {
	isIE : /MSIE/i.test(navigator.userAgent),
	isIE6 : /MSIE\s6/i.test(navigator.userAgent),
	product : "index",
	productList : ["zone","passport","consortia","center","game","charge","shop","jwl","service","channel"],
	woniuGameList:{10:{name:'九阴真经',url:'http://9yin.woniu.com/'}, 7:{name:'天子',url:'http://tz.woniu.com/'}, 12:{name:'帝国文明',url:'http://dg.woniu.com/'}, 3:{name:'机甲世纪',url:'http://aoa.woniu.com/'},6:{name:'机甲世纪Ⅱ',url:'http://aoa.woniu.com/'},13:{name:'机甲世纪革新版',url:'http://aoa.woniu.com/'},4:{name:'舞街区',url:'http://5jq.woniu.com/'},1:{name:'航海世纪',url:'http://vc.woniu.com/'},9:{name:'英雄之城',url:'http://hero.woniu.com/'}},	
	loginDoms : NAVFUN&&NAVFUN.loginDoms? NAVFUN.loginDoms :  ["woniunav_oncot"/*,"woniunav_back","woniunav_invite"*/],
	logoutDoms : NAVFUN&&NAVFUN.logoutDoms? NAVFUN.logoutDoms : ["woniunav_offcot"/*,"woniunav_indexs"*/],
	allDoms :  ["woniunav_oncot","woniunav_offcot"/*,"woniunav_indexs","woniunav_back","woniunav_invite"*/],
	TOP: {
		getDOMStr : function(_p,_u,_csu) {
			var name = (_u.nickName||_u.userName||"").replace(/</g,"&lt;").replace(/>/g,"&gt;");			
		    var service = (/[?&]service=/i).test(location.href) ? '' : '?service='+(location.host=="club.woniu.com"?"http://club.woniu.com/":location.href);		//防止service叠加
			if(WONIUCOMMON.NAV.autoLoginIn==false){
				service="";
			}
			//return ['调试中...'];
			return [
					'<div class="WN_total_MenuKKone">',

						'<div class="WN_total_MenuKK">',
							'<div class="WN_menuL">',
								'<div class="WN_menuR">',
									'<div class="WN_menuM">',
										'<a class="WN_logo" hidefocus="true" href="http://www.woniu.com/">',
											'<img src="http://client2.snailgame.net/comres/js/woniu/style/images/wn_logo.gif" alt="蜗牛网 www.woniu.com" />',
										'</a>',
										'<div class="WN_menuML" id="WN_menuML">',											
											'<span id="woniunav_offcot" style="display:'+(name?'none':'')+';"><a href="http://www.woniu.com/account/login.do'+service+'" class="WN_marginR" id="woniunav_loginBtn">[请登录]</a>&nbsp;&nbsp;<a class="WN_marginR" href="http://reg.woniu.com/?fromUrl=TL.WN.0.0.0" target="_blank" id="woniunav_reg">[免费注册]</a>',
//												'<a href="http://passport.woniu.com/summary.do?method=prepare&h=a" target="_blank">帐号管理</a>',
											'</span>',
											
											'<div class="WN_gameandspace" id="woniunav_oncot" style="display:'+(name?'':'none')+';">',
												'<span class="WN_menuRsayHi"></span>',
												'<div class="WN_display_user_LR">',
//													'<a href="javascript:WONIUCOMMON.NAVFUN(\'home\');" class="WN_user" hidefocus="true" id="woniunav_userName" title="进入我的地盘">'+name+'</a>',													

													'<div class="WN_selfCenter" style="display:none;" id="woniunav_listM" onmouseout="WONIUCOMMON.tikerClose();">',
														'<div class="WN_selfCenterKK">',
//															'<a href="http://my.woniu.com/" onmouseover="WONIUCOMMON.clearTiker();" hidefocus="true">个人中心</a><br />',
															'<a href="http://www.woniu.com/personal/showSNSCommunity?app=rightIndex" onclick="WONIUCOMMON.clearTiker();" hidefocus="true">个人中心</a><br />',
															'<a href="javascript:WONIUCOMMON.NAVFUN(\'home\');" onmouseover="WONIUCOMMON.clearTiker();" hidefocus="true">我的地盘</a><br />',
															'<a href="http://www.woniu.com/personal/showSNSCommunity?app=model/game" onmouseover="WONIUCOMMON.clearTiker();" hidefocus="true">我的游戏</a><br />',
															'<a href="http://www.woniu.com/personal/showSNSCommunity?app=model/effort" onmouseover="WONIUCOMMON.clearTiker();" hidefocus="true">我的成就</a><br />',
//															'<a href="http://www.woniu.com/apply/" target="_blank" id="woniunav_consortia" onmouseover="WONIUCOMMON.clearTiker();" hidefocus="true">玩家公会</a><br />',
//															'<a href="javascript:WONIUCOMMON.NAVFUN(\'passport\');" onmouseover="WONIUCOMMON.clearTiker();" hidefocus="true">我的通行证</a>',
														'</div>',
													'</div>',
													
													'<a hidefocus="true" href="javascript:;" class="selfCenter" id="woniunav_userName" onclick="WONIUCOMMON.NAVFUN(\'menuMain\');">'+ name +'</a>',
//													'<a href="javascript:WONIUCOMMON.NAVFUN(\'viewMsg\');" hidefocus="true" id="woniunav_msg" style="display:none;">(...)</a>',
													'<a href="http://www.woniu.com/account/logout.do" id="woniunav_logout" class="WN_menuMLOut">[退出]</a>',
													'<span class="WN_menuMLlink WN_menuMLlinkSp"><a href="http://www.woniu.com/personal/showSNSCommunity?app=model/message">消息</a><span class="msgNum" id="woniunav_msg" onclick="window.open(\'http://www.woniu.com/personal/showSNSCommunity?app=model/message\');" style="cursor:pointer;display:none;">..</span></span>',
													'<span class="WN_menuMLlink WN_menuMLlinkOp"><a href="http://invite.woniu.com/" target="_invite">邀请</a></span>',
													'<span class="WN_menuMLlink"><a href="http://www.woniu.com/personal/showSNSCommunity?app=model/info">设置</a></span>',
//													'<a href="http://passport.woniu.com/summary.do?method=prepare&h=a" target="_blank" style="margin-left:12px;">帐号管理</a>',
																									
//													'<a href="javascript:WONIUCOMMON.NAVFUN(\'viewMsg\');" hidefocus="true" class="WN_userMsg_Se" id="woniunav_msg" style="display:none;">(...)</a>',
												'</div>',

												'<span>&nbsp;</span>',
//												'<span class=WN_total_tmp id="woniunav_ZDYX">主打游戏：</span>',
												'<a href="javascript:WONIUCOMMON.NAVFUN(\'myGame\');" hidefocus="true" class="WN_total_tmp2" id="woniunav_myGame" style="display:none;">',
													
												'</a>',
//												'<a href="http://snslogin.woniu.com/login/logout.do?isRedirct=1&v='+(new Date().getTime())+'&targetUrl=" id="woniunav_logout">退出</a>',																								

												
//												'<a href="javascript:WONIUCOMMON.NAVFUN(\'home\');" hidefocus="true" class="WN_total_MenuIptKK">',
//													'我的地盘',
//												'</a>',
//												'<span>|</span>',											
//												'<a href="javascript:WONIUCOMMON.NAVFUN(\'passport\');" hidefocus="true">我的通行证</a>',
											'</div>',
											//'<a href="#" class="WN_userTeam" hidefocus="true">游戏中心</a>',

										'</div>',
										'<div class="WN_menuMR">',
//											'<a href="http://d1xn.woniu.com/elite09/" target="_blank" class="WN_question_Check" hidefocus="true" >',
//												'<img src="http://client2.snailgame.net/comres/js/woniu/style/images/b.gif" />',
//											'</a>',
//											'<a href="http://d1xn.woniu.com/tour09/" target="_blank" class="WN_question_Check" hidefocus="true" >',
//												'<img src="http://client2.snailgame.net/comres/js/woniu/style/images/a.gif" />',
//											'</a>',
//											'<a id="woniunav_consortia" href="http://www.woniu.com/apply/" target="_blank" class="WN_userTeam magLadd" hidefocus="true" style="margin-left:22px;">',
//												'<span id="woniunav_GuilldName">玩家公会</span>',
//												'<img alt="" src="http://client2.snailgame.net/comres/js/woniu/style/images/WN_newITEM.gif" />',
//											'</a>',
//											'<a id="woniunav_game" href="javascript:;" hidefocus="true" >蜗牛游戏</a>',
//											'<a id="woniunav_bbs" href="javascript:WONIUCOMMON.NAVFUN(\'bbs\')" hidefocus="true">论坛</a>',
//											'<a id="woniunav_shop" href="javascript:WONIUCOMMON.NAVFUN(\'shop\')" hidefocus="true">商城</a>',
//											'<a id="woniunav_jwl" href="javascript:WONIUCOMMON.NAVFUN(\'jwl\')" hidefocus="true">金网络</a>',
//											'<a id="woniunav_invite" href="http://invite.woniu.com/" hidefocus="true" class="WN_total_invite">邀请</a>',
//											'<div class="WN_home" id="woniunav_indexs">',
//												'<a href="http://www.woniu.com">社区</a>',			
//												'<a href="http://game.woniu.com">游戏</a>',
//												'<a href="http://www.d1xn.com">第1虚拟</a>',
//												'<a href="http://www.snailgame.net" target="_blank">蜗牛公司</a>',
//											'</div>',											
//											'<a id="woniunav_back" href="http://www.woniu.com/" hidefocus="true">蜗牛首页</a>',
											'<a href="http://imprest.woniu.com/imprest/imprest_main.html" target="_blank" class="WN_total_qlnk_payment">充值</a>',
											'<a href="http://www.woniu.com/community/index/" hidefocus="true" class="WN_total_qlnk_community">社区</a>',
											'<a href="http://club.woniu.com/" hidefocus="true" class="WN_total_qlnk_bbs">论坛</a>',
											'<a id="woniunav_service" href="javascript:WONIUCOMMON.NAVFUN(\'service\')" hidefocus="true" class="WN_total_qlnk_service">客服</a>',
//											'<a id="woniunav_service" href="http://res.woniu.com/imprest/imprest_main.html" target="_blank" class="WN_total_qlnk_help">帮助</a>',
											'<div id="woniunav_channel" onclick="WONIUCOMMON.NAVFUN(\'channel\');" class="fastWay">',
												'<a hidefocus="true" class="WN_menuFastWayMore"></a>',
											'</div>',
										'</div>',
									'</div>',
								'</div>',
							'</div>',
						'</div>',
												
						'<div class="WN_total_MenuIptKK">',
							'<div class="WN_total_MenuIpt">',
/*蜗牛游戏
								'<div class="fastWay_OPt fastWay_OPtone WN_menuMLopt" id="woniunav_list1" style="display:none" onmouseout="WONIUCOMMON.tikerClose();" >',
									'<div class="WN_optInnerAbs"></div>',
									'<iframe onmouseover="try{WONIUCOMMON.clearTiker();}catch(e){}" class="WN_aframeone" allowtransparency="true" scrolling="no" frameborder="0" hspace="0" src="http://client2.snailgame.net/comres/js/woniu/iframone.html"></iframe>',

								'</div>',
*/
//								'<div class="fastWay_OPt fastWay_OPttwo WN_menuMLopt" id="woniunav_list2" style="display:none" onmouseout="WONIUCOMMON.tikerClose();" >',
//									'<div class="WN_optInnerAbs"></div>',
//									'<iframe onmouseover="try{WONIUCOMMON.clearTiker();}catch(e){}" class="WN_aframeone" allowtransparency="true" scrolling="no" frameborder="0" hspace="0" src="http://client2.snailgame.net/comres/js/woniu/iframone.html"></iframe>',
//								'</div>',

								'<div class="fastWay_OPt" style="display:none" id="woniunav_list" onmouseout="WONIUCOMMON.tikerClose();">',
									//(WONIUCOMMON.NAV.isIE6?'<iframe style="width:400px;heigth:250px;position:absolute;z-index:-1;top:0px;left:0px;filter: alpha(opacity=0)"></iframe>':''),
									'<div class="WN_optInnerAbs"></div>',
									'<iframe onmouseover="try{WONIUCOMMON.clearTiker();}catch(e){}" class="WN_aframetwo" allowtransparency="true" scrolling="no" frameborder="0" hspace="0" src="http://client2.snailgame.net/comres/js/woniu/iframeMore.html?v201010426.1" style="height:312px"></iframe>',

								'</div>',
								'<input id="woniunav_ipt" name="" value="我要找人..." def="我要找人..." onblur="if(this.value==\'\'){this.value=this.getAttribute(\'def\');}" onfocus="if(this.value==this.getAttribute(\'def\')){this.value=\'\';}" onkeydown="WONIUCOMMON.NAV.search();" />',
								'<a href="javascript:WONIUCOMMON.NAV.search();" hidefocus="true" class="WN_total_search"></a>',
							'</div>',
						'</div>',
					'</div>',
					
					'<div class="WN_total_MenuKKtwo"></div>'
			].join("");
		}
	},
	BOT: {
		getDOMStr : function(_cdt) {
			return [
				//'<div class="WN_bottom">',
					'<div class="WN_bottomKK">',
//						'<div class="WN_bottomLogo" onclick="window.open(\'http://www.snailgame.net/\');" style="cursor:pointer;"></div>',
						'<div class="WN_bottomCot">',
								'<p class="WN_bottomCotLink"><a href="http://www.snailgame.net/" target="_blank">关于蜗牛</a> | <a href="http://www.woniu.com/" target="_blank">蜗牛网</a> | <a href="http://www.snailgame.net/cn/contact.shtml" target="_blank">联系方式</a> | <a href="http://jwl.woniu.com" target="_blank">金网络网站联盟</a> | <a href="http://www.snailgame.net/cn/recruitment.shtml" target="_blank">蜗牛招聘</a> | <a href="http://res.woniu.com/support/support.html" target="_blank">客服中心</a><a class="WN_bottomLink" href="http://www.snailgame.net/" target="_blank">-苏州蜗牛数字科技股份有限公司-</a></p>',
								'<p class="WN_bottomCotAbout"><a href="http://client1.snailgame.net/license/www_2010_205.jpg" target="_blank">网络文化经营许可证 文网文[2010]205号</a> | <a href="http://www.miibeian.gov.cn/" target="_blank">苏ICP备08012323号</a> <a href="http://client1.snailgame.net/license/B2-20080096.jpg" target="_blank">中华人民共和国增值电信业务经营许可证:苏B2-20080096</a></p>',
						'</div>',
					'</div>',
				//'</div>'
			].join("");
		}
	},
	getScript : function() {
		if (!this.script) {		
			var scripts = document.getElementsByTagName("script");
			var script = scripts[scripts.length-1];
			var src = script.getAttribute("src");
			if (src&&src.match(/woniuCommonNav/i)) {
				this.script = script;
			} else {
				for (var i=0;i<scripts.length ;i++ ) {
					var script = scripts[i];
					var src = script.getAttribute("src");
					if (src&&src.match(/woniuCommonNav/i)) {
						this.script = script;
						break;
					}
				}
			}			
		}
		return this.script;
	},
	importCss : function() {
		var head = document.getElementsByTagName("head")[0];
		
		if (this.cls) {	//自定义样式
			var _link = document.createElement("link");
			_link.href = this.cls;
			_link.rel = "stylesheet";
			_link.type = "text/css";
			head.appendChild(_link);
		} else {
			var _link = document.createElement("link");
			_link.href = "http://client2.snailgame.net/comres/js/woniu/style/style.css";
			_link.rel = "stylesheet";
			_link.type = "text/css";
			head.firstChild?head.insertBefore(_link,head.firstChild):head.appendChild(_link);
		}

		delete _link;
	},
	getCookie : function(key) {
		var reg = new RegExp("(^| )"+key+"=([^;]*)(;|$)");
		var arr = document.cookie.match(reg);
		return arr==null? null : decodeURIComponent(arr[2]); //unescape(arr[2]);
	},
	setCookie:function(sName, sValue, oExpires, sPath, sDomain, bSecure){
		var sCookie = sName + "=" + encodeURIComponent(sValue);
		if (oExpires) {
			sCookie += "; expires=" + oExpires.toGMTString();
		}
		if (sPath) {
			sCookie += "; path=" + sPath;
		}
		if (sDomain) {
			sCookie += "; domain=" + sDomain;
		}
		if (bSecure) {
			sCookie += "; secure";
		}
		document.cookie = sCookie;		
	},
	getQuery : function(key) {
		var reg = new RegExp("[?&]+"+key+"=([^\?&]*)[?&]?");
		var ret = location.search.match(reg);
		return ret ? ret[1] : "";
	},
	checkPromot : function() {	//检测推广码	
		var PRMT = this.getQuery("promotParam");
		if (PRMT) {
			this.setCookie("PRMT",PRMT,null,"/",".woniu.com");
		}
	},
	verifyIdentity : function() {
		var userInfo = {};

		var D1XN_INFO = this.getCookie("userInfoSNS");
		if (D1XN_INFO) {		
			var info = D1XN_INFO.split(/\+&&&&/g);
			var time = this.getCookie("lastTime");
			
			userInfo = {
				lastTime : time ? time.split(",")[0] : null,
				userId : info[0],
				account : (info[1]),
				nickName : (info[2]),
				sex : (info[3])
			};
		};

		this.User = {
			type : this.getCookie("type"),
			sex : userInfo["sex"],
			nickName : userInfo["nickName"],
			account : userInfo["account"],
			userId : userInfo["userId"],
			userGame : this.getCookie("userGame"),

			userName : this.getCookie("userName")
		};

		if (this.logStatus!=null) {
			this.isLogin = (this.logStatus=="true" ? true : false);
		} else{
			if (this.User["nickName"]||this.User["userName"]) {
				this.isLogin = true;
			}
		}		
	
        var remember = this.getCookie("remember");

        if(remember && !D1XN_INFO) { //有记住我但是没有身份的时候
			if(WONIUCOMMON.NAV.autoLoginIn==true){				
				location.replace("http://www.woniu.com/account/login.do?service="+location.href);
			}
            
        }
    },
	update : function(product, isLogin) {
		product = product || this.product;
		isLogin = isLogin || false;

		var oldSe = WONIUCOMMON.$("woniunav_"+this.product);
		if (oldSe) {
			oldSe.className = oldSe.className.replace(/\s+Se/, "");
		}
		
		var newSe = WONIUCOMMON.$("woniunav_"+product);		
		if (newSe) {
			newSe.className = newSe.className + " Se";
		}
		
		this.product = product;
		this.isLogin = isLogin;

		if (this.isLogin) {			
			this.verifyIdentity();
			WONIUCOMMON.$("woniunav_userName").innerHTML = (this.User.nickName || this.User.userName || "").replace(/</g,"&lt;").replace(/>/g,"&gt;");
//			$("woniunav_oncot").style.display = "";
//			$("woniunav_offcot").style.display = "none";
//
//			if (this.User.nickName && this.User.userName) {
//				this.getMessageNo();
//			}
			
			
//			if  (this.isLogin) {
				this.getGuild();
				this.getMessageNo();
				this.fillUserGame();
//			}
//			debugger;
			this.shiftLogStatus("login");
		} else {
//			this.clearUser();
			
//			$("woniunav_oncot").style.display = "none";
//			$("woniunav_offcot").style.display = "";
			
			this.shiftLogStatus("logout");
		}
	},
	shiftLogStatus:function(){
		var hide = this.allDoms;
		for(var i =0;i< hide.length;i++) {
			try {
				WONIUCOMMON.$(hide[i]).style.display = "none";
			} catch (e) {
				WONIUCOMMON.log(hide[i] + "隐藏->未找到");
			}
		}

		var show = this.isLogin ? //已登录				
			this.loginDoms : 
			this.logoutDoms;
			
		for(var i =0;i< show.length;i++) {
			try {
				WONIUCOMMON.$(show[i]).style.display = "";
			}catch(e){
				WONIUCOMMON.log(show[i] + "显示->未找到");
			}
		}
		
/*
		if (!this.User.nickName) { //有SNS身份
			var hideDoms = ["woniunav_center","woniunav_ZDYX"];
			for(var i=0;i<hideDoms.length;i++) {
				var _dom = WONIUCOMMON.$(hideDoms[i]);
				try {
					_dom.style.display = "none";
				}catch(e){
					WONIUCOMMON.log(hideDoms[i] + "未找到");
				}		
			}
		}
*/
	},
	//获取用户主打游戏官方地址
	getGameHome : function() {
		var url = "";
		var game = this.User.userGame;
		if (game && game > -1) {
			url = this.woniuGameList[game] ? this.woniuGameList[game]["url"] : null;
		}
		return url;
	},
	search : function() {
		var ipt;

		try {
			var evt = window.event || arguments.callee.caller.arguments[0];
			if (evt.keyCode == 13) {
				ipt = evt.srcElement || evt.target;
			}
		} catch(ex) {
			ipt = WONIUCOMMON.$("woniunav_ipt");
		}
		
		if (ipt) {
			var name = ipt.value.replace(/^\s+|\s+$/g, "");
			if (name && name.indexOf("我要找人") < 0) {
				ipt.focus();
				window.open("http://hi.woniu.com/home/search.html?searchStyle=exact&nickName=" + name, "_new");
			}
			else {
				window.open("http://hi.woniu.com/home/search.html", "_new");
			}
		}
	},
	scriptRequest : function(src,cb) {
		var script = document.createElement("script");
		script.type = "text/javascript";
		if (this.isIE) {		
			script.onreadystatechange = function() {
				if (script.readyState=="complete"||script.readyState=="loaded") {
					if(cb) {try{cb();}catch(e){}}
					script.parentNode.removeChild(script);
				}
			};
		} else {
			script.onload = function() {
				if(cb) {try{cb();}catch(e){}}
				script.parentNode.removeChild(script);
			};
		};
		script.src = src;
		document.getElementsByTagName("head")[0].appendChild(script);

		//return script;
	},
	getMessageNo : function(){
		if(this.User.userId){
//			this.scriptRequest("http://hi.woniu.com/newuser/newmessage.do?m=jsQuery&jsback=WONIUCOMMON.NAV.fillMsgInfo&userId="+this.User.userId+"&t="+(new Date().getTime()));
			this.scriptRequest("http://www.woniu.com/community/siteMsg.do?oper=getUserMsgCnt&fm=json&jsback=WONIUCOMMON.NAV.fillMsgInfo&userId="+this.User.userId);
		}		
	},
	//填充消息
	fillMsgInfo : function(msgs) {		
		var n=msgs['total']||0;
//		if (msgs) {
//			for(var i in msgs){
//				n += parseInt(Number(msgs[i]));
//			}
//		}

		var woniunav_msg = WONIUCOMMON.$("woniunav_msg");
		if (n > 0) {
			woniunav_msg.innerHTML = n; //"(0)".replace("0", n);
			woniunav_msg.style.display = "";
			woniunav_msg.parentNode.className = "WN_menuMLlink WN_menuMLlinkSp";
		} else {
			woniunav_msg.innerHTML = "0";
			woniunav_msg.style.display = "none";
			woniunav_msg.parentNode.className = "WN_menuMLlink";
		}
//		WONIUCOMMON.$("woniunav_msg").className = n>0 ? "WN_userMsg_Se" : "WN_userMsg";		
		
		if(window.fillMsgInfo) {
			window.fillMsgInfo(msgs);
		}
	},
	//填充主打游戏
	fillUserGame : function() {
		var game = this.User.userGame;
		if (game&&game>-1) {
			var gameName = this.woniuGameList[game] ? this.woniuGameList[game]["name"] : null;
			
//			if (!gameName) {	//如果不是官方游戏
//				try {
//					if (!woniuGameList) throw "notLoad";	//如果游戏字典已加载
//					var gameName = "";
//					for(var i =0;i<woniuGameList.length; i++) {
//						if (woniuGameList[i]["id"]==game) {
//							gameName = woniuGameList[i]["name"];
//							break;
//						}
//					}
//				} catch(e) {	//加载字典，回调时填充					
//					this.scriptRequest("http://www.woniu.com/cData/dictionary/woniuGame.js", function(){
//						WONIUCOMMON.NAV.fillUserGame();
//					});
//				}
//			}
			
			WONIUCOMMON.$("woniunav_myGame").innerHTML =  gameName||"";
		}
	},
	init : function() {
		this.product = this.getScript().getAttribute("product") || this.product || "index";
		this.noFoot = (this.getScript().getAttribute("noFoot") == "true" ? true : false);
		this.csu = this.getScript().getAttribute("csu") || "";
		this.cls = this.getScript().getAttribute("cls") || "";
		this.noCls = (this.getScript().getAttribute("noCls") == "true" ? true : false);
		this.delay = (this.getScript().getAttribute("delay") == "true" ? true : false);
		this.logStatus = (this.getScript().getAttribute("logStatus"));
        this.autoLoginIn=(this.getScript().getAttribute("autoLoginIn") == "false" ? false : true);
		if (!this.noCls) {
			this.importCss();
		}
		this.checkPromot();
		this.verifyIdentity();
		
		//this.getGuild();
		//this.update();
		//this.render();

		this.isIE ? document.attachEvent("onclick",WONIUCOMMON.closeAllList) : window.addEventListener("click",WONIUCOMMON.closeAllList,false);

		if (this.delay) {
			WONIUCOMMON.NAV.isIE ? (function(){
			//window.attachEvent("onload",function(){WONIUCOMMON.NAV.init();})
				document.attachEvent("onreadystatechange", function(){
						if (document.readyState == "complete" || document.readyState == "loaded") {				
							WONIUCOMMON.NAV.render();
						}
				});
			}()) : document.addEventListener("DOMContentLoaded",function(){WONIUCOMMON.NAV.render();}, false);
		} else {
			this.render();
		}

		//ie6下遮挡表单的控件 2010-9-8 修改by liwr
		
		if(this.isIE6&&WONIUCOMMON.$("woniunav_list")){
			var ifa = document.createElement("iframe");
			with(ifa.style){
				width = "430px";height = "280px";position = "absolute";zIndex = "-1";top = 0;left = 0;filter = "alpha(opacity=0)";
			}
			ifa.frameborder = "0";
			WONIUCOMMON.$("woniunav_list").insertBefore(ifa,WONIUCOMMON.$("woniunav_list").firstChild);
			//ifa.contentWindow.document.write("<html><body style='margin:0;padding:0'></body></html>");
			//ifa.contentWindow.document.documentElement.style.background="black";
		}
		//this.isIE ? document.attachEvent("onmouseover",WONIUCOMMON.tikerClose) : window.addEventListener("mouseover",WONIUCOMMON.tikerClose,false);
	},
	getGuild : function() {
		if (this.isLogin) {
			var guild = this.getCookie("GI_"+this.User["userId"]);
			if (guild&&guild!=",") {
				var tmp = guild.split(",");
				guild = {
					"guildDomain":tmp[0],
					"guildName":tmp[1]
				}
			}
			(guild) ? this.fillGuild(guild) : this.scriptRequest("http://hi.woniu.com/newuser/guild.do?account="+this.User["account"]+"&jsback=WONIUCOMMON.NAV.fillGuild"+"&t="+(new Date().getTime()));
		}
	},
	fillGuild : function(guild) {
		if (!guild["guildDomain"]||!guild["guildName"]) {
			return;
		};

		this.Guild = guild;
		var guildBtn = WONIUCOMMON.$("woniunav_consortia");
		guildBtn.href = "http://gh.woniu.com/"+guild["guildDomain"];

//		var guildNM = WONIUCOMMON.$("woniunav_GuilldName");
		guildBtn.innerHTML="我的公会";
		//guildNM.appendChild(document.createTextNode(guild["guildName"]));		

		this.setCookie("GI_"+this.User["userId"],[guild["guildDomain"],guild["guildName"]].join(","),null,"/","woniu.com");
	},
	render : function() {
		var _top = NAVFUN.topCotId?WONIUCOMMON.$(NAVFUN.topCotId) : document.createElement("div");
		_top.className = "WN_total";
		_top.innerHTML = this.TOP.getDOMStr(this.product, this.User, this.csu);
		//_top.style.height = "70px";
		document.body.insertBefore(_top,document.body.firstChild);
		delete _top;
		
		if (!this.noFoot) {		
			var _bot = NAVFUN.botCotId?WONIUCOMMON.$(NAVFUN.botCotId):document.createElement("div");
			_bot.className = "WN_bottom";
			_bot.innerHTML = this.BOT.getDOMStr(this.product);
			document.body.appendChild(_bot);
			delete _bot;
		}


		if  (this.isLogin) {
//			this.getGuild();
			this.getMessageNo();
			this.fillUserGame();
		}
		
		this.shiftLogStatus();
		
		var _regFromUrl = typeof(fromurl) == "undefined" ? "TL.WN.0.0.0" : fromurl;
		if(_regFromUrl) {
			WONIUCOMMON.$("woniunav_reg").href="http://reg.woniu.com/?fromUrl="+_regFromUrl;
		}
	},
	initTopBar : function(nickName, isLogin, columnName, myId, scrollFlag) {
		//this.update();
		/*
		WONIUCOMMON.NAV.User["nickName"] = nickName;
		WONIUCOMMON.NAV.User["userId"] = myId;
		WONIUCOMMON.NAV.update(columnName ,isLogin);

		if (isLogin) {// && isSNS
			WONIUCOMMON.NAV.getMessageNo();
		}
		*/
	}
};

initTopBar = function (nickName, isLogin, columnName, myId, scrollFlag) {
		/*setTimeout(function(){
			WONIUCOMMON.NAV.initTopBar(nickName, isLogin, columnName, myId, scrollFlag);
			initTopBar.flag = true;
		},initTopBar.flag?500:2200);*/
};
//initTopBar.flag = false;

WONIUCOMMON.NAV.init();

/*
WONIUCOMMON.NAV.isIE ? (function(){
//window.attachEvent("onload",function(){WONIUCOMMON.NAV.init();})
	document.attachEvent("onreadystatechange", function(){
			if (document.readyState == "complete" || document.readyState == "loaded") {				
				WONIUCOMMON.NAV.init();
			}
	});
}()) : document.addEventListener("DOMContentLoaded",function(){WONIUCOMMON.NAV.init();}, false);
*/
