/*	cookie操作类 */
var Tx_BaseCookie = {
	GetRootDomain: function(domain) {var domainsplite = domain.split(".");if (domainsplite.length > 2) {return domainsplite[domainsplite.length - 2] + "." + domainsplite[domainsplite.length - 1];} else {return domain;}},
	ClearCookie: function(name) { this.SetCookie(name, " ", -3600); },
	SetCookie: function(name, value, expires) {var expDate = new Date();expDate.setTime(expDate.getTime() + expires * 1000);var domainString = this.GetRootDomain(document.domain);var expString = ";expires=" + expDate.toGMTString();var pathString = ";path=/";var domainString = ";domain=" + this.GetRootDomain(document.domain);document.cookie = name + "=" + encodeURIComponent(value) + expString + pathString + domainString;},
	GetCookie: function(name) {var result = null;var myCookie = document.cookie + ";";var searchName = name + "=";var startOfCookie = myCookie.indexOf(searchName);var endOfCookie;if (startOfCookie != -1) {startOfCookie += searchName.length;endOfCookie = myCookie.indexOf(";", startOfCookie);result = myCookie.substring(startOfCookie, endOfCookie);try {result = decodeURI(result);} catch(e) {result = unescape(result);}}return result;},
	TxBBS_GetDomain: function(domain) { return this.GetRootDomain(domain); },
	TxBBS_SetCookie: function(name, value, expires, path, domain) {var expString = ((expires == null) ? ("") : (";expires=" + expires.toGMTString()));var pathString = ((path == null) ? ("") : (";path=" + path));var domainString = ((domain == null) ? ("") : (";domain=" + domain));document.cookie = name + "=" + escape(value) + expString + pathString + domainString;},
	TxBBS_GetCookie: function(name) { return this.GetCookie(name); },
	TxBBS_GetParm: function(name, str) {var result = null;var myStr = str + "&";var searchName = name + "=";var startOfStr = myStr.indexOf(searchName);var endOfStr;if (startOfStr != -1) {startOfStr += searchName.length;endOfStr = myStr.indexOf("&", startOfStr);result = myStr.substring(startOfStr, endOfStr);}return result;},
	TxBBS_SetParm: function(val, name, str) {var result = "";var myStr = str + "&";var searchName = name + "=";var startOfStr = myStr.indexOf(searchName);var endOfStr;if (startOfStr != -1) {startOfStr += searchName.length;endOfStr = myStr.indexOf("&", startOfStr);var perstr = myStr.substring(0, startOfStr);var nextstr = myStr.substring(endOfStr, myStr.length - 1);result = perstr + val + nextstr;} else {if (str == "") result = str + name + "=" + val;else result = str + "&" + name + "=" + val;}return result;},
	TxBBS_ConfigCookieName: "Permission",TxBBS_CurrentUserName: function() {var str = this.TxBBS_GetCookie(this.TxBBS_ConfigCookieName);if (this.TxBBS_FormsIsEffective() && str != null) {var username = decodeURI(this.TxBBS_GetParm("UserName", str));return (username != null) ? username : "未登录";} else {return "未登录";}},
	TxBBS_LoadConfig: function() {var indivstr = this.TxBBS_GetCookie(this.TxBBS_ConfigCookieName);if (indivstr != null) {nowPageStyle = this.TxBBS_GetParm("PageStyle", indivstr);nowOpenType = this.TxBBS_GetParm("OpenType", indivstr);nowPostStyle = this.TxBBS_GetParm("PostStyle", indivstr);}},
	TxBBS_SaveConfig: function(pageStyle, openType, postStyle) {var indivstr = this.TxBBS_GetCookie(this.TxBBS_ConfigCookieName);if (indivstr == null) indivstr = "";indivstr = this.TxBBS_SetParm(pageStyle, "PageStyle", indivstr);indivstr = this.TxBBS_SetParm(openType, "OpenType", indivstr);indivstr = this.TxBBS_SetParm(postStyle, "PostStyle", indivstr);var expDate = new Date();expDate.setTime(expDate.getTime() + 3600 * 24 * 365 * 1000);this.TxBBS_SetCookie(this.TxBBS_ConfigCookieName, indivstr, expDate, "/", this.TxBBS_GetDomain(document.domain));},
	TxBBS_CurrentUserID: function() {var str = this.TxBBS_GetCookie(this.TxBBS_ConfigCookieName);if (this.TxBBS_FormsIsEffective() && str != null) {var userid = this.TxBBS_GetParm("UserID", str);return (userid != null) ? userid : 0;} else {return 0;}},
	TxBBS_IsHeader: function() {var str = this.TxBBS_GetCookie(this.TxBBS_ConfigCookieName);if (this.TxBBS_FormsIsEffective() && str != null) return this.TxBBS_GetParm("IsHeader", str) == "True";else return false;},
	TxBBS_FormsCookieName: "TxNet2",
	TxBBS_FormsIsEffective: function() {var str = this.TxBBS_GetCookie(this.TxBBS_FormsCookieName);if (str != null && str != '') {return true;} else {return false;}}
};

//广告显示
TxAD_ShowBaiduAD = function(divID,adsrc,BaiduAdID,AdWidth,AdHeigth){var ad = $("#"+divID);if(ad.length>0){ad.html('<iframe src="'+adsrc+'?id='+BaiduAdID+'" width="'+AdWidth+'px" height="'+AdHeigth+'px" scrolling="no" frameborder="0" style="display:block;margin:0;background-color:transparent;" allowTransparency="true"></iframe>');}}

/*	功能：注册登录操作用到的URL*/
var Config = {
	TxRegPath: "http://reg.tiexue.net/js/loginbar.aspx",
	TxJpLoginPath: "http://reg.junph.com/CrossDomainLogin.aspx",
	TxCarLoginPath: "http://reg.qichelian.com/CrossDomainLogin.aspx",
	TxQuickRegister: "http://reg.tiexue.net/js/QuickRegister.aspx",
	TxBBSQuickRegister: "http://reg.tiexue.net/XmlHttp/BBSQuickRegister.aspx",
	TxPenfuLoginPath: "http://reg.pengfu.com/CrossDomainLogin.aspx",
	TxJunShiShuLoginPath: "http://reg.junshishu.com/CrossDomainLogin.aspx"
};

var CDomain=Tx_BaseCookie.GetRootDomain(document.domain);
try{document.domain=CDomain;}catch(e){}

/*	功能：短信操作使用的url*/
var MsgConfig={
    ComeToCarNew:"http://reg."+CDomain+"/js/CarFirstCome.aspx",
	NewInfoUrl:"http://msg."+CDomain+"/Out/ToolBarNew.aspx",
	ReadNewMsgUrl:"http://msg."+CDomain+"/Out/ReadNoteHtml.aspx",
	SendMsgUrl:"http://msg."+CDomain+"/Out/SendMsgNew.aspx",
	EditMsgUrl:"http://msg."+CDomain+"/Out/EditNoteNew.aspx",
	ValidateUrl:"http://msg."+CDomain+"/Dlg/Validate.aspx",
	RefreshMsgTimeLength:1,RefreshDataTime:10
};

/*	功能：好友操作用到的url*/
var FriendConfig={
	GoodFriendUrl:"http://i."+CDomain+"/js/InfoBarNew.aspx?FunName=GetMyFriend&num=",
	AddDelFriendUrl:"http://i."+CDomain+"/AddDeleteFriendNew.aspx?UserID=",
	AddMyFriendUrl:"http://i."+CDomain+"/AddFriendByNameNew.aspx",
	JudgeFriendUrl:"http://i."+CDomain+"/JudgeFriendNew.aspx?UserID=",
	OverTime:43200,
	RefreshDataTime:10
};

/* 公社操作用到的url*/
var GroupConfig={
	MyGroupUrl:"http://i."+CDomain+"/js/InfoBarNew.aspx?FunName=GetMyGroup&num=10",
	AddGroupUrl:"http://group."+CDomain+"/XmlHttp/g_addmemberByGroupNameNew.aspx",
	AddGroupUrlByID:"http://group."+CDomain+"/XmlHttp/g_addmemberByGroupID.aspx"
};

//功能：获得随即数
function Tx_getRandom(){return Math.round(Math.random()*100000);}

/*	功能：Jquery的ajax同步get*/
function GetJQueryHttpReq(serverUrl){
	var message="";
	jQuery.ajax({
		type:"get",
		dataType:"text/json",
		async:false,
		cache:false,
		url:serverUrl,
		error:function(XMLHttpRequest){
			message = "{result:[{status:0,message:\"ajax error\"}]}";
		},
		success:function(data){
			message = data;
		}
	});
	return message;
}
//异步get
function GetJQueryHttpReqAsync(serverUrl,callBack){
	var message="";
	jQuery.ajax({
		type:"get",
		dataType:"text/json",
		async:true,
		cache:false,
		url:serverUrl,
		error:function(XMLHttpRequest){
			callBack("{result:[{status:0,message:\"ajax error\"}]}");
		},
		success:function(data){
			callBack(data);
		}
	});
}

/*	功能：用户登录*	参数：userName:用户名 passWord:用户密码 expDT:保存时间 	isUseValidateCode:是否使用验证码  validateCode:验证码 */
Tx_UserLogin=function(userName,passWord,expDT,isUseValidateCode,validateCode){
	var queryURL="FunName=Login&LoginName="+escape(userName)+"&Password="+ escape(encodeURIComponent(passWord))+"&ExpDT="+expDT;
	if (isUseValidateCode){queryURL +='&ValidateCode='+validateCode;}
	else{queryURL +='&tmp='+ Tx_getRandom();}
	
	p=document.createElement('script'); p.id='TxLogJs';p.src=Config.TxRegPath+"?"+queryURL;document.body.appendChild(p);
	
	Tx_UserSingleLogin(userName,passWord,expDT);
}

/*	功能：用户退出	只有网站 君品 和汽车连 */
Tx_UserLogout = function(){
	var regPath=Config.TxRegPath+"?FunName=Logout&t="+Tx_getRandom();
	var junpinPath =Config.TxJpLoginPath+"?FunName=Logout&t="+Tx_getRandom();
	var qichePath = Config.TxCarLoginPath + "?FunName=Logout&t=" + Tx_getRandom();
	var pengfu = Config.TxPenfuLoginPath + "?FunName=Logout&t=" + Tx_getRandom();
	var junshishu = Config.TxJunShiShuLoginPath + "?FunName=Logout&t=" + Tx_getRandom();
	
	p=document.createElement('script'); p.id='TxLogOutJs';p.src=regPath;document.body.appendChild(p);
	
	p1=document.createElement('script'); p1.id='TxJunpOutJs';p1.src=junpinPath;document.body.appendChild(p1);
	
	p2=document.createElement('script'); p2.id='TxCarOutJs';p2.src=qichePath;document.body.appendChild(p2);
	
	p3=document.createElement('script'); p3.id='TxPengfuOutJs';p3.src=pengfu;document.body.appendChild(p3);
	p4=document.createElement('script'); p4.id='TxJunShiShuOutJs';p4.src=junshishu;document.body.appendChild(p4);
	//清除当前域的好友和公社
	Tx_GetCookieFirendAndGroup.Tx_ClearGroupAndFriend();
}

//game快速注册
Tx_QuickRegister = function(userName,passWord,renewPwd,email,validateNum){
	QuickRegisterInfoCheck(userName,passWord,renewPwd,email,validateNum);
	var queryURL = Config.TxQuickRegister+"?userName="+escape(userName)+"&passWord="+escape(encodeURIComponent(passWord))+"&renewPwd="+escape(encodeURIComponent(renewPwd))+"&email="+email+"&validateNum="+escape(validateNum);
	p=document.createElement('script'); p.id='TxQuickRegisterJs';p.src=queryURL;document.body.appendChild(p);
}

//BBS快速注册
TxBBS_QuickRegister = function(userName,passWord,renewPwd,email,validateNum){
	QuickRegisterInfoCheck(userName,passWord,renewPwd,email,validateNum);
	var queryURL = Config.TxBBSQuickRegister+"?userName="+escape(userName)+"&passWord="+escape(encodeURIComponent(passWord))+"&renewPwd="+escape(encodeURIComponent(renewPwd))+"&email="+email+"&validateNum="+escape(validateNum);
	p=document.createElement('script'); p.id='TxQuickRegisterJs';p.src=queryURL;document.body.appendChild(p);
}
//快速注册检查
QuickRegisterInfoCheck=function(userName,passWord,renewPwd,email,validateNum){
	if(TxLibraryTool.StringIsNullOrEmpty(userName)){
		alert("请输入用户名");return false;
	}
	var len = TxLibraryTool.StringLength(userName);
	if(len<2||len>16){
	    alert("输入用户名请少于16个字符，大于两个字符");return false;
	}
	if(TxLibraryTool.StringIsNullOrEmpty(passWord)){
		alert("密码不能为空");return false;
	}
	if(passWord.length>=6&&passWord.length<=16){
		if(passWord!=renewPwd){
			alert("两次输入的密码不正确，请重新填写");return false;
		}
	}
	else{
		alert("密码长度必须在6-16个字符之间");return false;
	}
	if(!TxLibraryTool.StringIsNullOrEmpty(email)){
		if(!TxLibraryTool.StringIsEmail(email)){
			alert("邮箱格式不正确");return false;
		}
	}
	if(TxLibraryTool.StringIsNullOrEmpty(validateNum)){
		alert("请输入验证码");return false;
	}
}
//实现单点登陆的军品和汽车连的登陆
Tx_UserSingleLogin=function(userName,passWord,expDT){
	var queryURL="FunName=Login&LoginName="+escape(userName)+"&Password="+escape(encodeURIComponent(passWord))+"&ExpDT="+expDT;

	p1=document.createElement('script'); p1.id='TxJunpJs';p1.src=Config.TxJpLoginPath+"?"+queryURL;document.body.appendChild(p1);
	
	p2=document.createElement('script'); p2.id='TxCarJs';p2.src=Config.TxCarLoginPath+"?"+queryURL;document.body.appendChild(p2);
	
	p3=document.createElement('script'); p3.id='TxCarJs';p3.src=Config.TxPenfuLoginPath+"?"+queryURL;document.body.appendChild(p3);
	
	p4=document.createElement('script'); p4.id='TxJunShiShuJs';p4.src=Config.TxJunShiShuLoginPath+"?"+queryURL;document.body.appendChild(p4);
}

