
// #####################################################################################
// ##  QQSHOW_SCRIPT    Copyright (C) 1998 - 2007 TENCENT Inc. All Rights Reserved    ##
// #####################################################################################

// ########################################################
// ##  for ie.version < 5.5
// ########################################################
/*@cc_on @*/
/*@if (@_jscript_version < 5.5)
Array.prototype.pop = function() { if (this.length>0) { var r = this[this.length-1]; this.length--; return r; } }
Array.prototype.push = function() { for (var i=0; i<arguments.length; ++i) { this[this.length] = arguments[i]; } return this.length; }
Array.prototype.splice = function() { var aEnd = this.slice(arguments[0]+arguments[1], this.length); var aRem = this.slice(arguments[0], arguments[1]); this.length = arguments[0]; for (var i=2; i<arguments.length; ++i) { this[this.length] = arguments[i]; } for (var i=0,nlen=this.length; i<aEnd.length; ++i,++nlen) { if (typeof(aEnd[i])!="undefined") { this[nlen] = aEnd[i]; } } return aRem; }
Array.prototype.unshift = function() { var aEnd = this.slice(0, this.length); this.length = 0; for (var i=0; i<arguments.length; ++i) { this[this.length] = arguments[i]; } for (var i=0,nlen=this.length; i<aEnd.length; ++i,++nlen) { if (typeof(aEnd[i])!="undefined") { this[nlen] = aEnd[i]; } } return this; }
@end
@*/
// ########################################################

// 生成 [0, nMax) 的随机整数
Math.randomInt = function(nMax) { return parseInt(Math.random()*nMax); };

Array.prototype.find = function(e) { for (var i=0; i<this.length; ++i) { if (this[i]==e) { return i; } } return null; };
Array.prototype.findmul = function(e) { var a = []; for (var i=0; i<this.length; ++i) { if (this[i]==e) { a.push(i); } } return a; };
Array.prototype.find_if = function(fnEQ) { for (var i=0; i<this.length; ++i) { if (fnEQ(this[i])) { return i; } } return null; };
Array.prototype.findmul_if = function(fnEQ) { var a = []; for (var i=0; i<this.length; ++i) { if (fnEQ(this[i])) { a.push(i); } } return a; };
Array.prototype.push_not = function(e) { if (this.find(e)==null) { return this.push(e); } return null; };
Array.prototype.push_not_if = function(e, fnEQ) { if (this.find_if(fnEQ)==null) { return this.push(e); } return null; };
Array.prototype.remove = function(e) { var a = this.findmul(e); for (var i=a.length-1; i>=0; --i) { this.splice(a[i], 1); } return a.length; };
Array.prototype.remove_if = function(fnEQ) { var a = this.findmul_if(fnEQ); for (var i=a.length-1; i>=0; --i) { this.splice(a[i], 1); } return a.length; };
Array.prototype.transform = function(fnOp) { for (var i=0; i<this.length; ++i) { this[i] = fnOp(this[i]); } return this; };

RegExp.showCharSet = /[\x00-\x09\x0B-\x0C\x0E-\x1F\x80-\xFF]/g;

