function isCanShowAvatar(CurAvatarStr) {
	var TempSplit,ItemSplit;
	TempSplit = CurAvatarStr.split("|");
	if (TempSplit.length != 25) return false;
	if (TempSplit[6] == "" || TempSplit[7] == "" || TempSplit[8] == "" || TempSplit[10] == "" || TempSplit[12] == "" || TempSplit[13] == "" || TempSplit[17] =="") return false;
	ItemSplit=TempSplit[7].split(".");
	if (ItemSplit[0] == "6" || ItemSplit[0] == "13") return false;
	ItemSplit=TempSplit[8].split(".");
	if (ItemSplit[0] == "5" || ItemSplit[0] == "12") return false;
	return true;
}
function AvatarShowToolbar(event,AvatarShowObj) {
	var parentObj = AvatarShowObj;
	for(i = parentObj.childNodes.length-1; i >= 0; i --) if (parentObj.childNodes[i].nodeType == 1) break;
	if (i >= 0) parentObj.childNodes[i].style.display = 'inline';
	return true;
}
function AvatarHideToolbar(event,AvatarShowObj) {
	var ToolbarObj,flag=false;
	var parentObj = AvatarShowObj;
	for(i = parentObj.childNodes.length-1; i >= 0; i --) if (parentObj.childNodes[i].nodeType == 1) break;
	if (i >= 0) ToolbarObj = parentObj.childNodes[i];
	var toElement = (event.toElement ? event.toElement : event.relatedTarget);
	if (toElement != null)	while (toElement.nodeType != 1) toElement = toElement.parentNode;
	
	while (toElement != null) {
		if (toElement.nodeType == 1 && toElement.attributes.getNamedItem("class") != null) {
			if (toElement.attributes.getNamedItem("class").nodeValue == 'AvatarShow') {flag=true; break;}
		}
		toElement = toElement.parentNode;
	}
	if (!flag) ToolbarObj.style.display = 'none';
}
function SelectToolbarItem(event) {
	var srcElement = (event.srcElement ? event.srcElement : event.target);
	if (srcElement) {
		srcElement.filters(0).enabled = false;
	}
}
function UnSelectToolbarItem(event) {
	var srcElement = (event.srcElement ? event.srcElement : event.target);
	if (srcElement) {
		srcElement.filters(0).enabled = true;
	}
}
function DvbbsShowAvatar(UserAvaSetting,isAllow,UserIsAva,AvaShowSetting,AvatarWidth,AvatarHeight,InnerLeft1,InnerTop1,InnerWidth1,InnerHeight1,InnerLeft2,InnerTop2,InnerWidth2,InnerHeight2,FaceStr,LocalPic,PicPath,OffsetLeft,OffsetTop,Title,UserName,TDObj,BlankURL,ForumURL) {
	var AvatarStr = "";
	var UserAvaSplit;
	var ToolByUser = "";
	var i;
	var CurPic;
	
	if (!ForumURL) {
		ForumURL = "";
	} else if (ForumURL.substr(ForumURL.length - 1, 1) != "/") {
		ForumURL = ForumURL + "/";
	}
	if (PicPath.substr(PicPath.length - 1, 1) != "/") PicPath = PicPath + "/";
	if ((isAllow!="1" && !isCanShowAvatar(UserAvaSetting)) || UserIsAva == "0") {
		UserAvaSetting = "";
	}
	if (AvaShowSetting >= "0" && AvaShowSetting <= "2") {
		UserAvaSplit = UserAvaSetting.split(",");
		if (UserAvaSplit.length > 1) {
			UserAvaSetting = UserAvaSplit[0];
			ToolByUser = UserAvaSplit[1];
		} else {
			UserAvaSetting = UserAvaSplit[0];
			ToolByUser = "";
		}
		if (UserAvaSetting.replace("|","") != "") {
			UserAvaSplit = UserAvaSetting.split("|");
			if (UserAvaSplit.length == 25) {
				AvatarStr = AvatarStr + "<DIV Class='AvatarShow' style='overflow:hidden;padding:0px;position:relative;";
				switch(AvaShowSetting) {
					case "0" :
						AvatarStr = AvatarStr + "top:" + OffsetTop + "px;left:" + OffsetLeft + "px;width:" + AvatarWidth + "px;height:" + AvatarHeight + "px";
						break;
					case "1" :
						AvatarStr = AvatarStr + "top:" + OffsetTop + "px;left:" + OffsetLeft + "px;width:" + InnerWidth1 + "px;height:" + InnerHeight1 + "px";
						break;
					case "2" :
						AvatarStr = AvatarStr + "top:" + OffsetTop + "px;left:" + OffsetLeft + "px;width:" + InnerWidth2 + "px;height:" + InnerHeight2 + "px";
						break;
				}
				AvatarStr = AvatarStr + "'>";
				for(i = 0; i < 25; i ++) {
					if (UserAvaSplit[i] != "") {
						if (LocalPic == 0)
							CurPic = PicPath + UserAvaSplit[i].split(".")[0] + "/" + (i+1) + "/00/";
						else
							CurPic = FixPath(ForumURL, PicPath) + (i+1) + "/" + UserAvaSplit[i].split(".")[0] + ".Gif";
						AvatarStr = AvatarStr + "<IMG src='" + CurPic + "' style='padding:0px;position:absolute;";
						switch(AvaShowSetting) {
							case "0" :
								AvatarStr = AvatarStr + "top:0px;left:0px;width:" + AvatarWidth + "px;height:" + AvatarHeight + "px;display:inline;z-index:" + (i+1) + ";'>";
								break;
							case "1" :
								AvatarStr = AvatarStr + "top:" + (-InnerTop1) + "px;left:" + (-InnerLeft1) + "px;width:" + AvatarWidth + "px;height:" + AvatarHeight + "px;display:inline;z-index:" + (i+1) + ";'>";
								break;
							case "2" :
								AvatarStr = AvatarStr + "top:" + (-InnerTop2) + "px;left:" + (-InnerLeft2) + "px;width:" + AvatarWidth + "px;height:" + AvatarHeight + "px;display:inline;z-index:" + (i+1) + ";'>";
								break;
						}
					}
				}
				if (ToolByUser != "") {
					AvatarStr = AvatarStr + "<DIV style='background-color:#f3f3f3;filter:alpha(opacity=70);padding-top:2px;position:absolute;z-index:99;top:0px;left:0px;width:";
					switch(AvaShowSetting) {
						case "0" :
							AvatarStr = AvatarStr + AvatarWidth;
							break;
						case "1" :
							AvatarStr = AvatarStr + InnerWidth1;
							break;
						case "2" :
							AvatarStr = AvatarStr + InnerWidth2;
							break;
					}
					AvatarStr = AvatarStr + "px;height:20px;font-size:12px;text-align:center;'><MARQUEE DIRECTION='left' BEHAVIOR='SCROLL' SCROLLAMOUNT='10' SCROLLDELAY='200'><font color='#404040'><b>";
					if (Title)
						if (Title == '您的虚拟形象') {
							AvatarStr = AvatarStr + "您";
						} else {
							if (UserName)
								AvatarStr = AvatarStr + UserName;
							else
								AvatarStr = AvatarStr + '该形象';
					}
					AvatarStr = AvatarStr + "正在被<ShakeDirection href='" + ForumURL + "dispuser.asp?name=" + ToolByUser + "' target=_blank unselectable='on'><font color='red' unselectable='on'>" + ToolByUser + "</ShakeDirection></font>整蛊中……</font></b></MARQUEE></DIV>";
				}
				AvatarStr = AvatarStr + "<IMG oncontextmenu='return false;' ";
				if (BlankURL) AvatarStr = AvatarStr + "onclick=window.open('" + BlankURL + "','_blank') ";
				AvatarStr = AvatarStr + "onmouseover=AvatarShowToolbar(event,this.parentNode) onmouseout=AvatarHideToolbar(event,this.parentNode) src='" + ForumURL + "Dv_Plus/Avatar/Pic/blank.gif' style='padding:0px;position:absolute;";
				if (BlankURL) AvatarStr = AvatarStr + "cursor:pointer;";
				switch(AvaShowSetting) {
					case "0" :
						AvatarStr = AvatarStr + "top:0px;left:0px;width:" + AvatarWidth + "pxheight:" + AvatarHeight + "px;display:inline;z-index:50;'";
						break;
					case "1" :
						AvatarStr = AvatarStr + "top:" + (-InnerTop1) + "px;left:" + (-InnerLeft1) + "v;width:" + AvatarWidth + "px;height:" + AvatarHeight + "px;display:inline;z-index:50;'";
						break;
					case "2" :
						AvatarStr = AvatarStr + "top:" + (-InnerTop2) + "px;left:" + (-InnerLeft2) + "px;width:" + AvatarWidth + "px;height:" + AvatarHeight + "px;display:inline;z-index:50;'";
						break;
				}
				if (Title)
					AvatarStr = AvatarStr + " title='" + Title + "'>";
				else
					AvatarStr = AvatarStr + ">";
				if (BlankURL) AvatarStr = AvatarStr + "</a>";
				if (ForumURL == "" || document.URL.substr(0, ForumURL.length).toLowerCase() == ForumURL.toLowerCase()) {
					AvatarStr = AvatarStr + "<DIV style='background-color:#ffffff;padding-left:0px;position:absolute;border:1px solid #808080;display:none;z-index:100;";
					switch(AvaShowSetting) {
						case "0" :
							if (UserName)
								AvatarStr = AvatarStr + "top:" + (AvatarHeight - 18) + "px;left:" + (AvatarWidth - 82) + "px;width:80px;height:16px;";
							else
								AvatarStr = AvatarStr + "top:" + (AvatarHeight - 18) + "px;left:" + (AvatarWidth - 50) + "px;width:48px;height:16px;";
							break;
						case "1" :
							if (UserName)
								AvatarStr = AvatarStr + "top:" + (InnerHeight1 - 18) + "px;left:" + (InnerWidth1 - 82) + "px;width:80px;height:16px;";
							else
								AvatarStr = AvatarStr + "top:" + (InnerHeight1 - 18) + "px;left:" + (InnerWidth1 - 50) + "px;width:48px;height:16px;";
							break;
						case "2" :
							if (UserName)
								AvatarStr = AvatarStr + "top:" + (InnerHeight2 - 18) + "px;left:" + (InnerWidth2 - 82) + "px;width:80px;height:16px";
							else
								AvatarStr = AvatarStr + "top:" + (InnerHeight2 - 18) + "px;left:" + (InnerWidth2 - 50) + "px;width:48px;height:16px";
							break;
					}
					AvatarStr = AvatarStr + "' onmouseout='AvatarHideToolbar(event,this.parentNode)'>";
					if (UserName)
						AvatarStr = AvatarStr + "<table width='80' height='16' border='0' cellpadding='0' cellspacing='0'>";
					else
						AvatarStr = AvatarStr + "<table width='48' height='16' border='0' cellpadding='0' cellspacing='0'>";
					AvatarStr = AvatarStr + "<tr height='16' align='center'>";
					AvatarStr = AvatarStr + "<td width='16'><img onclick=PlusOpen('" + ForumURL + "Plus_Avatar_Copy.asp?avatar=" + UserAvaSetting + "',500,400) border=0 oncontextmenu='return false;' style='cursor:pointer;filter:gray' src='" + ForumURL + "Dv_Plus/Avatar/Pic/CopyAvatar.gif' onmouseover=SelectToolbarItem(event) onmouseout=UnSelectToolbarItem(event) title='复制该形象'></td>";
					AvatarStr = AvatarStr + "<td width='16'><img onclick=PlusOpen('" + ForumURL + "Plus_Avatar_ShowList.asp?avatar=" + UserAvaSetting + "',500,400) border=0 oncontextmenu='return false;' style='cursor:pointer;filter:gray' src='" + ForumURL + "Dv_Plus/Avatar/Pic/ShowList.gif' onmouseover=SelectToolbarItem(event) onmouseout=UnSelectToolbarItem(event) title='查看该形象的物品清单'></td>";
					AvatarStr = AvatarStr + "<td width='16'><img onclick=PlusOpen('" + ForumURL + "Plus_Avatar_Favorite.asp?avatar=" + UserAvaSetting + "',500,400) border=0 oncontextmenu='return false;' style='cursor:pointer;filter:gray' src='" + ForumURL + "Dv_Plus/Avatar/Pic/Favorite.gif' onmouseover=SelectToolbarItem(event) onmouseout=UnSelectToolbarItem(event) title='加入到我的形象收藏夹'></td>";
					if (UserName) {
						AvatarStr = AvatarStr + "<td width='16'><img onclick=window.open('" + ForumURL + "Plus_Avatar_Photo.asp?shopid=197&username=" + UserName + "','_blank') border=0 oncontextmenu='return false;' style='cursor:pointer;filter:gray' src='" + ForumURL + "Dv_Plus/Avatar/Pic/RequestPhoto.gif' onmouseover=SelectToolbarItem(event) onmouseout=UnSelectToolbarItem(event) title='向" + UserName + "发出合影请求'></td>";
						AvatarStr = AvatarStr + "<td width='16'><img onclick=PlusOpen('" + ForumURL + "Plus_Avatar_UseTools.asp?username=" + UserName + "',550,480) border=0 oncontextmenu='return false;' style='cursor:pointer;filter:gray' src='" + ForumURL + "Dv_Plus/Avatar/Pic/Faddle.gif' onmouseover=SelectToolbarItem(event) onmouseout=UnSelectToolbarItem(event) title='对" + UserName + "的形象使用整人道具'></td>";
					}
					AvatarStr = AvatarStr + "</tr>";
					AvatarStr = AvatarStr + "</table>"
					AvatarStr = AvatarStr + "</DIV>";
				}
				AvatarStr = AvatarStr + "</DIV>";
			} else {
				AvatarStr = AvatarStr + FaceStr.replace(/&amp;/gi,"&").replace(/&lt;/gi,"<").replace(/&gt;/gi,">");
			}
		} else {
			AvatarStr = AvatarStr + FaceStr.replace(/&amp;/gi,"&").replace(/&lt;/gi,"<").replace(/&gt;/gi,">");
		}
	} else {
		AvatarStr = AvatarStr + FaceStr.replace(/&amp;/gi,"&").replace(/&lt;/gi,"<").replace(/&gt;/gi,">");
	}
	if (!TDObj)
		document.write(AvatarStr);
	else
		TDObj.innerHTML = AvatarStr;
}
function DvbbsShowMarriageAvatar(UserName,UserAvaSetting,SpouseName,SpouseAvaSetting,AvatarWidth,AvatarHeight,InnerLeft1,InnerTop1,InnerWidth1,InnerHeight1,InnerLeft2,InnerTop2,InnerWidth2,InnerHeight2,FaceStr,LocalPic,PicPath,OffsetLeft,OffsetTop,Title,ForumURL) {
	var AvatarStr = "";
	var UserAvaSplit;
	var SpouseAvaSplit;
	var i,j;
	var CurPic, CurItem;
	var NameWidth, NameLeft, NameTop;
	
	if (!ForumURL) {
		ForumURL = "";
	} else if (ForumURL.substr(ForumURL.length - 1, 1) != "/") {
		ForumURL = ForumURL + "/";
	}
	if (PicPath.substr(PicPath.length - 1, 1) != "/") PicPath = PicPath + "/";
	if (UserAvaSetting.replace("|","") != "" && SpouseAvaSetting.replace("|","") != "") {
		UserAvaSplit = UserAvaSetting.split("|");
		SpouseAvaSplit = SpouseAvaSetting.split("|");
		if (UserAvaSplit.length == 25 && SpouseAvaSplit.length == 25) {
			AvatarStr = AvatarStr + "<DIV Class='MarriageShow' style='overflow:hidden;padding:0px;position:relative;top:" + OffsetTop + "px;left:" + OffsetLeft + "px;width:" + AvatarWidth + "px;height:" + AvatarHeight + "px'>";
			for(i = 0; i < 25; i ++) {
				if (i == 4)
					for(j = 0; j < 17; j ++) {
						if (SpouseAvaSplit[j + 4] != "") {
							CurItem = SpouseAvaSplit[j + 4].split(".")[0];
							if (LocalPic == 0)
								CurPic = PicPath + CurItem + "/" + (j+5) + "/00/";
							else
								CurPic = FixPath(ForumURL, PicPath) + (j+5) + "/" + CurItem + ".Gif";
							AvatarStr = AvatarStr + "<IMG src='" + CurPic + "' style='padding:0px;position:absolute;top:0px;left:-" + Math.floor(AvatarWidth / 4) + "px;width:" + AvatarWidth + "px;height:" + AvatarHeight + "px;display:inline;z-index:" + (i+1+j) + ";'>";
						}
					}
				if (UserAvaSplit[i] != "") {
					CurItem = UserAvaSplit[i].split(".")[0];
					if (LocalPic == 0)
						CurPic = PicPath + CurItem + "/" + (i+1) + "/00/";
					else
						CurPic = FixPath(ForumURL, PicPath) + (i+1) + "/" + CurItem + ".Gif";
					AvatarStr = AvatarStr + "<IMG src='" + CurPic + "' style='padding:0px;position:absolute;top:0px;left:0px;width:" + AvatarWidth + "px;height:" + AvatarHeight + "px;display:inline;z-index:";
					if (i < 4)
						AvatarStr = AvatarStr + (i+1) + ";'>";
					else
						AvatarStr = AvatarStr + (i+18) + ";'>";
				}
			}
			if (SpouseName != '') {
				NameWidth = (SpouseName.length + 6) * 6;
				NameLeft = Math.floor((AvatarWidth - NameWidth) / 2 - AvatarWidth / 4);
				NameTop = AvatarHeight - 30;
				AvatarStr = AvatarStr + "<DIV style='z-index:48;left:" + NameLeft + "px;position:absolute;top:" + NameTop + "px;width:" + AvatarWidth + "px;height:20px;padding-top:3px;padding-left:3px;text-align:left;word-break:keep-all;line-height:12px;font-family:宋体;color:#ffffff;font-size:12px;filter:progid:DXImageTransform.Microsoft.dropShadow(Color=000000,offX=1,offY=1,positive=true)'><img src='" + ForumURL + "Dv_Plus/Avatar/Pic/Heart.gif' border='0' width='18' height='18'>" + SpouseName + "</div>";
			}
			if (UserName != '') {
				NameWidth = UserName.length * 6;
				NameLeft = Math.floor((AvatarWidth - NameWidth) / 2);
				NameTop = 20;
				AvatarStr = AvatarStr + "<DIV style='z-index:49;left:" + NameLeft + "px;position:absolute;top:" + NameTop + "px;width:" + AvatarWidth + "px;padding-top:3px;padding-left:3px;text-align:left;word-break:keep-all;line-height:12px;font-family:宋体;color:#ffffff;font-size:12px;filter:progid:DXImageTransform.Microsoft.dropShadow(Color=000000,offX=1,offY=1,positive=true)'>" + UserName + "</div>";
			}
			AvatarStr = AvatarStr + "<IMG oncontextmenu='return false;' src='" + ForumURL + "Dv_Plus/Avatar/Pic/blank.gif' style='padding:0;position:absolute;top:0;left:0;width:" + AvatarWidth + ";height:" + AvatarHeight + ";display:inline;z-index:50;'";
			if (Title)
				AvatarStr = AvatarStr + " title='" + Title + "'>";
			else
				AvatarStr = AvatarStr + " title='" + UserName + "与" + SpouseName + "的结婚照'>";
			AvatarStr = AvatarStr + "</DIV>";
		} else {
			AvatarStr = AvatarStr + FaceStr;
		}
	}
	document.write(AvatarStr);
}

function FixPath(ForumURL, PicPath) {
	var pos;
	if (ForumURL != "") {
		if (!(PicPath.substr(0, 7) == "http://" || PicPath.substr(0, 8) == "https://")) {
			if (PicPath.substr(0, 1) == "/") {
				pos = ForumURL.indexOf("/", 8);
				if (pos >= 0)
					return ForumURL.substr(0, pos - 1) + PicPath;
				else
					return ForumURL + PicPath;
			} else {
				return ForumURL + PicPath;
			}
		} else
			return PicPath;
	} else
		return PicPath;
}