/*
*	功能：发短信 需跨域 在web,config中药配置
*	参数：MsgID:短信ID 传0, UserList:用户名列表，以,分开 
*	Title:标题	Content:内容	ValidateCode:验证码
*	ToSended是否保存到发件箱
*/
Tx_SendMsg = function(UserList,Title,Content,ValidateCode,ToSended,MsgID){
	var sUrl="agent.aspx?desturl="+encodeURIComponent(MsgConfig.SendMsgUrl);
	if(MsgID==null) MsgID="";
	var message="";
	jQuery.ajax({
		type:"POST",
		async:false,
		dataType:"text/json",
		url:sUrl,
		data:{UserList:encodeURIComponent(UserList),MsgID:MsgID,ToSendedCheck:ToSended,Title:encodeURIComponent(Title),Content:encodeURIComponent(Content),ValidateCode:ValidateCode},
		error:function(XMLHttpRequest){
			message = "{result:[{status:0,message:\"ajax error\"}]}";
		},
		success:function(msg){
			message = msg;
		}
	});
	return message;
}

/*	功能：读取短信 	参数：短信ID*/
Tx_ReadNewMsg = function(MsgID){
	var queryURL =MsgConfig.ReadNewMsgUrl+"?MsgID="+MsgID;
	return GetJQueryHttpReq("agent.aspx?desturl="+encodeURIComponent(queryURL));
}

/*	功能：获得新短信数量*/
Tx_NewMsg= function(){
	var queryURL=MsgConfig.NewInfoUrl+"?tmp="+Tx_getRandom()
	return GetJQueryHttpReq("agent.aspx?desturl="+encodeURIComponent(queryURL));
}

/*	功能：获得新短信ID 以，分割 */
Tx_NewMsgID= function(){
	var queryURL=MsgConfig.NewInfoUrl+"?FunName=GetMyNewNote&tmp="+Tx_getRandom()
	return GetJQueryHttpReq("agent.aspx?desturl="+encodeURIComponent(queryURL));
}

/*	功能：读取所有短信 *	参数：MsgID:短信ID 为0的话获得所有*/
Tx_ReadNewMsg = function(MsgID){
	var queryURL = MsgConfig.ReadNewMsgUrl+"?MsgID="+MsgID
	return GetJQueryHttpReq("agent.aspx?desturl="+encodeURIComponent(queryURL));
}

/*功能：加好友 需跨域 在web,config中要配置	参数：UserName 用户名*/
Tx_AddMyFriend=function(addUserName){
	var sUrl="agent.aspx?desturl="+encodeURIComponent(FriendConfig.AddMyFriendUrl);
	addUserName = encodeURIComponent(addUserName)
	var message="";
	jQuery.ajax({
		type:"POST",
		dataType:"text/json",
		url:sUrl,
		async:false,
		data:{UserName:addUserName},
		error:function(XMLHttpRequest){
			message = "{result:[{status:0,message:\"ajax error\"}]}";
		},
		success:function(msg){
			message = msg;
		}
	});
	return message;
}

/*	功能：判断是否好友 需跨域 在web,config中要配置	参数：UserID 好友ID */
Tx_IsMyFriend=function(UserID){
	var sUrl="agent.aspx?desturl="+encodeURIComponent(FriendConfig.JudgeFriendUrl+UserID+"&rd="+Math.random());
	return GetJQueryHttpReq(sUrl);
}

/*	删除好友 需跨域 在web,config中要配置	UserID 好友ID*/
Tx_AddDelMyFriend = function(UserID){
	var sUrl="agent.aspx?desturl="+encodeURIComponent(FriendConfig.AddDelFriendUrl+UserID+"&rd="+Math.random());
	return GetJQueryHttpReq(sUrl);
}

/*获得好友列表 在web,config中要配置	num 好友数量 */
Tx_GetMyFriend = function(num){
	var sUrl="agent.aspx?desturl="+encodeURIComponent(FriendConfig.GoodFriendUrl+num);
	return GetJQueryHttpReq(sUrl);
}

/*	获得所在公社 在web,config中要配置*/
Tx_GetMyGroup = function(){
	var sUrl="agent.aspx?desturl="+encodeURIComponent(GroupConfig.MyGroupUrl);
	var group = GetJQueryHttpReq(sUrl);
	return group;
}
/*获得验证码的url地址	参数：用户名*/
Tx_RefreshValidCode = function(userName){var url = 'http://reg.'+CDomain+'/Validate.aspx?UserName='+escape(userName)+'&tmp='+Tx_getRandom();return url;}

//获得验证码的url地址
Tx_RefreshValidCodeNoName = function(){var url = 'http://reg.'+CDomain+'/ValiImageCode.aspx?tmp='+Tx_getRandom();return url;}

var FriendCacheData=null;
var GroupCacheData=null;
//好友及公社类 从cookie中获得好友及公社信息
Tx_GetCookieFirendAndGroup={
	//从服务器获得好友信息
	Tx_GetMyFriendsFromServer:function(divID,callBack){
		TxBBS_UserID= Tx_BaseCookie.TxBBS_CurrentUserID();
		if(TxBBS_UserID>0){
			var queryURL="agent.aspx?desturl="+encodeURIComponent(FriendConfig.GoodFriendUrl+10);
			jQuery.ajax({
				type:"get",
				dataType:"text/json",
				async:true,
				cache:false,
				url:queryURL,
				error:function(XMLHttpRequest){
					Tx_GetCookieFirendAndGroup.Tx_ClearFriendCookie();
				},
				success:function(data){
					FriendCacheData = data;
					//更新缓冲Cookie值
					temp = data;var temp2="111";
					if (TxLibraryTool.StringIsNullOrEmpty(temp)){
						temp=null;temp2=null;
					}
					if(temp!=null){
						temp= Tx_GetCookieFirendAndGroup.Tx_SetFriendToCookieOld(temp);
						if(TxLibraryTool.StringIsNullOrEmpty(temp)){
							temp=null;temp2=null;
						}
					}
					//取当前时间
					var curdate = new Date();
					curdate.setTime(curdate.getTime()+10*60000);
					temp = temp + "|" + curdate.getFullYear() + "-" + (curdate.getMonth()+1) + "-" + curdate.getDate() + " " + curdate.getHours() + ":" + curdate.getMinutes() + ":" + curdate.getSeconds();
					Tx_BaseCookie.SetCookie("TxFriends",escape(temp),3600*24);
					if(temp2!=null){
						callBack(divID);
					}
				}
			});
		}
	},
	//从cookie中获得好友信息
	Tx_GetMyFriendsFromCookie:function(divID,callBack){
		//读取Cookie
		var temp = Tx_BaseCookie.GetCookie("TxFriends");
		//如果Cookie获取为空值,立即从服务器段获取
		if (temp==null||typeof(temp)==null||temp=="null"){
			this.Tx_GetMyFriendsFromServer(divID,callBack);
			temp = Tx_BaseCookie.GetCookie("TxFriends");
			FriendCacheData = unescape(temp).split("|")[0];
			return FriendCacheData;
		}
		var arr = unescape(temp).split("|");
		FriendCacheData = arr[0];
		//判断好友数据是否过期 FDataAvail=1:有效,=0:正在获取,=null:数据过期
		if (arr.length==2){
			SaveDate = arr[1];
			var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; 
			var r = SaveDate.match(reg); 
			if(r!=null){
				var dt = new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]);
				var curdate = new Date();
				if (curdate>dt){
					this.Tx_GetMyFriendsFromServer(divID,callBack);
					temp = Tx_BaseCookie.GetCookie("TxFriends");
					FriendCacheData = unescape(temp).split("|")[0];
					return FriendCacheData;
				}
			}
		}
		return FriendCacheData;
	},
	//清除cookie中的好友信息
	Tx_ClearFriendCookie:function(){
		FriendCacheData="";
		Tx_BaseCookie.ClearCookie("TxFriends");
	},
	//从服务器端获取公社信息
	Tx_GetMyGroupsFromServer:function(divID,callBack){
		var TxTB_UserID = Tx_BaseCookie.TxBBS_CurrentUserID();
		if (TxTB_UserID==0) return;
		var queryURL="agent.aspx?desturl="+encodeURIComponent(GroupConfig.MyGroupUrl);
			jQuery.ajax({
				type:"get",
				dataType:"text/json",
				async:true,
				cache:false,
				url:queryURL,
				error:function(XMLHttpRequest){
					Tx_GetCookieFirendAndGroup.Tx_ClearGroupCookie();
				},
				success:function(data){
					if (data==null){data=null;}
					GroupCacheData = data;
					if (data==""){GroupCacheData =null};
					//更新缓冲Cookie值
					if(GroupCacheData!=null){
						GroupCacheData = Tx_GetCookieFirendAndGroup.Tx_SetGroupToCookieOld(GroupCacheData);
						if(TxLibraryTool.StringIsNullOrEmpty(GroupCacheData)){
							GroupCacheData=null;
						}
					}
					Tx_BaseCookie.SetCookie("TxGroups",escape(GroupCacheData),3600*24);
					if(GroupCacheData!=null){
						callBack(divID);
					}
				}
			});
	},
	//从cookie中取公社信息
	Tx_GetMyGroupsFromCookie:function(divID,callBack){
		//读取Cookie
		var temp = Tx_BaseCookie.GetCookie("TxGroups");
		//如果Cookie获取为空值,立即从服务器段获取
		if (temp==null||typeof(temp)==null||temp=="null"){
			this.Tx_GetMyGroupsFromServer(divID,callBack);
			GroupCacheData = unescape(Tx_BaseCookie.GetCookie("TxGroups"));
			return GroupCacheData;
		}
		GroupCacheData = unescape(temp);
		return GroupCacheData;
	},
	//清除cookie中的公社信息
	Tx_ClearGroupCookie:function(){
		GroupCacheData = "";
		Tx_BaseCookie.ClearCookie("TxGroups");
	},
	//清除cookie中的好友及公社信息
	Tx_ClearGroupAndFriend:function(){
		this.Tx_ClearGroupCookie();
		this.Tx_ClearFriendCookie();
	},
	//给cookie中的好友及公社添加信息
	Tx_SetFriendToCookieOld:function(json){
		var oldfriend="";
		if(!TxLibraryTool.StringIsNullOrEmpty(json)){
			var result=eval('(' + json + ')');
			if(result.result[0].status==1){
				for(var i=0;i<result.result[0].message.length;i++){
					oldfriend += result.result[0].message[i].UserIDB+","+result.result[0].message[i].UserNameB+","+result.result[0].message[i].MyDomain+","+result.result[0].message[i].Face+","+result.result[0].message[i].IsOnlineB;
					if(i!=result.result[0].message.length-1){
						oldfriend +=";"
					}
				}
			}
		}
		return oldfriend;
	},
	Tx_SetGroupToCookieOld:function(json){
		var oldgroup="";
		if(!TxLibraryTool.StringIsNullOrEmpty(json)){
			var result=eval('(' + json + ')');
			if(result.result[0].status==1){
				for(var i=0;i<result.result[0].message.length;i++){
					oldgroup += result.result[0].message[i].GroupID+","+result.result[0].message[i].GroupName+","+result.result[0].message[i].DomainName;
					if(i!=result.result[0].message.length-1){
						oldgroup +=";"
					}
				}
			}
		}
		return oldgroup;
	}
}
//短信数量
Tx_MsgPublic={
	Tx_GetMsgNumFromServer:function(callBack){
		var TxTB_UserID = Tx_BaseCookie.TxBBS_CurrentUserID();
		if (TxTB_UserID==0) return;
		var queryURL="agent.aspx?desturl="+encodeURIComponent(MsgConfig.NewInfoUrl+"?tmp="+Tx_getRandom());
		jQuery.ajax({
			type:"get",
			dataType:"text/json",
			async:true,
			cache:false,
			url:queryURL,
			error:function(XMLHttpRequest){
				Tx_BaseCookie.SetCookie("TxMsgNew","0",3600*24);
				Tx_BaseCookie.SetCookie("TxMsgAvail","1",MsgConfig.RefreshMsgTimeLength*10*60);
			},
			success:function(data){
				if (data==null){data="";}
				MsgCacheData = data;
				if (data==""){MsgCacheData =0};
				//更新缓冲Cookie值
				if(!TxLibraryTool.StringIsNullOrEmpty(data)){
					var  result=eval('(' + data + ')');
					if(result.result[0].status==1){
						MsgCacheData=parseInt(result.result[0].message);
					}
					else{MsgCacheData=0;}
				}
				Tx_BaseCookie.SetCookie("TxMsgNew",MsgCacheData,3600*24);
				Tx_BaseCookie.SetCookie("TxMsgAvail","1",MsgConfig.RefreshMsgTimeLength*10*60);
				if(MsgCacheData>=0){
					callBack();
				}
			}
		});
	},
	Tx_GetMsgNumFromCache:function(callBack){
		//判断短信数据是否过期 TxMsgAvail=1:有效,=0:正在获取,=null:数据过期
		temp = Tx_BaseCookie.GetCookie("TxMsgAvail");
		if (temp==null){
			this.Tx_GetMsgNumFromServer(callBack);
			Tx_BaseCookie.SetCookie("TxMsgAvail","0",40);	//短信数据获取中
			return;
		}
		//读取Cookie
		var temp = Tx_BaseCookie.GetCookie("TxMsgNew");
		//如果Cookie获取为空值,立即从服务器段获取
		if (temp==null){
			this.Tx_GetMsgNumFromServer(callBack);
			return;
		}
		if (temp=="")temp="0";
		var Count = parseInt(temp);
		return Count;
	},
	Tx_ReadMsg:function(callBack){
		var temp = Tx_BaseCookie.GetCookie("TxMsgNew");
		//如果Cookie获取为空值,立即从服务器段获取
		if (temp==null){
			Tx_BaseCookie.SetCookie("TxMsgNew","0",MsgConfig.RefreshMsgTimeLength*10*60);
			this.Tx_GetMsgNumFromServer(callBack);
			return;
		}
		if (temp=="")temp="0";
		var NewInfoCount = parseInt(temp);
		if (NewInfoCount>0){NewInfoCount--};
		//更新缓冲Cookie值
		Tx_BaseCookie.SetCookie("TxMsgNew",NewInfoCount,MsgConfig.RefreshMsgTimeLength*10*60);
		if (typeof(callBack) == 'function'){callBack();}
	},
	Tx_ClearMsgNumCookie:function(){
		Tx_BaseCookie.ClearCookie("TxMsgNew");
		Tx_BaseCookie.ClearCookie("TxMsgAvail");
	}
}