String.prototype.chsetReplace = function() { return this.replace(RegExp.showCharSet , "?"); };
String.prototype.chsetAlert = function(v) { if (!this.chsetCheck()) { alert((v?v+"中":"")+'请不要使用"'+this.match(RegExp.showCharSet).toString()+'"等字符。'); return false; }else{ return true; } };
String.prototype.chsetCheck = function() { return !this.match(RegExp.showCharSet); };
String.prototype.between = function(b, e) { var bp = this.indexOf(b); if (bp==-1) { return (""); } bp += b.length; var ep = this.indexOf(e, bp); if (ep==-1) { return (""); } return this.substr(bp, ep-bp); };
String.prototype.replaceAll = function(s, t) { return this.split(s).join(t); };
String.prototype.asclen = function() { return this.replace(/[\u0100-\uffff]/g, "  ").length; };
String.prototype.asccut = function(n) { var i = 0; while (n>0 && i<this.length) { n -= this.charCodeAt(i)>=256 ? 2 : 1; i += (n>=0); } return this.substr(0, i); };
//String.prototype.escHtmlEp = function() { return this.replace(/[&'"<>\/\\\-\x00-\x1f\x80-\xff]/g, function(r){ return "&#"+r.charCodeAt(0)+";" }); };
//用做过滤HTML标签里面的东东 比如这个例子里的<input value="XXXX">  XXXX就是要过滤的
String.prototype.escHtmlEp = function() { return this.replace(/[&'"<>\/\\\-\x00-\x1f\x80-\xff]/g, function(r){ return "&#"+r.charCodeAt(0)+";" }); };
//String.prototype.escHtml = function() { return this.replace(/[&'"<>\/\\\-\x00-\x09\x0b-\x0c\x1f\x80-\xff]/g, function(r){ return "&#"+r.charCodeAt(0)+";" }).replace(/\r\n/g, "<BR>").replace(/\n/g, "<BR>").replace(/\r/g, "<BR>").replace(/ /g, "&nbsp;"); };
//用做过滤直接放到HTML里的
String.prototype.escHtml = function() { return this.replace(/[&'"<>\/\\\-\x00-\x09\x0b-\x0c\x1f\x80-\xff]/g, function(r){ return "&#"+r.charCodeAt(0)+";" }).replace(/\r\n/g, "<BR>").replace(/\n/g, "<BR>").replace(/\r/g, "<BR>").replace(/ /g, "&nbsp;"); };
//String.prototype.escScript = function() { return this.replace(/[\\"']/g, function(r){ return "\\"+r; }).replace(/%/g, "\\x25").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\x01/g, "\\x01"); };
//用做过滤直接放到HTML里js中的
String.prototype.escScript = function() { return this.replace(/[\\"']/g, function(r){ return "\\"+r; }).replace(/%/g, "\\x25").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\x01/g, "\\x01"); };
//String.prototype.escUrl = function() { return escape(this).replace(/\+/g, "%2B"); };
//用做过滤直接URL参数里的  比如 http://show8.qq.com/abc_cgi?a=XXX  XXX就是要过滤的
String.prototype.escUrl = function() { return escape(this).replace(/\+/g, "%2B"); };
//String.prototype.escMiniUrl = function() { return this.replace(/[\x00-\xff]/g, escape).replace(/\+/g, "%2B"); };
String.prototype.escMiniUrl = function() { return this.replace(/%/g, "%25"); };
//String.prototype.escHrefScript = function() { return this.escScript().escMiniUrl().escHtmlEp(); };
//用做过滤直接放到<a href="javascript:XXXX">中的
String.prototype.escHrefScript = function() { return this.escScript().escMiniUrl().escHtmlEp(); };
//String.prototype.escRegexp = function() { return this.replace(/[\\\^\$\*\+\?\{\}\.\(\)\[\]]/g, function(a,b){ return "\\"+a; }); };
//用做过滤直接放到正则表达式中的
String.prototype.escRegexp = function() { return this.replace(/[\\\^\$\*\+\?\{\}\.\(\)\[\]]/g, function(a,b){ return "\\"+a; }); };
String.prototype.escape = function() { return escape(this); };
String.prototype.unescape = function() { return unescape(this); };
Date.prototype.format = function(v) { var a={"Y":this.getFullYear(), "m":LENFix(this.getMonth()+1, 2), "d":LENFix(this.getDate(), 2), "H":LENFix(this.getHours(), 2), "M":LENFix(this.getMinutes(), 2), "S":LENFix(this.getSeconds(), 2)}; return v.replace(/%[YmdHMS]/g, function(v){ return (a[v.substr(1)]); }); };




/*
对需要出现在一个URI的一部分的不信任输入进行编码 
例如:
<a href="http://search.msn.com/results.aspx?q1=[Un-trusted-input]& q2=[Un-trusted-input]">Click Here!</a>
以下字符将会被编码: 
除[a-zA-Z0-9.-_]以外的字符都会被替换成URL编码
*/
function UriComponentEncode(sStr)
{
	sStr = encodeURIComponent(sStr);
	sStr = sStr.replace(/~/g,"%7E");
	sStr = sStr.replace(/!/g,"%21");
	sStr = sStr.replace(/\*/g,"%2A");
	sStr = sStr.replace(/\(/g,"%28");
	sStr = sStr.replace(/\)/g,"%29");
	sStr = sStr.replace(/'/g,"%27");
	sStr = sStr.replace(/\?/g,"%3F");
	sStr = sStr.replace(/;/g,"%3B");
	return sStr;
}

// 注:以下所有转义(包括对应的对象方法)都是直接填充模板时使用,不一定适用于属性设置
function escUrl(v) { return v.escUrl(); };
function escHtml(v) { return v.escHtml(); };
function escHtmlEp(v) { return v.escHtmlEp(); };
function escScript(v) { return v.escScript(); };
function escHrefScript(v) { return v.escHrefScript(); };

function toExpTime(v , sFmt)
{
	if (isNaN(v) ) return 0;
	var nM = truncate (v / 2678400 , 1);
	var nD = truncate (v / 86400 , 1);
	if(!sFmt || sFmt == "M")
	{
		if( nM >= 1)
			return nM + "个月";
		else 
			return parseInt(nD) + " 天 ";
	} else {
		return parseInt(nD) + " 天 ";
	}
	
}
function truncate (nVal, nNum)
{
	var nRet = null;
	try
	{
		if (nVal==0 || nNum==0)
			return 0;
		nVal = 1 * nVal;
		nNum = 1 * nNum;
		if (isNaN(nVal) || isNaN(nNum))
		{
			nRet = 0;
		}
		else if (nNum >= 0 && nNum <= 18)
		{
			var strX = nVal.toString();
			var arrX = strX.split(".");
			if ( arrX[1] )
			{
				if (arrX[1].length > nNum)
					arrX[1] = arrX[1].substr(0, nNum);
				strX = arrX.join(".");
			}
			else
				strX = arrX[0];
				nRet = parseFloat(strX);
		}
		else
		{
			nRet = 0;
		}
	}
	catch(e)
	{
		nRet = 0;
	}

	return nRet;
}
// ########################################################

function DebugMessage(v)
{
	return "["+v.toString()+"]";
};

// ########################################################

// var _Prm = new PARAM("a=1&b=2", "&", "="); var a = _Prm["a"]; var b = _Prm["b"]
function PARAM(valPairs, elemSep, pairSep)
{
	if (valPairs)
	{
		var aElem = valPairs.toString().split(elemSep);
		for (var i=0; i<aElem.length; ++i)
		{
			var aPair = aElem[i].split(pairSep);
			(aPair.length>1) && (this[aPair[0]] = unescape(aPair[1]));
		}
	}
};

// var a = getParam("a=1&b=2", "a", "&", "=");
function getParam(valPairs, sName, elemSep, pairSep)
{
	var xParam = new PARAM(valPairs, elemSep, pairSep);
	return xParam[sName] ? xParam[sName] : "";
};

// var sParam = setParam("a=1", "b", "2");
function setParam(valPairs, n, v)
{
	valPairs = valPairs.toString();
	n = n.toString();
	v = v.toString().escUrl();
	var r = new RegExp("(^|\\W)"+n+"=[^&]*", "g");
	return (valPairs.match(r)) ? valPairs.replace(r, "$1"+n+"="+v) : valPairs+(valPairs ? "&" : "")+n+"="+v;
};

// var sParam = getURLParam("a", "http://w.w.w/?a=1&b=2);
function getURLParam(sName, sUrl)
{
	(!sUrl) && (sUrl = window.location.href);
	sUrl = sUrl.toString();
	var nIndex = sUrl.indexOf("?");
	return (nIndex>=0) ? getParam(sUrl.substr(nIndex+1), sName, "&", "=") : "";
};

// var sUrl = setURLParam("http://w.w.w/?a=1", "b", "2");
function setURLParam(u, n, v)
{
	u = u.toString();
	n = n.toString();
	v = v.toString().escUrl();
	var r = new RegExp("(^|\\W)"+n+"=[^&]*", "g");
	
	return (u.match(r)) ? u.replace(r, "$1"+n+"="+v) : u+(u.indexOf("?")==-1 ? "?" : "&")+n+"="+v;
};

// var sParam = getHashParam("b", window.location);
function getHashParam(n, l)
{
	l || (l=window.location);
	return l.hash ? getParam(unescape(l.hash.substr(1)), n, "&", "=") : "";
};

// setHashParam("b", "2", window.location);
function setHashParam(n, v, l)
{
	l || (l=window.location);
	v = v.toString().escUrl();
	var u = unescape(l.hash.substr(1));
	var r = new RegExp("(^|\\W)"+n+"=[^&]*", "g");
	l.hash = 	escape((u.match(r)) ? u.replace(r, "$1"+n+"="+v) : u+(u.length ? "&" : "")+n+"="+v);
};

// ########################################################

// ---- DO NOT call this function in applications ----
function setCookie(sName, sValue, nExpireSec, sDomain, sPath) { var sCookie = sName+"="+escape(sValue)+";"; if (nExpireSec) { var oDate = new Date(); oDate.setTime(oDate.getTime()+parseInt(nExpireSec)*1000); sCookie += "expires="+oDate.toUTCString()+";"; } if (sDomain) { sCookie += "domain="+sDomain+";"; } if (sPath) { sCookie += "path="+sPath+";" } document.cookie = sCookie; };

// ########################################################

function getCookie(sName)
{
	return getParam(document.cookie, sName, "; ", "=");
};

function QQCookie(sName, sValue, nExpSec)
{
	setCookie(sName, sValue, nExpSec, "qq.com", "/");
};

function QSCookie(sName, sValue, nExpSec)
{
	setCookie(sName, sValue, nExpSec, "show8.qq.com", "/");
};

// ########################################################

// 检查是否可信任URL
function CheckUrlCredit(sUrl)
{
	//return sUrl.match(/^https{0,1}:\/\/[a-zA-Z0-9_\-.]+.qq.com(\/|$)/) ? true : sUrl.charAt(0)=="/" ? true : false;
	return (/^(https?:\/\/)?[\w\-.]+\.(qq|paipai|soso|taotao)\.com($|\/|\\)/i).test(sUrl)||(/^[\w][\w\/\.\-_%]+$/i).test(sUrl)||(/^[\/\\][^\/\\]/i).test(sUrl) ? true : false;
};

// ########################################################

function _MSIE() { return (window.navigator.appName.toUpperCase().indexOf("MICROSOFT")>=0); };

function _FireFox() { return (window.navigator.appName.toUpperCase().indexOf("NETSCAPE")>=0); };

function _MSIEUSERDATA()
{
	function _USERData(oObj, sName, sCookie)
	{
		this._Object = oObj;
		this._svName = sName;
		this._Cookie = sCookie;
		this._Object.addBehavior("#default#userData");			
		
		this._Object.load(this._svName);

		if (!getCookie(this._Cookie) || parseInt(this._Object.getAttribute(this._Cookie)) < parseInt(getCookie(this._Cookie)))
		{
			this.expiresDiscard();
		}  

		if (!getCookie(this._Cookie))
		{
			QSCookie(this._Cookie, new Date().getTime());
		}
	};
	_USERData.prototype.expiresDiscard = function()
	{
		this._Object.expires = new Date(new Date().getTime()-365*86400000).toUTCString();
		this._Object.save(this._svName);
		this._Object.load(this._svName);
		this._Object.expires = new Date(new Date().getTime()+365*86400000).toUTCString();
	};
	
	// ########################################################
	var _userData_ = null;
	// ########################################################
	
	window.getUserData = function(sName)
	{
		if (!_userData_)
		{
			_userData_ = new _USERData(document.documentElement, "QQSHOW", "QSUDTMmilliSeconds");
		}
		return _userData_._Object.getAttribute(sName);
	};
	window.setUserData = function(sName, sValue)
	{
		if (!_userData_)
		{
			_userData_ = new _USERData(document.documentElement, "QQSHOW", "QSUDTMmilliSeconds");
		}
		_userData_._Object.setAttribute(sName, sValue);
		_userData_._Object.setAttribute(_userData_._Cookie, new Date().getTime());
		_userData_._Object.save(_userData_._svName);
	};
};

function _FF2XUSERDATA()
{
	window.getUserData = function(sName)
	{
		return window.sessionStorage.getItem(sName);
	};
	window.setUserData = function(sName, sValue)
	{
		return window.sessionStorage.setItem(sName, sValue);
	};
};

function _NOUSERDATA()
{
	window.getUserData = function(sName)
	{
		return alert("your browser does not support this feature.\nwe suggest you to use Internet Explorer 5.0+ or Firefox 2.0+");
	};
	window.setUserData = function(sName, sValue)
	{
		return alert("your browser does not support this feature.\nwe suggest you to use Internet Explorer 5.0+ or Firefox 2.0+");
	};
};

// ########################################################
_MSIE() ? _MSIEUSERDATA() : (window.sessionStorage) ? _FF2XUSERDATA() : _NOUSERDATA();
// ########################################################

// ########################################################

function XMLREQ(fnCall, fnFail)
{
	this._XmlREQ = (window.XMLHttpRequest) ? (new XMLHttpRequest()) : (window.ActiveXObject) ? ((function(){try{return new ActiveXObject("Msxml2.XMLHTTP");}catch(e){return new ActiveXObject("Microsoft.XMLHTTP")};})()) : null;
	var this__XmlREQ = this._XmlREQ;
	this._XmlREQ.onreadystatechange = function() { if (this__XmlREQ.readyState==4) { this__XmlREQ.status==200 ? (fnCall ? fnCall(this__XmlREQ) : null) :  (fnFail ? fnFail(this__XmlREQ) : null); } };
};
XMLREQ.prototype.open = function(sUrl,type)
{
	var aDat = sUrl.split("?");
	this._XmlREQ.open("POST", aDat[0], type);
    aDat[1] && this._XmlREQ.setRequestHeader("Content-length", aDat[1].length);
	this._XmlREQ.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	this._XmlREQ.setRequestHeader("If-Modified-Since", "0");
	this._XmlREQ.send(aDat[1] ? aDat[1] : null);
};
XMLREQ.prototype.close = function()
{
	this._XmlREQ.abort();
};

// ########################################################

// 用户基本信存取 所有用户基本信息请以本功能实现

window.QUSER = {};
window.QUSER.getInfo = function(sName)
{
	var sData = getCookie("QSUSRINF");
	var oParam = new PARAM(sData, "&", "=");
	return oParam[sName] ? oParam[sName] : "";
};
window.QUSER.setInfo = function(sName, sValue)
{
	var sData = getCookie("QSUSRINF");
	QSCookie("QSUSRINF", setParam(sData, sName, sValue));
};
window.QUSER.getAvSex = function()
{
	var sSex = QUSER.getInfo("avsex");
	if(sSex.length == 0) 
	{QUSER.setInfo("avsex","F");return "F";}
	else return sSex;
};
window.QUSER.getStyle = function()
{
	var sStyle = QUSER.getInfo("style");
	if(sStyle.length == 0) 
	{QUSER.setInfo("style","1");return 1;}
	else return parseInt(sStyle);
};
// ########################################################

// 请求XML并以回调函数处理请求成功及失败的情况
// function fnCall(xmlReq){} function fnFail(xmlReq){}
function getXml(sUrl, fnCall, fnFail, type)
{
	var xmlReq = new XMLREQ(fnCall , fnFail);
	xmlReq.open(sUrl,type);
	return xmlReq;
};

// 请求XML并以回调函数处理请求失败及逻辑返回成功失败的情况
// function fnSucc(xmlDoc){} function fnFail(xmlDoc){} function fnError(xmlReq){}
function getQQSHOWXml(sUrl, fnSucc, fnFail, fnError)
{
	function fnCall(xmlReq)
	{
		var xmlDoc = xmlReq.responseXML;
		(xmlDoc.getElementsByTagName("QQSHOW")[0].getAttribute("code")==0) ? (fnSucc ? fnSucc(xmlDoc) : null) : (fnFail ? fnFail(xmlDoc) : null);
	};
	return getXml(sUrl, fnCall, fnError,true);
};

//以同步方式调用ajax,在某些ff的情况下需要应用
function getQQSHOWSyncXml(sUrl, fnSucc, fnFail, fnError)
{
	function fnCall(xmlReq)
	{
		var xmlDoc = xmlReq.responseXML;
		(xmlDoc.getElementsByTagName("QQSHOW")[0].getAttribute("code")==0) ? (fnSucc ? fnSucc(xmlDoc) : null) : (fnFail ? fnFail(xmlDoc) : null);
	};
	return getXml(sUrl, fnCall, fnError,false);
}

// 以mapName映射规则用XML节点内容替换字符串
// mapName = [[xmlName, htmlName(, fnTrans(xmlValue))](, ...)]
function replaceHtmlWithXml(xmlNode, sHtml, mapName, iAbsIndex, iRltIndex)
{
	var eData = {"@abs(I)":iAbsIndex && iAbsIndex.toString() || "0", "@rlt(I)":iRltIndex && iRltIndex.toString() || "0"};
	for (var i=0; i<mapName.length; ++i)
	{
		var vData = (mapName[i][0].constructor!=Array) ? (eData[mapName[i][0]]||xmlNode.getAttribute(mapName[i][0])) : ([].concat(mapName[i][0]).transform(function(v){ return (eData[v]||xmlNode.getAttribute(v)); }));
		sHtml = sHtml.replace(new RegExp(mapName[i][1].escRegexp(), "g"), (mapName[i][2] ? mapName[i][2](vData) : vData).toString().replace(/\$/g, "$$$$"));
	}
	return sHtml;
};

// 以XML内容替换并显示HTML文档
// sHtml = "<%--HD--%>...<%--LB--%>...<%--EB--%>...<%--EE--%>...<%--LE--%>...<%--TL--%>";
function showQQSHOWXmlNode(xmlDoc, oParent, xmlNodeName, sHtml, mapName, bi, ei, ne)
{
	var xmlNode = xmlDoc.getElementsByTagName(xmlNodeName);
	(!bi || bi<0) && (bi=0);
	(!ei || ei<0) && (ei=xmlNode.length);
	(!ne || ne<0) && (ne=1);
	var sHtmlHd = sHtml.between("<%--HD--%>", "<%--LB--%>");
	var sHtmlTl = sHtml.between("<%--LE--%>", "<%--TL--%>");
	var sHtmlLB = sHtml.between("<%--LB--%>", "<%--EB--%>");
	var sHtmlLE = sHtml.between("<%--EE--%>", "<%--LE--%>");
	var sHtmlEM = sHtml.between("<%--EB--%>", "<%--EE--%>");
	var aHtml = [];
	for (var i=bi; i<ei; i+=ne)
	{
		aHtml.push(sHtmlLB);
		for (var n=0; n<Math.min(ei-i, ne); ++n)
		{
			aHtml.push(replaceHtmlWithXml(xmlNode[i+n], sHtmlEM, mapName, i+n, i-bi+n));
		}
		aHtml.push(sHtmlLE);
	}
	oParent.innerHTML = sHtmlHd+aHtml.join("")+sHtmlTl;
};

// 请求并显示Xml数据
function showQQSHOWXml(sUrl, oParent, xmlNodeName, sHtml, mapName, bi, ei, ne, fnSucc, fnFail, fnError)
{
	return getQQSHOWXml(sUrl, function(xmlDoc){ showQQSHOWXmlNode(xmlDoc, oParent, xmlNodeName, sHtml, mapName, bi, ei, ne); fnSucc&&fnSucc(xmlDoc); }, fnFail, fnError);
};


// mapName = [[xmlName, htmlName(, fnTrans(xmlValue))](, ...)]
function replaceHtmlWithData(xData, sHtml, mapName, iAbsIndex, iRltIndex)
{
	var eData = {"@abs(I)":iAbsIndex && iAbsIndex.toString() || "0", "@rlt(I)":iRltIndex && iRltIndex.toString() || "0"};
	for (var i=0; i<mapName.length; ++i)
	{
		var vData = (mapName[i][0].constructor!=Array) ? (eData[mapName[i][0]]||xData[mapName[i][0]]) : ([].concat(mapName[i][0]).transform(function(v){ return (eData[v]||xData[v]); }));
		sHtml = sHtml.replace(new RegExp(mapName[i][1].escRegexp(), "g"), (mapName[i][2] ? mapName[i][2](vData) : vData).toString().replace(/\$/g, "$$$$"));
	}
	return sHtml;
};

// sHtml = "<%--HD--%>...<%--LB--%>...<%--EB--%>...<%--EE--%>...<%--LE--%>...<%--TL--%>";
function showQQSHOWData(xData, oParent, sHtml, mapName, bi, ei, ne)
{
	(!bi || bi<0) && (bi=0);
	(!ei || ei<0) && (ei=xData.length);
	(!ne || ne<0) && (ne=1);
	var sHtmlHd = sHtml.between("<%--HD--%>", "<%--LB--%>");
	var sHtmlTl = sHtml.between("<%--LE--%>", "<%--TL--%>");
	var sHtmlLB = sHtml.between("<%--LB--%>", "<%--EB--%>");
	var sHtmlLE = sHtml.between("<%--EE--%>", "<%--LE--%>");
	var sHtmlEM = sHtml.between("<%--EB--%>", "<%--EE--%>");
	var aHtml = [];
	for (var i=bi; i<ei; i+=ne)
	{
		aHtml.push(sHtmlLB);
		for (var n=0; n<Math.min(ei-i, ne); ++n)
		{
			aHtml.push(replaceHtmlWithData(xData[i+n], sHtmlEM, mapName, i+n, i-bi+n));
		}
		aHtml.push(sHtmlLE);
	}
	oParent.innerHTML = sHtmlHd+aHtml.join("")+sHtmlTl;
};

// 页码样式
function styleQQSHOWPage(nIndex)
{
	this.linkHtml = function(u, t) { return t.toString().link(u); };
	this.activeHtml = function(u, t) { return '<a href="'+u.escMiniUrl().escHtmlEp()+'" class="em">'+t.toString().escHtml()+'</a>'; };
	this.separate = function() { return ('|'); };
	this.positionHtml = function(n, a) { return ('第'+n+'/'+a+'页 '); };
	this.randomHtml = function(u, a) { return (' 跳到<input type="text" id="page_no" name="page_no" class="page_no" size="3" maxlength="4" onkeydown="if(event.keyCode != 13) return;else {var v = parseInt(this.value,10);if((isNaN(v))||(v<=0||v>'+a+')) { alert(\'您输入的页码不正确。\'); } else { window.location=(\''+u('[@_pno]')+'\'.replace(/\\\[@_pno\\\]/g, Math.max(1, Math.min('+a+', parseInt(v))))); };void(0);}"/>页<a onclick="javascript:var v=parseInt(this.parentNode.getElementsByTagName(\'INPUT\')[0].value, 10);if((isNaN(v))||(v<=0||v>'+a+')) { alert(\'您输入的页码不正确。\'); } else { window.location=(\''+u('[@_pno]')+'\'.replace(/\\\[@_pno\\\]/g, Math.max(1, Math.min('+a+', parseInt(v))))); };void(0);" class="go_page"><img src="http://imgcache.qq.com/qqshow/v2_1/global/img/btn_go.gif" alt="GO" /></a>'); };
	this.prevHtml = function(u) { return (u ? "上一页".link(u) : "<a>上一页</a>"); };
	this.nextHtml = function(u) { return (u ? "下一页".link(u) : "<a>下一页</a>"); };
};

// 显示页面内容信息
function showQQSHOWPage(pno, pall, fnUrl, oParent, nStyle ,thin)
{
	if(thin)
	{
		var iDisPage = thin;
	}else
	{
	  var iDisPage = pno < 10 ? 10 : (pno < 100 ? 8 : 6);
  }
	pno = parseInt(pno);
	pall = parseInt(pall);
	var oStyle = new styleQQSHOWPage(nStyle);
	var aHtml = [];
	aHtml.push(oStyle.prevHtml((pno>1) && fnUrl(pno-1)));
	var bi = Math.min(Math.max(pno - iDisPage / 2 , 1), Math.max(1, pall - iDisPage));
	var ei = Math.max(Math.min(pno + iDisPage / 2, pall), Math.min( bi + iDisPage, pall));
	while (bi <= ei)
	{
		aHtml.push(bi==pno ? oStyle.activeHtml(fnUrl(bi), bi++) : oStyle.linkHtml(fnUrl(bi), bi++));
	}
	aHtml.push(oStyle.nextHtml((pno<pall) && fnUrl(pno+1)));
	oParent.innerHTML = oStyle.positionHtml(pno, pall)+aHtml.join(oStyle.separate())+oStyle.randomHtml(fnUrl, pall);
};

// ########################################################

// ########################################################

// 打印FLASH对象
function QQSHOW_CreateFlashObject(sHtml)
{
	document.write(sHtml);
};

// 设置FLASH对象
function QQSHOW_setFlashObject(sHtml, oParent)
{
	oParent.innerHTML = sHtml;
};

// 返回FLASH的HTML代码
function QQSHOW_avShow(sShow,iW,iH)
{
	var nStyle = (sShow.match(/V1#[MFU]_0_/) ? 0 : 1);
	var w = iW || [140, 186][nStyle];
	var h = iH || [226, 300][nStyle];
	var mapName = [["[@_W]", w], ["[@_H]", h], ["[@_SHOW]", escape(sShow)]];
	var sHtml = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,19,0" width="[@_W]" height="[@_H]">  <param name="movie" value="http://qqshow2-item.qq.com/1000000/53/02/" />  <param name="quality" value="high" />  <param name="flashvars" value="sItems=[@_SHOW]">  <param name="wmode" value="transparent">  <param name="allowScriptAccess" value="always" />  <embed src="http://qqshow2-item.qq.com/1000000/53/02/" flashvars="sItems=[@_SHOW]" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" allowScriptAccess="always" width="[@_W]" height="[@_H]"></embed></object>';
	for (var i=0; i<mapName.length; ++i)
	{
		sHtml = sHtml.replace(new RegExp(mapName[i][0].escRegexp(), "g"), mapName[i][1]);		
	}
	return sHtml;
};

function QQSHOW_photo(sShow , iW , iH)
{
	var nStyle = (sShow.match(/V1#[MFU]_0_/) ? 0 : 1);
	var w = iW ? iW : 280;
	var h = iH ? iH : 226;

	var mapName = [["[@_W]", w], ["[@_H]", h], ["[@_SHOW]", escape(sShow)]];
	var sHtml = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,19,0" width="[@_W]" height="[@_H]">  <param name="movie" value="http://qqshow2-item.qq.com/1000000/55/02/" />  <param name="quality" value="high" />  <param name="flashvars" value="sItems=[@_SHOW]">  <param name="wmode" value="transparent">  <param name="allowScriptAccess" value="always" />  <embed src="http://qqshow2-item.qq.com/1000000/55/02/" flashvars="sItems=[@_SHOW]" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" allowScriptAccess="always" width="[@_W]" height="[@_H]"></embed></object>';
	for (var i=0; i<mapName.length; ++i)
	{
		sHtml = sHtml.replace(new RegExp(mapName[i][0].escRegexp(), "g"), mapName[i][1]);
	}
	return sHtml;
};

function QQSHOW_firendListShow(itemNo , iW , iH)
{
	var w = iW ? iW : 280;
	var h = iH ? iH : 226;
	
	var mapName = [["[@_W]", w], ["[@_H]", h], ["[@_itemno]", escape(itemNo)]];
	var sHtml = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="[@_W]" height="[@_H]" id="mlist_flash" align="middle"> <param name="movie" value="/img/swf/qqshow_friendlist.swf" />       <param name="quality" value="best" />  <param name="flashvars" value="itemno=[@_itemno]"> <param name="wmode" value="transparent"> <param name="bgcolor" value="#ffffff" />  <param name="allowScriptAccess" value="always" /> <embed src="/img/swf/qqshow_friendlist.swf" flashvars="itemno=111" quality="high" bgcolor="#ffffff" width="500" height="350" name="mlist_club_qqshowurl" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" /> ';
	for (var i=0; i<mapName.length; ++i)
	{
		sHtml = sHtml.replace(new RegExp(mapName[i][0].escRegexp(), "g"), mapName[i][1]);
	}
	return sHtml;
};

function QQSHOW_commonFlash(swf, iW, iH, arrVar)
{
  var sVar="";
  if(typeof(arrVar)=="undefined")
    arrVar=[];
  if(arrVar.length>0)
  {
    sVar=arrVar.join('&');
  }
	var mapName = [["[@_W]", iW], ["[@_H]", iH], ["[@_swf]", swf], ["[@_var]", sVar]];
	var sHtml = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="[@_W]" height="[@_H]" id="mlist_flash" align="middle"> <param name="movie" value="[@_swf]" />       <param name="quality" value="best" />  <param name="wmode" value="transparent"> <param name="bgcolor" value="#ffffff" />  <param name="allowScriptAccess" value="always" /> <param name="flashvars" value="[@_var]"> <embed src="[@_swf]" quality="high" bgcolor="#ffffff" width="[@_W]" height="[@_H]" name="mlist_club_qqshowurl" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="[@_var]"/> ';
	for (var i=0; i<mapName.length; ++i)
	{
		sHtml = sHtml.replace(new RegExp(mapName[i][0].escRegexp(), "g"), mapName[i][1]);
	}
	return sHtml;
};
// ########################################################

// ########################################################

// Q点格式转换为Q币格式
function QBPrice(nQPoint)
{
	var iPrice = parseInt(nQPoint ? nQPoint : "0", 10) || 0;	// set to 0 if invalid
	return (parseInt(iPrice/10) +"."+ parseInt(iPrice%10));
};

// 取登录用户号码(不进行超时检查)
function GetUin()
{
	return (parseInt(getCookie('uin').match(/\d+/), 10) || 0);
};

// 性别格式转换 Mm1->M  Uu0->U ...->F
function SEX(v)
{
	return (v=="M"||v=="m"||v==1) ? "M" : (v=="U"||v=="u"||v==0) ? "U" : "F"; 
};

// 性别反转 F->M ...->F
function SEX_reverse(v)
{
	return SEX(v)=="F" ? "M" : "F";
};

//显示性别
function SexWord(v)
{
  return (SEX(v)=="M") ? "(男)" : (v=="F"?"(女)":"");
};

// 数字转为定长串 长度不足的以前面加0
function LENFix(i, n)
{
	var sRet = i.toString();
	while (sRet.length < n)
	{
		sRet = "0"+sRet;
	}
	return sRet;
};

// 是否闰年
function isleapyear(y)
{
	return (y%4==0 && y%100!=0 || y%400==0);
};

// 某年某月有多少天
function DAYOfMonth(y, m)
{
	return [31, isleapyear(y)?29:28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m-1];
};
// ########################################################

// 购物车相关操作

// CARTFmt = [name|no|num|price|price|type|uin|msg|param|itemType]

var QSCART_Name = "CART";

//红钻包月免费物品cookies信息

var QSVIPCART_Name = "CART_Free"

function EQCartItem(_1, _2)
{
	return (_1[1]==_2[1] && _1[6]==_2[6]);
};
function EncodeCart(aSet)
{
	aSet[0] = !aSet[0] ? "" : aSet[0].toString().replace(/[#\|%]/g, function(a,b){return "%"+a.charCodeAt(0).toString(16);});
	aSet[7] = !aSet[7] ? "" : aSet[7].toString().replace(/[#\|%]/g, function(a,b){return "%"+a.charCodeAt(0).toString(16);});
	aSet[8] = !aSet[8] ? "" : aSet[8].toString().replace(/[#\|%]/g, function(a,b){return "%"+a.charCodeAt(0).toString(16);});
	
	return aSet.join("|");
};
function DecodeCart(sSet)
{
	var aSet = sSet.split("|");
	aSet[0] = unescape(aSet[0]);
	aSet[1] = parseInt(aSet[1]);
	aSet[2] = parseInt(aSet[2]);
	aSet[3] = parseInt(aSet[3]);
	aSet[4] = parseInt(aSet[4]);
	aSet[5] = parseInt(aSet[5]);
	aSet[6] = parseInt(aSet[6]);
	aSet[7] = unescape(aSet[7]);
	aSet[8] = unescape(aSet[8]);
	aSet[9] = unescape(aSet[9]);
	return aSet;
};

function CartString(aCart)
{
	return [].concat(aCart).transform(EncodeCart).join("#");
}

function CartVector(sCart)
{
	return sCart.split("#").transform(DecodeCart);
};

function saveCart(aCart)
{
	QSCookie(QSCART_Name, CartString(aCart));
	setHeaderCartNum();
};

function saveVipCart(aCart)
{
	QSCookie(QSVIPCART_Name, CartString(aCart));
	setHeaderCartNum();
	//setHeaderCartNum(countCartNum());
};
function countCartNum()
{
	var aPrice = getCartPrice();
	return(aPrice[3]);
	/*var aVipPrice = getVipCartPriceInfo();
	return (aPrice[3] + aVipPrice[3]);*/
}

function getCart()
{
	var sCart = getCookie(QSCART_Name);
	if (sCart)
	{
		return CartVector(sCart);
	}
	return [];
};

function getVipCart()
{
	var sCart = getCookie(QSVIPCART_Name);
	if (sCart)
	{
		return CartVector(sCart);
	}
	return [];
};

// 把物品加到购物车 如果已经存在则不作处理
function setCart(aSet)
{
	var aCart = getCart();
	if (aCart.find_if(function(e){ return EQCartItem(e, aSet); })==null)
	{
		if(aCart.length >=20)
		{
			return false;
		}
		aCart.push(aSet);
		saveCart(aCart);
	}
	return true;
};

function setVipCart(aSet)
{
	var aCart = getVipCart();
	if (aCart.find_if(function(e){ return EQCartItem(e, aSet); })==null)
	{
		if(aCart.length >=20)
		{
			return false;
		}
		aCart.push(aSet);
		saveVipCart(aCart);
	}
	return true;
};

// 增加购物车物品数量 如果不存在则直接加到购物车
function incCart(aSet)
{
	var aCart = getCart();
	var afind = aCart.find_if(function(e){ return EQCartItem(e, aSet); });
	if (afind!=null)
	{
		aCart[afind][2] += aSet[2];
		if (aCart[afind][2] <= 0)
		{
			aCart.splice(afind, 1);
		}
		saveCart(aCart);
	}
	else
	{
		setCart(aSet);
	}
};
function incVipCart(aSet)
{
	var aCart = getVipCart();
	var afind = aCart.find_if(function(e){ return EQCartItem(e, aSet); });
	if (afind!=null)
	{
		aCart[afind][2] += aSet[2];
		if (aCart[afind][2] <= 0)
		{
			aCart.splice(afind, 1);
		}
		saveVipCart(aCart);
	}
	else
	{
		setVipCart(aSet);
	}
};

// 清空购物车
function clsCart()
{
	saveCart([]);
};

// 清空vip购物车
function clsVipCart()
{
	saveVipCart([]);
};

// 取购物车价格及数量等信息
// return [price, vipPrice, cartSize, cartCount]
function getCartPrice(aCart)
{
	var aCart = arguments[0] || getCart();
	var aPrice = [0, 0, aCart.length, 0];
	for (var i=0; i<aCart.length; ++i)
	{
		aPrice[0] += aCart[i][3]*aCart[i][2];
		aPrice[1] += aCart[i][4]*aCart[i][2];
		aPrice[3] += aCart[i][2];
	}
	return aPrice;
};
function getVipCartPriceInfo(aCart)
{
	var aCart = arguments[0] || getVipCart();
	var aPrice = [0, 0, aCart.length, 0];
	for (var i=0; i<aCart.length; ++i)
	{
		aPrice[0] += aCart[i][3]*aCart[i][2];
		aPrice[1] += aCart[i][4]*aCart[i][2];
		aPrice[3] += aCart[i][2];
	}
	return aPrice;
};
//更新torfra信息
function updateHeaderInfo()
{
	if(top.topfra)
	{
		try{
			top.topfra.updateMsg();
		}catch(e){}
	}
};

// 更新topfra导航购物车数量显示
function setHeaderCartNum()
{
	if(top.topfra)
	{
		if(top.topfra.document && top.topfra.document.getElementById("cart_num"))
		{
			var nlen = countCartNum();
			var sMessage = "";
			sMessage += nlen==0 ? "" : ("("+nlen+")");
			if(_MSIE())
			{
				top.topfra.document.getElementById("cart_num").innerHTML = sMessage;
			}
			else
			{
				top.topfra.document.getElementById("cart_num").textContent = sMessage;
			}
			updateHeaderInfo();
		}
		else
		{
			setTimeout(setHeaderCartNum, 1000);
		}
	}
};
// ########################################################

// 循环添加数字选项到select对象中
function SelectAppendOption(oSelect, bi, ei, nlen)
{
	if (bi > ei)
	{
		for (var i=bi; i>=ei; --i)
		{
			oSelect.options[oSelect.options.length] = (new Option(LENFix(i, nlen), LENFix(i, nlen)));
		}
	}
	else
	{
		for (var i=bi; i<=ei; ++i)
		{
			oSelect.options[oSelect.options.length] = (new Option(LENFix(i, nlen), LENFix(i, nlen)));
		}
	}
};

// 年select
function SelectYearOption(oSelect, bi, ei, nlen)
{
	return SelectAppendOption(oSelect, bi, ei, nlen);
};
// 月select
function SelectMonthOption(oSelect, nlen)
{
	return SelectAppendOption(oSelect, 1, 12, 2);
};
// 日select
function SelectDayOption(oSelect, y, m, nlen)
{
	return SelectAppendOption(oSelect, 1, DAYOfMonth(y, m), nlen);
};

function ShowUnsupport()
{
	if(top.mainfra)
		top.mainfra.FloatShow('/inc/note.html', 500, 198);
	else
		FloatShow('/inc/note.html', 500, 198);
}

function ShowLogin()
{
	if(top.mainfra)
	{
        //_MSIE();
        if (_MSIE())
        {
	      top.mainfra.FloatShow('/inc/login_box.html', 462, 295, null, null, 0, -100 );
	    }else
	    {
	      top.mainfra.FloatShow('/inc/login_box.html', 462, 295, null, null, 0, 0);
	    }
		//top.mainfra.FloatShow('/inc/login_box.html', 462, 295, null, null, 0, 0 );
	}
	else
	{
	    if (_MSIE())
	    {
	      FloatShow('/inc/login_box.html', 462, 295, null, null, 0, -100 );
	    }else
	    {
	      FloatShow('/inc/login_box.html', 462, 295, null, null, 0, 0);
	    }
		//FloatShow('/inc/login_box.html', 462, 295, null, null, 0, 0 );
    }
		
};
// ########################################################
// iProcType: 1:确认但必须跳转  2--确认可以不跳转
// url:	
// target:  mainfra,url会在mainfra显示（默认）
//			top, 全页面跳转
function CheckLogin(iProcType, url, target)
{
	var iUin = GetUin();
	if(iUin <10000 || iUin>999999999)
	{
		var loginUrl = "/inc/login_box.html";
		var loginUrlTop = "http://show8.qq.com/login.html";
		if(url && url.length >0)
		{
			if(target && target == "top") loginUrl = setURLParam(loginUrl, "url", url);
			else loginUrl = setURLParam(loginUrl,"url",setURLParam("http://show8.qq.com/show.html","MUrl",url));
			if(target && target == "top") loginUrlTop = setURLParam(loginUrlTop, "url", url);
			else loginUrlTop = setURLParam(loginUrlTop,"url",setURLParam("http://show8.qq.com/show.html","MUrl",url));
		}
		if (iProcType==1)
		{
			if(confirm("您还没有登录，是否登录？"))
			{
				if(top.mainfra && typeof(top.mainfra.FloatShow) == "function") 
				{
				  if (_MSIE())
				  {
				    top.mainfra.FloatShow(loginUrl, 460, 295, null, null, 0, -100);
				  }else
				  {
				    top.mainfra.FloatShow(loginUrl, 460, 295, null, null, 0, 0);
				  }
			    }
				else if(typeof(FloatShow) == "function") FloatShow(loginUrl, 460, 295, null, null, 200, 0);
				else location = loginUrlTop;	
				return false;
			}
		}
		else if(2 == iProcType)
		{
			if (confirm("您还没有登录，是否登录？"))
			{
				if(top.mainfra && typeof(top.mainfra.FloatShow) == "function") 
				{
				  if (_MSIE())
				  {
				    top.mainfra.FloatShow(loginUrl, 460, 295, null, function(){location = "/inc/main.html";}, 0, -100);
				  }else
				  {
				    top.mainfra.FloatShow(loginUrl, 460, 295, null, function(){location = "/inc/main.html";}, 0, 0);
				  }
			    }
				else if(typeof(FloatShow) == "function") FloatShow(loginUrl, 460, 295, null, null, 200, 0);
				else location = loginUrlTop;
				return false;
			}
			else 
			{
				if(top.mainfra) top.mainfra.location.href = '/inc/main.html';
				else location = "http://show8.qq.com";
				return false;
			}
		}	
		else return false;
	}
	return iUin;
};

// ########################################################

// QQShow请求失败时公共回调函数
function QQShowCommREQError()
{
	alert("请求失败，请稍候再试。");
};

// QQShow基本公共返回码基本处理
function QQShowCommXMLError(xmlDoc)
{
	var iCode = xmlDoc.getElementsByTagName("QQSHOW")[0].getAttribute("code");
	var sMessage = xmlDoc.getElementsByTagName("QQSHOW")[0].getAttribute("message");
	if (iCode==-1100 || iCode==-1003)
	{
		return alert("操作失败，请稍候再试。");
	}
	else if (iCode==-1001)
	{
		return !QQShowCommXMLError._onlogin && (QQShowCommXMLError._onlogin=true) && confirm("对不起，您还没登录，现在登录？") && (top.location.href="/login.html?url="+("http://show8.qq.com/show.html?MUrl="+(top.mainfra||window).location.href.escUrl()).escUrl()) && 0;
	}
	else if (iCode==-1002)
	{
		return alert("您输入的参数有错，请重新输入，谢谢。");
	}
	else if (iCode==-1004)
	{
		return alert("对不起，您操作太频繁，请稍候再试。");
	}
	else if (iCode==-1005)
	{
		return alert("对不起，您还没注册QQ秀。");
	}
	else if(iCode == -1006)
	{
		return alert("对不起，您的好友还没有注册QQ秀！");
	}
	else if(iCode == -1007)
	{
		return alert("对不起，对方不是您的7天好友！");
	}
	else if(iCode == -1008)
	{
		return alert("对不起，您不是对方的7天好友！");
	}

	return true;
};

// ########################################################

function goCartWithLocation()
{
	var sUrl = "/mall/inc/cart.html#pmSelect%3DACC";
	goToCart(sUrl);
};
function goToCartFromSave()
{
	var sUrl = "/mall/inc/cart.html#"+escape("saveav=1");
	goToCart(sUrl);
};
function goToCart(sUrl)
{
	var win = top.mainfra || window;
	if (win.location.href.indexOf("http://show8.qq.com/mall/inc/cart.html")==0)
	{
		win.location.reload();
		return;
	}
	else if(win.location.href.indexOf("/mall/inc/cart.html")!=-1)
	{	 
		win.location.reload();
	}
	else
	{
		QSCookie("mallloc", win.location.href);				
		win.location = sUrl;
	}	
};

function goMallWithLocation()
{
	var win = top.mainfra || window;
	//if (getCookie("mallloc"))
	//逻辑：我的QQ秀，论坛，排行版购买物品后，点返回商城继续购物，返回商城首页，其他则是返回当前操作页。
	if ((getCookie("mallloc").length>0) && (getCookie("mallloc").indexOf("/my/inc") == -1))
	{
		win.location = getCookie("mallloc");
	}
	else
	{
	  if("function"==typeof(frameChange))
	  {
		  frameChange(201010000);
		//win.location.href = "/inc/main.html";
	  }
	}
};

// 放进购物车并跳转到购物车页面
function Buy(sName, iNo, iPrice, iPriceVip, iVipItem, vFrom)
{
	if (CheckLogin(1))
	{
		if (iVipItem==1 && QUSER.getInfo("vip")!=1)
		{
			alert("您不是红钻用户，不能购买红钻物品["+sName+"]");
		}
		else
		{
			if(!setCart([sName, iNo, 1, iPrice, iPriceVip, 0, 0, "", vFrom ? vFrom.toString() : "", iVipItem]))
			{
				alert("您的购物车已满，请支付后继续购物。");
			}
			goCartWithLocation();
		}
	}
};

// 赠送商城物品
function Send(sName, iNo, iPrice, iPriceVip, iVipItem, vFrom)
{
	if (CheckLogin(1))
	{
		if (iVipItem==1 && QUSER.getInfo("vip")!=1)
		{
			alert("您不是红钻用户，不能赠送红钻物品["+sName+"]");
			return;
		}
		else if(iPrice == 0)
		{
			alert("对不起，免费物品不能赠送他人。");
			return;
		}
		else
		{
			function OnOK(x)
			{
				var _Prm = new PARAM(x, "&", "=");
				//alert(_Prm["info"]);
				setCart(DecodeCart(_Prm["info"]));
				alert("成功支付后自动赠送!");
				goCartWithLocation();
			};
			
			var aParam = [sName, iNo, 1, iPrice, iPriceVip, iVipItem, 0, "", vFrom ? vFrom.toString() : "",iVipItem];
			FloatShow("/mall/inc/don.html?info="+EncodeCart(aParam).escUrl(), 440, 300, OnOK);
		}
	}
};

// 索要商城物品
function Ask(sName, iNo, iPrice, iPriceVip, iVipItem, vFrom)
{
	if (CheckLogin(1))
	{
		if (iVipItem==1 && QUSER.getInfo("vip")!=1)
		{
			alert("您不是红钻用户，不能索要红钻物品["+sName+"]");
		}
		else if(iPrice == 0)
		{
			alert("对不起，不能索要免费物品。");
			return;
		}
		else
		{
			var aParam = [sName, iNo, 1, iPrice, iPriceVip, iVipItem, 0, "", vFrom ? vFrom.toString() : "", iVipItem];
			FloatShow("/mall/inc/req.html?info="+EncodeCart(aParam).escUrl(), 503, 248)
		}
	}
};

function AskMul(aCart)
{
	if (CheckLogin(1))
	{
		if (QUSER.getInfo("vip")!=1 && aCart.find_if(function(v){ return (v[5]!=0); })!=null)
		{
			alert("您不是红钻用户不能购买红钻物品["+sName+"]");
		}
		else
		{
			FloatShow("/mall/inc/req.html?info="+CartString(aCart).escUrl(), 500, 225+aCart.length*27)
		}
	}
};

function ItemCollectionAdd(ino)
{
	function onResp(xmlDoc)
	{
		MaskEnd([top.mainfra, top.leftfra, top.topfra]);
		if (QQShowCommXMLError(xmlDoc))
		{
		    var node = xmlDoc.getElementsByTagName("QQSHOW")[0] ; 
			var iCode = xmlDoc.getElementsByTagName("QQSHOW")[0].getAttribute("code");
			var mapCodeMessage = {
				"-1" : "收藏物品号无效",
				"-10": "该物品已经在收藏中"
			};
			
			if (iCode == 0)
			{
				var irb = parseInt(node.getAttribute("rb"));
			    var iret = parseInt(node.getAttribute("set"));
			    if( iret < 0  ) 
			    {
			        alert("收藏成功");
			    }
			    else if( 1 == iret )
			    {
			        try{ top.mainfra.FloatShow('/inc/col_suc2.html', 524, 320, null , null, 40, -50); }catch(e){alert("收藏成功");} ; 
			    }
			    else
			    {
			         QUSER.setInfo("bean" , irb) ;
			         try{ top.mainfra.FloatShow('/inc/col_suc1.html', 524, 320, null , null, 40, -50); }catch(e){alert("收藏成功");} ; 
			    }
			}
			else if (mapCodeMessage[iCode])
			{
				alert("操作失败["+mapCodeMessage[iCode]+"]");
			}
			else
			{
				alert("操作失败"+DebugMessage(iCode));
			}
		}
	};
	function onError()
	{
		MaskEnd([top.mainfra, top.leftfra, top.topfra]);
		alert("操作失败");
	};
	if(CheckLogin(1))
	{
		MaskStart([top.mainfra, top.leftfra, top.topfra]);
		getQQSHOWXml("http://show8.qq.com/cgi-bin/qqshow_user_itemcollection_add?item="+ino, onResp, onResp, onError);
	}
};

function ItemCollectionDel(ino, fnCallBack)
{
	if (!confirm("确定删除吗？"))
	{
		return;
	}
	function onResp(xmlDoc)
	{
		setTimeout("MaskEnd([top.mainfra, top.leftfra, top.topfra])", 1000);
		var iCode = xmlDoc.getElementsByTagName("QQSHOW")[0].getAttribute("code");
		if (iCode == 0)
		{
			//alert("删除成功");
		}
		else if (QQShowCommXMLError(xmlDoc))
		{
			alert("操作失败");
		}
		fnCallBack && fnCallBack(xmlDoc);
	};
	function onError()
	{
		setTimeout("MaskEnd([top.mainfra, top.leftfra, top.topfra])", 1000);
		alert("操作失败");
	};
	if(CheckLogin(1))
	{
		MaskStart([top.mainfra, top.leftfra, top.topfra]);
		getQQSHOWXml("http://show8.qq.com/cgi-bin/qqshow_user_itemcollection_del?item="+ino, onResp, onResp, onError);
	}
};

// vData = [sShow, sName, sTags, sDesc, iType]
function ShowCollectionAdd(vData, fnCallBack)
{
	function onResp(xmlDoc)
	{
		MaskEnd([top.mainfra, top.leftfra, top.topfra]);
		if (QQShowCommXMLError(xmlDoc))
		{
		    var node = xmlDoc.getElementsByTagName("QQSHOW")[0] ; 
			var iCode = node.getAttribute("code");
			var sName = node.getAttribute("itemname");
			var mapCodeMessage = {
				"-23": "基本形象不能收藏",
				"-25": "整套收藏时，身上物品不能超过20件，请您删除为20件以下再进行收藏。",
				"-26": "当前形象内"+(sName?"的物品["+sName+"]":"有")+"与您的形象性别不一致，请脱下后再收藏。",
				"-27": "当前形象内"+(sName?"的物品["+sName+"]":"有")+"与您的形象风格不一致，请脱下后再收藏。"
			};
			if (iCode == 0)
			{
			    var irb = parseInt(node.getAttribute("rb"));
			    var iret = parseInt(node.getAttribute("set"));
			    if( iret < 0  ) 
			    {
			        alert("收藏成功");
			    }
			    else if( 1 == iret )
			    {
			        try{ top.mainfra.FloatShow('/inc/col_suc2.html', 524, 320, null , null, 40, -50); }catch(e){alert("收藏成功");} ; 
			    }
			    else
			    {
			         QUSER.setInfo("bean" , irb) ;
			         try{ top.mainfra.FloatShow('/inc/col_suc1.html', 524, 320, null , null, 40, -50); }catch(e){alert("收藏成功");} ; 
			    }
			   
				fnCallBack && fnCallBack(0);
			}
			else if (mapCodeMessage[iCode])
			{
				alert("操作失败["+mapCodeMessage[iCode]+"]");
				fnCallBack && fnCallBack(-1);
			}
			else
			{
				alert("操作失败"+DebugMessage(iCode));
				fnCallBack && fnCallBack(-1);
			}
		}
	};
	function onError()
	{
		MaskEnd([top.mainfra, top.leftfra, top.topfra]);
		alert("操作失败");
		fnCallBack && fnCallBack(-1);
	};

	if (arguments[0][0].length==0)
	{
		return alert("参数错误");
	}

	var sShow = arguments[0][0];
	var sName = arguments[0][1] || "我的收藏";
	var sTags = arguments[0][2] || "";
	var sDesc = arguments[0][3] || "";
	var iType = arguments[0][4] || 0;

	var sUrl = setURLParam("http://show8.qq.com/cgi-bin/qqshow_user_showcollection_add", "show", huffcompress(sShow));
	sUrl = setURLParam(sUrl, "name", sName);
	sUrl = setURLParam(sUrl, "tags", sTags);
	sUrl = setURLParam(sUrl, "desc", sDesc);
	sUrl = setURLParam(sUrl, "type", iType);

	MaskStart([top.mainfra, top.leftfra, top.topfra]);
	getQQSHOWXml(sUrl, onResp, onResp, onError);
};

// vData = [iID, sName, sTags, sDesc, iType]
function ShowCollectionSet(vData, fnCallBack, vWndMask)
{
	vWndMask || (vWndMask = [top.mainfra, top.leftfra, top.topfra]);
	function onResp(xmlDoc)
	{
		setTimeout(function(){ MaskEnd(vWndMask); }, 1000);
		if (QQShowCommXMLError(xmlDoc))
		{
			var iCode = xmlDoc.getElementsByTagName("QQSHOW")[0].getAttribute("code");
			var mapCodeMessage = {
				"-11": "作品名称中含有不能发表的内容",
				"-12": "作品名称不能为空",
				"-13": "作品描述中含有不能发表的内容",
				"-14": "标签中含有不能发表的内容"
			};
			if (iCode == 0)
			{
				alert("保存成功");
				fnCallBack && fnCallBack(0);
			}
			else if (mapCodeMessage[iCode])
			{
				alert("操作失败["+mapCodeMessage[iCode]+"]");
				fnCallBack && fnCallBack(-1);
			}
			else
			{
				alert("操作失败"+DebugMessage(iCode));
				fnCallBack && fnCallBack(-1);
			}
		}
	};
	function onError()
	{
		setTimeout(function(){ MaskEnd(vWndMask); }, 1000);
		alert("操作失败");
		fnCallBack && fnCallBack(-1);
	};
	if(CheckLogin(1))
	{
		if (!(arguments[0][0]>=0))
		{
			return alert("参数错误");
			fnCallBack && fnCallBack(-1);
		}

		var iID = arguments[0][0];
		var sName = arguments[0][1] || "我的收藏";
		var sTags = arguments[0][2] || "";
		var sDesc = arguments[0][3] || "";
		var iType = arguments[0][4] || 0;

		var sUrl = setURLParam("http://show8.qq.com/cgi-bin/qqshow_user_showcollection_set", "id", iID);
		sUrl = setURLParam(sUrl, "name", sName);
		sUrl = setURLParam(sUrl, "tags", sTags);
		sUrl = setURLParam(sUrl, "desc", sDesc);
		sUrl = setURLParam(sUrl, "type", iType);

		MaskStart(vWndMask);
		getQQSHOWXml(sUrl, onResp, onResp, onError);
	}
};

function ShowCollectionDel(iID, fnCallBack)
{
	if (!confirm("确定删除吗？"))
	{
		return;
	}
	function onResp(xmlDoc)
	{
		setTimeout("MaskEnd([top.mainfra, top.leftfra, top.topfra])", 1000);
		var iCode = xmlDoc.getElementsByTagName("QQSHOW")[0].getAttribute("code");
		if (iCode == 0)
		{
			//alert("删除成功");
		}
		else if (QQShowCommXMLError(xmlDoc))
		{
			alert("操作失败");
		}
		fnCallBack && fnCallBack(xmlDoc);
	};
	function onError()
	{
		setTimeout("MaskEnd([top.mainfra, top.leftfra, top.topfra])", 1000);
		alert("操作失败");
	};
	if(CheckLogin(1))
	{
		MaskStart([top.mainfra, top.leftfra, top.topfra]);
		getQQSHOWXml("http://show8.qq.com/cgi-bin/qqshow_user_showcollection_del?id="+iID, onResp, onResp, onError);
	}
};

function ShowCollectionPrepare()
{
	if(CheckLogin(1))
	{
		var oQSAV = document.getElementById(g_sAVId).cQSAV;
		var sItemSn = oQSAV.ToItemSn(0, 0, 0);
		
		//var itemNum = top.leftfra.document.getElementById("myavatar").cQSAV.ItemCount();
		
		var count = SpecTypeItemCount(sItemSn,3) + SpecTypeItemCount(sItemSn,4);
		var arrObj = GetItemInfArr(sItemSn);
		var itemNum = oQSAV.ItemCount();
		var itemNum = itemNum - count;
		
		if(itemNum == 0)
		{
			alert("基本形象不可以收藏哦。");return;
		}
		else  if(itemNum > 20)
		{
			alert("身上物品超过了20件，请您删除一些再收藏。");return;
		}
		var sItemSn = top.leftfra.document.getElementById("myavatar").cQSAV.ToItemSn(0, 0, 0);
		/*Eutopia  filter*/
		sItemSn = filterForSpecItem(sItemSn,3);
		sItemSn = filterForSpecItem(sItemSn,4);
		/*Eutopia  filter end*/
		ShowCollectionAdd([sItemSn, "我的收藏", "", "", 0]);
	}
};

// ########################################################

// 试穿物品
function PutOn(iItemNo, chSex, sPlyNo, iFStl, bPoseBind, iDefX, iDefY, bMov, bRot, bSelc, bSpecail, sText, sMallNo)
{
	top.leftfra && top.leftfra.ShopTryItem && top.leftfra.ShopTryItem(iItemNo, chSex, sPlyNo, iFStl, bPoseBind, iDefX, iDefY, bMov, bRot, bSelc, bSpecail, sText, sMallNo);
};

// 试穿形象
function PutOnShow(sShow, sFrom)
{
	top.leftfra && top.leftfra.TryOnShow && top.leftfra.TryOnShow(sShow, sFrom);
};

function ReturnMallNo()
{
	if(getHashParam("mallno").length > 0) return getHashParam("mallno");
	else if(top.g_iMallNo) return top.g_iMallNo;
	else return 0;
}

// ########################################################

// 共用功能显示[进度屏蔽/浮动窗口/...]

function DivCreate(oWin, oParent, sID, zIndex, iLeft, iTop, sWidth, sHeight, sDisplay)
{
	if (oWin && oWin.document && !oWin.document.getElementById(sID))
	{
		var e = oWin.document.createElement("DIV");
		e.id = sID;
		e.style.position = "absolute";
		e.style.zIndex = zIndex;
		e.style.left = iLeft;
		e.style.top = iTop;
		e.style.width = sWidth;
		e.style.height = sHeight;
		e.style.display = sDisplay;
		try{ oParent && oParent.appendChild(e); } catch(e) { }
		return e;
	}
	if (oWin.document.getElementById(sID)) return oWin.document.getElementById(sID);
	else return null;
};

function PageMaskCreate(oWin)
{
	if(oWin && oWin.document)
	{
		if (!oWin.document.getElementById("ID_QQSHOW_WAIT_BACKGND"))
		{
			var ebg = DivCreate(oWin, oWin.document.body, "ID_QQSHOW_WAIT_BACKGND", 65529, 0, 0, "100%", "100%", "none");
			ebg.style.backgroundColor = "#0000FF";
			ebg.style.opacity = 0.35;
			ebg.style.filter = "alpha(opacity=35)";
		}
		return oWin.document.getElementById("ID_QQSHOW_WAIT_BACKGND");
	}
	else return null;
};

function ProcessCreate(oWin)
{
	if(oWin && oWin.document && oWin.document.body)
	{
		if (!oWin.document.getElementById("ID_QQSHOW_WAIT_PROCESS"))
		{
			var epr = DivCreate(oWin, oWin.document.body, "ID_QQSHOW_WAIT_PROCESS", 65530, 0, 0, "100%", "100%", "none");
			//epr.innerHTML = '<table width="100%" height="200" border="0"><tr><td align="center" valign="bottom"><img src="http://show8.qq.com/img/base/wait.gif" /></td></tr></table>';
			epr.innerHTML = '<table width="100%" height="200" border="0"><tr><td>&nbsp;</td><td width="308" valign="bottom"><div style="width:308px;height:54px;"><span style="display:block;float:left;width:58px;height:54px;background:url(http://imgcache.qq.com/qqshow/v2/img/loading_bg_l.gif);"></span><span style="display:block;float:left;width:250px;height:54px;background:url(http://imgcache.qq.com/qqshow/v2/img/loading_bg_m.gif);line-height:54px;color:#fff;text-indent:10px;font-size:12px;font-weight:bold;">处理中，请稍候...</span></div></td><td>&nbsp;</td></tr></table>';
		}
		return oWin.document.getElementById("ID_QQSHOW_WAIT_PROCESS");
	}
	else return null;
};

function PageMaskShow(oWin)
{
	var e = PageMaskCreate(oWin);
	if(e)
	{
		e.style.height = Math.max((oWin.document.body.offsetHeight), oWin.document.documentElement.clientHeight)+"px";
		e.style.display = "block";
	}
};

function ProcessShow(oWin, lTxt)
{
	var e = ProcessCreate(oWin);
	if(!lTxt) lTxt = ["处理中，请稍候..."];
	if(e && oWin.document.body)
	{
		(lTxt) && (e.getElementsByTagName("SPAN")[1].innerHTML = lTxt[0]);
		e.style.height = (oWin.document.body.offsetHeight)+"px";
		e.getElementsByTagName("TABLE")[0].height = Math.max(Math.min(oWin.document.documentElement.scrollTop+150, 	oWin.document.body.offsetHeight-100), 100);
		e.style.display = "block";
	}
};

function PageMaskHide(oWin)
{
	var e = PageMaskCreate(oWin);
	e.style.display = "none";
};

function ProcessHide(oWin)
{
	var e = ProcessCreate(oWin);
	e.style.display = "none";
};

function MaskStart(lWin)
{
	for (var i=0; i<arguments[0].length; ++i)
	{
		try{ PageMaskShow(arguments[0][i]); } catch(e) { }
	}
};

function MaskEnd(lWin)
{
	for (var i=0; i<arguments[0].length; ++i)
	{
		try{ PageMaskHide(arguments[0][i]); } catch(e) { }
	}
};

function WaitStart(lWin, lTxt, bTxt)
{
	for (var i=0; i<arguments[0].length; ++i)
	{
		if(arguments[0][i])
		{
			PageMaskShow(arguments[0][i]);
		}
	}
	if(arguments[0][0] && !bTxt) ProcessShow(arguments[0][0], lTxt);
};

function WaitEnd(lWin)
{
	for (var i=0; i<arguments[0].length; ++i)
	{
		try{ PageMaskHide(arguments[0][i]);} catch(e){ }
	}
	try{ ProcessHide(arguments[0][0]); } catch(e) { }
};

function FloatShow(sUrl, iWidth, iHeight, OnOK, OnCancel, iLeft, iTop, oWin, fras, zIndex)
{
	var izIndex = zIndex?zIndex:65530;
	oWin = oWin || window;
	iLeft = typeof(iLeft)=="number" ? iLeft : 75;
	iTop = typeof(iTop)=="number" ? iTop : 45;
	var ifras = null;
	if (typeof(fras) != "undefined" && fras != null && fras != "null")
	{
	  ifras = fras;
	}else
	{
		ifras = [window, top.mainfra, top.leftfra, top.topfra];
	}
	FloatShow.Show = function(sUrl, iWidth, iHeight, iLeft, iTop)
	{
		MaskStart(ifras);
		var e = DivCreate(oWin, oWin.document.body, "ID_QQSHOW_FLOAT_WIN", izIndex, 0, 50, "100%", "1", "none");
		if(e && "object" == typeof(e) && "div" == e.tagName.toString().toLowerCase())
		{
		e.style.top = (Math.max(Math.min(oWin.document.documentElement.scrollTop+100, Math.max(oWin.document.body.offsetHeight-100,100)), 50))+"px";
		e.innerHTML = '<table id="w_head" align="center" style="position:absolute;left:'+iLeft+'px;top:'+iTop+'px;"><tr><td align="center"><iframe allowtransparency=true id="ID_QQSHOW_FLOAT_IFRAME" name="ID_QQSHOW_FLOAT_IFRAME" width="'+iWidth+'" height="'+iHeight+'" frameborder="0" scrolling="no"></iframe></td></tr></table><div id="d_border" style="display:none;border:1px dotted #000000; position:absolute;"></div>';
		e.getElementsByTagName("IFRAME")[0].src = sUrl;
		e.style.display = "block";
		}
		else throw "create div failed ";
	};
	
	FloatShow.Hide = function()
	{
	  MaskEnd([window, top.mainfra, top.leftfra, top.topfra]);
	  
		if (arguments[0])
		{
		  var fra = arguments[0];
		  if (fra && fra.document)
		  {
		    if(fra.document.getElementById("ID_QQSHOW_FLOAT_WIN"))
				fra.document.getElementById("ID_QQSHOW_FLOAT_WIN").style.display = "none";	
		  }
		}else
		{
			if(document.getElementById("ID_QQSHOW_FLOAT_WIN"))
				document.getElementById("ID_QQSHOW_FLOAT_WIN").style.display = "none";	
		}
	};
	
	FloatShow.DireOnCancel = function()
	{
		OnCancel && OnCancel(arguments[0]);
	};

	FloatShow.OnOK = function()
	{
		FloatShow.Hide();
		OnOK && OnOK(arguments[0]);
	};

	FloatShow.OnCancel = function()
	{
		FloatShow.Hide();
		OnCancel && OnCancel(arguments[0]);
	};

	FloatShow.AutoSize = function()
	{
		try
		{
			function FindIFrame(sName) { for (var i=0; i<window.frames.length; ++i) { if (window.frames[i].name==sName) { return window.frames[i]; } } return null; };
			var e = document.getElementById("ID_QQSHOW_FLOAT_IFRAME");
			var w = _MSIE() ? window.frames["ID_QQSHOW_FLOAT_IFRAME"] : FindIFrame("ID_QQSHOW_FLOAT_IFRAME");
			if ((w.document.documentElement.scrollTop=500) && (w.document.documentElement.scrollTop!=0))
			{
				e.height = parseInt(e.height)+w.document.documentElement.scrollTop+"px";
				w.document.documentElement.scrollTop = 0;
			}
			if ((w.document.documentElement.scrollLeft=500) && (w.document.documentElement.scrollLeft!=0))
			{
				e.width = parseInt(e.width)+w.document.documentElement.scrollLeft+"px";
				w.document.documentElement.scrollLeft = 0;
			}
		}
		catch(e)
		{
		}
	};

	FloatShow.Show(sUrl, iWidth, iHeight, iLeft, iTop);
};
//红钻包月添加
function RBuyAll(show,from)
{
	if (CheckLogin(1))
	{
		//红钻用户,且不是"特供品"才进入红钻免费页面
		if (QUSER.getInfo("vip") == 1)
		{
			ShowVipMonthPageAll(show,from);
			return;
		}else
		{
			BuyAll(show,from);
		}
	}
};
function ShowVipMonthPageAll(show,from)
{
	function OnOK(x)
	{
		BuyAll(show,from);
	};
	function OnCancel(x)
	{
	};
	if (top.mainfra && top.topfra)
	{
		FloatShow("/mall/inc/buy_tips_box.html", 555, 390, OnOK, OnCancel, 0, -100, top.mainfra, null);
	}
	else
	{
		setTimeout("ShowVipMonthPageAll()", 1000);
	}
};
//按形象串整套购买
function BuyAll(show, from)
{
    /*Eutopia filter begin*/
    
	show = filterForSpecItem(show,3);
	show = filterForSpecItem(show,4);
	
    /*Eutopia filter end*/
    
	if(CheckLogin(1))
	{
		var arrObj = top.leftfra.GetItemInfArr(show);
		var sItemNo = "";
		for(var i = 0; i<arrObj.length; i++)
		{
			if(sItemNo.length > 0) sItemNo += "|";
			sItemNo += arrObj[i]._iItemNo;  
		}
		var sUrl = "/cgi-bin/qqshow_item_info?item="+sItemNo.escUrl();
		function fnSucc(xmlDoc)
		{
			var aItemXml = xmlDoc.getElementsByTagName("node");
			for(var i=0;i<aItemXml.length;i++)					 
			{
			  setCart([aItemXml[i].getAttribute("iname"),aItemXml[i].getAttribute("ino"),1,aItemXml[i].getAttribute("ipriceori"),aItemXml[i].getAttribute("ipricevip"),0, 0, "",from.length>0?from:"", aItemXml[i].getAttribute("itype")]);
			}
			goCartWithLocation();
		}
		function fnFail(xmlDoc)
		{
            var sMessage = xmlDoc.getElementsByTagName("QQSHOW")[0].getAttribute("message");
			if (sMessage == "")
			{
			  sMessage = "获取物品详情失败";
			}
			alert(sMessage);
			return;
		}
		function fnError()
		{
			alert("对不起，系统繁忙，请稍后再试。");
			return;
		}
		getQQSHOWXml(sUrl, fnSucc, QQShowCommXMLError&&fnFail, fnError);
	}
}
//赠送身上的所有物品
function sendAll(i)
{
	var n = i || 0;
	if (CheckLogin(1))
	{
		var oQSAV = document.getElementById(g_sAVId).cQSAV;
		var sItemSn = oQSAV.ToItemSn(0, 0, 0);
		/*Eutopia Filter*/
		var count = SpecTypeItemCount(sItemSn,3) + SpecTypeItemCount(sItemSn,4);
		
		sItemSn = filterForSpecItem(sItemSn,3);
		sItemSn = filterForSpecItem(sItemSn,4);
		/****end***/
			
		var arrObj = GetItemInfArr(sItemSn);
		var itemNum = oQSAV.ItemCount();
		itemNum = itemNum - count;
		if(itemNum == 0) 
		{
			return alert("您的身上没有任何物品，请添加物品之后赠送");
		}
		else if(itemNum > 20)
		{
			return alert("对不起，单次赠送物品数量不能超过20件。");
		}
		if (top.mainfra && "function"==typeof(top.mainfra.FloatShow))
		{
			top.mainfra.FloatShow("http://show8.qq.com/mall/inc/don_mul.html", 596, 461, null, null, 0, -100);
		}
		else if(n == 0)
		{
			top.mainfra.location.href = "/inc/main.html";
			setTimeout(function(){sendAll(n+1)}, 400);
		}
		else if(n < 10)
		{
			setTimeout(function(){sendAll(n+1)}, 400);
		}
	}
};
//索要身上的所有物品
function askAll(i)
{
	var n = i || 0;
	if (CheckLogin(1))
	{
		var oQSAV = document.getElementById(g_sAVId).cQSAV;
		var sItemSn = oQSAV.ToItemSn(0, 0, 0);

		/*Eutopia Filter*/
		var count = SpecTypeItemCount(sItemSn,3) + SpecTypeItemCount(sItemSn,4);
		
		sItemSn = filterForSpecItem(sItemSn,3);
		sItemSn = filterForSpecItem(sItemSn,4);
		/****end***/
		
		var arrObj = GetItemInfArr(sItemSn);
		var itemNum = oQSAV.ItemCount();
		var itemNum = itemNum - count;
		
		if(itemNum == 0) 
		{
			return alert("您的身上没有任何物品，请添加物品后索要.");
		}
		else if(itemNum > 20)
		{
			return alert("对不起，单次索要物品数量不能超过20件。");
		}
		if (top.mainfra && "function"==typeof(top.mainfra.FloatShow))
		{
			top.mainfra.FloatShow("http://show8.qq.com/mall/inc/req_mul.html",596,401,null,null,0, -100);
		}
		else if(n == 0)
		{
			top.mainfra.location.href = "/inc/main.html";
			setTimeout(function(){askAll(n+1)},400);
		}
		else if(n < 10)
		{
			setTimeout(function(){askAll(n+1)},400);
		}
	}
};
// ########################################################

//floatshow 移动事件处理

function EventRouter(event)
{
	var sType = event.type;
	var oEle = event.srcElement || event.target;
	var oWindow = document.getElementById("w_head");
	var oBorder = document.getElementById("d_border");
	switch (sType)
	{
	case "mousedown":
        if(oEle.tagName.toUpperCase() == "A")
        {
            return;
        }
        oWindow.m_bDown = true;
        oBorder.style.width = oWindow.offsetWidth + 2 + "px";
        oBorder.style.height = oWindow.offsetHeight + 2 + "px";
        oBorder.style.left =  oWindow.offsetLeft + "px";
        oBorder.style.top =  oWindow.offsetTop  +"px";
        oBorder.style.display = "";
        addEventListener(document.body,"onmousemove",EventRouter);
        addEventListener(document.body,"onmouseup",EventRouter);
        if(document.all)
            oBorder.setCapture(true);
		break;
		
	case "mouseup":
		if(!oWindow.m_bDown ) return;
		oWindow.style.left = oBorder.style.left;
		oWindow.style.top = oBorder.style.top;
		oBorder.style.display = "none";
		removeEventListener(document.body,"onmousemove",EventRouter);
		removeEventListener(document.body,"onmouseup",EventRouter);
		//oDebug.value += "removeEvent ok! \n";
		oWindow.m_bDown = false;
		if(document.all)
			oBorder.releaseCapture(true);
		break;
	case "mousemove":
        if(!oWindow.m_bDown) return;
        var iM_x = event.clientX;
        var iM_y;
        var iScrollTop = document.body.scrollTop + document.documentElement.scrollTop;
        iM_y = event.clientY + iScrollTop;
        var oMask = document.getElementById("ID_QQSHOW_FLOAT_WIN");
        var _left = iM_x - oWindow.clientWidth / 2;
        var _top = iM_y - 20;
        
        var iW = oWindow.clientWidth ;
        var iH = oWindow.clientHeight ; 
		var oWin;
		if(window.frameElement) oWin = window.frameElement;
		else oWin = document.body;
        _left = _left < 15 ? 0 : (_left + iW > oWin.offsetWidth ? (oWin.offsetWidth - iW) : _left);
        _top = _top < 15 ? 0 : (_top + iH - iScrollTop > (document.all ? oWin.clientHeight : document.body.clientHeight ) ? ( (document.all ? oWin.clientHeight :document.body.clientHeight ) - iH  + iScrollTop) : _top );
       
        _top = _top - oMask.offsetTop;
        //当父窗口过小时 处理。
        _top = _top < (-oMask.offsetTop) ? (-oMask.offsetTop):_top;
        oBorder.style.left = _left + "px";
        oBorder.style.top =  _top + "px";
		break;
	default:
		break;
	}
};

function addEventListener (oElem, oEvents, fnHandler) {
	if (!oElem || !oEvents || !fnHandler) return;
	
	if ((typeof oEvents == "string" || oEvents instanceof String)) {
		_addEventListener(oElem, oEvents, fnHandler);
	} else {
		for (var i=0,nLen=oEvents.length; i<nLen; i++) {
			_addEventListener(oElem, oEvents[i], fnHandler);
		}
	}
};
function _addEventListener(oElem, sEvent, fnHandler) {
	if (!oElem || !sEvent || !fnHandler) return;
	
	if (oElem.attachEvent) {
		if (sEvent.indexOf("on") == -1)
			sEvent = "on" + sEvent;
		oElem.attachEvent(sEvent, fnHandler);
	} else {
		if (sEvent.indexOf("on") == 0)
			sEvent = sEvent.substr(2);
		oElem.addEventListener(sEvent, fnHandler, false);
	}
};

function removeEventListener (oElem, oEvents, fnHandler) {
	if (!oElem || !oEvents || !fnHandler) return;
	
	if ((typeof oEvents == "string" || oEvents instanceof String)) {
		_removeEventListener(oElem, oEvents, fnHandler);
	} else {
		for (var i=0,nLen=oEvents.length; i<nLen; i++) {
			_removeEventListener(oElem, oEvents[i], fnHandler);
		}
	}
};

function _removeEventListener(oElem, sEvent, fnHandler) {
	if (!oElem || !sEvent || !fnHandler) return;
	
	if (oElem.detachEvent) {
		if (sEvent.indexOf("on") == -1)
			sEvent = "on" + sEvent;
		oElem.detachEvent(sEvent, fnHandler);
	} else {
		if (sEvent.indexOf("on") == 0)
			sEvent = sEvent.substr(2);
		oElem.removeEventListener(sEvent, fnHandler, false);
	}
};

// ########################################################
function GetJs(url,loadFn)
{
	this.bExec = false;
	this.sUrl = url;
	this.fnOnload = function()
	{
		if(!this.bExec)
		{
			loadFn();
			this.bExec = true;
		}
	};
};
GetJs.prototype.init = function()
{
	var t = this;
	var oScript = document.createElement("SCRIPT");
	oScript.onload = function()
	{
		t.fnOnload();	
	};
	oScript.onerror = function()
	{
		t.bExec = true;
	};
	oScript.onreadystatechange = function()
	{
		if((oScript.readyState!="loaded")&&(oScript.readyState!="complete")) return;
		oScript.onreadystatechange = null;		
		t.fnOnload();
	}; 
	oScript.setAttribute("TYPE","text/javascript");	
	oScript.src = t.sUrl;
	document.getElementsByTagName("HEAD")[0].appendChild(oScript);
};

//检查客户端分辨率
function CheckClientScreen()
{
	var iScreenW = parseInt(screen.width);
	var iScreenH = parseInt(screen.height);
	if( iScreenW <= 800 || iScreenH <=600 )
	{
		alert("对不起，您的电脑分辨率太低，无法正常浏览商城，请调整电脑分辨率到1024*768以上！");
		return -1;
	}
	return 0;
};

// QQ秀帮助框
function QQShowHelpBox(sContent, sTitle, sWinTitle, oWin, iType, bTxt)
{
    QQShowHelpBox.OnClose = function()
    {
        WaitEnd([top.mainfra, top.leftfra, top.topfra]);
        FloatShow.Hide();
    };
    
    QQShowHelpBox.init = function(oDoc)
    {
        var eWinTitle = oDoc.getElementById("ID_WinTitle");
        var eTitle    = oDoc.getElementById("ID_Title");
        var eContent  = oDoc.getElementById("ID_Content");
        
        sWinTitle && eWinTitle && (eWinTitle.innerHTML = sWinTitle.escHtml());
        sTitle    && eTitle    && (eTitle.innerHTML    = sTitle.escHtml());
        sContent  && eContent  && (eContent.innerHTML  = sContent.escHtml());
    };
    
    QQShowHelpBox.Show = function()
    {
        var sFile = '/help/inc/help_box.html';
        
        iType && (!isNaN(iType)) && (sFile = '/help/inc/help_box_' + iType + '.html');
        
        var iWidth  = 461;
        var iHeight = 230;
        oWin || (oWin = top.mainfra ? top.mainfra : window);
	    oWin.FloatShow(sFile, iWidth, iHeight);
    };
    
	WaitStart([top.mainfra, top.leftfra, top.topfra], null, bTxt);
	QQShowHelpBox.Show();
};

/*
	QQ秀系统对话框
	分为三种模式。
*/

function QQShowDialog( iType , sMsg , sTitle , fnOk , fnNo , fnCancel, oWin, iWidth, iHeight, bTxt)
{
	var m_itype = iType ? iType :  1 ;
	var m_sMsg  = sMsg ? sMsg: "";
	var m_sTitle = sTitle ?sTitle : "提示";
	var m_func_ok = fnOk? fnOk: function(){};
	var m_func_no = fnNo ?fnNo: function(){};
	var m_func_cancel = fnCancel ?fnCancel: function(){};	
	var _width = iWidth?iWidth:504;	
	var _height = iHeight?iHeight:198;
	
	QQShowDialog.Show = function ()
	{		
		if(oWin)
			oWin.FloatShow('/inc/alert.html',  _width,  _height);			
		else if(top.mainfra)
			top.mainfra.FloatShow('/inc/alert.html', _width,  _height);
		else
			FloatShow('/inc/alert.html', _width,  _height);
	};
	QQShowDialog.OnOk = function ()
	{
		try{
			m_func_ok();
		}catch(e){};
		FloatShow.Hide();
		WaitEnd([top.mainfra, top.leftfra, top.topfra]);
	};
	
	QQShowDialog.OnNo = function ()
	{
		try{
			m_func_no();
		}catch(e){};
		FloatShow.Hide();
		WaitEnd([top.mainfra, top.leftfra, top.topfra]);
	};
	QQShowDialog.OnCancel = function ()
	{
		try{
			m_func_cancel();
		}catch(e){};
		FloatShow.Hide();
		WaitEnd([top.mainfra, top.leftfra, top.topfra]);
		
	};
	QQShowDialog.AddListener = function(oEle , fnEvt)
	{
		if(oEle){
			addEventListener(oEle ,"onclick" , fnEvt );
		}
	};
	QQShowDialog.init = function(oDoc)
	{
		//	oDoc.getElementById("b_ok").innerHTML = 
		//	oDoc.getElementById("b_no").innerHTML = 
		//	oDoc.getElementById("b_cancel").innerHTML = 
		oDoc.getElementById("title").innerHTML = m_sTitle.escHtml();
		oDoc.getElementById("msg").innerHTML = m_sMsg.escHtml();
		var oBok = oDoc.getElementById("b_ok");
		var oBno = oDoc.getElementById("b_no");
		var oBcancel = oDoc.getElementById("b_cancel");
		
		QQShowDialog.AddListener(oBok,QQShowDialog.OnOk);
		QQShowDialog.AddListener(oBno,QQShowDialog.OnNo);
		QQShowDialog.AddListener(oBcancel,QQShowDialog.OnCancel);
		
		if(m_itype == 1)		
		{
			oBok.className="left_btn_1";	
		}
		else if(m_itype == 2){
			oBno.style.display = "";
		}else if(m_itype == 3){
			oBno.style.display = "";
			oBcancel.style.display = "";
		}
		
	};
	WaitStart([top.mainfra, top.leftfra, top.topfra],null,bTxt);
	QQShowDialog.Show();
};

function GetTypes()
{
	return ["休闲","正装","运动","礼服","奇幻","卡通"];
}

function InitCombo(oEle)
{
	if(oEle.tagName != "SELECT") return;
	var sType = GetTypes();
	oEle.options.length = 0;
	for(var i=0;i<sType.length;i++)
	{
		oEle.options[i] = (new Option(sType[i], sType[i]));
	}
}

function encodehuffman(sSrc)
{
	var mapName = [];
mapName[48] = [1,String.fromCharCode( 0 )];
mapName[57] = [6,String.fromCharCode( 1 )];
mapName[124] = [6,String.fromCharCode( 33 )];
mapName[46] = [5,String.fromCharCode( 17 )];
mapName[49] = [4,String.fromCharCode( 9 )];
mapName[54] = [6,String.fromCharCode( 5 )];
mapName[56] = [6,String.fromCharCode( 37 )];
mapName[52] = [5,String.fromCharCode( 21 )];
mapName[50] = [6,String.fromCharCode( 13 )];
mapName[38] = [8,String.fromCharCode( 45 , 0 )];
mapName[10] = [9,String.fromCharCode( 173 , 0 )];
mapName[70] = [10,String.fromCharCode( 173 , 1 )];
mapName[100] = [15,String.fromCharCode( 173 , 3 )];
mapName[105] = [16,String.fromCharCode( 173 , 67 , 0 )];
mapName[65] = [18,String.fromCharCode( 173 , 195 , 0 )];
mapName[69] = [18,String.fromCharCode( 173 , 195 , 2 )];
mapName[4] = [23,String.fromCharCode( 173 , 195 , 1 )];
mapName[5] = [23,String.fromCharCode( 173 , 195 , 65 )];
mapName[2] = [23,String.fromCharCode( 173 , 195 , 33 )];
mapName[3] = [23,String.fromCharCode( 173 , 195 , 97 )];
mapName[8] = [23,String.fromCharCode( 173 , 195 , 17 )];
mapName[9] = [23,String.fromCharCode( 173 , 195 , 81 )];
mapName[6] = [23,String.fromCharCode( 173 , 195 , 49 )];
mapName[7] = [23,String.fromCharCode( 173 , 195 , 113 )];
mapName[34] = [22,String.fromCharCode( 173 , 195 , 9 )];
mapName[36] = [22,String.fromCharCode( 173 , 195 , 41 )];
mapName[0] = [23,String.fromCharCode( 173 , 195 , 25 )];
mapName[1] = [23,String.fromCharCode( 173 , 195 , 89 )];
mapName[33] = [22,String.fromCharCode( 173 , 195 , 57 )];
mapName[22] = [23,String.fromCharCode( 173 , 195 , 5 )];
mapName[23] = [23,String.fromCharCode( 173 , 195 , 69 )];
mapName[20] = [23,String.fromCharCode( 173 , 195 , 37 )];
mapName[21] = [23,String.fromCharCode( 173 , 195 , 101 )];
mapName[26] = [23,String.fromCharCode( 173 , 195 , 21 )];
mapName[27] = [23,String.fromCharCode( 173 , 195 , 85 )];
mapName[24] = [23,String.fromCharCode( 173 , 195 , 53 )];
mapName[25] = [23,String.fromCharCode( 173 , 195 , 117 )];
mapName[13] = [23,String.fromCharCode( 173 , 195 , 13 )];
mapName[14] = [23,String.fromCharCode( 173 , 195 , 77 )];
mapName[11] = [23,String.fromCharCode( 173 , 195 , 45 )];
mapName[12] = [23,String.fromCharCode( 173 , 195 , 109 )];
mapName[18] = [23,String.fromCharCode( 173 , 195 , 29 )];
mapName[19] = [23,String.fromCharCode( 173 , 195 , 93 )];
mapName[15] = [23,String.fromCharCode( 173 , 195 , 61 )];
mapName[17] = [23,String.fromCharCode( 173 , 195 , 125 )];
mapName[62] = [22,String.fromCharCode( 173 , 195 , 3 )];
mapName[64] = [22,String.fromCharCode( 173 , 195 , 35 )];
mapName[59] = [22,String.fromCharCode( 173 , 195 , 19 )];
mapName[60] = [22,String.fromCharCode( 173 , 195 , 51 )];
mapName[84] = [22,String.fromCharCode( 173 , 195 , 11 )];
mapName[91] = [22,String.fromCharCode( 173 , 195 , 43 )];
mapName[78] = [22,String.fromCharCode( 173 , 195 , 27 )];
mapName[83] = [22,String.fromCharCode( 173 , 195 , 59 )];
mapName[41] = [22,String.fromCharCode( 173 , 195 , 7 )];
mapName[42] = [22,String.fromCharCode( 173 , 195 , 39 )];
mapName[39] = [22,String.fromCharCode( 173 , 195 , 23 )];
mapName[40] = [22,String.fromCharCode( 173 , 195 , 55 )];
mapName[47] = [22,String.fromCharCode( 173 , 195 , 15 )];
mapName[58] = [22,String.fromCharCode( 173 , 195 , 47 )];
mapName[43] = [22,String.fromCharCode( 173 , 195 , 31 )];
mapName[44] = [22,String.fromCharCode( 173 , 195 , 63 )];
mapName[67] = [14,String.fromCharCode( 173 , 35 )];
mapName[117] = [13,String.fromCharCode( 173 , 19 )];
mapName[103] = [16,String.fromCharCode( 173 , 11 , 0 )];
mapName[165] = [23,String.fromCharCode( 173 , 139 , 0 )];
mapName[166] = [23,String.fromCharCode( 173 , 139 , 64 )];
mapName[162] = [23,String.fromCharCode( 173 , 139 , 32 )];
mapName[164] = [23,String.fromCharCode( 173 , 139 , 96 )];
mapName[169] = [23,String.fromCharCode( 173 , 139 , 16 )];
mapName[170] = [23,String.fromCharCode( 173 , 139 , 80 )];
mapName[167] = [23,String.fromCharCode( 173 , 139 , 48 )];
mapName[168] = [23,String.fromCharCode( 173 , 139 , 112 )];
mapName[156] = [23,String.fromCharCode( 173 , 139 , 8 )];
mapName[157] = [23,String.fromCharCode( 173 , 139 , 72 )];
mapName[154] = [23,String.fromCharCode( 173 , 139 , 40 )];
mapName[155] = [23,String.fromCharCode( 173 , 139 , 104 )];
mapName[160] = [23,String.fromCharCode( 173 , 139 , 24 )];
mapName[161] = [23,String.fromCharCode( 173 , 139 , 88 )];
mapName[158] = [23,String.fromCharCode( 173 , 139 , 56 )];
mapName[159] = [23,String.fromCharCode( 173 , 139 , 120 )];
mapName[181] = [23,String.fromCharCode( 173 , 139 , 4 )];
mapName[182] = [23,String.fromCharCode( 173 , 139 , 68 )];
mapName[179] = [23,String.fromCharCode( 173 , 139 , 36 )];
mapName[180] = [23,String.fromCharCode( 173 , 139 , 100 )];
mapName[185] = [23,String.fromCharCode( 173 , 139 , 20 )];
mapName[186] = [23,String.fromCharCode( 173 , 139 , 84 )];
mapName[183] = [23,String.fromCharCode( 173 , 139 , 52 )];
mapName[184] = [23,String.fromCharCode( 173 , 139 , 116 )];
mapName[173] = [23,String.fromCharCode( 173 , 139 , 12 )];
mapName[174] = [23,String.fromCharCode( 173 , 139 , 76 )];
mapName[171] = [23,String.fromCharCode( 173 , 139 , 44 )];
mapName[172] = [23,String.fromCharCode( 173 , 139 , 108 )];
mapName[177] = [23,String.fromCharCode( 173 , 139 , 28 )];
mapName[178] = [23,String.fromCharCode( 173 , 139 , 92 )];
mapName[175] = [23,String.fromCharCode( 173 , 139 , 60 )];
mapName[176] = [23,String.fromCharCode( 173 , 139 , 124 )];
mapName[132] = [23,String.fromCharCode( 173 , 139 , 2 )];
mapName[133] = [23,String.fromCharCode( 173 , 139 , 66 )];
mapName[130] = [23,String.fromCharCode( 173 , 139 , 34 )];
mapName[131] = [23,String.fromCharCode( 173 , 139 , 98 )];
mapName[136] = [23,String.fromCharCode( 173 , 139 , 18 )];
mapName[137] = [23,String.fromCharCode( 173 , 139 , 82 )];
mapName[134] = [23,String.fromCharCode( 173 , 139 , 50 )];
mapName[135] = [23,String.fromCharCode( 173 , 139 , 114 )];
mapName[30] = [23,String.fromCharCode( 173 , 139 , 10 )];
mapName[31] = [23,String.fromCharCode( 173 , 139 , 74 )];
mapName[28] = [23,String.fromCharCode( 173 , 139 , 42 )];
mapName[29] = [23,String.fromCharCode( 173 , 139 , 106 )];
mapName[128] = [23,String.fromCharCode( 173 , 139 , 26 )];
mapName[129] = [23,String.fromCharCode( 173 , 139 , 90 )];
mapName[32] = [23,String.fromCharCode( 173 , 139 , 58 )];
mapName[127] = [23,String.fromCharCode( 173 , 139 , 122 )];
mapName[148] = [23,String.fromCharCode( 173 , 139 , 6 )];
mapName[149] = [23,String.fromCharCode( 173 , 139 , 70 )];
mapName[146] = [23,String.fromCharCode( 173 , 139 , 38 )];
mapName[147] = [23,String.fromCharCode( 173 , 139 , 102 )];
mapName[152] = [23,String.fromCharCode( 173 , 139 , 22 )];
mapName[153] = [23,String.fromCharCode( 173 , 139 , 86 )];
mapName[150] = [23,String.fromCharCode( 173 , 139 , 54 )];
mapName[151] = [23,String.fromCharCode( 173 , 139 , 118 )];
mapName[140] = [23,String.fromCharCode( 173 , 139 , 14 )];
mapName[141] = [23,String.fromCharCode( 173 , 139 , 78 )];
mapName[138] = [23,String.fromCharCode( 173 , 139 , 46 )];
mapName[139] = [23,String.fromCharCode( 173 , 139 , 110 )];
mapName[144] = [23,String.fromCharCode( 173 , 139 , 30 )];
mapName[145] = [23,String.fromCharCode( 173 , 139 , 94 )];
mapName[142] = [23,String.fromCharCode( 173 , 139 , 62 )];
mapName[143] = [23,String.fromCharCode( 173 , 139 , 126 )];
mapName[230] = [23,String.fromCharCode( 173 , 139 , 1 )];
mapName[231] = [23,String.fromCharCode( 173 , 139 , 65 )];
mapName[228] = [23,String.fromCharCode( 173 , 139 , 33 )];
mapName[229] = [23,String.fromCharCode( 173 , 139 , 97 )];
mapName[234] = [23,String.fromCharCode( 173 , 139 , 17 )];
mapName[235] = [23,String.fromCharCode( 173 , 139 , 81 )];
mapName[232] = [23,String.fromCharCode( 173 , 139 , 49 )];
mapName[233] = [23,String.fromCharCode( 173 , 139 , 113 )];
mapName[222] = [23,String.fromCharCode( 173 , 139 , 9 )];
mapName[223] = [23,String.fromCharCode( 173 , 139 , 73 )];
mapName[220] = [23,String.fromCharCode( 173 , 139 , 41 )];
mapName[221] = [23,String.fromCharCode( 173 , 139 , 105 )];
mapName[226] = [23,String.fromCharCode( 173 , 139 , 25 )];
mapName[227] = [23,String.fromCharCode( 173 , 139 , 89 )];
mapName[224] = [23,String.fromCharCode( 173 , 139 , 57 )];
mapName[225] = [23,String.fromCharCode( 173 , 139 , 121 )];
mapName[246] = [23,String.fromCharCode( 173 , 139 , 5 )];
mapName[247] = [23,String.fromCharCode( 173 , 139 , 69 )];
mapName[244] = [23,String.fromCharCode( 173 , 139 , 37 )];
mapName[245] = [23,String.fromCharCode( 173 , 139 , 101 )];
mapName[250] = [23,String.fromCharCode( 173 , 139 , 21 )];
mapName[251] = [23,String.fromCharCode( 173 , 139 , 85 )];
mapName[248] = [23,String.fromCharCode( 173 , 139 , 53 )];
mapName[249] = [23,String.fromCharCode( 173 , 139 , 117 )];
mapName[238] = [23,String.fromCharCode( 173 , 139 , 13 )];
mapName[239] = [23,String.fromCharCode( 173 , 139 , 77 )];
mapName[236] = [23,String.fromCharCode( 173 , 139 , 45 )];
mapName[237] = [23,String.fromCharCode( 173 , 139 , 109 )];
mapName[242] = [23,String.fromCharCode( 173 , 139 , 29 )];
mapName[243] = [23,String.fromCharCode( 173 , 139 , 93 )];
mapName[240] = [23,String.fromCharCode( 173 , 139 , 61 )];
mapName[241] = [23,String.fromCharCode( 173 , 139 , 125 )];
mapName[198] = [23,String.fromCharCode( 173 , 139 , 3 )];
mapName[199] = [23,String.fromCharCode( 173 , 139 , 67 )];
mapName[196] = [23,String.fromCharCode( 173 , 139 , 35 )];
mapName[197] = [23,String.fromCharCode( 173 , 139 , 99 )];
mapName[202] = [23,String.fromCharCode( 173 , 139 , 19 )];
mapName[203] = [23,String.fromCharCode( 173 , 139 , 83 )];
mapName[200] = [23,String.fromCharCode( 173 , 139 , 51 )];
mapName[201] = [23,String.fromCharCode( 173 , 139 , 115 )];
mapName[189] = [23,String.fromCharCode( 173 , 139 , 11 )];
mapName[190] = [23,String.fromCharCode( 173 , 139 , 75 )];
mapName[187] = [23,String.fromCharCode( 173 , 139 , 43 )];
mapName[188] = [23,String.fromCharCode( 173 , 139 , 107 )];
mapName[194] = [23,String.fromCharCode( 173 , 139 , 27 )];
mapName[195] = [23,String.fromCharCode( 173 , 139 , 91 )];
mapName[192] = [23,String.fromCharCode( 173 , 139 , 59 )];
mapName[193] = [23,String.fromCharCode( 173 , 139 , 123 )];
mapName[214] = [23,String.fromCharCode( 173 , 139 , 7 )];
mapName[215] = [23,String.fromCharCode( 173 , 139 , 71 )];
mapName[212] = [23,String.fromCharCode( 173 , 139 , 39 )];
mapName[213] = [23,String.fromCharCode( 173 , 139 , 103 )];
mapName[218] = [23,String.fromCharCode( 173 , 139 , 23 )];
mapName[219] = [23,String.fromCharCode( 173 , 139 , 87 )];
mapName[216] = [23,String.fromCharCode( 173 , 139 , 55 )];
mapName[217] = [23,String.fromCharCode( 173 , 139 , 119 )];
mapName[206] = [23,String.fromCharCode( 173 , 139 , 15 )];
mapName[207] = [23,String.fromCharCode( 173 , 139 , 79 )];
mapName[204] = [23,String.fromCharCode( 173 , 139 , 47 )];
mapName[205] = [23,String.fromCharCode( 173 , 139 , 111 )];
mapName[210] = [23,String.fromCharCode( 173 , 139 , 31 )];
mapName[211] = [23,String.fromCharCode( 173 , 139 , 95 )];
mapName[208] = [23,String.fromCharCode( 173 , 139 , 63 )];
mapName[209] = [23,String.fromCharCode( 173 , 139 , 127 )];
mapName[102] = [16,String.fromCharCode( 173 , 75 , 0 )];
mapName[72] = [20,String.fromCharCode( 173 , 203 , 0 )];
mapName[82] = [20,String.fromCharCode( 173 , 203 , 8 )];
mapName[96] = [22,String.fromCharCode( 173 , 203 , 4 )];
mapName[112] = [22,String.fromCharCode( 173 , 203 , 36 )];
mapName[93] = [22,String.fromCharCode( 173 , 203 , 20 )];
mapName[94] = [22,String.fromCharCode( 173 , 203 , 52 )];
mapName[123] = [22,String.fromCharCode( 173 , 203 , 12 )];
mapName[125] = [22,String.fromCharCode( 173 , 203 , 44 )];
mapName[118] = [22,String.fromCharCode( 173 , 203 , 28 )];
mapName[121] = [22,String.fromCharCode( 173 , 203 , 60 )];
mapName[80] = [21,String.fromCharCode( 173 , 203 , 2 )];
mapName[81] = [21,String.fromCharCode( 173 , 203 , 18 )];
mapName[254] = [23,String.fromCharCode( 173 , 203 , 10 )];
mapName[255] = [23,String.fromCharCode( 173 , 203 , 74 )];
mapName[252] = [23,String.fromCharCode( 173 , 203 , 42 )];
mapName[253] = [23,String.fromCharCode( 173 , 203 , 106 )];
mapName[61] = [21,String.fromCharCode( 173 , 203 , 26 )];
mapName[99] = [20,String.fromCharCode( 173 , 203 , 6 )];
mapName[88] = [21,String.fromCharCode( 173 , 203 , 14 )];
mapName[126] = [22,String.fromCharCode( 173 , 203 , 30 )];
mapName[120] = [22,String.fromCharCode( 173 , 203 , 62 )];
mapName[75] = [20,String.fromCharCode( 173 , 203 , 1 )];
mapName[79] = [20,String.fromCharCode( 173 , 203 , 9 )];
mapName[16] = [21,String.fromCharCode( 173 , 203 , 5 )];
mapName[163] = [22,String.fromCharCode( 173 , 203 , 21 )];
mapName[191] = [22,String.fromCharCode( 173 , 203 , 53 )];
mapName[89] = [20,String.fromCharCode( 173 , 203 , 13 )];
mapName[97] = [19,String.fromCharCode( 173 , 203 , 3 )];
mapName[109] = [19,String.fromCharCode( 173 , 203 , 7 )];
mapName[101] = [15,String.fromCharCode( 173 , 43 )];
mapName[107] = [21,String.fromCharCode( 173 , 107 , 0 )];
mapName[122] = [21,String.fromCharCode( 173 , 107 , 16 )];
mapName[85] = [21,String.fromCharCode( 173 , 107 , 8 )];
mapName[106] = [21,String.fromCharCode( 173 , 107 , 24 )];
mapName[71] = [20,String.fromCharCode( 173 , 107 , 4 )];
mapName[76] = [20,String.fromCharCode( 173 , 107 , 12 )];
mapName[63] = [19,String.fromCharCode( 173 , 107 , 2 )];
mapName[87] = [20,String.fromCharCode( 173 , 107 , 6 )];
mapName[90] = [20,String.fromCharCode( 173 , 107 , 14 )];
mapName[92] = [19,String.fromCharCode( 173 , 107 , 1 )];
mapName[73] = [21,String.fromCharCode( 173 , 107 , 5 )];
mapName[98] = [21,String.fromCharCode( 173 , 107 , 21 )];
mapName[74] = [20,String.fromCharCode( 173 , 107 , 13 )];
mapName[114] = [21,String.fromCharCode( 173 , 107 , 3 )];
mapName[119] = [21,String.fromCharCode( 173 , 107 , 19 )];
mapName[104] = [21,String.fromCharCode( 173 , 107 , 11 )];
mapName[113] = [21,String.fromCharCode( 173 , 107 , 27 )];
mapName[68] = [19,String.fromCharCode( 173 , 107 , 7 )];
mapName[116] = [16,String.fromCharCode( 173 , 235 , 0 )];
mapName[37] = [14,String.fromCharCode( 173 , 27 )];
mapName[66] = [16,String.fromCharCode( 173 , 59 , 0 )];
mapName[108] = [17,String.fromCharCode( 173 , 187 , 0 )];
mapName[115] = [17,String.fromCharCode( 173 , 187 , 1 )];
mapName[111] = [16,String.fromCharCode( 173 , 123 , 0 )];
mapName[110] = [16,String.fromCharCode( 173 , 251 , 0 )];
mapName[77] = [11,String.fromCharCode( 173 , 7 )];
mapName[45] = [9,String.fromCharCode( 109 , 0 )];
mapName[86] = [9,String.fromCharCode( 109 , 1 )];
mapName[35] = [8,String.fromCharCode( 237 , 0 )];
mapName[53] = [6,String.fromCharCode( 29 )];
mapName[55] = [7,String.fromCharCode( 61 )];
mapName[51] = [7,String.fromCharCode( 125 )];
mapName[95] = [2,String.fromCharCode( 3 )];

	var curbyte = 0;
	var curbit  = 0;
	var result="";
	if (sSrc.substr(0,1)!='V'||sSrc.length>1024*6)
	{
		alert("对不起,形象串错误。");
		return "";
	}
	result += String.fromCharCode(Math.floor(sSrc.length/256)%256);
	result += String.fromCharCode((sSrc.length)%256);
	for (i=0;i<sSrc.length ;i++ )
	{
		for (j=0;j< mapName[sSrc.charCodeAt(i)][0];j++ )
		{
			curbyte |= ((mapName[sSrc.charCodeAt(i)][1].charCodeAt(j/8)>>(j%8))&1)<<curbit;

			if (++curbit==8)
			{
				result +=  String.fromCharCode(curbyte);
				curbyte = 0;
				curbit = 0;
			}
		}
	  
	}
	if (curbit>0)
	{
		result +=  String.fromCharCode(curbyte);
	}
	return result;
};

function conv64(instr)
{
	var mapSymbol =["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E",
					"F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T",
					"U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i",
					"j","k","l","m","n","o","p","q","r","s","t","u","v","w","x",
					"y","z","-","_"];
	var sSrc = instr;
	//alert("src length ="+sSrc.length+"<br/>"+sSrc+"<br/>")
	var curbyte = 0;
	var curbit  = 0;
	var encode  = "";
	for (i=0;i<sSrc.length ;i++ )
	{
		for (j=0;j< 8;j++ )
		{ 
			curbyte |=(sSrc.charCodeAt(i)>>(7-j)&1)<<(5-curbit);
			if (++curbit==6)
			{ //alert("soyml =" + curbyte)
				encode +=  mapSymbol[curbyte];
				curbyte = 0;
				curbit  = 0;
			}
		}
	}
	if (curbit>0)
	{
		encode += mapSymbol[curbyte];
	}
	return encode;
};
function huffcompress(str)
{
	return "Z2"+conv64(encodehuffman(str));
};
/*
Eutopia Item Filter
filter special type items
params: sStr - the show string
        type - the special type of the item
the type means:        
iItemNo_iPlyNo_iDefX_iDefY_bMov_bRot_bSelc_bPoseBind_iType_iDlyNo_iXPos_iYPos_iRot_bColor_iColor_iOffset_iZoom_iRev_sTxt|...#sTxt
                                                       |
return the filted str or the original str if on error

*********this function ignore all showStr errors*********
*/
function filterForSpecItem(sStr,type)
{
  var retArr = [];
  var defArr = sStr.split("#");
  if(defArr.length < 3)
  {
    //alert("error for filter");
    return sStr;
  }
  var itemArr = defArr[2].split("|");
  for (var i=0; i<itemArr.length; i++)
  {
    var itemSpcArr = itemArr[i].split("_");
    if (itemSpcArr.length < 18)
    {
      //alert("error for item"+i);
      return sStr;
    }
    if (itemSpcArr[8] == type)
    {
      continue;
    }else
    {
      retArr.push(itemArr[i]);
    }
  }
  return (defArr[0]+"#"+defArr[1]+"#"+retArr.join("|")+"#");
};

/*
Eutopia Item Counter
count special type items NUM
params: sStr - the show string
        type - the special type of the item
the type means:
iItemNo_iPlyNo_iDefX_iDefY_bMov_bRot_bSelc_bPoseBind_iType_iDlyNo_iXPos_iYPos_iRot_bColor_iColor_iOffset_iZoom_iRev_sTxt|...#sTxt
                                                       |
return the count NUM

*********this function ignore all showStr errors*********
*/
function SpecTypeItemCount(sStr,type)
{
  var count = 0;
  var defArr = sStr.split("#");
  if(defArr.length < 3)
  {
    //alert("error for filter");
    return count;
  }
  var itemArr = defArr[2].split("|");
  for (var i=0; i<itemArr.length; i++)
  {
    var itemSpcArr = itemArr[i].split("_");
    if (itemSpcArr.length < 18)
    {
      //alert("error for item"+i);
      return count;
    }
    if (itemSpcArr[8] == type)
    {
      count++;
    }else
    {
    	continue;
    }
  }
  return count;
};

function SpecTypeArrayStr(sStr,type)
{
  var TypeArray = new Array();
  var defArr = sStr.split("#");
  if(defArr.length < 3)
  {
    //alert("error for filter");
    return TypeArray;
  }
  var itemArr = defArr[2].split("|");
  for (var i=0; i<itemArr.length; i++)
  {
    var itemSpcArr = itemArr[i].split("_");
    if (itemSpcArr.length < 18)
    {
      //alert("error for item"+i);
      return TypeArray;
    }
    if (itemSpcArr[8] == type)
    {
      TypeArray.push(itemSpcArr.join("_"));
    }else
    {
    	continue;
    }
  }
  return TypeArray;
};
function getVipLevel(score)
{
	var level2 = 400;
	var level3 = 800;
	var level4 = 1600;
	var level5 = 3000;
	var level6 = 5000;
	var level7 = 7000;
	var level_distin = 2000;
	if (score <= 0) return 0;	
	else if (score >0 && score <level2) return 1;
	else if (score <level3) return 2;
	else if (score <level4) return 3;
	else if (score <level5) return 4;
	else if (score <level6) return 5;
	else if (score <level7) return 6;
	else return 7;//(parseInt((score-level7)/level_distin,10) + 7);
};
function getVipLevelVal(level)
{
	switch(level)
	{
		case 1:
			return 0;
			break;
		case 2:
			return 400;
			break;
		case 3:
			return 800;
			break;
		case 4:
			return 1600;
			break;
		case 5:
			return 3000;
			break;
		case 6:
			return 5000;
			break;
		case 7:
			return 7000;
			break;
		default:
			return ((level-7)*2000 + 7000);
			break;
	}
};
//html正文编码：对需要出现在HTML正文里(除了HTML属性外)的不信任输入进行编码
function HtmlEncode(sStr)
{
	sStr = sStr.replace(/&/g,"&amp;");
	sStr = sStr.replace(/>/g,"&gt;");
	sStr = sStr.replace(/</g,"&lt;");
	sStr = sStr.replace(/"/g,"&quot;");
	sStr = sStr.replace(/'/g,"&#39;");
	return sStr;
};

//html正文解码：对HtmlEncode函数的结果进行解码
function HtmlUnEncode(sStr)
{
	sStr = sStr.replace(/&amp;/g,"&");
	sStr = sStr.replace(/&gt;/g,">");
	sStr = sStr.replace(/&lt;/g,"<");
	sStr = sStr.replace(/&quot;/g,'"');
	sStr = sStr.replace(/&#39;/g,"'");
	return sStr;
};

/*
html属性编码：对需要出现在HTML属性里的不信任输入进行编码
注意:
(1)该函数不适用于属性为一个URL地址的编码.这些标记包括:a/img/frame/iframe/script/xml/embed/object...
属性包括:href/src/lowsrc/dynsrc/background/...
(2)该函数不适用于属性名为 style="[Un-trusted input]" 的编码
*/
function HtmlAttributeEncode(sStr)
{
	sStr = sStr.replace(/&/g,"&amp;");
	sStr = sStr.replace(/>/g,"&gt;");
	sStr = sStr.replace(/</g,"&lt;");
	sStr = sStr.replace(/"/g,"&quot;");
	sStr = sStr.replace(/'/g,"&#39;");
	sStr = sStr.replace(/=/g,"&#61;");
	sStr = sStr.replace(/`/g,"&#96;");
	return sStr;
};

/*
检查uin的合法性
*/
/*
function checkuin(num)
{
	var num2 = num.replace(/\s+$/g, "").replace(/^\s+/g, "");
	return ( (/^[123456789][\d]{4,8}$/).test(num2)||(/^1[\d]{9}$/).test(num2) ) ? true : false;
}
*/