//登陆类型用来判断是来自哪里的登陆
var loginBarType=0;
var msgCallBack=function(){};
var TxTB_UserID=0;
var TxTB_UserName="";
var ValidateCode="";
var NewMsgCount=0;
var hInterval;
try{TxTB_UserID=Tx_BaseCookie.TxBBS_CurrentUserID();TxTB_UserName=Tx_BaseCookie.TxBBS_CurrentUserName();}catch(e){}

/* ============ 第一个登陆条 首页 白页 begin 303 ================ */
Tx_InitLoginBar = function(TopBarID,BarWidth){
	if(BarWidth==0){BarWidth=970;}
	var gameLink = '<a id="zhengzhansifangurl" href="http://zzsf.game.tiexue.net/"><font color="blue">征战四方</font> </a><br> <a id="diguowenmingurl" href="http://dg.game.tiexue.net/"><font color="blue">帝国文明</font> </a><br><a id="zhanzhengzhiluurl" href="http://zz.game.tiexue.net/"><font color="blue">战争之路</font> </a><br><a id="chuanqiguoduurl" href="http://cq.game.tiexue.net/"><font color="blue">传奇国度</font> </a><br><a id="juedizhanzhengurl" href="http://jd.game.tiexue.net/"><font color="blue">绝地战争</font> </a><br><a href="http://as.game.tiexue.net/"><font color="blue">傲视天地</font> </a><br><!--<a href="http://wm.tiexue.com/"><font color="blue">热血文明</font></a><br>//--><a href="http://x.tiexue.net/Monitor/Monitor.aspx?PlaceID=34&TargetUrl=http%3a%2f%2fwot.kongzhong.com%2f"><font color="blue">坦克世界</font></a>';
	var topHtml="";
	document.write('<style type="text/css">.TxPublic_Post2Login_text{background:#fff;vertical-align:middle;width:65px;height:16px;border:1px solid #dbdbdb}.TxPublic_Post2Login_select{vertical-align:middle}.TxPublic_Post2Login_valeimg{cursor: pointer; height: 18px;vertical-align: top; margin: 2px 5px 0px 3px; }.TxPublic_Post2Login_logp{float:left;width:38px;height:18px;line-height:18px;text-align:center;background:url(http://www.itiexue.net/images/login_btn.gif) no-repeat;margin-left:5px;display:inline}.TxPublic_Post2Login_logspan{display:block;text-decoration:none;color:#535353;cursor:pointer}.TxPublic_Post2Login_logoutp{background:url(http://www.itiexue.net/images/login_btn2.gif) no-repeat;width:53px;float:left;height:18px;line-height:18px;text-align:center;margin-top:0;margin-left:5px;display:inline}.TxPublic_Post2Login_h4{font-size:12px;font-weight:normal;text-align:center;cursor:pointer;}.TxPublic_Post2Login_rightspan{display:block;text-decoration:none;border:1px solid #faf9fa;padding:0px 0px;cursor:pointer}.TxPublic_Post2Login_righta{display:block;text-decoration:none;border:1px solid #faf9fa;padding:3px 0px}.TxPublic_Post2Login_rightShowDiv{clear:both;display:none;background:#f1f1f1;border:1px solid #999999;position:absolute;clear:both;z-index:2000;}.TxPublic_Post2Login_rightShowDiv p{margin:0}.TxPublic_Post2Login_gameLi{float:left;width:58px;height:18px;line-height:18px;text-align:left;background:url(http://www.itiexue.net/images/login_btn2.gif) no-repeat;margin-left:5px;display:inline}.TxPublic_Post2Login_gameDiv{clear:both;display:none;background:#f1f1f1;border:1px solid #999999;position:absolute;text-align:left;padding:5px;width:160px}.TxPublic_Post2Login_gameSpan{display:block;text-decoration:none;color:#535353;cursor:pointer;margin-left:3px;padding-bottom:0px;margin-bottom:0px}*{padding-top:0px;margin-top:0px}h4{margin:0;padding:0}TxPublic_Post2Login ul,TxPublic_Post2Login li{margin:0;padding:0;line-height:18px;}</style>');
	//<!--登陆前 start-->
	topHtml +="<div style=\"width:"+BarWidth+"px;margin:0px auto;\" class=\"TxPublic_Post2Login\"><div style=\"overflow:hidden;background:url(http://www.itiexue.net/images/top_bg.jpg) repeat-x;padding:1px 0px 0px 10px;height:23px;margin:0;\">";
	topHtml +="<dl id=\"loginBefor\" style=\"float:left;width:620px;\">";
	topHtml +="<dd style=\"float:left;margin-top:1px;margin-top:2px;padding-left: 1px; margin-left: 0px;\">";
	topHtml +="用户名：<input type=\"text\" id=\"txtUserName\" class=\"TxPublic_Post2Login_text\" onmousemove=\"loginmosemove(this)\" onmouseout=\"loginmoseout(this)\" />&nbsp;密码：<input onkeyup=\"EnterSubmit();\" type=\"password\" class=\"TxPublic_Post2Login_text\" id=\"txtUserPassword\" onmousemove=\"loginmosemove(this)\" onmouseout=\"loginmoseout(this)\" />&nbsp;<select id=\"sTime\" class=\"TxPublic_Post2Login_select\"><option value=\"1\">1天</option><option value=\"7\">1周</option><option value=\"30\">1月</option><option value=\"365\">1年</option></select><img id=\"ValidateCodeImg\" onclick=\"RefreshValidCode()\" class=\"TxPublic_Post2Login_valeimg\" style=\"display: none;\"><input type=\"text\" id=\"txtLoginValidate\" class=\"TxPublic_Post2Login_text\" onmousemove=\"loginmosemove(this)\" onmouseout=\"loginmoseout(this)\" onkeyup=\"EnterSubmit();\" style=\"display: none;\" />";
	topHtml +="</dd>";
	topHtml +="<dt style=\"float:left;margin:3px 0px 0px 10px\">";
	topHtml +="<p class=\"TxPublic_Post2Login_logp\"><span class=\"TxPublic_Post2Login_logspan\" href=\"javascript:void(0);\" onclick=\"LoginIn()\" onfocus=\"this.blur()\">登录</span></p><p class=\"TxPublic_Post2Login_logp\"><span class=\"TxPublic_Post2Login_logspan\" onclick=\"top.location.href=\'http://bbs.tiexue.net/\'\" onfocus=\"this.blur()\">游客</span></p><p class=\"TxPublic_Post2Login_logp\"><span class=\"TxPublic_Post2Login_logspan\" onclick=\"top.location.href=\'http://reg.tiexue.net/register.aspx\'\" onfocus=\"this.blur()\">注册</span></p>";
	topHtml +="<ul style=\"width:58px;float:left;\"><li class=\"TxPublic_Post2Login_gameLi\"><span id=\"game1\" class=\"TxPublic_Post2Login_gameSpan\" onclick=\"javascript://void(0)\" onfocus=\"this.blur()\" onmouseover=\"showNav('game1','gameshow1')\">进入游戏</span>";
	topHtml +='<div class=\"TxPublic_Post2Login_gameDiv\" id="gameshow1" style=\"width:60px\">'+gameLink+'<br></div>';
	topHtml +='</li></ul>';
	topHtml +="</dt></dl>";
	//<!--登陆前 end-->
	//<!--登陆后 start-->
	topHtml +="<dl id=\"loginLater\" style=\"float:left;width:550px;display:none;margin:0;padding:0\">";
	topHtml +="<dd style=\"float:left;margin:4px 0 0 0;line-height:normal;padding:0 0 0 1px;\">欢迎你：<span style=\"color:red;padding:0px 5px;\" id=\"UserNameInfo\"></span><span onclick=\"SeeMsg()\" id=\"NewMsgNum\" style=\"cursor:pointer;display:none\" >一条新消息</span><span style=\"cursor:pointer;\" onclick=\"WantSendMsg()\" id=\"msgNew\">新短信</span></dd><dt style=\"float:left;margin:3px 0px 0px 10px\">";
	topHtml +="<p class=\"TxPublic_Post2Login_logoutp\"><span class=\"TxPublic_Post2Login_logspan\" onclick=\"top.location.href=\'http://bbs.tiexue.net\'\" onfocus=\"this.blur()\">进入社区</span></p>";
	topHtml +="<ul style=\"display:none;float:left;width:60px;\" id=\"myGameShow\"><li class=\"TxPublic_Post2Login_gameLi\"><span id=\"game12\"  class=\"TxPublic_Post2Login_gameSpan\" onclick=\"javascript://void(0)\" onfocus=\"this.blur()\" onmouseover=\"showNav('game12','gameshow2')\">进入游戏</span>";
	topHtml += '<div class=\"TxPublic_Post2Login_gameDiv\" id="gameshow2"  style=\"width:60px\">'+gameLink+'<br></div></li></ul>';
	
	topHtml +="<p class=\"TxPublic_Post2Login_logoutp\"><a style=\"display:block;line-height:18px;text-decoration:none;color:#535353\" href=\"javascript:void(0)\" onfocus=\"this.blur()\" id=\"userUrl\">个人中心</a></p><p class=\"TxPublic_Post2Login_logoutp\"><span class=\"TxPublic_Post2Login_logspan\" onfocus=\"this.blur()\" onclick=\"Tx_UserLogout()\">退出</span></p></dt></dl>";
	 //<!--登陆后 end-->
	topHtml +="<ul style=\"float:right;padding:2px 20px 0px 0px;list-style:none\">";
	 topHtml +="<li style=\"float:left;width:45px\" onmouseover=\"msHover(this,0)\" onmouseout=\"msOut(this,0)\"><h4 class=\"TxPublic_Post2Login_h4\" style=\"display:none;\" id=\"loginblog\"><span style=\"display:block;text-decoration:none;border:1px solid #faf9fa;padding:0px 0px\" onclick=\"LoginToBlog()\">博客</span></h4><div></div></li>";
	topHtml += "<li style=\"float:left;width:45px\" onmouseover=\"msHover(this,0)\" onmouseout=\"msOut(this,0)\">";
	topHtml +="<h4 class=\"TxPublic_Post2Login_h4\" id=\"Nav_1\"><span class=\"TxPublic_Post2Login_rightspan\" href=\"javascript:void(0)\" onclick=\"LoginToGroup()\">公社</span></h4>";
	topHtml +="<div  class=\"TxPublic_Post2Login_rightShowDiv\" style=\"text-align:center;width:100px;display:none\" id=\"subNav_1\"><p>登录后使用</p><p><a href=\"http://group.tiexue.net/\">匿名浏览</a></p></div>";
	topHtml +="</li>";
	topHtml +="<li style=\"float:left;width:45px\" onmouseover=\"msHover(this,0)\" onmouseout=\"msOut(this,0)\" id=\"Nav_2Li\"><h4 class=\"TxPublic_Post2Login_h4\" id=\"Nav_2\"><span class=\"TxPublic_Post2Login_rightspan\" href=\"javascript:void(0)\" onclick=\"LoginToFriends()\">好友</span></h4>";
	topHtml +="<div class=\"TxPublic_Post2Login_rightShowDiv\" style=\"text-align:left;clear:both;_width:140px;display:none\" id=\"subNav_2\"><p>登录后使用</p></div></li>";
	topHtml +="<li style=\"float:left;width:45px\" onmouseover=\"msHover(this,0)\" onmouseout=\"msOut(this,0)\">";
	topHtml +="<h4 class=\"TxPublic_Post2Login_h4\" onmouseover=\"showNav('Nav_3','subNav_3')\" id=\"Nav_3\"><span class=\"TxPublic_Post2Login_rightspan\" href=\"javascript:void(0)\">经济</span></h4>";
	topHtml +="<div class=\"TxPublic_Post2Login_rightShowDiv\" style=\"width:70px;text-align:center\" id=\"subNav_3\">";
	topHtml +="<p><a class=\"TxPublic_Post2Login_righta\" href=\"http://i.tiexue.net/BankDefault.aspx\">银行账户</a></p><p><a class=\"TxPublic_Post2Login_righta\" href=\"http://pay.tiexue.net/\">购买金币</a></p><p><a class=\"TxPublic_Post2Login_righta\" href=\"http://market.tiexue.net/\">劳动力市场</a></p>";
	topHtml +="</div></li><li style=\"float:left;width:45px\" onmouseover=\"msHover(this,0)\" onmouseout=\"msOut(this,0)\">";
	topHtml +="<h4 class=\"TxPublic_Post2Login_h4\" onmouseover=\"showNav('Nav_4','subNav_4')\" id=\"Nav_4\"><span class=\"TxPublic_Post2Login_rightspan\" href=\"javascript:void(0)\">设置</span></h4>";
	topHtml +="<div class=\"TxPublic_Post2Login_rightShowDiv\" style=\"width:70px;text-align:center\" id=\"subNav_4\">";
	topHtml +="<p><a class=\"TxPublic_Post2Login_righta\" href=\"http://i.tiexue.net/BasicData.aspx\">个人信息</a></p><p><a class=\"TxPublic_Post2Login_righta\" href=\"http://i.tiexue.net/UserAvatarNativeNew.aspx\">修改头像</a></p><p><a class=\"TxPublic_Post2Login_righta\" href=\"http://i.tiexue.net/ModPassword.aspx\">修改密码</a></p><p><a class=\"TxPublic_Post2Login_righta\" href=\"http://i.tiexue.net/ModEmail.aspx\">修改信箱</a></p><p><a class=\"TxPublic_Post2Login_righta\" href=\"http://reg.tiexue.net/FindPassWord.aspx\">找回密码</a></p>";
	topHtml +="</div></li>";
	topHtml +="<li style=\"float:left;width:45px\" onmouseover=\"msHover(this,0)\" onmouseout=\"msOut(this,0)\"><h4 class=\"TxPublic_Post2Login_h4\"><span class=\"TxPublic_Post2Login_rightspan\" onclick=\"top.location.href=\'http://help.tiexue.net/\'\">帮助</span></h4><div></div></li>";
	topHtml +="</ul>";
	topHtml += "</div></div>";
	if(TopBarID!=null){
		TopBarID.html(topHtml);
	}else{
		document.write(topHtml);
	}
	sHtml=null; 
	ResetUserLoginStatus();
}

function msHover(obj,types){obj.style.background="#b6bdd2";obj.style.border="1px solid #ccc";}
function msOut(obj){obj.style.background="none";obj.style.border="none";}
function msHover1(obj,types){obj.style.background="#b6bdd2";obj.style.borderBottom="1px solid #000";}
function msOut1(obj){obj.style.background="none";obj.style.bordeBottomr="1px solid #000";}

//登录
function LoginIn(){
	var userName=jQuery("#txtUserName");var passWord=jQuery("#txtUserPassword");var expDT=jQuery("#sTime");
	if (userName.val().length < 1){alert("用户ID不能为空");userName.focus();return;}
	else if(passWord.val().length<1){alert("密码不能为空");passWord.focus();return;}
	if(jQuery("#ValidateCodeImg")[0].style.display==""){var txtLoginValidate=jQuery("#txtLoginValidate");
		if(txtLoginValidate.val().length<1){alert("验证码不能为空");txtLoginValidate.focus();return;}
		Tx_UserLogin(userName.val(),passWord.val(),expDT.val(),true,txtLoginValidate.val());
	}
	else{
		Tx_UserLogin(userName.val(),passWord.val(),expDT.val(),false,"");
	}
}

//捕捉住回车提交事件!
function EnterSubmit(){if (event.keyCode == 13){LoginIn();}}
//改变登录退出后界面的布局
function ResetUserLoginStatus(){
	try{TxTB_UserID=Tx_BaseCookie.TxBBS_CurrentUserID();TxTB_UserName=Tx_BaseCookie.TxBBS_CurrentUserName();}catch(e){}
	if(TxTB_UserID==0){
		jQuery("#loginBefor")[0].style.display="block";
		jQuery("#loginLater").hide();jQuery("#ValidateCodeImg").hide();jQuery("#txtLoginValidate").hide();jQuery("#myGameShow").hide();jQuery("#txtUserName").val("");
		jQuery("#txtUserPassword").val("");jQuery("#loginblog").hide();$("#Nav_2Li").hide();
		var subNav_1=jQuery("#subNav_1");subNav_1.html("<p>登录后使用</p><p><a href=\"http://group.tiexue.net/\">匿名浏览</a></p>");
		if(hInterval!=null){
			clearInterval(hInterval);
		}
	}
	else{
		showMsgNumByAsync();
		jQuery("#loginBefor").hide();jQuery("#loginLater")[0].style.display="block";jQuery("#loginblog")[0].style.display="block";$("#Nav_2Li")[0].style.display="block";jQuery("#myGameShow")[0].style.display="block";jQuery("#UserNameInfo").html(TxTB_UserName); 
		var userUrl=jQuery("#userUrl")[0];
		if(window.location.href.indexOf("book.tiexue.net")>-1){$("#userUrl").parent(".TxPublic_Post2Login_logoutp").css("background-image","url(http://book.itiexue.net/images/v4/bookbg.jpg)");userUrl.href="http://book.tiexue.net/MyCenter.aspx";}
		else if(window.location.href.indexOf("www.junshishu.com")>-1){$("#userUrl").parent(".TxPublic_Post2Login_logoutp").css("background-image","url(http://js.itiexue.net/book/images/v4/bookbg.jpg)");userUrl.href="http://www.junshishu.com/MyCenter.aspx";}
		else{userUrl.href="http://"+TxTB_UserID+".i.tiexue.net/";}userUrl.target="_blank";
		showAsyncNewFirend();
		showAsyncNewGroup();
	}
}

function SeeMsg(){
	Tx_MsgPublic.Tx_ReadMsg(msgCallBack);
	ShowMsgLayer("查看新短信",MsgConfig.ReadNewMsgUrl);
}

//要发短信
function WantSendMsg(){ShowMsgLayer("发短信",MsgConfig.EditMsgUrl);}
function WantToMsg(userName){ShowMsgLayer("发短信",MsgConfig.EditMsgUrl+"?UserList="+escape(userName));}

//登录验证码
function RefreshValidCode(){var userName=jQuery("#txtUserName");jQuery("#ValidateCodeImg").attr("src",Tx_RefreshValidCode(userName.val()))}

//退出
function UserLogOut(){
	Tx_BaseCookie.ClearCookie("UserID");
	Tx_UserLogout();
	jQuery("#loginBefor")[0].style.display="block";jQuery("#loginLater").hide();jQuery("#ValidateCodeImg").hide();jQuery("#txtLoginValidate").hide();jQuery("#myGameShow").hide();jQuery("#txtUserName").val("");jQuery("#txtUserPassword").val("");jQuery("#loginblog").hide();$("#Nav_2Li").hide();
	var subNav_2=jQuery("#subNav_2");subNav_2.html("<p>登录后使用</p>");var subNav_1=jQuery("#subNav_1");subNav_1.html("<p >登录后使用</p><p><a href=\"http://group.tiexue.net/\">匿名浏览</a></p>");
	if(hInterval!=null){
		clearInterval(hInterval);
	}
}

//到博客
function LoginToBlog(){top.location.href='http://'+Tx_BaseCookie.TxBBS_CurrentUserID()+'.i.tiexue.net/blog/';}
function LoginToFriends(){top.location.href='http://'+Tx_BaseCookie.TxBBS_CurrentUserID()+'.i.tiexue.net/friends_1.html'}
function LoginToGroup(){top.location.href='http://group.tiexue.net/'}

//读短信的方法异步读取
function showMsgNumByAsync(){
	TxBBS_UserID= Tx_BaseCookie.TxBBS_CurrentUserID();
	if(TxBBS_UserID>0){
		msgCallBack=function(){showAsyncMsgNum2()};
		GetMsgNum();
	}
	setTimeout("showMsgNumByAsync()",300000);
}
function GetMsgNum(){
	var temp = Tx_MsgPublic.Tx_GetMsgNumFromCache(function(){showAsyncMsgNum2()});
	if(!TxLibraryTool.StringIsNullOrEmpty(temp)){
		var myCount =parseInt(temp)
		if(myCount>=0){
			showAsyncMsgNum2();
		}
	}
}
function showAsyncMsgNum2(){
	var myCount = Tx_MsgPublic.Tx_GetMsgNumFromCache(function(){showAsyncMsgNum2()});
	if(myCount>0){
			jQuery("#NewMsgNum")[0].style.display="";jQuery("#msgNew").hide();jQuery("#NewMsgNum").html(myCount+"条新短信")
		}
		else{
			jQuery("#NewMsgNum").hide();jQuery("#msgNew")[0].style.display="";
		}
}

//异步加载好友列表
function showAsyncNewFirend(){
	TxBBS_UserID= Tx_BaseCookie.TxBBS_CurrentUserID();
	if(TxBBS_UserID>0){
		var t=  Tx_GetCookieFirendAndGroup.Tx_GetMyFriendsFromCookie("subNav_2",function(){SetAsyncMyFirendTo("subNav_2")});
		if(t!=null&&t!='null'&&t!=""){
			SetAsyncMyFirendTo("subNav_2");
		}
	}
	else{
		var a = "<p onmouseover=\"msHover1(this,1)\" onmouseout=\"msOut1(this,1)\" style=\"border-bottom:1px solid #000;height:20px;line-height:20px;text-align:center;cursor:pointer;\">&nbsp;&nbsp;&nbsp;&nbsp;<a  href=\"http://"+TxTB_UserID+".i.tiexue.net/friends_1.html\">好友管理</a>&nbsp;&nbsp;</p>";
		a += "<p>登录后使用</p>";
		var subNav_2=jQuery("#subNav_2");
		subNav_2.html(a);
	}
}

function SetAsyncMyFirendTo(divID){
	data = Tx_GetCookieFirendAndGroup.Tx_GetMyFriendsFromCookie(divID,function(){SetAsyncMyFirendTo(divID)});
	var friendHtml="";
	TxBBS_UserID= Tx_BaseCookie.TxBBS_CurrentUserID();
	friendHtml=friendHtml+"<p onmouseover=\"msHover1(this,1)\" onmouseout=\"msOut1(this,1)\" style=\"border-bottom:1px solid #000;height:20px;line-height:20px;text-align:center;cursor:pointer;\">&nbsp;&nbsp;&nbsp;&nbsp;<a  href=\"http://"+TxTB_UserID+".i.tiexue.net/friends_1.html\">好友管理</a>&nbsp;&nbsp;</p>";
	var result=data;
	var thisObj = $("#"+divID);
	if (thisObj!=null){
		if(result!=""&&result!=null&&result!='null'&&typeof(result)!=null){
			var frends =  result.split(';');
			if(frends!=null&&frends!='undefined'){
				for(var i=0;i<frends.length;i++){
					var myfirend = frends[i].split(',');var myUserID= myfirend[0];var myUserName=myfirend[1];
					friendHtml+="<p onmouseover=\"msHover(this,0)\" onmouseout=\"msOut(this,0)\" style=\"border-bottom:1px solid #ffffff;height:20px;line-height:20px;text-align:left;cursor:pointer;\">&nbsp;<img style=\"vertical-align:middle;\" src=\"http://www.itiexue.net/images/note.gif\" alt=\"发短信\" title=\"发短信\" onclick=\"WantToMsg('"+myUserName+"')\" style=\"cursor:pointer;\"/>&nbsp;<a  style=\"\"target=\"_blank\" href=\"http://"+myUserID+".i.tiexue.net/blog/\">"+myUserName+"</a></p>";
				}
			}
			thisObj.html(friendHtml);
			friendHtml="";
		}
	}
}

//我的公社
function showAsyncNewGroup(){
	TxBBS_UserID= Tx_BaseCookie.TxBBS_CurrentUserID();
	if(TxBBS_UserID>0){
		var t=  Tx_GetCookieFirendAndGroup.Tx_GetMyFriendsFromCookie("subNav_1",function(){SetAsyncMyGroupTo("subNav_1")});
		if(t!=null&&t!='null'&&t!=""){
			SetAsyncMyGroupTo("subNav_1");
		}
	}
	else{
		var noshow="<p  style=\"border-bottom:1px solid #000;height:20px;line-height:20px\">没有加入公社</p><p onmouseover=\"msHover(this,0)\" onmouseout=\"msOut(this,0)\" style=\"height:20px;line-height:20px\"><a href=\"http://group.tiexue.net/\">&nbsp;匿名浏览</a></p>";
		var subNav_2=jQuery("#subNav_1");
		subNav_2.html(noshow);
	}
}
//异步加载公社信息
function SetAsyncMyGroupTo(divID){
	var data =Tx_GetCookieFirendAndGroup.Tx_GetMyGroupsFromCookie(divID,function(){SetAsyncMyGroupTo(divID)});
	var groupHtml="<p style=\"border-bottom:1px solid #000;height:20px;line-height:20px\" onmouseover=\"msHover1(this,1)\" onmouseout=\"msOut1(this,1)\"><a href=\"http://group.tiexue.net/groupslistv2_"+TxTB_UserID+"_1.html\">&nbsp;公社管理</a></p>";
	if(!TxLibraryTool.StringIsNullOrEmpty(data)){
		var noshow="<p  style=\"border-bottom:1px solid #000;height:20px;line-height:20px\">没有加入公社</p><p onmouseover=\"msHover(this,0)\" onmouseout=\"msOut(this,0)\" style=\"height:20px;line-height:20px\"><a href=\"http://group.tiexue.net/\">&nbsp;匿名浏览</a></p>";
		if(data!=""&&data!=null&&data!='null'&&typeof(data)!=null){
			var groups =  data.split(';');
			if(groups!=null&&groups!='undefined'){
				if(groups.length>0){
					for(var i=0;i<groups.length;i++){
						var mygroup = groups[i].split(',');
						groupHtml+="<p onmouseover=\"msHover(this,0)\" onmouseout=\"msOut(this,0)\" style=\"border-bottom:1px solid #ffffff;height:20px;line-height:20px;text-align:left;cursor:pointer;\" onclick=\"top.location.href=\'http://group.tiexue.net/"+mygroup[2]+"/\'\">&nbsp;"+mygroup[1]+"</p>";
					}
				}
				else{groupHtml=groupHtml;
				}
			}
			else{groupHtml=groupHtml;
			}
		}
		else{
			groupHtml=groupHtml;
		}
		var subNav_1=$("#"+divID);
		if(subNav_1!=null){
			subNav_1.html(groupHtml);
		}
	}
}

//显示样式
function showNav (baseID, divID) {
	baseID = jQuery("#"+baseID)[0];divID  = jQuery("#"+divID)[0];
	if (showNav.timer){clearTimeout(showNav.timer);}hideCur();
	divID.style.display = 'block';showNav.cur = divID;
	if (! divID.isCreate) {
		divID.isCreate = true;
		divID.onmouseover = function () {if (showNav.timer) clearTimeout(showNav.timer);hideCur();divID.style.display = 'block';};
		function hide () {showNav.timer = setTimeout(function () {divID.style.display = 'none';}, 0);}
		divID.onmouseout = hide;baseID.onmouseout = hide;
	}
	function hideCur () {
		showNav.cur && (showNav.cur.style.display = 'none');
	}
}
/* ========================= 第一个登陆条 end ================== */
//登陆返回处理参数
function Tx_LoginFun(value){
	if(!TxLibraryTool.StringIsNullOrEmpty(value)){
		var result=value.split('|');
		if(loginBarType==2){//第二个登陆条
			if(result[0]=="true"){
				LogonBar2UserLoginStatus();
			}
			else{
				if(result[1].indexOf('验证码')!=-1){
					$("#valaCode")[0].style.display='';$("#valCode")[0].style.display='';$("#ValiCodeImg")[0].style.display='';$("#valCode").select();
					RefreshValCode();
					alert('此账号已经发生多次无效登录，须要输入验证码');
				}
				else{
					if(result[1].indexOf('用户名')!=-1){
						$("#userName").select();
						alert(result[1])
					}
					else if(result[1].indexOf('密码')!=-1){
						$("#passWord").select();
						alert(result[1])
					}
				}
			}
		}
		else if(loginBarType==12){//default页使用
			if(result[0]=="true"){
				LogonBar2UserLoginStatus();
				TxBBS_userPanelSHowHide();
			}
			else{
				if(result[1].indexOf('验证码')!=-1){
					$("#valaCode")[0].style.display='';$("#valCode")[0].style.display='';$("#ValiCodeImg")[0].style.display='';$("#valCode").select();
					RefreshValCode();
					alert('此账号已经发生多次无效登录，须要输入验证码');
				}else{
					if(result[1].indexOf('用户名')!=-1){
						$("#userName").select();
						alert(result[1])
					}
					else if(result[1].indexOf('密码')!=-1){
						$("#passWord").select();
						alert(result[1])
					}
				}
			}
		}
		else if(loginBarType==73){//汽车连页使用
			if(result[0]=="true"){
				AutoUserLoginStatus();
				ComeCarLian();
			}
			else{
				if(result[1].indexOf('验证码')!=-1){
					$("#valaCode")[0].style.display='';$("#valCode")[0].style.display='';$("#ValiCodeImg")[0].style.display='';$("#valCode").select();
					RefreshValCode();
					alert('此账号已经发生多次无效登录，须要输入验证码');
				}else{
					if(result[1].indexOf('用户名')!=-1){
						$("#userName").select();
						alert(result[1])
					}
					else if(result[1].indexOf('密码')!=-1){
						$("#passWord").select();
						alert(result[1])
					}
				}
			}
		}
		else if(loginBarType==3){//post2页快速登陆
			if(result[0]=="true"){
				post2UserLoginStatus();
			}
			else{
				if(result[1].indexOf('验证码')!=-1){
					$("#post2valCode")[0].style.display='';$("#post2valeCode")[0].style.display='';$("#post2ValiCodeImg")[0].style.display='';
					RefreshPost2QucikValCode();
					alert('此账号已经发生多次无效登录，须要输入验证码');
				}else alert(result[1]);
			}
		}
		else if(loginBarType==14){
			if(result[0]=="true"){
				TxBBS_PostbuttonReply();
				Tx_LayerHide();
			}
			else{
				if(result[1].indexOf('验证码')!=-1){
					$("#postQuickRegisterValCode")[0].style.display='';$("#postQuickRegistervalCode")[0].style.display='';
					RefreshPostQuickRegisterValCode();
					alert('此账号已经发生多次无效登录，须要输入验证码');
				}else alert(result[1]);
			}
		}
		else if(loginBarType==4){// 黄页发帖登陆
			if(result[0]=="true"){
				$("#submitpost").trigger("click");
			}
			else{
				if(result[1].indexOf('验证码')!=-1){
					$("#postQuickValCode")[0].style.display='';$("#postQuickvalCode")[0].style.display='';
					RefreshPostQuickValCode();
					alert('此账号已经发生多次无效登录，须要输入验证码');
				}else alert(result[1]);
			}
		}
		else if(loginBarType==99){
			if(result[0]=="true"){
				MyLoginSuccessAction();
			}
			else{
				MyLoginFailureAction(result[1]);
			}
		}
		else{//第一个登陆条 白页和首页
			if(result[0]=="true"){
				ResetUserLoginStatus();
			}
			else {
				if(result[1].indexOf('验证码')!=-1){
					jQuery("#ValidateCodeImg")[0].style.display="";jQuery("#txtLoginValidate")[0].style.display="";RefreshValidCode();
					alert('此账号已经发生多次无效登录，须要输入验证码');
				}
				else{
					alert(result[1]);
				}
			}
		}
	}
}

//退出
function Tx_LogoutFinish(Flags){
	Tx_GetCookieFirendAndGroup.Tx_ClearGroupAndFriend();
	Tx_MsgPublic.Tx_ClearMsgNumCookie();
	if(loginBarType==2){
		LogonBar2UserLoginStatus();
	}
	else if(loginBarType==12){
		LogonBar2UserLoginStatus();
		TxBBS_userPanelSHowHide();
	}
	else if(loginBarType==73){
		AutoUserLoginStatus();
	}
	else if(loginBarType==3){
	}
	else if(loginBarType==99){
		MyLogOutStatusChange();
	}
	else{
		ResetUserLoginStatus();
	}
}
//登陆时的input变化
function loginmosemove(obj){obj.style.borderColor='#ff0000';}
function loginmoseout(obj){obj.style.borderColor='#DBDBDB';}

/* ============= 汽车连登陆条 BBS begin 303================= */

Tx_InitLoginBarAuto= function(loginBar,type){
	//发帖登陆
	if(!TxLibraryTool.StringIsNullOrEmpty(type)){loginBarType = 12;}
	else{loginBarType =2;}
	document.write('<style type="text/css">#post_head_loginurl .moseOver1{background:#fffce6;color:#bc1c1e;}.TxPublic_PostLogin_text{width:54px;height:15px;background:white;margin-right:5px;border:1px solid #acacac;padding:0px}.TxPublic_PostLogin_img{margin:0px 0px 0px 3px;vertical-align:middle;padding:0px;border:0px}.TxPublic_PostLogin_linka{margin:0px 0px 0px 5px;vertical-align:middle;padding:0px;color:#FFF}.TxPublic_PostLogin_div{float:left;padding:0px;margin:0px;list-style:;}.TxPublic_PostLogin_div dl{padding:0px;margin:0px;}.TxPublic_PostLogin_div dt{float:left;overflow:hidden;padding:0px;margin:0px;}.TxPublic_PostLogin_div dd{float:left;overflow:hidden;list-style:none;padding:0px;margin:0px;list-style:none;}.TxPublic_PostLogin_Site{float:right;margin-top:2px;padding:0px;list-style:none;}.TxPublic_PostLogin_Site a{padding:3px;color:white;float:left;margin-right:7px;overflow:hidden;list-style:none;outline:none;text-decoration:none}.TxPublic_PostLogin_Site span{padding:3px 0px;color:white;float:left;margin-right:7px;overflow:hidden;list-style:none;}.TxPublic_PostLogin_inputimg{margin:0px 0px 0px 5px;vertical-align:middle;padding:0px;}.TxPublic_PostLogin_valimg{margin:0px 0px 0px 5px;vertical-align:middle;border:none;padding:0px;}</style>');
	
	var topHTML ='';
	topHTML += '<div id="post_head_login" class="TxPublic_PostLogin_div">';
	topHTML += '<dl style="display:" id="loginBegin"> <dt>用户名：<input id="userName" type="text" onmousemove="loginmosemove(this)" onmouseout="loginmoseout(this)" class="TxPublic_PostLogin_text" />密码：<input id="passWord" type="password" onmousemove="loginmosemove(this)" onmouseout="loginmoseout(this)" class="TxPublic_PostLogin_text" /><span id="valaCode" style="display:none;">验证码：</span><input id="valCode" type="text" onmousemove="loginmosemove(this)" onmouseout="loginmoseout(this)" class="TxPublic_PostLogin_text" style="display:none;" /></dt><dd ><img id="ValiCodeImg" onclick=\"RefreshValCode()\" class="TxPublic_PostLogin_valimg" style="display:none;"  /><select id="sTime" style="margin:0px 0px 0px 5px;vertical-align:middle;height:20px;padding:0px;"><option value="1">一天</option><option value="7">一周</option><option value="30">一月</option></select><input class="TxPublic_PostLogin_img" onclick=\"return LoginBar2In()\" type="image" src="http://www.itiexue.net/images/bbs/login_btn.gif" /><a href="http://reg.tiexue.net/register.aspx" style="border:0px" target="_blank"><img class="TxPublic_PostLogin_img" src="http://www.itiexue.net/images/bbs/register_btn.gif" /></a><a href="http://reg.tiexue.net/FindPassword.aspx" target="_blank"><img class="TxPublic_PostLogin_img" src="http://www.itiexue.net/images/bbs/rgister_btn.gif" /></a></dd></dl>';
	topHTML += '<dl id="loginEnd"><dt >欢迎您：<span id="myName"></span><a href="http://msg.tiexue.net/" target="_blank"><img id="myMail" class="TxPublic_PostLogin_valimg" src="http://www.itiexue.net/images/bbs/0801035.gif" /></a><span id="myMailNum" style="margin-left:0px;display:none;">2</span></dt><dd ><input class="TxPublic_PostLogin_inputimg" onclick="LoginBar2UserLogOut()" type="image" src="http://www.itiexue.net/images/bbs/auto_btn.gif" /><span class="TxPublic_PostLogin_linka" ID="myHome">我的首页</span><a class="TxPublic_PostLogin_linka" target="_blank" href="http://i.tiexue.net/BasicData.aspx" >设置</a><a class="TxPublic_PostLogin_linka" target="_blank" href="http://i.tiexue.net/BankDefault.aspx" >账户</a><a class="TxPublic_PostLogin_linka" target="_blank" href="http://i.tiexue.net/MyRank.aspx" >军衔</a><a class="TxPublic_PostLogin_linka" target="_blank" href="http://i.tiexue.net/HonorDefault.aspx" >功勋</a><a target="_blank" href="http://www.junph.com/ty/?hmsr=tiexue&hmmd=word&hmpl=gerenzhongxin&hmkw=tiyan&hmci=zyl"><strong style="color:yellow;padding-left:5px">免费体验</strong></a></dd></dl>';
	topHTML += '</div>';
	topHTML += '<div id="post_head_loginurl" class="TxPublic_PostLogin_Site">';
	topHTML += '<a target="_blank" href="http://www.qichelian.com">汽车连首页</a><a target="_blank" href="http://www.qichelian.com/chewen_1.html">社会车闻</a><a target="_blank" href="http://www.qichelian.com/wanche_1.html">用车玩车</a><a target="_blank" href="http://www.qichelian.com/chehuo_1.html">车祸图集</a><a target="_blank" href="http://www.qichelian.com/huabian_1.html">花边猎奇</a><a target="_blank" href="http://www.qichelian.com/xiangche_1.html">香车美女</a>';
	topHTML += '</div>';
	$("body").css({ margin:"0px",padding:"0px","list-style":"none" });
	var postLoginBar = $("#"+loginBar);
	if(postLoginBar!=null){postLoginBar.html(topHTML);}
	else{document.write(topHTML);}
	topHTML=null;
	LogonBar2UserLoginStatus();
}

/* ============= 汽车连登陆条 BBS end 303================= */

/* ============= 第二个登陆条 BBS post2页 begin 303================= */

Tx_InitLoginBarPost= function(loginBar,type){
	//发帖登陆
	if(!TxLibraryTool.StringIsNullOrEmpty(type)){loginBarType = 12;}
	else{loginBarType =2;}
	document.write('<style type="text/css">#post_head_loginurl .moseOver1{background:#fffce6;color:#bc1c1e;}.TxPublic_PostLogin_text{width:54px;height:15px;background:white;margin-right:5px;border:1px solid #acacac;padding:0px}.TxPublic_PostLogin_img{margin:0px 0px 0px 3px;vertical-align:middle;padding:0px;border:0px}.TxPublic_PostLogin_linka{margin:0px 0px 0px 5px;vertical-align:middle;padding:0px;color:#FFF}.TxPublic_PostLogin_div{float:left;padding:0px;margin:0px;list-style:;}.TxPublic_PostLogin_div dl{padding:0px;margin:0px;}.TxPublic_PostLogin_div dt{float:left;overflow:hidden;padding:0px;margin:0px;}.TxPublic_PostLogin_div dd{float:left;overflow:hidden;list-style:none;padding:0px;margin:0px;list-style:none;}.TxPublic_PostLogin_Site{float:right;margin-top:2px;padding:0px;list-style:none;}.TxPublic_PostLogin_Site a{padding:3px;color:white;float:left;margin-right:7px;overflow:hidden;list-style:none;outline:none;text-decoration:none}.TxPublic_PostLogin_Site span{padding:3px 0px;color:white;float:left;margin-right:7px;overflow:hidden;list-style:none;}.TxPublic_PostLogin_inputimg{margin:0px 0px 0px 5px;vertical-align:middle;padding:0px;}.TxPublic_PostLogin_valimg{margin:0px 0px 0px 5px;vertical-align:middle;border:none;padding:0px;}</style>');
	
	var topHTML ='';
	topHTML += '<div id="post_head_login" class="TxPublic_PostLogin_div">';
	topHTML += '<dl style="display:" id="loginBegin"> <dt>用户名：<input id="userName" type="text" onmousemove="loginmosemove(this)" onmouseout="loginmoseout(this)" class="TxPublic_PostLogin_text" />密码：<input id="passWord" type="password" onmousemove="loginmosemove(this)" onmouseout="loginmoseout(this)" class="TxPublic_PostLogin_text" /><span id="valaCode" style="display:none;">验证码：</span><input id="valCode" type="text" onmousemove="loginmosemove(this)" onmouseout="loginmoseout(this)" class="TxPublic_PostLogin_text" style="display:none;" /></dt><dd ><img id="ValiCodeImg" onclick=\"RefreshValCode()\" class="TxPublic_PostLogin_valimg" style="display:none;"  /><select id="sTime" style="margin:0px 0px 0px 5px;vertical-align:middle;height:20px;padding:0px;"><option value="1">一天</option><option value="7">一周</option><option value="30">一月</option></select><input class="TxPublic_PostLogin_img" onclick=\"return LoginBar2In()\" type="image" src="http://www.itiexue.net/images/bbs/login_btn.gif" /><a href="http://reg.tiexue.net/register.aspx" style="border:0px" target="_blank"><img class="TxPublic_PostLogin_img" src="http://www.itiexue.net/images/bbs/register_btn.gif" /></a><a href="http://reg.tiexue.net/FindPassword.aspx" target="_blank"><img class="TxPublic_PostLogin_img" src="http://www.itiexue.net/images/bbs/rgister_btn.gif" /></a></dd></dl>';
	topHTML += '<dl id="loginEnd"><dt >欢迎您：<span id="myName"></span><a href="http://msg.tiexue.net/" target="_blank"><img id="myMail" class="TxPublic_PostLogin_valimg" src="http://www.itiexue.net/images/bbs/0801035.gif" /></a><span id="myMailNum" style="margin-left:0px;display:none;">2</span></dt><dd ><input class="TxPublic_PostLogin_inputimg" onclick="LoginBar2UserLogOut()" type="image" src="http://www.itiexue.net/images/bbs/auto_btn.gif" /><span class="TxPublic_PostLogin_linka" ID="myHome">我的首页</span><a class="TxPublic_PostLogin_linka" target="_blank" href="http://i.tiexue.net/BasicData.aspx" >设置</a><a class="TxPublic_PostLogin_linka" target="_blank" href="http://i.tiexue.net/BankDefault.aspx" >账户</a><a class="TxPublic_PostLogin_linka" target="_blank" href="http://i.tiexue.net/MyRank.aspx" >军衔</a><a class="TxPublic_PostLogin_linka" target="_blank" href="http://i.tiexue.net/HonorDefault.aspx" >功勋</a><a target="_blank" href="http://www.junph.com/ty/?hmsr=tiexue&hmmd=word&hmpl=gerenzhongxin&hmkw=tiyan&hmci=zyl"><strong style="color:yellow;padding-left:5px">免费体验</strong></a><a target="_blank" href="http://www.junph.com/junpin/?hmsr=Itad&hmmd=bbs&hmpl=anniu&hmkw=junph&hmci=zyl "><strong style="color:yellow;padding-left:5px">军品装备</strong></a></dd></dl>';
	topHTML += '</div>';
	topHTML += '<div id="post_head_loginurl" class="TxPublic_PostLogin_Site">';
	topHTML += '<a  target="_blank" href="http://www.tiexue.net/">网站首页</a><a target="_blank" href="http://mil.tiexue.net/">军事</a><a target="_blank" href="http://bbs.tiexue.net/">社区</a><a target="_blank" href="http://book.tiexue.net/");>读书</a><span>|</span><a target="_blank" href="http://pic.tiexue.net/">图片</a><a target="_blank" href="http://jingcha.tiexue.net/">警察</a><a  target="_blank" href="http://game.tiexue.net/">游戏</a><a target="_blank" href="http://www.tiexue.net/mobile/" onclick="_gaq.push([\'_trackEvent\', \'第一屏-导航\', \'clicked\', \'手机\'])">手机</a><span>|</span><!--<a target="_blank" href="http://wm.tiexue.com/">热血文明</a>//--><a target="_blank" href="http://www.junph.com/">铁血君品行</a><a target="_blank" href="http://bbs.qichelian.com/">汽车连</a><span >|</span><a target="_blank" href="http://help.tiexue.net/">帮助</a>';
	topHTML += '</div>';
	$("body").css({ margin:"0px",padding:"0px","list-style":"none" });
	var postLoginBar = $("#"+loginBar);
	if(postLoginBar!=null){postLoginBar.html(topHTML);}
	else{document.write(topHTML);}
	topHTML=null;
	LogonBar2UserLoginStatus();
}

//第二个登陆试用
function LoginBar2In(){
	var userName=jQuery("#userName");var passWord=jQuery("#passWord");var expDT=jQuery("#sTime");
	if (userName.val().length < 1){alert("用户ID不能为空");userName.focus();return false;}
	else if(passWord.val().length<1){alert("密码不能为空"); passWord.focus();return false;}
	if($("#valCode")[0].style.display==""){
		Tx_UserLogin(userName.val(),passWord.val(),expDT.val(),true,$("#valCode").val());
	}
	else{Tx_UserLogin(userName.val(),passWord.val(),expDT.val(),false,"");}
}

//退出
function LoginBar2UserLogOut(){
	Tx_BaseCookie.ClearCookie("UserID");
	Tx_UserLogout();
	$("#loginBegin")[0].style.display="block";$("#loginEnd")[0].style.display="none";$("#valaCode")[0].style.display='none';$("#valCode")[0].style.display='none';$("#ValiCodeImg")[0].style.display='none';
	if(hInterval!=null){
		clearInterval(hInterval);
	}
}

//登录验证码
function RefreshValCode(){var userName=$("#userName");$("#ValiCodeImg").attr("src",Tx_RefreshValidCode(userName.val()))}

//改变登录退出后界面的布局
function LogonBar2UserLoginStatus(){
	try{
		TxTB_UserID=Tx_BaseCookie.TxBBS_CurrentUserID();
		TxTB_UserName=Tx_BaseCookie.TxBBS_CurrentUserName();
	}catch(e){}
	if(TxTB_UserID==0){
		$("#loginBegin")[0].style.display="block";$("#loginEnd")[0].style.display="none"; $("#valaCode")[0].style.display='none';$("#valCode")[0].style.display='none';$("#ValiCodeImg")[0].style.display='none';
		if(hInterval!=null){
			clearInterval(hInterval);
		}
	}
	else{
		$("#loginBegin")[0].style.display="none";$("#loginEnd")[0].style.display="block";
		$("#myName").html(TxTB_UserName);
		$("#myHome").html("<a style=\"color:#FFF\" href='http://"+TxTB_UserID+".i.tiexue.net/' target='_blank' >我的首页</a>");
		showLoginBar2MsgNumByAsync();
	}
}

function AutoUserLoginStatus(){
	try{
		TxTB_UserID=Tx_BaseCookie.TxBBS_CurrentUserID();
		TxTB_UserName=Tx_BaseCookie.TxBBS_CurrentUserName();
	}catch(e){}
	if(TxTB_UserID==0){
		$("#loginBegin").css("display","block");
		$("#loginEnd").add("#valaCode").add("#valCode").add("#ValiCodeImg").css("display","none");
		if(hInterval!=null){
			clearInterval(hInterval);
		}
	}
	else{
		$("#loginBegin").css("display","none");
		$("#loginEnd").css("display","block");
		$("#myName").html(TxTB_UserName);
		$("#myHome").html('<a href="http://hi.qichelian.com/'+TxTB_UserID+'/index.html" target="_blank">进入个人中心</a>');
		showLoginBar2MsgNumByAsync();
	}
}

/* 读短信的方法异步读取 */
function showLoginBar2MsgNumByAsync(){
	TxBBS_UserID= Tx_BaseCookie.TxBBS_CurrentUserID();
	if(TxBBS_UserID>0){
		msgCallBack=function(){GetLoginBar2AsyncNewMsgNum()};
		var myCount = Tx_MsgPublic.Tx_GetMsgNumFromCache(function(){GetLoginBar2AsyncNewMsgNum()});
		if(!TxLibraryTool.StringIsNullOrEmpty(myCount)){
			GetLoginBar2AsyncNewMsgNum();
		}
	}
	setTimeout("showLoginBar2MsgNumByAsync()",300000);
}

//短信数量显示 异步时调用
function GetLoginBar2AsyncNewMsgNum(){
	var myCount = Tx_MsgPublic.Tx_GetMsgNumFromCache(function(){GetLoginBar2AsyncNewMsgNum()});
	if(myCount>0){
		$("#myMail").attr("src","http://www.itiexue.net/images/bbs/08010351.gif")
		$("#myMailNum")[0].style.display="";
		$("#myMailNum").html('[<span style=\"cursor:pointer;\" onclick=\"loginBar2SeeMsg()\"">'+myCount+'</span>]');
	}
	else{
		$("#myMail").attr("src","http://www.itiexue.net/images/bbs/0801035.gif");
		$("#myMailNum")[0].style.display="none";
	}
}

//看短信
function loginBar2SeeMsg(){
	Tx_MsgPublic.Tx_ReadMsg(msgCallBack);
	ShowMsgLayer("查看新短信",MsgConfig.ReadNewMsgUrl);
}
/* ============ 第二个登陆条 end ============ */


/* ================ BBS post2白页登陆 begin============= */
//第二个登陆试用
TxBBS_Post2LoginIn = function(){
	loginBarType = 3;
	var userName=jQuery("#post2userName");var passWord=jQuery("#post2passWord");
	if (userName.val().length < 1){alert("用户ID不能为空");userName.focus();return;}
	else if(passWord.val().length<1){alert("密码不能为空"); passWord.focus();return;}
	if($("#post2valeCode")[0].style.display==""){
		Tx_UserLogin(userName.val(),passWord.val(),1,true,$("#post2valCode").val());
	}
	else{
		Tx_UserLogin(userName.val(),passWord.val(),1,false,"");
	}
}

function post2UserLoginStatus(){
	$("#userLogin").html("<span >发帖用户：</span>"+Tx_BaseCookie.TxBBS_CurrentUserName());
}

//登录验证码
function RefreshPost2QucikValCode(){var userName=$("#post2userName");$("#post2ValiCodeImg").attr("src",Tx_RefreshValidCode(userName.val()))}
/* =============== BBS post2白页登陆 end ============== */

/*================= BBS post页登陆 begin ===========================*/
//第二个登陆试用
TxBBS_PostQuickLoginIn = function(typeID){
	if(typeID==2){loginBarType = 14;}
	else{loginBarType = 4;}
	var userName=jQuery("#postQuickUserName");var passWord=jQuery("#postQuickpassWord");var exdate = $(":radio[name='postQuickDates'][checked]").val();
	if (userName.val().length < 1){alert("用户ID不能为空");userName.focus();return;}
	else if(passWord.val().length<1){alert("密码不能为空"); passWord.focus();return;}
	if($("#postQuickValCode")[0].style.display==""){
		Tx_UserLogin(userName.val(),passWord.val(),exdate,true,$("#postQuickvalCode").val());
	}
	else{Tx_UserLogin(userName.val(),passWord.val(),exdate,false,"");}
}

//登录验证码
function RefreshPostQuickValCode(){var userName=$("#postQuickUserName");$("#postQuickimg").attr("src",Tx_RefreshValidCode(userName.val()))}

/*============ BBS post页登陆 end===================*/

/*============== BBS post页登陆和注册 begin =======================*/
//第二个登陆试用
TxBBS_PostQuickLoginInAndRegister = function(){
	loginBarType = 14;

	var userName=jQuery("#postQuickRegisterUserName");var passWord=jQuery("#postQuickRegisterpassWord");var exdate = $(":radio[name='postQuickRegisterDates'][checked]").val();
	if (userName.val().length < 1){alert("用户ID不能为空");userName.focus();return;}
	else if(passWord.val().length<1){alert("密码不能为空"); passWord.focus();return;}
	if($("#postQuickRegisterValCode")[0].style.display==""){
		Tx_UserLogin(userName.val(),passWord.val(),exdate,true,$("#postQuickRegistervalCode").val());
	}
	else{Tx_UserLogin(userName.val(),passWord.val(),exdate,false,"");}
}

//登录验证码
function RefreshPostQuickRegisterValCode(){var userName=$("#postQuickRegisterUserName");$("#postQuickRegisterimg").attr("src",Tx_RefreshValidCode(userName.val()))}

/*============= BBS post页登陆和注册 end=====================*/

/*==============  BBS 公共登录登录 begin ===================== */
TXBBS_BBSPublicIndexLogin = function(){loginBarType = 99;MyLoginBefore();}
/*================  BBS首页登录 end ===================== */

//未登录提示
Tx_ShowNotLoginAlert = function(){
	if(Tx_BaseCookie.TxBBS_CurrentUserID()<=0){
		ShowBgLayer("提示",false,'<div  style="font-size:12px;width:200px;height:75px;margin:0px auto;text-align:center"><p style="margin:10px 0px;padding:0px">还没有登录。请登录后再操作</p></div>',"200px","103px");
		return false;
	}
	else{return true;}
}

/* ========== js弹出框 begin 303 ============= */
/* 弹出框 URL 参数，标题 url */
ShowMsgLayer = function(title,url){ShowLayerWithWidth(title,url,'430px','360px');}

/*弹出框 标题 url 宽度长度*/
ShowLayerWithWidth = function(title,url,width,height){
	Layer.Show({title: title,src: url,follow: true,move:false,bg:false, panel: 'p2', sWidth:width, sHeight:height,cSpeed: 0,callBack: function() { },firstFun: function() { }});
}

/* 弹出框 传HTML代码*/
ShowBgLayer = function(title,bg,sHtml){ShowBgLayer(title,bg,sHtml,'660px','430px')}

/* 弹出框 传HTML代码* 参数，标题 是否使用背景,html代码*/
ShowBgLayer = function(title,bg,sHtml,width,height){
	Layer.Show({title: title,follow: true,move:false,bg:bg, panel: 'p5',html:sHtml,sWidth:width, sHeight:height, cSpeed: 0,callBack: function() { },firstFun: function() { }});
}

//操作等待提示
Tx_ProcessShow = function(msg){
	var maskbg="#ccc";
	var h1 = parseInt(document.body.clientHeight)+parseInt(document.body.scrollTop);
	var h2 = parseInt(window.screen.availHeight);
	var ds=parseInt(document.documentElement.scrollTop);
	var h=h1>h2?h1:h2;
	$("body").append("<div id='proessMask' style='width:100%; height:"+h+"px; text-align:center; background-color:"+maskbg+"; position:absolute; top:0px; left:0px;filter: alpha(opacity=70); opacity: 0.7; z-index:10000; '></div>");
	$("body").append("<div id='proessMask2' style='width:100%;position:absolute; top:"+(h2/2-200+ds)+"px; left:0px; z-index:100011; text-align:center; '><div style='width:300px; min-height:100px; height:auto; border-width:0px 0px 0px 0px; border-style:solid; border-color:"+maskbg+"; position:static;margin:0px auto; font-size:12px; text-align:left; padding:0px; line-height:18px;'></div><div style='width:300px; height:40px; border-width:0px 0px 0px 0px; border-style:solid; border-color:"+maskbg+"; position:static; background-color:#fff; margin:0px auto; font-size:12px; text-align:center; padding:8px; line-height:18px;'>"+msg+"<br/><img src=\"http://js.itiexue.net/com/tiexue/images/loading.gif\" /></div></div>")
}
//操作等待提示关闭
Tx_ProcessHide = function(){$("#proessMask").remove();$("#proessMask2").remove();}
//关闭弹出层
Tx_LayerHide = function(){
	var _scr=document.getElementById("tempid").innerHTML;
	var e=document.getElementById('pop_close_'+_scr);
	TxLayerClose(e);
};
//关闭带ifame的弹出层
Tx_parentClose = function(){
	var _scr=window.frameElement.src;
	var e=parent.document.getElementById('pop_close_'+_scr.GetPara('rand'));
	TxLayerClose(e);
};

TxLayerClose= function(e){
	if(!e) return;
	if (document.all) e.click();
	else if (document.createEvent) {
		var ev = document.createEvent('MouseEvents');
		ev.initEvent('click', false, true);
		e.dispatchEvent(ev);
	};
}

//弹出框
var Layer = new Object();
	Layer = {
		zIndex: 2009,Hash: {},
		Config: {
			bg: '<iframe id="pop_bg2_{0}" scrolling=0 frameborder=0 style="position:absolute;left:0;top:0;z-index:1000;width:100%;background:black;filter:alpha(opacity=70);" ></iframe>',
			bg1: '<div  style="width:100%; height:{0}px; text-align:center; background-color:#ccc; position:absolute; top:0px; left:0px;filter: alpha(opacity=70); opacity: 0.7; z-index:10000;"></div>',
			p2:'<div style="position:absolute;height:{8};width:{9};overflow:hidden;padding:1px;background:url(http://www.itiexue.net/Images/pop_box_center_bg.png);_background:#888;" id="{3}{0}">'+
				 '<span id="tempid" style="display:none">{0}</span><div style="background:none repeat scroll 0 0 #FFFFFF;height: 100%;">'+
				 '<div style="height:28px;overflow:hidden;background:#fff url(http://www.itiexue.net/Images/pop_repeat_x_bg.gif) 0 0 repeat-x;">'+
				 '<div id="{4}{0}"><h3 id="pop_title_{0}" style="margin:0;padding:0 0 0 12px;line-height:28px;float:left;font-size:13px;color:#48555a; width:80%; cursor:move; text-align:left;">{6}</h3></div>'+
				'<div style="float:right;display:inline;margin:2px 2px 0 0;"><span href="javascript:;" id="{5}{0}" title="关闭" style="width:22px;height:23px;display:block;overflow:hidden;text-indent:-9999px;background:url(http://www.itiexue.net/Images/pop_norepeat_bg.gif);cursor:pointer;">关闭</span></div></div>'+
				 '<div style="background:none repeat scroll 0 0 #FFFFFF;height:{10}px;"><iframe  style="margin: 0px; padding: 0;height: 100%; width:100%" id="pop_frame_{0}" frameborder="0" scrolling="no" haslayout="-1" src="{1}"></div></div></div>',
			p5 :'<div style="position:absolute;height:{8};width:{9};overflow:hidden;padding:1px;background:url(http://www.itiexue.net/Images/pop_box_center_bg.png);_background:#888;" id="{3}{0}">'+
				 '<span id="tempid" style="display:none">{0}</span><div style="background:none repeat scroll 0 0 #FFFFFF;">'+
				 '<div style="height:28px;overflow:hidden;background:#fff url(http://www.itiexue.net/Images/pop_repeat_x_bg.gif) 0 0 repeat-x;">'+
				 '<div id="{4}{0}"><h3 id="pop_title_{0}" style="margin:0;padding:0 0 0 12px;line-height:28px;float:left;font-size:13px;color:#48555a; width:80%; cursor:move; text-align:left;">{6}</h3></div>'+
				'<div style="float:right;display:inline;margin:2px 2px 0 0;"><span href="javascript:;" id="{5}{0}" title="关闭" style="width:22px;height:23px;display:block;overflow:hidden;text-indent:-9999px;background:url(http://www.itiexue.net/Images/pop_norepeat_bg.gif);cursor:pointer;">关闭</span></div></div><div style="background:none repeat scroll 0 0 #FFFFFF;height:{10}px;margin-top:0px!important; padding-top:1px!important;">{7}</div></div></div>'
			},
		
		Show:function(config){//显示
			if(!config) throw {msg:'请输入参数'};
			var _json={
			panel: config.panel||'p3', //样式模板
			title: config.title||'', //标题
			tid: config.title||'pop_title_', //标题id
			html: config.html||'', //传入的html代码
			bg: !!config.bg||false, //背景
			sWidth:config.sWidth||'660px', //传入的宽度
			sHeight:config.sHeight||'430px', //传入的宽度
			cid: config.cid||'pop_cont_', //主内容id
			hid: config.hid||'pop_head_', //拖动id
			clid: config.clid||'pop_close_', //关闭id
			src: config.src||'', //iframe地址
			fcon: config.fcon||'', //底部内容
			follow: !!config.follow||false, //跟随
			move: !!config.move||false , //移动
			sSpeed: config.sSpeed||5, //淡进
			cSpeed: config.cSpeed||0, //关闭速度
			fSpeed: config.fSpeed||100, //跟随延迟
			callBack: config.callBack|| function(){}, //结束回调函数
			firstFun: config.firstFun|| function(){}, //预先执行函数
			noRand: config.noRand //是否添加随机值在url末尾
			};
			var _temdId= !!!_json.noRand ? Math.floor(Math.random()*10000000000) : 1;
			this.Hash[_temdId+'']=_json.cid+_temdId;
			var _div=document.createElement('div');
			_div.id='pop_container_'+_temdId;
			_div.style.display='none';
			_div.$sndaId=_temdId;
			_div.$cSpeed=_json.cSpeed;
			_div.$callBack=_json.callBack;
			if(_json.src.indexOf('?')>0) _json.src=_json.src+'&rand='+_temdId;
			else _json.src=_json.src+'?rand='+_temdId;
			if(config.bg){
				_div.innerHTML= this.Config.bg.Format(_temdId)+this.Config[_json.panel].Format(_temdId,"",_json.fcon,_json.cid,_json.hid,_json.clid,_json.title,_json.html,_json.sHeight,_json.sWidth,(parseInt(_json.sHeight)-29));
			}
			else{
				_div.innerHTML= this.Config[_json.panel].Format(_temdId,"",_json.fcon,_json.cid,_json.hid,_json.clid,_json.title,_json.html,_json.sHeight,_json.sWidth,(parseInt(_json.sHeight)-29));
			}
			document.body.appendChild(_div);
			var tempiframe = document.getElementById("pop_frame_"+_temdId);
			if(tempiframe!=null&&tempiframe!=''&&tempiframe!='undefined'){
				tempiframe.src = _json.src;
			}
			this.SetBackGround("pop_bg2_"+_temdId,"pop_bg1_"+_temdId);
			var _close=document.getElementById(_json.clid+_temdId);
			if(_close){//绑定关闭
			addEventHandler(_close,'click',this.Close,false);
			_close.$sndaId=_temdId;
			};
			this.BeMiddle(_temdId);//设置居中
			if(_json.follow) this.Follow(_json);//设置跟随
			if(_json.move){//设置拖动
			var _m=document.getElementById(_json.cid+_temdId);
			var _h=document.getElementById(_json.hid+_temdId);
			this.Drag(_h,_m,0,0);
			};
			fadeIn(_div,100,_json.sSpeed);
			},
		Close:function(evt){//关闭
			var num,_elem= getCurrentElem(evt);
			if(!_elem.$sndaId) return false;
			else num=_elem.$sndaId;
			if(!Layer.Hash[num+'']) return false;
			var _o=document.getElementById('pop_container_'+num);
			var _con=document.getElementById(Layer.Hash[num+'']);
			var callBack=function(){
			removeNode(_o);
			_o.$callBack();
			};
			delete Layer.Hash[num+''];
			if(_o && _con) fadeOut(_con,_o.$cSpeed,true,callBack);
			cancelBubble(evt)
		},
		Follow:function(config){//跟随
			var timer;
			var scollEvent=function(){
			if(timer) return;
			timer = setTimeout(function() {
			var _winWidth = Postion.windowWidth(),
			_winHeight = Postion.windowHeight();
			for(var o in Layer.Hash){ 
			if(!o) continue;
			var _div=document.getElementById(Layer.Hash[o+'']);
			var w= getStyle( _div , 'width').replace('px','')>>0;var h = getStyle( _div , 'height').replace('px','')>>0;
			var sX = Postion.scrollX();var sY = Postion.scrollY();setX(_div,sX + (_winWidth-w)/2);setY(_div,sY +(_winHeight-h)/2)
			};
			timer=null;
			},config.fSpeed);
			};
			addEventHandler(window,'scroll',scollEvent,false);
			addEventHandler(window,'resize',scollEvent,false);
			addEventHandler(window,'load',scollEvent,false);
		},
		BeMiddle:function(id){//居中
			var _div=document.getElementById(this.Hash[id+'']),
			_width = getStyle( _div , 'width' ),
			_height = getStyle( _div , 'height');
			_div.style.left =( Postion.windowWidth()/2 - (_width.replace('px','')>>0)/2 + Postion.scrollX()) + 'px';
			_div.style.top =( Postion.windowHeight()/2 - (_height.replace('px','')>>0)/2 + Postion.scrollY()) + 'px';
			this.zIndex+=1;
			_div.style.zIndex= this.zIndex;
		},
		SetBackGround:function(){//设置背景宽度
			for(var i=0,j=arguments.length;i<j;i+=1) {
			(function(o,h,w){
			if(o){ o.style.height=h; o.style.width=w; };
			})(document.getElementById(arguments[i]),
			(Math.max( Postion.windowHeight(), Postion.pageHeight())) + "px",
			(Math.max( Postion.windowWidth(), Postion.pageWidth())) + "px");
			};
		},
		Drag:function(o,root,minX,minY,opacity){//移动
			 !o.$Root&&(o.$Root=root||o);
			 opacity = opacity||0.3;
			 var x,y,_cloneItem = ['height','width','left','top'],timer;
			 var DragEvent={
				 mousedown:function(evt){//拖动开始
					evt = evt || window.event;
					x = evt.layerX || evt.offsetX;y = evt.layerY || evt.offsetY;
					_clone.style.left=root.style.left;_clone.style.top=root.style.top;
					document.body.appendChild(_clone);
					addEventHandler(document,'mousemove',DragEvent.move,false);
					addEventHandler(document,'mouseup',DragEvent.end,false);
					hide(root);
					return false;
				},
				clone:function(e,opacity){//克隆对象样式
					var _div = document.createElement('div');
					_div.$handle = o;_div.$root = root;_div.innerHTML=root.innerHTML;
					_div.style.background="#888"; _div.style.position="absolute"; _div.style.height="100%"; _div.style.width="100%";
					_div.style.overflow="hidden"; _div.style.padding="5px"; _div.style.filter = 'alpha(opacity='+(opacity * 100)+')';
					_div.style.opacity = opacity;
					for(var i=0;i<_cloneItem.length;i+=1) _div.style[_cloneItem[i]]=getStyle(e,_cloneItem[i]);
					return _div;
				},
				end:function(evt){//结束拖动
					evt = evt || window.event;
					_clone.$temp && setX(_clone.$root,_clone.$temp.left)&&setY(_clone.$root,_clone.$temp.top);
					removeEventHandler(document,'mousemove',DragEvent.move,false);
					root.style.left=_clone.style.left;root.style.top=_clone.style.top;
					removeNode(_clone);show(root);
				},
				compare:function(){//比较
					if(_clone.$minX != null) _clone.$temp.left = Math.max(_clone.$temp.left , _clone.$minX) + Postion.scrollX();
					if(_clone.$minY != null) _clone.$temp.top = Math.max(_clone.$temp.top , _clone.$minY) + Postion.scrollY(); 
				},
				move:function(evt){//移动
					if(timer) return;
					var evt = evt|| window.event,left=evt.clientX- x,top=evt.clientY- y; 
					if(evt.clientX>(Postion.windowWidth()-parseInt(root.style.width))){left = Postion.windowWidth()-parseInt(root.style.width)-30}
					if(evt.clientY>(Postion.windowHeight()-parseInt(root.style.height))){top= Postion.windowHeight()-parseInt(root.style.height)}

					timer=setTimeout(function(){
					_clone.$temp = {left:left,top:top};
					DragEvent.compare();
					setX(_clone,_clone.$temp.left);setY(_clone,_clone.$temp.top);
					timer = null;
					},10);
					cancelBubble(evt);
				}
			};
			var _clone = DragEvent.clone(o.$Root,opacity);//克隆
			_clone.$minX = typeof minX != 'undefined' ? minX : null;
			_clone.$minY = typeof minY != 'undefined' ? minY : null;
			addEventHandler(o,'mousedown',DragEvent.mousedown,false);
		}
	}
	
	addEventHandler =function(a,b,c,d){if(a.addEventListener)a.addEventListener(b,c,d);else if(a.attachEvent)a.attachEvent("on"+b,c);else a["on"+b]=c}
	removeEventHandler=function(a,b,c,d){if(a.removeEventListener)a.removeEventListener(b,c,d);else if(a.detachEvent)a.detachEvent('on'+b,c);else a['on'+b]=null}
	getCurrentElem = function(a){a=a||window.event;return a.srcElement||a.target}
	removeNode = function(a){a.parentNode&&a.parentNode.removeChild(a);}
	var Postion = {
		scrollX:function(){var a=document.documentElement;return self.pageXOffset||(a&&a.scrollLeft)||document.body.scrollLeft||0},
		scrollY:function(){var a=document.documentElement;return self.pageYOffset||(a&&a.scrollTop)||document.body.scrollTop||0},
		windowWidth:function(){var a=document.documentElement;return self.innerWidth||(a&&a.clientWidth)||document.body.clientWidth},
		windowHeight:function(){var a=document.documentElement;return self.innerHeight||(a&&a.clientHeight)||document.body.clientHeight},
		pageWidth:function(){return document.body.scrollWidth},
		pageHeight:function(){return document.body.scrollHeight}
	}
	setX = function(a,b){a.style.left=b+"px";}
	setY = function(a,b){a.style.top=b+"px";}
	getStyle = function(a,b){if(a.style[b])return a.style[b];else if(a.currentStyle)return a.currentStyle[b];else if(document.defaultView&&document.defaultView.getComputedStyle){b=b.replace(/([A-Z])/g,"-$1");b=b.toLowerCase();var s=document.defaultView.getComputedStyle(a,"");return s&&s.getPropertyValue(b)}else return null;}
	hide = function(a){var b=getStyle(a,"display");if(b!="none")a.$oldDisplay=b;a.style.display="none";}
	getCurrentElem = function(a){a=a||window.event;return a.srcElement||a.target}
	show=function(a){a.style.display=a.$oldDisplay||"block";}
	setOpacity=function(a,b){if(a.filters)a.style.filter="alpha(opacity="+b+")";else a.style.opacity=b/100;}
	fadeIn=function(b,c,d){show(b);}
	fadeOut=function(b,c,d,e){for(var i=0;i<100;i+=2){(function(){var a=i;setTimeout(function(){if(a==98){if(!d)hide(b);else removeNode(b);e()}},(i+1)*c)})()}}
	StopDefault=function(e){if(e&&e.preventDefault)e.prefentDefault();else window.event.returnValue=false;return false}
	cancelBubble =function(a){a=a||window.event;if(window.event)a.cancelBubble=true;else a.stopPropagation()},
	//扩展方法
	String.prototype.Format = function() {var a = this; var b = arguments.length;for (var i = 0; i < b; i += 1) a = a.replace(new RegExp("\\{" + i + "\\}", "g"), arguments[i]); return a };
	String.prototype.GetPara=function(e){var svalue = this.match(new RegExp("[\?\&]" + e + "=([^\&]*)(\&?)","i"));return svalue ? svalue[1] :svalue; };

/* ===== js弹出框 end 303 ========= */

/*本类公共方法begin*/
var TxLibraryTool = {
	StringIsNullOrEmpty:function(strMsg){//判断是否为空
		var isEmpty = false;
		if(strMsg=="" || strMsg==null || strMsg=="undefined"||strMsg=="null"||typeof(strMsg)=="undefined"){isEmpty = true;}
		return isEmpty;
	},
	StringLength:function(strMsg){//字符串的长度
		var len = 0;
		for(i=0;i<strMsg.length;i++){
			if(strMsg.charCodeAt(i) > 255){len = len +2;}
			else{len = len +1;}
		}
		return len;
	},
	StringIsEmail:function(email){
		return (/^[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]*)*@[a-zA-Z0-9\-]+([\.][a-zA-Z0-9\-]+)+$/ig.test(email))
	}
}
/*本类公共方法end*/
//访问汽车连首页、汽车连论坛首页的自动开通汽车连个人中心
function ComeCarLian(){
	if (Tx_BaseCookie.TxBBS_CurrentUserID()==0){return;}//匿名用户退出
	//cookie判断是否来过汽车连
	jQuery.ajax({
    type:"get",
    url:"agent.aspx?desturl=" + encodeURIComponent(MsgConfig.ComeToCarNew),
    dataType:"application/x-www-form-urlencoded",
    error:function(XMLHttpRequest){
		//alert("设置第一次来发生错误"); //屏蔽掉异步错误
    },
    success:function(data){
        //第一次访问汽车连，开通个人中心 返回 true
        //以后访问返回 false:已来过
		}
    });
}

//生成底部导航
function GetCompanyNodeContent(Node)
{
    if(Node=="about")
    {
        var html = '';
        html += '<a href="http://www.tiexue.net/company/" target="_blank">关于铁血</a>';  
        html += ' | ';  
        html += '<a href="http://www.tiexue.net/company/ad.htm" target="_blank">广告洽谈</a>';  
        html += ' | ';  
        html += '<a href="http://www.tiexue.net/company/products.htm" target="_blank">旗下产品</a>';  
        html += ' | ';   
        html += '<a href="http://www.tiexue.net/company/hr.htm" target="_blank">招贤纳士</a>';  
        html += ' | ';  
        html += '<a href="http://www.tiexue.net/company/contact.htm" target="_blank">值班客服</a>';  
        html += ' | ';  
        html += '<a href="http://www.tiexue.net/company/disclaimer.htm" target="_blank">免责声明</a>';  
        html += ' | ';  
        html += '<a href="http://www.tiexue.net/company/report.htm" target="_blank">侵权举报</a>';  
        html += ' | ';  
        html += '<a href="http://www.tiexue.net/mobile/" target="_blank">手机上铁血</a>';  
        document.write(html);
        html = '';
    }
    if(Node=="version")
    {
         var htmlv ='铁血社区 Ver2.3 铁血网版权所有2001-2011';  
         document.write(htmlv);
         htmlv = '';
    }
    if(Node=="law")
    {
         var htmll ='网站法律顾问：北京市鑫诺律师事务所 刘容律师';   
         document.write(htmll);
         htmll = '';
    }
    if(Node=="record")
    {
        var htmlr ='京ICP证050083号 京ICP备09067787 <a href="http://www.tiexue.net/Images/0607-095.jpg">京网文［2010］0607-095号</a> 公安机关备110108902146';   
        document.write(htmlr);
        htmlr = '';
    }
} 

//生成底部导航(汽车连项目专用)
function GetCompanyNodeContentWithQCL(Node)
{
    if(Node=="about")
    {
        var html = '';
        html += '<a href="http://assist.qichelian.com/cagetory/qichelian.htm#open(2,2)" target="_blank">关于我们</a>';
        html += '<span>|</span>';
        html += '<a href="http://assist.qichelian.com/cagetory/qichelian.htm#open(3,2)" target="_blank">联系我们</a>';
        html += '<span>|</span>';
        html += '<a href="http://assist.qichelian.com/cagetory/qichelian.htm#open(4,2)" target="_blank">商务洽谈</a>';
        html += '<span>|</span>';
        html += '<a href="http://assist.qichelian.com/cagetory/qichelian.htm#open(5,2)" target="_blank">免责声明</a>';
        html += '<span>|</span>';
        html += '<a href="http://assist.qichelian.com/cagetory/qichelian.htm#open(6,2)" target="_blank">侵权举报</a>';
        document.write(html);
        html = '';
    } 
    if(Node=="record")
    {
        var htmlr ='京ICP备09067787号-3 京公网安备110108400543号';   
        document.write(htmlr);
        htmlr = '';
    }
    if(Node=="version")
    {
         var htmlv ='2010 qichelian.com all rights reserved';  
         document.write(htmlv);
         htmlv = '';
    }
} 
