//////////////////////////// 用户信息类

function QQSHOWUSERINF()
{
  this._iUin = 0; //QQ号
  this._chUserSex = 'F';  //用户性别
  this._sItemSn = ""; //用户形象串
};

//////////////////////////// 形象信息类

function QQSHOWAVINF(chS, iAT, iDT, iFT, iLv, iSc, iX, iY, sEmo)
{
  this._chAvSex = chS;  //当前形象性别
  this._iAvStyle = iAT; //风格
  this._iDefType = iDT; //基本形象类型
  this._iFootType = iFT;  //腿姿势
  this._iZoomLv = iLv;  //缩放级别
  this._iScale = iSc;   //缩放比率
  
  this._iRev = 0;//翻转预留
  
  this._iXPos = iX; //移动X坐标
  this._iYPos = iY; //移动Y坐标
  this._sEmo = sEmo;  //心情秀
};

QQSHOWAVINF.prototype.IsReady = function ()
{
  if(  typeof(this._chAvSex)=="undefined"
     ||typeof(this._iAvStyle)=="undefined"
     ||typeof(this._iDefType)=="undefined"
     ||typeof(this._iFootType)=="undefined"
     ||typeof(this._iZoomLv)=="undefined"
     ||typeof(this._iScale)=="undefined"
     ||typeof(this._iRev)=="undefined"
     ||typeof(this._iXPos)=="undefined"
     ||typeof(this._iYPos)=="undefined"
     ||typeof(this._sEmo)=="undefined"
    )
    return false;
  else
    return true;
};

QQSHOWAVINF.prototype.Check = function ()
{
  return true;//needwork//
};

QQSHOWAVINF.prototype.ToStr = function ()
{
  return (this._chAvSex+"_"+this._iAvStyle+"_"+this._iDefType+"_"+this._iFootType+"_"+this._iScale+"_"+this._iRev+"_"+this._iXPos+"_"+this._iYPos);
};

//////////////////////////// 物品信息类

function QQSHOWITEMINF(iNo, iPly, iDX, iDY, bM, bR, bS, bP, iT, iDly, iX, iY, iR, sLogo, cSex, iPose)
{
  this._iItemNo = iNo;  //物品编号
  this._iPlyNo = iPly;  //物理层
  this._iDefX = iDX;  //默认X坐标
  this._iDefY = iDY;  //默认Y坐标
  this._bMov = bM;  //可移动性
  this._bRot = bR;  //可旋转性
  this._bSelc = bS; //可选择性
  this._bPoseBind = bP; //POSE绑定
  this._iType = iT; //物品类型
  
  this._bColor = 0; //颜色预留
  this._iColor = 0;
  this._iOffset = 0;
  
  this._iDlyNo = iDly;  //展示层
  this._iXPos = iX; //当前X坐标
  this._iYPos = iY; //当前Y坐标
  this._iRot = iR;  //当前旋转角度
  
  this._iZoom = 100;  //放大预留
  this._iRev = 0; //偏转预留
  
  this._sLogo = sLogo; //个性物品标示
  
  this._bEdit = 0;//在载入完毕后是否显示编辑框
  this._cSex = "U";
  if(cSex) this._cSex = cSex;
  this._iPose = 0;
  if(iPose) this._iPose = iPose;
};

QQSHOWITEMINF.prototype.Check = function ()
{
  return true;//needwork//
};

QQSHOWITEMINF.prototype.ToStr = function ()
{
  return (this._iItemNo+"_"+this._iPlyNo+"_"+this._iDefX+"_"+this._iDefY+"_"+this._bMov+"_"+this._bRot+"_"+this._bSelc+"_"+this._bPoseBind+"_"+this._iType+"_"+this._iDlyNo+"_"+this._iXPos+"_"+this._iYPos+"_"+this._iRot+"_"+this._bColor+"_"+this._iColor+"_"+this._iOffset+"_"+this._iZoom+"_"+this._iRev+"_"+escape(this._sLogo));
};

//////////////////////////// FLASH类

function QQSHOWFLS()
{
  this._oFlash = null;  //Flash对象
  this._bReady = 0;   //Flash8Shell 0-装载中 1-装载完毕
  this._bF6Ready = 0; //Flash6Web 0-装载中 1-装载完毕
  this._iType = 0;  //0-商城换装 1-照相馆
};

QQSHOWFLS.prototype.Init = function (oFlash)
{
  this._oFlash = oFlash;
};

QQSHOWFLS.prototype.GetReady = function ()
{
  return this._bReady;
};

QQSHOWFLS.prototype.SetReady = function (iVal)
{
  this._bReady = iVal;
};

QQSHOWFLS.prototype.Zoom = function (iScale, iX, iY)
{
  FlsZoom(this._oFlash, this._iType, iScale, iX, iY); 
};

QQSHOWFLS.prototype.Move = function (iX, iY)
{
  FlsMove(this._oFlash, this._iType, iX, iY); 
};

QQSHOWFLS.prototype.Load = function (iDlyNo, iNo, sUrl, iXPos, iYPos, iRot, bMov, bRot, bSelc, iType, sLogo, sEmo)
{
  if(1 == IsAvItem(iDlyNo))
    FlsLoadAvItem(this._oFlash, this._iType, iDlyNo, iNo, sUrl, iXPos, iYPos, iRot, bMov, bRot, bSelc, iType, sLogo, sEmo);
  else
    FlsLoadItem(this._oFlash, this._iType, iDlyNo, iNo, sUrl, iXPos, iYPos, iRot, bMov, bRot, bSelc, iType, sLogo, sEmo);
};

QQSHOWFLS.prototype.Unload = function (iDlyNo)
{
  var iNo = iXPos = iYPos = iRot = bMov = bRot = bSelc = iType = 0;
  var sUrl = sLogo = sEmo = "";
  if(1 == IsAvItem(iDlyNo))
    FlsLoadAvItem(this._oFlash, this._iType, iDlyNo, iNo, sUrl, iXPos, iYPos, iRot, bMov, bRot, bSelc, iType, sLogo, sEmo);
  else
    FlsLoadItem(this._oFlash, this._iType, iDlyNo, iNo, sUrl, iXPos, iYPos, iRot, bMov, bRot, bSelc, iType, sLogo, sEmo);
};

QQSHOWFLS.prototype.CleanAll = function ()
{
  FlsCleanItem(this._oFlash, this._iType); 
};

QQSHOWFLS.prototype.MoveItem = function (iLy, iX, iY, iR)
{
  if(1 == IsAvItem(iLy))
    FlsMoveItem(this._oFlash, this._iType, 1, iLy, iX, iY, iR);
  else
    FlsMoveItem(this._oFlash, this._iType, 0, iLy, iX, iY, iR);
};

QQSHOWFLS.prototype.Mode = function (iType)
{
  FlsChangeMode(this._oFlash, this._iType, iType)
};

QQSHOWFLS.prototype.ClnEdit = function ()
{
  FlsCleanEdit(this._oFlash);
};

QQSHOWFLS.prototype.ShowEdit = function (iLy)
{
  FlsShowEdit(this._oFlash, iLy);
};

QQSHOWFLS.prototype.PlayEmotion = function(iEmoId)
{
  FlsPlayEmotion(this._oFlash, this._iType, iEmoId);
};

//////////////////////////// 撤消记录类

function UNDOREC()
{
  this._sId = "";   //名称
  this._iIndex = -1;    //索引 指向操作前状态的串
  this._arrItemsn = [];   //形象串数组
};

UNDOREC.prototype.Init = function (iUin, chSex, iStyle)
{
  this._sId = "UndoRec_"+iUin+"_"+chSex+"_"+iStyle;
};

UNDOREC.prototype.GetId = function ()
{
  return this._sId;
};

UNDOREC.prototype.GetIdx = function ()
{
  return this._iIndex;
};

UNDOREC.prototype.SetIdx = function (iIdx)
{
  this._iIndex = iIdx;
};

UNDOREC.prototype.GetLength = function ()
{
  return this._arrItemsn.length;
};

UNDOREC.prototype.FromStr = function (sSn)
{
  return sSn.toString().split('&');
};

UNDOREC.prototype.ToStr = function ()
{
  return this._arrItemsn.join('&');
};

UNDOREC.prototype.Push = function (iIdx, sSn)
{
  this._arrItemsn[iIdx] = sSn;
};

UNDOREC.prototype.Del = function (iIdx)
{
  this._arrItemsn.length = iIdx;
};

UNDOREC.prototype.Get = function (iIdx)
{
  return this._arrItemsn[iIdx];
};

UNDOREC.prototype.Save = function ()
{
  setUserData(this._sId+"_Index", this._iIndex);
  setUserData(this._sId+"_Items", this.ToStr());
};

UNDOREC.prototype.Load = function ()
{
  var sIdx = getUserData(this._sId+"_Index");
  this._iIndex = (sIdx==null||isNaN(parseInt(sIdx)))?-1:parseInt(sIdx);
  var sArrSn = getUserData(this._sId+"_Items");
  this._arrItemsn = (sArrSn==null)?[]:this.FromStr(sArrSn);
};


//////////////////////////// 商城物品信息类

function SHOPTRYINF(iNo, chSex, sPly, iFStl, bPose, iDX, iDY, bMov, bRot, bSelc, iType, sLogo)
{
  this.iItemNo = iNo;
  this.chSex = chSex;
  this.sPlyNo = sPly;
  this.iFStl = iFStl;
  this.bPoseBind = bPose;
  this.iDefX = iDX;
  this.iDefY = iDY;
  this.bMov = bMov;
  this.bRot = bRot;
  this.bSelc = bSelc;
  this.iType = iType;
  this.sLogo = sLogo;
};

SHOPTRYINF.prototype.ToStr = function ()
{
  return (this.iItemNo+"_"+this.chSex+"_"+this.sPlyNo+"_"+this.iFStl+"_"+this.bPoseBind+"_"+this.iDefX+"_"+this.iDefY+"_"+this.bMov+"_"+this.bRot+"_"+this.bSelc+"_"+this.iType+"_"+escape(this.sLogo));
};


//////////////////////////// 身上物品记录类

function BODYREC()
{
  this._iIndex = -1;
	this._sId = "";
	this._arrInf = [];
};

BODYREC.prototype.Init = function (iUin, chSex, iStyle)
{
  this._sId = "BdyRec_"+iUin+"_"+chSex+"_"+iStyle;
};

BODYREC.prototype.Clear = function ()
{
  this._arrInf=[];
};

BODYREC.prototype.Push = function (stInf)
{
  this._arrInf.push(stInf);
};

BODYREC.prototype.GetIdx = function ()
{
  return this._iIndex;
};

BODYREC.prototype.GetLength = function ()
{
  return this._arrInf.length;
};

BODYREC.prototype.SetIdx = function (iIdx)
{
  this._iIndex = iIdx;
};

BODYREC.prototype.Get = function (iIdx)
{
  return this._arrInf[iIdx];
};

BODYREC.prototype.GetAll = function ()
{
	return this._arrInf;
};

//////////////////////////// 试穿记录类

function TRYREC()
{
	this._iIndex = -1;
	this._sId = "";
	this._arrInf = [];
};

TRYREC.prototype.Init = function (iUin, chSex, iStyle)
{
  this._sId = "TryRec_"+iUin+"_"+chSex+"_"+iStyle;
};

TRYREC.prototype.GetLength = function ()
{
  return this._arrInf.length;
};

TRYREC.prototype.GetIdx = function ()
{
  return this._iIndex;
};

TRYREC.prototype.SetIdx = function (iIdx)
{
  this._iIndex = iIdx;
};

TRYREC.prototype.Find = function(stInf)
{
  if(0 == this._arrInf.length)
    return -1;
  
  for(var i=0; i<this._arrInf.length; i++)
    if(this._arrInf[i].iItemNo == stInf.iItemNo)
      return i;
  return -1;
};

TRYREC.prototype.Push = function(stInf)
{
  var iIdx = this.Find(stInf);
  if(-1 == iIdx)
  {
		if(this._arrInf.length >= 50)
		{
			this._arrInf.shift();
			}
    this._arrInf.push(stInf);
    iIdx = this._arrInf.length-1;
  }
  return iIdx;
};

TRYREC.prototype.Get = function(iIdx)
{
  return this._arrInf[iIdx];
};

TRYREC.prototype.GetAll = function()
{
  return this._arrInf;
};

TRYREC.prototype.Save = function()
{
  if(this._arrInf.length==0)
    return;
    
  var sRecInfo = this._iIndex+"#";
  for(var i=0; i<this._arrInf.length; i++)
    sRecInfo += this._arrInf[i].ToStr()+"|";
    
  setUserData(this._sId, sRecInfo);
};

TRYREC.prototype.Load = function ()
{
  this._arrInf = [];
  var sRecInfo = getUserData(this._sId);
  if(sRecInfo == null)
    return;
    
  var arrTmp1 = sRecInfo.toString().split('#');
  if(arrTmp1.length != 2)
    return;

  this._iIndex = parseInt(arrTmp1[0]);
  this._arrInf = [];
  if(!arrTmp1[1] || arrTmp1[1]=="")
    return;
  
  var arrTmp2 = arrTmp1[1].toString().split('|');
  for(var i=0; i<arrTmp2.length; i++)
  {
    if(arrTmp2[i] != "")
    {
      var arrTmp3 = arrTmp2[i].split('_');
      if(arrTmp3.length != 12)
      {
        alert("RecStrToObj() 解析出错 第"+(i+1)+"个物品信息 length为("+arrTmp2.length+") != 12 sRecStr:"+sRecStr);
        return;
      }
      this._arrInf.push(new SHOPTRYINF(arrTmp3[0], arrTmp3[1], arrTmp3[2], arrTmp3[3], arrTmp3[4], arrTmp3[5], arrTmp3[6], arrTmp3[7], arrTmp3[8], arrTmp3[9], arrTmp3[10], unescape(arrTmp3[11])));
    }
  }
};

//////////////////////////// 物品来源类
function TRACEITEM()
{
  this._sId = "";
  this._arrFrom = []; 
};

TRACEITEM.prototype.Init = function (iUin)
{
  this._sId = "Trace_"+iUin;
};

TRACEITEM.prototype.Check = function (iNo)
{
  for(var i=0; i<this._arrFrom.length; i++)
    if(iNo == this._arrFrom[i][0])
      return i; 
  return -1;
};

TRACEITEM.prototype.Load = function ()
{
  this._arrFrom = [];
  var sFromInfo = getUserData(this._sId);
  if(!sFromInfo)
    return;
    
  var arrTmp1 = sFromInfo.toString().split('|');
  for(var i=0; i<arrTmp1.length; i++)
  {
    if(!arrTmp1[i])
    {
      continue;
    }
    else
    {
      var arrTmp2 = arrTmp1[i].toString().split('.');
      if(!arrTmp2[0] || !arrTmp2[1] || isNaN(parseInt(arrTmp2[0])))
        continue;
      else
        this._arrFrom.push([parseInt(arrTmp2[0]), arrTmp2[1]]);
    }
  }
};

TRACEITEM.prototype.Save = function ()
{
  if(this._arrFrom.length == 0)
    return;
    
  var sFromInfo = "";
  for(var i=0; i<this._arrFrom.length; i++)
    sFromInfo += this._arrFrom[i][0]+"."+this._arrFrom[i][1]+"|";
    
  setUserData(this._sId, sFromInfo);
};

TRACEITEM.prototype.Push = function (iNo, sFrom)
{
  var iIdx = this.Check(iNo);
  if(-1 == iIdx)
    this._arrFrom.push([iNo, sFrom]);
  else if(-1!=iIdx || sFrom!=this._arrFrom[iIdx][1])
    this._arrFrom[iIdx][1] = sFrom;
};

TRACEITEM.prototype.Get = function (iNo)
{
  var iIdx = this.Check(iNo);
  if(-1 == iIdx)
    return "";
  else
    return this._arrFrom[iIdx][1];
};

//////////////////////////// 形象类

function QQSHOWAV()
{
  /********** 形象属性 **********/
  this._stUserInf = new QQSHOWUSERINF();
  this._stAvInf = new QQSHOWAVINF();
  this._arrItemInf = [];
  this._stFlash = new QQSHOWFLS();
  
  /********** 记录属性 **********/
  this._cUndoRec = new UNDOREC();
  this._cBodyRec = new BODYREC();
  this._cTryRec = new TRYREC();
  this._cTrace = new TRACEITEM();
  
  /********** 配置属性 **********/
  //基本形象层配置  _arrDefShow[性别_风格_基本形象类型]
  this._arrDefShow = [];
  this._arrDefShow["F_0_0"] = [[402,1],[406,5],[436,4],[451,3],[461,2],[473,6],[482,1]];
  this._arrDefShow["M_0_0"] = [[402,7],[406,11],[436,10],[451,9],[461,8],[473,12],[482,7]];
  this._arrDefShow["F_1_0"] = [[402,1000013],[406,1000018],[436,1000016],[448,1000017],[450,1000012],[451,1000014],[461,1000020],[465,1000011],[469,1000019],[473,1000015],[482,1000013]];
  this._arrDefShow["M_1_0"] = [[402,1000003],[406,1000008],[436,1000006],[448,1000007],[450,1000002],[451,1000004],[461,1000010],[465,1000001],[469,1000009],[473,1000005],[482,1000003]];
  
  //缩放配置 _arrZoomCfg[Lv]=[[放大倍率, 初始X坐标, Y, 可移动物品初始X坐标, Y], ...]
  this._arrZoomCfg = [[100, 0, 0, 20, 160], [150, -35, -8, 35, 130], [210, -77, -17, 45, 105],[280, -126, -30, 55, 80], [410, -217, -54, 60, 55]];
  this._arrZoomCfg_bk = [[100, 0, 0, 20, 160], [150, -35, -8, 35, 130], [210, -77, -17, 45, 105],[280, -126, -30, 55, 80], [410, -217, -54, 60, 55]];
  
  //腿姿势配置
  this._iFtLy = 406;  //下身层
  this._arrFtLy = [421, 430]; //触发变脚姿势的层
  this._arrBdLy = [409, 412, 415, 418, 424, 427]; //随脚姿势变化的鞋袜层
  this._arrBdCfg = [];  //_arrBdCfg[性别_风格_基本形象类型][iFootType]=[[下身基本层, 415\424层鞋的X坐标(偏移), Y, 旋转, 418\427层鞋的X坐标(偏移), Y, 旋转], ...]
  this._arrBdCfg["F_1_0"] = [[1000018, 0, 0, 0, 0, 0, 0], [1000501, 3, -2, 1, 8, 1, -1], [1000502, 6, -9, 4, 14, 2, -4], [1000503, 3, -4, 1, -4, 8, -9], [1000504, -2, -1, 0, 15, 0, 0], [1000505, 1, -6, 3, 55, -15, 7], [1000506, 18, -18, 12, -42, 37, -28]];
  this._arrBdCfg["M_1_0"] = [[1000008, 0, 0, 0, 0, 0, 0], [1000511, -7, -5, 2, 2, -1, 1], [1000512, -10, 1, -2, 13, -5, 8], [1000513, -14, 5, -5, 13, -5, 7], [1000514, -4, -3, 3, 24, -7, 14], [1000515, -10, -1, 0, 11, -3, 6], [1000516, 98, -27, 34, -21, 12, -9]];
 
  //模式配置 0-编辑模式  1-移动模式(移动整个形象)
  this._bViewMode = 0; 
  
  //UserData配置 0-不使用  1-使用
  this._bSaveUserData = 0;
  
  /********** 特殊系数 **********/
  
  //特殊类型物品 [游戏秀，真脸秀]
  this._arrSPType = [101, 102];
  //炫脸秀特殊缩放系数
  this._arrZoomCfg_face = [[50, 34, 65, 20, 160],[75, 17, 41, 20, 160],[100, 0, 45, 20, 160]]; 
  
  //炫脸秀 时尚形象偏移
  this._iFacePos = 40;
};
 

QQSHOWAV.prototype.Init = function (iUin, chSex, sItemSn)
{
  this._stUserInf._iUin = iUin;
  this._stUserInf._chUserSex = chSex;
  this._stUserInf._sItemSn = sItemSn;
  this._bSaveUserData = 1;
};

QQSHOWAV.prototype.IsReady = function ()
{
  if(this._stAvInf.IsReady()==true && this._stFlash._bReady == 1 && this._stFlash._bF6Ready == 1)
    return true;
  else
    return false;
};

QQSHOWAV.prototype.MakeDefStr = function (chS, iAT, iDT, iFT, iLv, iX, iY)
{
  var arrVar = ['F', 1, 0, 0, 100, 0, 0, ''];
  if(arguments.length >= 1)
    arrVar[0] = chS;
  if(arguments.length >= 2)
    arrVar[1] = iAT;
  if(arguments.length >= 3)
    arrVar[2] = iDT;
  if(arguments.length >= 4)
    arrVar[3] = iFT;
  if(arguments.length >= 5)
    arrVar[4] = iLv;
  if(arguments.length >= 6)
    arrVar[5] = iX;
  if(arguments.length >= 7)
    arrVar[6] = iY;
  
  return ("V1#"+arrVar[0]+"_"+arrVar[1]+"_"+arrVar[2]+"_"+arrVar[3]+"_"+arrVar[4]+"_0_"+arrVar[5]+"_"+arrVar[6]+"##");
};


QQSHOWAV.prototype.LyHasItem = function (iLy, arrItem)
{//iRetCode: -1-没 other-是,并返回iItemNo
  for(var i=0;i<arrItem.length;i++)
    if(arrItem[i]._iDlyNo == iLy)
      return arrItem[i]._iItemNo;
  return -1;
};

QQSHOWAV.prototype.IsFootLayer = function (iLy)
{
  for(var i=0; i<this._arrFtLy.length; i++)
	{		
		if(iLy == this._arrFtLy[i])
		{
				return i;
		}
	}
	return -1;
};

QQSHOWAV.prototype.IsBindLayer = function (iLy)
{
  for(var i=0; i<this._arrBdLy.length; i++)
		if(iLy == this._arrBdLy[i])
			return i;
	return -1;
};

QQSHOWAV.prototype.CntSpcItem = function (iType)
{
  var arrTmp = [];
  for(var i=0; i<this._arrItemInf.length; i++)
		if(iType == this._arrItemInf[i]._iType)
		{
		  var iNo = this._arrItemInf[i]._iItemNo;
		  var iBo = 0;
		  for(var j=0; j<arrTmp.length; j++)
		  {
		    if(iNo == arrTmp[j])
		      iBo = 1;
		  }
		  if(iBo==0)
			  arrTmp.push(iNo);
		}
			
	return arrTmp.length;
};

QQSHOWAV.prototype.IsDefItemNo = function(iItemNo, chSex, iStyle, iDefType, iFoot)
{//iRetCode: -1-不是 other-是,并返回LyNo
	for(var i=0; i<this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType].length; i++)
	{
		if(iItemNo == this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType][i][1])
			return this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType][i][0];
		else if(iStyle!=0 && iItemNo==this._arrBdCfg[chSex+"_"+iStyle+"_"+iDefType][iFoot][0])//看是否是不同腿姿势的基本形象
		  return this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType][i][0];
	}
	return -1;
};

QQSHOWAV.prototype.IsDefLayer = function(iDlyNo, chSex, iStyle, iDefType, iFtType)
{//iRetCode: -1-不是 other-是,并返回ItemNo
	for(var i=0; i<this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType].length; i++)
		if(iDlyNo == this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType][i][0])
		{
		  if(this._iFtLy == iDlyNo && iStyle != 0)//下身层 需要结合脚姿势定
		    return this._arrBdCfg[chSex+"_"+iStyle+"_"+iDefType][iFtType][0];
		  else
			  return this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType][i][1];
		}
	return -1;
};

QQSHOWAV.prototype.RemoveDef = function(arrItem, chSex, iStyle, iDefType, iFoot)
{
  var arrRet = [];
  if(chSex == "M" || chSex == "F")
  {
  for(var i=0; i<arrItem.length; i++)
    if(this.IsDefItemNo(arrItem[i]._iItemNo, chSex, iStyle, iDefType, iFoot) == -1)
      arrRet.push(arrItem[i]);
  }
  else arrRet = arrItem;   
  return arrRet;
};

QQSHOWAV.prototype.AddDef = function(arrItem, chSex, iStyle, iDefType, iFoot)
{
  var arrRet = [].concat(arrItem);
  for(var i=0; i<this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType].length; i++)
   	if(this.LyHasItem(this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType][i][0], arrItem) == -1)
   	{
   	  if(0!=iFoot && this._iFtLy==this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType][i][0])
   	    arrRet.push(new QQSHOWITEMINF(this._arrBdCfg[chSex+"_"+iStyle+"_"+iDefType][iFoot][0], this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType][i][0], 0, 0, 0, 0, 0, 0, 0, this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType][i][0], 0, 0, 0, ""));
   	  else
   	    arrRet.push(new QQSHOWITEMINF(this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType][i][1], this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType][i][0], 0, 0, 0, 0, 0, 0, 0, this._arrDefShow[chSex+"_"+iStyle+"_"+iDefType][i][0], 0, 0, 0, ""));
  	}
  return arrRet;
};

QQSHOWAV.prototype.Sort = function(arrItem, iType)
{//iType: 1-按Dly 2-按ItemNo 从小到大
  var arrRet = [].concat(arrItem);
  switch(parseInt(iType))
  {
    case 1:
    {
      arrRet.sort(function(a,b){return a._iDlyNo-b._iDlyNo;});
      return arrRet;
    }
    case 2:
    {
      arrRet.sort(function(a,b){return (a._iItemNo.toString()>b._iItemNo.toString()?1:-1);});
      return arrRet;
    }
    default:
    {
      return arrRet;
    }
  }
};

QQSHOWAV.prototype.ToStr = function(stAv, arrInf)
{
  var sRetStr = "V1#"+stAv.ToStr()+"#";
  for(var i=0; i<arrInf.length; i++)
  {
    sRetStr += arrInf[i].ToStr()+((i==arrInf.length-1)?"":"|");
  }
  sRetStr += "#"+escape(stAv._sEmo);
  
  return sRetStr;
};

QQSHOWAV.prototype.ToItemSn = function(bRemoveDef, bCheck, bSortByDLy)
{
  if(bRemoveDef)
  {
    this._arrItemInf = this.RemoveDef(this._arrItemInf, this._stAvInf._chAvSex, this._stAvInf._iAvStyle, this._stAvInf._iDefType, this._stAvInf._iFootType);
  }
  
  if(bCheck)
  {
    if(!this._stAvInf.Check())
    {
      alert("ToItemSn() AvInf.Check() return False.");
      return "";
    }
    
    for(var i=0; i<this._arrItemInf.length; i++)
    {
      if(!this._arrItemInf[i].Check())
      {
        alert("ToItemSn() ItemArr["+i+"].Check() return False.");
        return "";
      }
    }
  }
  
  if(bSortByDLy)
  {
    this._arrItemInf = this.Sort(this._arrItemInf, 1);
  }
  
  return this.ToStr(this._stAvInf, this._arrItemInf);
};

QQSHOWAV.prototype.FromStr = function(sSn, objRet)
{// iRetcode: 0-成功 other-失败  返回信息在objRet里, objRet.sErrMsg,objRet.stAvInfo,objRet.arrItemInf
  objRet.sErrMsg = "";
	var arrTmp1 = sSn.toString().split('#');
	if(4 != arrTmp1.length)
	{
		objRet.sErrMsg = "QQSHOWAV.FromStr() 解析形象串异常. 根据'#'切割 长度["+arrTmp1.length+"]!=4 \nsItemSn:"+sSn;
		return -1;
	}
	
	var arrTmp2 = arrTmp1[1].split('_');
	if(8 != arrTmp2.length)
	{
		objRet.sErrMsg = "QQSHOWAV.FromStr() 解析形象串异常. 用户形象信息串 根据'_'切割 长度["+arrTmp2.length+"]!=8 \nsItemSn:"+sSn;
		return -2;
	}
	
	var arrItem = [];
	if(arrTmp1[2] != "")
	{
		var arrTmp3 = arrTmp1[2].split('|');
		for(var i=0;i<arrTmp3.length;i++)
		{
			var arrTmp4 = arrTmp3[i].split('_');
			if(19 != arrTmp4.length)
			{
				objRet.sErrMsg = "QQSHOWAV.FromStr() 解析形象串异常. 物品信息串["+i+"] 根据'_'切割 长度["+arrTmp4.length+"]!=19 \nsItemSn:"+sSn;
				return -3;
			}
			var stItemInf = new QQSHOWITEMINF(arrTmp4[0],parseInt(arrTmp4[1]),parseInt(arrTmp4[2]),parseInt(arrTmp4[3]),parseInt(arrTmp4[4]),parseInt(arrTmp4[5]),parseInt(arrTmp4[6]),parseInt(arrTmp4[7]),parseInt(arrTmp4[8]),parseInt(arrTmp4[9]), arrTmp4[10], arrTmp4[11],parseInt(arrTmp4[12]),unescape(arrTmp4[18]));
			arrItem.push(stItemInf);
		}
	}
	var stAvInf = new QQSHOWAVINF(arrTmp2[0],parseInt(arrTmp2[1]),parseInt(arrTmp2[2]),parseInt(arrTmp2[3]), this.GetZoomLv(parseInt(arrTmp2[4])),parseInt(arrTmp2[4]), arrTmp2[6], arrTmp2[7] ,unescape(arrTmp1[3]));
	objRet.stAvInfo = stAvInf;
	objRet.arrItemInf = arrItem;
	return 0;
};

QQSHOWAV.prototype.FromItemSn = function(sSn, bAddDef)
{
  var objRet = new Object();
  if(0 != this.FromStr(sSn, objRet))
  {
    alert(objRet.sErrMsg);
    return;
  }
  
  this._stAvInf = objRet.stAvInfo;
  this._arrItemInf = objRet.arrItemInf;
  
  if(bAddDef)
  {
    this._arrItemInf = this.AddDef(this._arrItemInf, this._stAvInf._chAvSex, this._stAvInf._iAvStyle, this._stAvInf._iDefType, this._stAvInf._iFootType);
  }
  
  //真脸秀缩放特殊处理
  if(this.CntSpcItem(102)>0)
    this.ChgZoomCfg();
  else
    this.ResetZoomCfg();
  this.ResetZoomLv();
};

QQSHOWAV.prototype.InitShow = function ()
{
	this._stFlash.Zoom(this._stAvInf._iScale, this._stAvInf._iXPos, this._stAvInf._iYPos);	
	this._stFlash.CleanAll();
	this.LoadItemArray(this._arrItemInf);
	this.SaveAvToUserData();
};

QQSHOWAV.prototype.GetZoomLv = function (iScale)
{
  var iLv = 0;
  if(iScale<=this._arrZoomCfg[0][0])
  {
  	iLv=0;
  	return iLv;
  }
  else if(iScale>=this._arrZoomCfg[this._arrZoomCfg.length-1][0])
  {
  	iLv=this._arrZoomCfg.length-1;
  	return iLv;
  }
  for(var i=0; i<this._arrZoomCfg.length; i++)
  {
    if(iScale == this._arrZoomCfg[i][0])
    {  
    	iLv=i;
    	return iLv;
  	}
  	else if(((i+1)<this._arrZoomCfg.length)&&(iScale>this._arrZoomCfg[i][0])&&(iScale<this._arrZoomCfg[i+1][0]))
  	{
  		iLv=i;
  		return iLv;
  	}
  }
  return iLv;
};

QQSHOWAV.prototype.ResetZoomLv = function ()
{
  this._stAvInf._iZoomLv = this.GetZoomLv(this._stAvInf._iScale);
};

QQSHOWAV.prototype.ZoomInOut = function (iType)
{//iType: 1-放大 2-缩小
	var iLv = (iType==1)?++this._stAvInf._iZoomLv:--this._stAvInf._iZoomLv;
	this._stAvInf._iScale = this._arrZoomCfg[iLv][0];
	this._stAvInf._iXPos = this._arrZoomCfg[iLv][1];
  this._stAvInf._iYPos = this._arrZoomCfg[iLv][2];
  this._stFlash.Zoom(this._stAvInf._iScale, this._stAvInf._iXPos, this._stAvInf._iYPos);
};

QQSHOWAV.prototype.ZoomLv = function (iLv)
{//iLv: 级数
  if(this._arrZoomCfg.length-1<iLv || iLv<0)
    return;
  this._stAvInf._iZoomLv = iLv;
	this._stAvInf._iScale = this._arrZoomCfg[iLv][0];
	this._stAvInf._iXPos = this._arrZoomCfg[iLv][1];
  this._stAvInf._iYPos = this._arrZoomCfg[iLv][2];
  this._stFlash.Zoom(this._stAvInf._iScale, this._stAvInf._iXPos, this._stAvInf._iYPos);
};

QQSHOWAV.prototype.GetZoomLvMax = function ()
{
  return this._arrZoomCfg.length-1;
};

QQSHOWAV.prototype.MoveDef = function ()
{
  this._stAvInf._iXPos = this._arrZoomCfg[this._stAvInf._iZoomLv][1];
  this._stAvInf._iYPos = this._arrZoomCfg[this._stAvInf._iZoomLv][2];
  this._stFlash.Move(this._stAvInf._iXPos, this._stAvInf._iYPos);
};

QQSHOWAV.prototype.LoadItem = function (iItemNo, iPlyNo, iDlyNo, iFStl, iDefX, iDefY, iRot, bMov, bRot, bSelc, bPose, iType, sLogo)
{
  var iTmpX = iDefX;
  var iTmpY = iDefY;
  if(bMov==1 && iDefX==0 && iDefY==0 && IsAvItem(iDlyNo))//移动到左下默认位置
  {
    iTmpX = this._arrZoomCfg[this._stAvInf._iZoomLv][3];
    iTmpY = this._arrZoomCfg[this._stAvInf._iZoomLv][4];
  }  
  
  if(iType==this._arrSPType[1] && this._stAvInf._iAvStyle==1 && iDefX==0 && iDefY==0)//炫脸秀时尚情况下偏移
  {
    iTmpY = -this._iFacePos;
  }
  
  if(this._stFlash._oFlash)
  {
  	this._stFlash.Load(iDlyNo, iItemNo, GetUrl(iItemNo, iPlyNo, iType), iTmpX, iTmpY, iRot, bMov, bRot, bSelc, iType, sLogo, this._stAvInf._sEmo);
  }
  this._arrItemInf.push(new QQSHOWITEMINF(iItemNo, iPlyNo, iDefX, iDefY, bMov, bRot, bSelc, bPose, iType, iDlyNo, iTmpX, iTmpY, iRot, sLogo));
  this._arrItemInf[this._arrItemInf.length-1]._bEdit = 1;
};

QQSHOWAV.prototype.LoadItemArray = function(arrItem)
{
	for(var i=0; i<arrItem.length; i++)
	{
		this._stFlash.Load(arrItem[i]._iDlyNo, arrItem[i]._iItemNo, GetUrl(arrItem[i]._iItemNo, arrItem[i]._iPlyNo, arrItem[i]._iType), arrItem[i]._iXPos, arrItem[i]._iYPos, arrItem[i]._iRot, arrItem[i]._bMov, arrItem[i]._bRot, arrItem[i]._bSelc, arrItem[i]._iType, arrItem[i]._sLogo, this._stAvInf._sEmo);
	}
};

QQSHOWAV.prototype.UnLoadItem = function (iIdx)
{
  if(this._stFlash._oFlash)
	{
	  this._stFlash.Unload(this._arrItemInf[iIdx]._iDlyNo);
	}
	this._arrItemInf.splice(iIdx, 1);
};

QQSHOWAV.prototype.GetAvUserData = function(iUin, chSex, iStyle)
{
  return getUserData("AvInfo_"+iUin+"_"+chSex+"_"+iStyle);
};

QQSHOWAV.prototype.SaveAvToUserData = function()
{
 	if(this._bSaveUserData == 1 && this.ItemCount() >0)
	  setUserData("AvInfo_"+this._stUserInf._iUin+"_"+this._stAvInf._chAvSex+"_"+this._stAvInf._iAvStyle, this.ToItemSn(0, 0, 0));
};

QQSHOWAV.prototype.ItemCount = function(bCntDef)
{//bCntDef 0:不含基本形象物品  1:包含
  if(this._arrItemInf.length < 1)
    return 0;
    
  var iCnt = 0;
  var arrItem = this.Sort(this._arrItemInf, 2);
  for(var i=0; i<arrItem.length; i++)
  {
    if(!bCntDef)
    {
      if(0==i && -1==this.IsDefItemNo(arrItem[i]._iItemNo, this._stAvInf._chAvSex, this._stAvInf._iAvStyle, this._stAvInf._iDefType, this._stAvInf._iFootType))
        iCnt++;
      if(i>0 && arrItem[i]._iItemNo!=arrItem[i-1]._iItemNo && -1==this.IsDefItemNo(arrItem[i]._iItemNo, this._stAvInf._chAvSex, this._stAvInf._iAvStyle, this._stAvInf._iDefType, this._stAvInf._iFootType))
        iCnt++;
    }
    else
    {
      if(0==i)
        iCnt++;
      if(i>0 && arrItem[i]._iItemNo!=arrItem[i-1]._iItemNo)
        iCnt++;
    }
  }
  return iCnt;
};

QQSHOWAV.prototype.GetNewDly = function(iPlyNo)
{
  var arrFntDLy = [];
  var arrSpeDly = [];
  var arrFntBkgDly = [];
  var arrBkgDLy = [];
	for(var i=0; i<this._arrItemInf.length; i++)
	{
		var iTemp = this._arrItemInf[i]._iDlyNo;
		if((iTemp >= 600)&&(iTemp <= 650))//记住身前形象已分配的层号
			arrFntDLy.push(iTemp);
		else if((iTemp >= 900)&&(iTemp <= 949))//记住特殊物品已分配的层
			arrSpeDly.push(iTemp);
		else if((iTemp >= 750)&&(iTemp <= 799))//记住身前场景已分配的层
			arrFntBkgDly.push(iTemp);
		else if((iTemp >= 250)&&(iTemp <= 299))//记住身后形象已分配的层号
			arrBkgDLy.push(iTemp);
	}
	
	var iDlyNo;
	if(999 == iPlyNo)//身前
		iDlyNo = GetMinLy(arrFntDLy, 600, 650);
	else if(950 == iPlyNo)
		iDlyNo = GetMinLy(arrSpeDly, 900, 949);
	else if(800 == iPlyNo)
		iDlyNo = GetMinLy(arrFntBkgDly, 750, 799);
	else//身后
		iDlyNo = GetMinLy(arrBkgDLy, 250, 299);
		
	return iDlyNo;
};

QQSHOWAV.prototype.InitDefShow = function ()
{
  var sTmp = this.MakeDefStr(QUSER.getAvSex(), QUSER.getStyle());
  this.FromItemSn(sTmp, true);
};

QQSHOWAV.prototype.GetLy = function (iItemNo, arrItem)
{
  var arrRet = [];
  for(var i=0;i<arrItem.length;i++)
    if(arrItem[i]._iItemNo == iItemNo)
      arrRet.push(arrItem[i]._iDlyNo);
  return arrRet;
};

QQSHOWAV.prototype.FindItem = function (iNo, arrNo)
{
  for(var i=0; i<arrNo.length; i++)
    if(iNo == arrNo[i])
      return i;
  return -1;
};

QQSHOWAV.prototype.GetRelateLy = function (sLy, iFtStl)
{
  var arrPlyNo = sLy.toString().split('.');
  var arrRelateLy = [];
  var arrRelateNo = [];
  var arrShoes = [415, 418, 424, 427];
  for(var i=0; i<arrPlyNo.length; i++)
  {
    var iNo = this.LyHasItem(arrPlyNo[i], this._arrItemInf);
    
    //如果是已在身上的层则检查其相关层
    if((-1 != iNo))
    {
      if(-1 == this.FindItem(iNo, arrRelateNo))
      {
        arrRelateLy = arrRelateLy.concat(this.GetLy(iNo, this._arrItemInf));
        arrRelateNo.push(iNo);
      }   
    }  
	//对鞋子的相关层进行检查    
    if(-1 == iNo)
    {
    	for(var k=0;k<arrShoes.length;k++)
    	{
    		if(arrPlyNo[i] == arrShoes[k])
			{
				for(var n =0;n<arrShoes.length;n++)
				{
					iNo = this.LyHasItem(arrShoes[n], this._arrItemInf);
    				if(-1 != iNo) break;
				}
				break;
			}
    	}
    }    
    if(-1 != iNo)
    {
    	//鞋子层物品，则找出相关层
    	if(-1 == this.FindItem(iNo, arrRelateNo))
		  {
		    arrRelateLy = arrRelateLy.concat(this.GetLy(iNo, this._arrItemInf));
		    arrRelateNo.push(iNo);
		  }
    }  
    //如果是裤子层，且跟当前姿势不一致，取出所有裤子层
	if(-1 != this.IsFootLayer(arrPlyNo[i]) && iFtStl != this._stAvInf._iFootType)//是改变姿势物品
	{
		for(k=0;k<this._arrFtLy.length;k++)
    	{
			iNo = this.LyHasItem(this._arrFtLy[k], this._arrItemInf);    		
			if(-1 != iNo)
			{
				if(-1 == this.FindItem(iNo, arrRelateNo))
				{
					//如果身上已有该裤子层，则取出所有相关层。如果没有只取该层
				    arrRelateLy = arrRelateLy.concat(this.GetLy(iNo, this._arrItemInf));
				    arrRelateNo.push(iNo);
				}
			}
			else if(-1 == this.FindItem(this._arrFtLy[k], arrRelateLy))arrRelateLy.concat(this._arrFtLy[k]);
    	}
	}         
  }
  return arrRelateLy;
};

QQSHOWAV.prototype.UpdateBindItem = function (iBasicLy)
{
  var iChangDef = -1;
  for(var i=0; i<this._arrItemInf.length; i++)
  {
    var iIdx = this.IsBindLayer(this._arrItemInf[i]._iPlyNo);
    if((-1!=iIdx) && (1==this._arrItemInf[i]._bPoseBind))//属于随动层则移动
    {
      this._arrItemInf[i]._iXPos = this._arrBdCfg[this._stAvInf._chAvSex+"_"+this._stAvInf._iAvStyle+"_"+this._stAvInf._iDefType][this._stAvInf._iFootType][(iIdx%2==0?1:4)];
      this._arrItemInf[i]._iYPos = this._arrBdCfg[this._stAvInf._chAvSex+"_"+this._stAvInf._iAvStyle+"_"+this._stAvInf._iDefType][this._stAvInf._iFootType][(iIdx%2==0?2:5)];
      this._arrItemInf[i]._iRot = this._arrBdCfg[this._stAvInf._chAvSex+"_"+this._stAvInf._iAvStyle+"_"+this._stAvInf._iDefType][this._stAvInf._iFootType][(iIdx%2==0?3:6)]; 
	  if(this._stFlash._oFlash)
		{
		  this._stFlash.MoveItem(this._arrItemInf[i]._iPlyNo, this._arrItemInf[i]._iXPos, this._arrItemInf[i]._iYPos, this._arrItemInf[i]._iRot);
		}
    }
    
    //是否需要更换下身
    if(this._iFtLy==this._arrItemInf[i]._iPlyNo && this._arrBdCfg[this._stAvInf._chAvSex+"_"+this._stAvInf._iAvStyle+"_"+this._stAvInf._iDefType][this._stAvInf._iFootType][0]!=this._arrItemInf[i]._iItemNo)
      iChangDef = i;
  }

  if(-1 != iChangDef && (typeof(iBasicLy)=="undefined" || -1==iBasicLy))//更换下身层
  {
    this._arrItemInf.splice(iChangDef, 1);
	  this.LoadItem(this._arrBdCfg[this._stAvInf._chAvSex+"_"+this._stAvInf._iAvStyle+"_"+this._stAvInf._iDefType][this._stAvInf._iFootType][0], this._iFtLy, this._iFtLy, 0, 0, 0, 0, 0, 0, 0, 0, 0, "");
	  return true;
	}
	else return false;
};

QQSHOWAV.prototype.ShopLoadItem = function(iItemNo, iPlyNo, iFStl, bPoseBind, iDefX, iDefY, bMov, bRot, bSelc, iType, sLogo)
{//iRetcode 0:没变化 1:有变化 2:需要更新绑定物品
  if("undefined" == typeof(sLogo))
    sLogo="";
  
	if(999 == iPlyNo || 950 == iPlyNo || 800 == iPlyNo || 1 == iPlyNo)//动态层换装 需要同步修改qqshow_user_saveshow.cpp
	{
	  if(0 == iItemNo)
	    return 0;
		var iIdx = -1;
		for(var i=0; i<this._arrItemInf.length; i++)
		{//根据iItemNo遍历
			if(iItemNo == this._arrItemInf[i]._iItemNo)
			{
				iIdx = i;
				break;
			}
		}
		
		if(iIdx != -1)//身上已有该物品 脱
		{
			this.UnLoadItem(iIdx);
			return 1;
		}
		else//还没这个物品 穿
		{
			var iTempDly = this.GetNewDly(iPlyNo);
			for(var k=0;k<this._arrItemInf.length;k++)
			{
				if(iTempDly == this._arrItemInf[k]._iDlyNo)
				{
					this.UnLoadItem(k);
					break;
				}
			}
		  	this.LoadItem(iItemNo, iPlyNo, iTempDly , iFStl, iDefX, iDefY, 0, bMov, bRot, bSelc, bPoseBind, iType, sLogo);
			return 1;
		}
	}
	else//固定层换装
	{
	  if(0 == iItemNo)//脱衣服
		{
		  var iIdx = -1;
		  for(var i=0; i<this._arrItemInf.length; i++)
  		{
  			if(iPlyNo == this._arrItemInf[i]._iPlyNo)
  			{
  				iIdx = i;
  				break;
  			}
  		}
  		if(iIdx == -1)
  		  return 0;
  		  
			var iDefItemNo = this.IsDefLayer(iPlyNo, this._stAvInf._chAvSex, this._stAvInf._iAvStyle, this._stAvInf._iDefType, this._stAvInf._iFootType);
			if(iDefItemNo == -1)//不是基本形象层 脱
			{
				this.UnLoadItem(iIdx);
				return 1;
			}
			else//是基本形象层 换成基本形象
			{
			  this._arrItemInf.splice(iIdx, 1);
				this.LoadItem(iDefItemNo, iPlyNo, iPlyNo, 0, 0, 0, 0, 0, 0, 0, 0, 0, "");
				return 1;
			}
		}
		
		var iIdx = iAvItemNo = -1;
		for(var i=0; i<this._arrItemInf.length; i++)
		{//根据层号找
			if(iPlyNo == this._arrItemInf[i]._iDlyNo)//该层已有物品
			{
				iIdx = i;
				iAvItemNo = this._arrItemInf[i]._iItemNo;
				break;
			}
		}
		
		if(iAvItemNo == iItemNo)//该层已有同样物品
		{
			//是否是基本形象层
			var iDefItemNo = this.IsDefLayer(iPlyNo, this._stAvInf._chAvSex, this._stAvInf._iAvStyle, this._stAvInf._iDefType, this._stAvInf._iFootType);
			
			if(iDefItemNo == -1)//不是基本形象层 脱
			{
				this.UnLoadItem(iIdx);
				return 1;
			}
			else//是基本形象层
			{
				if(iDefItemNo == iItemNo)//基本形象不能再脱了
				{
					return 0;
				}
				else//换成基本形象
				{
				  this._arrItemInf.splice(iIdx, 1);
					this.LoadItem(iDefItemNo, iPlyNo, iPlyNo, 0, 0, 0, 0, 0, 0, 0, 0, 0, "");
					return 1;
				}
			}
		}
		else
		{
		  var iRetCode = 1;
		  var iRot =0;
		  var iIdx2 = this.IsBindLayer(iPlyNo);
		  if(-1 != iIdx2)//是随姿势绑定物品
		  {
		    iDefX = this._arrBdCfg[this._stAvInf._chAvSex+"_"+this._stAvInf._iAvStyle+"_"+this._stAvInf._iDefType][this._stAvInf._iFootType][(iIdx2%2==0?1:4)];
		    iDefY = this._arrBdCfg[this._stAvInf._chAvSex+"_"+this._stAvInf._iAvStyle+"_"+this._stAvInf._iDefType][this._stAvInf._iFootType][(iIdx2%2==0?2:5)];
		    iRot = this._arrBdCfg[this._stAvInf._chAvSex+"_"+this._stAvInf._iAvStyle+"_"+this._stAvInf._iDefType][this._stAvInf._iFootType][(iIdx2%2==0?3:6)];
		  }
		  if(-1 != this.IsFootLayer(iPlyNo) && iFStl != this._stAvInf._iFootType)//是改变姿势物品
      {     
        this._stAvInf._iFootType = iFStl;
        iRetCode = 2;
      }
			if(-1 != iAvItemNo)//该层有另一件物品 换
			{
			  this._arrItemInf.splice(iIdx, 1);
			  this.LoadItem(iItemNo, iPlyNo, iPlyNo, iFStl, iDefX, iDefY, iRot, bMov, bRot, bSelc, bPoseBind, iType, sLogo);
			  return iRetCode;
			}
			else//还没有这一层 穿
			{
        this.LoadItem(iItemNo, iPlyNo, iPlyNo, iFStl, iDefX, iDefY, iRot, bMov, bRot, bSelc, bPoseBind, iType, sLogo);
			  return iRetCode;
			}
		}
	}
};

QQSHOWAV.prototype.ShopProc = function (iItemNo, chSex, sPlyNo, iFStl, bPoseBind, iDefX, iDefY, bMov, bRot, bSelc, iType, sLogo)
{
  var arrLyNo = this.GetRelateLy(sPlyNo, iFStl);
	var arrPlyNo = sPlyNo.toString().split('.');
	var iChg = 0;
	var bMoveBind = 0;
	
	//进行试穿逻辑
	for(var i=0; i<arrPlyNo.length; i++)
	{
	  var iRet = this.ShopLoadItem(iItemNo, arrPlyNo[i], iFStl, bPoseBind, iDefX, iDefY, bMov, bRot, bSelc, iType, sLogo);
	  if(iRet > 0)
	    iChg = 1;
	  if(2 == iRet)
	    bMoveBind = 1;
  }
  
  //脱掉物品关联的多余的层
	for(var i=0; i<arrLyNo.length; i++)
	{
	  var bHasTry = 0;
	  for(var j=0; j<arrPlyNo.length; j++)
	  {
	    if(arrLyNo[i]==arrPlyNo[j])
	    {
	      bHasTry = 1;
	      break;
	    }
	  }
	  
	  if(0 == bHasTry)//试穿物品没有这层  脱
	    {
	    	if(this.ShopLoadItem(0, arrLyNo[i], 0, 0, 0, 0, 0, 0, 0, 0, "")>0)
	      iChg= 1;
	    }
	}
	
	//大小鞋判断
	iShoeType = 0;//试穿鞋状态 0-无鞋 1-小鞋 2-大鞋
	for(var i=0; i<arrPlyNo.length; i++)
	{
	  if(arrPlyNo[i]==415 || arrPlyNo[i]==418)//试穿小鞋
	  {
	    iShoeType = 1;
	    break;
	  }
	  else if(arrPlyNo[i]==424 || arrPlyNo[i]==427)//试穿大鞋
	  {
	    iShoeType = 2;
	    break;
	  }
	}
	
	if(iShoeType == 1)//穿小鞋,脱大鞋
	{
	  if(this.ShopLoadItem(0, 424, 0, 0, 0, 0, 0, 0, 0, 0, "")>0)
	      iChg= 1;
	  if(this.ShopLoadItem(0, 427, 0, 0, 0, 0, 0, 0, 0, 0, "")>0)
	      iChg= 1;
	}
	else if(iShoeType == 2)//穿大鞋,脱小鞋
	{
	  if(this.ShopLoadItem(0, 415, 0, 0, 0, 0, 0, 0, 0, 0, "")>0)
	      iChg= 1;
	  if(this.ShopLoadItem(0, 418, 0, 0, 0, 0, 0, 0, 0, 0, "")>0)
	      iChg= 1;
	}
	
	//物品随姿势动逻辑
	if(1 == bMoveBind)
	{
	  var iBasicLy = -1;
	  for(var i=0;i<this._arrFtLy.length;i++)
      {
        for(var j=0; j<arrPlyNo.length; j++)
        {
          if(this._iFtLy == arrPlyNo[j])//记录是否有腿基本形象层
            iBasicLy = j;
         }
      }
	  //更新绑定物品位置+更新腿姿势层
	  this.UpdateBindItem(iBasicLy);
	}	
	return iChg;
};

QQSHOWAV.prototype.ReqEditItem = function(sMsg)
{//接收Flash回调调整物品
  var objTmp;
  eval("objTmp="+ sMsg);
  if(typeof(objTmp) != "object" || typeof(objTmp.iLyNo)!=="number" || (typeof(objTmp.iNo)!=="number" && typeof(objTmp.iNo)!=="string") || typeof(objTmp.iXPos)!=="number" || typeof(objTmp.iYPos)!=="number" || typeof(objTmp.iRot)!=="number")
	  return;
	  
	for(var i=0; i<this._arrItemInf.length; i++)
	{
	  if(this._arrItemInf[i]._iDlyNo == objTmp.iLyNo && this._arrItemInf[i]._iItemNo == objTmp.iNo)
	  {
	    this._arrItemInf[i]._iXPos = objTmp.iXPos;
	    this._arrItemInf[i]._iYPos = objTmp.iYPos;
	    this._arrItemInf[i]._iRot = objTmp.iRot;
	    break;
	  }
	}
};

QQSHOWAV.prototype.ReqMoveAv = function(sMsg)
{//接收Flash回调调整形象位置
  var objTmp;
  eval("objTmp="+ sMsg);
  if(typeof(objTmp) != "object" || typeof(objTmp.iXPos)!=="number" || typeof(objTmp.iYPos)!=="number" || typeof(objTmp.iRot)!=="number")
	  return;
	
	this._stAvInf._iXPos = objTmp.iXPos;
	this._stAvInf._iYPos = objTmp.iYPos;
};

QQSHOWAV.prototype.ReqUnloadItem = function(sMsg)
{//接收Flash回调删除
  var objTmp;
  eval("objTmp="+ sMsg);
  if(typeof(objTmp) != "object" || typeof(objTmp.iLyNo)!=="number" || (typeof(objTmp.iNo)!=="number" && typeof(objTmp.iNo)!=="string"))
	  return;
	
	var iIdx;
	for(var i=0; i<this._arrItemInf.length; i++)
	{
	  if(this._arrItemInf[i]._iDlyNo == objTmp.iLyNo && this._arrItemInf[i]._iItemNo == objTmp.iNo)
	  {
	    iIdx = i;
	    break;
	  }
	}
	
	if(iIdx != null)
	{
    this._arrItemInf.splice(iIdx, 1);
  }
};

QQSHOWAV.prototype.ReqLoadItem = function(sMsg)
{
  var objTmp;
  eval("objTmp="+ sMsg);
  if(typeof(objTmp) != "object" || typeof(objTmp.iDLyNo)!=="number" || (typeof(objTmp.iNo)!=="number" && typeof(objTmp.iNo)!=="string"))
	  return;
  
  var iIdx;
	for(var i=0; i<this._arrItemInf.length; i++)
	{
	  if(this._arrItemInf[i]._iDlyNo == objTmp.iDLyNo && this._arrItemInf[i]._iItemNo == objTmp.iNo)
	  {
	    iIdx = i;
	    break;
	  }
	}
	
	if(iIdx!=null && 1==this._arrItemInf[iIdx]._bMov && 1==this._arrItemInf[iIdx]._bEdit)
	{
    this._stFlash.ClnEdit();
	  this._stFlash.ShowEdit(objTmp.iDLyNo);
	  this._arrItemInf[iIdx]._bEdit = 0;
  }
};

QQSHOWAV.prototype.SetEmoTxt = function(sTxt)
{//修改个性文字
  this._stAvInf._sEmo = sTxt;
  for(var i=0; i<this._arrItemInf.length; i++)
  {
    if(this._arrItemInf[i]._iType == 1)
    {
      if(this._stFlash._oFlash)
		{
		  this._stFlash.Load(this._arrItemInf[i]._iDlyNo, this._arrItemInf[i]._iItemNo, GetUrl(this._arrItemInf[i]._iItemNo, this._arrItemInf[i]._iPlyNo, this._arrItemInf[i]._iType), this._arrItemInf[i]._iXPos, this._arrItemInf[i]._iYPos, this._arrItemInf[i]._iRot, this._arrItemInf[i]._bMov, this._arrItemInf[i]._bRot, this._arrItemInf[i]._bSelc, 1, this._arrItemInf[i]._sLogo, this._stAvInf._sEmo);
		}
    }
  }
};

QQSHOWAV.prototype.GetEmoItemCnt = function()
{
  var iCnt = 0;
  for(var i=0; i<this._arrItemInf.length; i++)
  {
    if(this._arrItemInf[i]._iType == 1)
    {
      iCnt++;
    }
  }
  return iCnt;
};

QQSHOWAV.prototype.GetViewMode = function ()
{
  return this._bViewMode;
};

QQSHOWAV.prototype.SetViewMode = function (iType)
{
  this._bViewMode = iType;
};

QQSHOWAV.prototype.ChangeMode = function (iType)
{//iType 0-编辑模式  1-预览模式
  if(iType!=0 && iType!=1)
    return;
  this._stFlash.Mode(iType);
  this._bViewMode = iType;
};


QQSHOWAV.prototype.ClnEdit = function ()
{
  this._stFlash.ClnEdit();
};

/////// Flash相关
QQSHOWAV.prototype.InitFlash = function (oFlash)
{
  this._stFlash.Init(oFlash);
};

/////// 撤消重做相关
QQSHOWAV.prototype.InitUndoRec = function ()
{
  if(this._cUndoRec.GetLength()>0 && this._cUndoRec.GetId()==("UndoRec_"+this._stUserInf._iUin+"_"+this._stAvInf._chAvSex+"_"+this._stAvInf._iAvStyle))
    return;
  this._cUndoRec.Init(this._stUserInf._iUin, this._stAvInf._chAvSex, this._stAvInf._iAvStyle);
  this._cUndoRec.Load();
};

QQSHOWAV.prototype.SaveUndo = function (sSn)
{
  var iIdx = this._cUndoRec.GetIdx();
  if(this._cUndoRec.Get(iIdx) == sSn)
    return;
  
  this._cUndoRec.Del(iIdx+1);
  this._cUndoRec.Push(iIdx+1, sSn);
  this._cUndoRec.SetIdx(iIdx+1);
  
  if(this._cUndoRec.GetLength() > 10)
  {
    var aTmp = [];
    for(var i=1;i<this._cUndoRec.GetLength();i++)
    {
      aTmp[i-1] = this._cUndoRec._arrItemsn[i];
    }
    this._cUndoRec._arrItemsn = aTmp;
    this._cUndoRec.SetIdx(iIdx);
  }
  
  this._cUndoRec.Save();
};

QQSHOWAV.prototype.SaveRedo = function ()
{
  this._cUndoRec.Push(this._cUndoRec.GetLength(), this.ToItemSn(0, 0, 0));
  this._cUndoRec.Save();
};


QQSHOWAV.prototype.GetUnRedoRec = function (iIdx)
{
  this._cUndoRec.SetIdx(iIdx-1);
  return this._cUndoRec.Get(iIdx);
};

QQSHOWAV.prototype.GetUnRedoIdx = function ()
{
  return this._cUndoRec.GetIdx();
};

QQSHOWAV.prototype.GetUnRedoLen = function ()
{
  return this._cUndoRec.GetLength();
};

/////// 身上物品相关
QQSHOWAV.prototype.UpdateBodyRec = function ()
{
  this._cBodyRec.Init(this._stUserInf._iUin, this._stAvInf._chAvSex, this._stAvInf._iAvStyle);
  this._cBodyRec.Clear();
  
  var chSex = this._stAvInf._chAvSex;
  var iFStl = this._stAvInf._iFootType;
  var iStl = this._stAvInf._iAvStyle;
  var iDT = this._stAvInf._iDefType;
  var arrItem = [].concat(this._arrItemInf);
  arrItem.sort(function(a,b){return (a._iItemNo.toString()>b._iItemNo.toString()?1:-1);});
  
  var sPlyNo="";
  for(var i=1; i<arrItem.length+1; i++)
  {
    if((i<arrItem.length)&&(arrItem[i-1]._iItemNo==arrItem[i]._iItemNo))
        sPlyNo += ((sPlyNo=="")?"":".")+arrItem[i-1]._iPlyNo;
    else
    {
      if(this.IsDefItemNo(arrItem[i-1]._iItemNo, chSex, iStl, iDT, iFStl) == -1)
        this._cBodyRec.Push(new SHOPTRYINF(arrItem[i-1]._iItemNo, chSex, (sPlyNo+((sPlyNo=="")?"":".")+arrItem[i-1]._iPlyNo), iFStl, arrItem[i-1]._bPoseBind, arrItem[i-1]._iDefX, arrItem[i-1]._iDefY, arrItem[i-1]._bMov, arrItem[i-1]._bRot, arrItem[i-1]._bSelc, arrItem[i-1]._iType, arrItem[i-1]._sLogo));
      sPlyNo = "";
    }
  }
  this._cBodyRec.SetIdx((this._cBodyRec.GetLength()-1));
};

QQSHOWAV.prototype.GetBodyRec = function(iIdx)
{
  var stInf = this._cBodyRec.Get(iIdx);
  if(!stInf)
    return new SHOPTRYINF(0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, "");
  else
  {
    this._cBodyRec.SetIdx(iIdx);
    return stInf;
  }
};

QQSHOWAV.prototype.GetBodyAll = function()
{
	var stAllInfo = this._cBodyRec.GetAll();
	if (!stAllInfo)
	{
	  return [new SHOPTRYINF(0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, "")];
	}
	else
	{
		return stAllInfo;
	}
};

QQSHOWAV.prototype.GetLastBodyRec = function ()
{
  this.UpdateBodyRec();
  return this.GetBodyRec(this._cBodyRec._arrInf.length-1);
};

QQSHOWAV.prototype.NextBodyRec = function ()
{
  return (this._cBodyRec.GetIdx()+1 < this._cBodyRec.GetLength())?this.GetBodyRec(this._cBodyRec.GetIdx()+1):this.GetBodyRec(0);
};

QQSHOWAV.prototype.PrevBodyRec = function ()
{
  return (this._cBodyRec.GetIdx() > 0)?this.GetBodyRec(this._cBodyRec.GetIdx()-1):this.GetBodyRec(this._cBodyRec.GetLength()-1);
};


/////// 试穿记录相关
QQSHOWAV.prototype.InitTryRec = function ()
{
  this._cTryRec.Init(this._stUserInf._iUin, this._stAvInf._chAvSex, this._stAvInf._iAvStyle);
  this._cTryRec.Load();
  if(this._cTryRec.GetLength() > 0)
  {
    if(-1 == this._cTryRec.GetIdx())
      this._cTryRec.SetIdx((this._cTryRec.GetLength()-1));
    return this._cTryRec.Get(this._cTryRec.GetIdx());
  }
  return new SHOPTRYINF(0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, "");
};

QQSHOWAV.prototype.PushTryRec = function (iItemNo, chSex, sPlyNo, iFStl, iPose, iDefX, iDefY, bMov, bRot, bSelc, iType, sLogo)
{
  var iIdx = this._cTryRec.Push(new SHOPTRYINF(iItemNo, chSex, sPlyNo, iFStl, iPose, iDefX, iDefY, bMov, bRot, bSelc, iType, sLogo));
  this._cTryRec.SetIdx(iIdx);
  this._cTryRec.Save();
  return this._cTryRec.Get(iIdx);
};

QQSHOWAV.prototype.GetTryRec = function (iIdx)
{
  var stInf = this._cTryRec.Get(iIdx);
  if(!stInf)
    return new SHOPTRYINF(0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, "");
  else
  {
    this._cTryRec.SetIdx(iIdx);
    return stInf;
  }
};

QQSHOWAV.prototype.GetAllTryRec = function ()
{
  var stInf = this._cTryRec.GetAll();
  if(!stInf)
    return new SHOPTRYINF(0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, "");
  else
  {
    return stInf;
  }
};


QQSHOWAV.prototype.NextTryRec = function ()
{
  return (this._cTryRec.GetIdx()+1 < this._cTryRec.GetLength())?this.GetTryRec(this._cTryRec.GetIdx()+1):this.GetTryRec(0);
};

QQSHOWAV.prototype.PrevTryRec = function ()
{
  return (this._cTryRec.GetIdx() > 0)?this.GetTryRec(this._cTryRec.GetIdx()-1):this.GetTryRec(this._cTryRec.GetLength()-1);
};


/////// 物品来源相关
QQSHOWAV.prototype.InitTrace = function ()
{
  this._cTrace.Init(this._stUserInf._iUin);
  this._cTrace.Load();
};

QQSHOWAV.prototype.SetTrace = function (iNo, sFrom)
{
  this.InitTrace();
  this._cTrace.Push(iNo, sFrom);
  this._cTrace.Save();
};

QQSHOWAV.prototype.GetTrace = function (iNo)
{
  this.InitTrace();
  return this._cTrace.Get(iNo);
};

/////// 播放表情随动物品
QQSHOWAV.prototype.PlayEmotion = function(iEmoId)
{
  this._stFlash.PlayEmotion(iEmoId);
};

////// 真脸秀相关
QQSHOWAV.prototype.ChgZoomCfg = function()
{
  this._arrZoomCfg = this._arrZoomCfg_face;
};

QQSHOWAV.prototype.ResetZoomCfg = function()
{
  this._arrZoomCfg = this._arrZoomCfg_bk;
};

//////////////////// 上面用到的

function GetMinLy(arrLy, iMin, iMax)
{
	if(arrLy.length-1 == iMax-iMin)
	{
		return arrLy[0];
	}
	else if(arrLy.length>0)
	{
		var iRet;
		for(iRet=iMin; iRet<iMax+1; iRet++)
		{	
		  var iIdx = -1;
		  for (var i=0; i<arrLy.length; ++i)
		    if (arrLy[i]==iRet)
		      iIdx = i;
			if(-1 == iIdx)
				break;
		}
		return iRet;
	}
	else
		return iMin;
};

function GetUrl(sNo, iLy, iType)
{
  var tmpArr = sNo.toString().split('.');

	if(iType>100)
	  return("http://qqshow2-udv.qq.com/"+tmpArr[0]+"_"+tmpArr[1]+"_"+tmpArr[2]+"_"+iLy);
	else
	  return("http://qqshow2-item.qq.com/"+tmpArr[0]+"/"+iLy+"/02/");
};

function FlsZoom(oFlash, iT, iScale, iX, iY)
{
	oFlash.TCallLabel((iT==0?"_root.FlashAvatar_mc":"_root"), "FDef");
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iScale":"iScale"), iScale);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iAvXPos":"iAvXPos"), iX);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iAvYPos":"iAvYPos"), iY);
	oFlash.TCallLabel((iT==0?"_root.FlashAvatar_mc":"_root"),"FZoom"); 
};

function FlsMove(oFlash, iT, iX, iY)
{    
	oFlash.TCallLabel((iT==0?"_root.FlashAvatar_mc":"_root"), "FDef");
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iAvXPos":"iAvXPos"), iX);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iAvYPos":"iAvYPos"), iY);
	oFlash.TCallLabel((iT==0?"_root.FlashAvatar_mc":"_root"),"FMove");
};

function FlsPlayEmotion(oFlash, iT, iEmoId)
{
  oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iEmoId":"iEmoId"), iEmoId);
  oFlash.TCallLabel((iT==0?"_root.FlashAvatar_mc":"_root"),"FPlayEmotion"); 
};

function FlsLoadItem(oFlash, iT, iDlyNo, iNo, sUrl, iXPos, iYPos, iRot, bMov, bRot, bSelc, iType, sLogo, sEmo)
{
  if(sLogo=="undefined")
    sLogo="";
    
  if(sEmo=="undefined")
    sEmo="";
    
	oFlash.TCallLabel((iT==0?"_root.FlashAvatar_mc":"_root"), "FDef");
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iDlyNo":"iDlyNo"), iDlyNo);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iNo":"iNo"),  iNo);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.sUrl":"sUrl"), sUrl);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iXPos":"iXPos"), iXPos);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iYPos":"iYPos"), iYPos);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iRot":"iRot"), iRot);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.bMov":"bMov"), bMov);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.bRot":"bRot"), bRot);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.bSelc":"bSelc"), bSelc);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iType":"iType"), iType);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.sLogo":"sLogo"), sLogo);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.sTxt":"sTxt"), sEmo);
	oFlash.TCallLabel((iT==0?"_root.FlashAvatar_mc":"_root"),"FLoadItem");
};

function FlsLoadAvItem(oFlash, iT, iDlyNo, iNo, sUrl, iXPos, iYPos, iRot, bMov, bRot, bSelc, iType, sLogo, sEmo)
{
  if(sLogo=="undefined")
    sLogo="";
    
  if(sEmo=="undefined")
    sEmo="";
    
	oFlash.TCallLabel((iT==0?"_root.FlashAvatar_mc":"_root"), "FDef");
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iDlyNo":"iDlyNo"), iDlyNo);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iNo":"iNo"),  iNo);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.sUrl":"sUrl"), sUrl);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iXPos":"iXPos"), iXPos);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iYPos":"iYPos"), iYPos);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iRot":"iRot"), iRot);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.bMov":"bMov"), bMov);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.bRot":"bRot"), bRot);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.bSelc":"bSelc"), bSelc);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iType":"iType"), iType);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.sLogo":"sLogo"), sLogo);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.sTxt":"sTxt"), sEmo);
	oFlash.TCallLabel((iT==0?"_root.FlashAvatar_mc":"_root"),"FLoadAvItem");
};

function FlsCleanItem(oFlash, iT)
{
	oFlash.TCallLabel((iT==0?"_root.FlashAvatar_mc":"_root"),"FCleanItem");
};

function FlsMoveItem(oFlash, iT, iType, iLy, iX, iY, iR)
{    
	oFlash.TCallLabel((iT==0?"_root.FlashAvatar_mc":"_root"), "FDef");
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iType":"iType"), iType);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iDlyNo":"iDlyNo"), iLy);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iXPos":"iXPos"), iX);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iYPos":"iYPos"), iY);
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.iRot":"iRot"), iR);
	oFlash.TCallLabel((iT==0?"_root.FlashAvatar_mc":"_root"),"FMoveItem");
};

function FlsChangeMode(oFlash, iT, iType)
{    
	oFlash.TCallLabel((iT==0?"_root.FlashAvatar_mc":"_root"), "FDef");
	oFlash.SetVariable((iT==0?"_root.FlashAvatar_mc.bSelc":"bSelc"), iType);
	oFlash.TCallLabel((iT==0?"_root.FlashAvatar_mc":"_root"),"FOpMode");
};

function FlsCleanEdit(oFlash)
{
	oFlash.TCallLabel("_root.FlashAvatar_mc","FClearEditFra");
};

function FlsShowEdit(oFlash, iLy)
{    
	oFlash.TCallLabel("_root.FlashAvatar_mc", "FDef");
	oFlash.SetVariable("_root.FlashAvatar_mc.iDlyNo", iLy);
	oFlash.TCallLabel("_root.FlashAvatar_mc","FShowEditFra");
};

function InnerHTMLInitFlash(sId, sUrl, iWidth, iHeight, oPar, iType)
{//iType 0-商城 1-照相馆
  var sStyle ="";
  if(iWidth==186)
  {
    sStyle = 'class="flash1"';
  }
  else if(iWidth==140)
  {
    sStyle = 'class="flash2"';
  }
  var sFlash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" id="'+sId+'" '+(iType==0?sStyle:"")+'>';
  sFlash += '<param name="movie" value="'+sUrl+'" />';
  sFlash += '<param name="quality" value="high" />';
  sFlash += '<param name="wmode" value="transparent">';
  sFlash += '<param name="allowScriptAccess" value="always" />';
  sFlash += '<embed src="'+sUrl+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" allowScriptAccess="always" name="'+sId+'"><\/embed>';
  sFlash += '<\/object>'; 
  oPar.innerHTML = sFlash; 
};



//////////照相馆////////////////////

////////////////
function CAMAVINF()
{
  this._iX = 0;
  this._iY = 0;
  this._iLy = 0;
  this._sItemsn = "";
  
  this._arrItem = [];
  this._sEmo = "";
};

CAMAVINF.prototype.Init = function (iX, iY, iLy, sSn)
{
  this._iX = iX;
  this._iY = iY;
  this._iLy = iLy;
  this._sItemsn = sSn; 
  
  var oQSAV = new QQSHOWAV();
  var oRet = new Object();
  if(0 != oQSAV.FromStr(sSn, oRet))
  {
    alert(oRet.sErrMsg);
    return;
  }
  
  this._arrItem = oRet.arrItemInf;
  this._sEmo = oRet.stAvInfo._sEmo;
};
/////
function CAMITEMINF(iNo, iPly, iDX, iDY, bM, bR, bS, iT, iDly, iX, iY, iR, sLogo)
{
  this._iItemNo = iNo;  //物品编号
  this._iPlyNo = iPly;  //物理层
  this._iDefX = iDX;  //默认X坐标
  this._iDefY = iDY;  //默认Y坐标
  this._bMov = bM;  //可移动性
  this._bRot = bR;  //可旋转性
  this._bSelc = bS; //可选择性
  this._bPoseBind = 0; //POSE绑定
  this._iType = iT; //物品类型
  
  this._bColor = 0; //颜色预留
  this._iColor = 0;
  this._iOffset = 0;
  
  this._iDlyNo = iDly;  //展示层
  this._iXPos = iX; //当前X坐标
  this._iYPos = iY; //当前Y坐标
  this._iRot = iR;  //当前旋转角度
  
  this._iZoom = 0;  //放大预留
  this._iRev = 0; //偏转预留
  
  this._sLogo = sLogo; //个性物品标示
};

CAMITEMINF.prototype.ToString = function ()
{
   return (this._iItemNo+"_"+this._iPlyNo+"_"+this._iDefX+"_"+this._iDefY+"_"+this._bMov+"_"+this._bRot+"_"+this._bSelc+"_"+this._bPoseBind+"_"+this._iType+"_"+this._iDlyNo+"_"+this._iXPos+"_"+this._iYPos+"_"+this._iRot+"_"+this._bColor+"_"+this._iColor+"_"+this._iOffset+"_"+this._iZoom+"_"+this._iRev+"_"+escape(this._sLogo));
};

////
function CAMFLASH()
{
  this._iType = 1;
};

CAMFLASH.prototype = new  QQSHOWFLS;

CAMFLASH.prototype.LoadAvItem = function (iId, iLy, iDlyNo, iNo, sUrl, iXPos, iYPos, iRot, bMov, bRot, bSelc, iType, sLogo, sEmo)
{
  FlsLoadAv(this._oFlash, iId, iLy, iDlyNo, iNo, sUrl, iXPos, iYPos, iRot, bMov, bRot, bSelc, iType, sLogo, sEmo);
};

CAMFLASH.prototype.MoveAv = function (iId, iLy, iXPos, iYPos)
{
  FlsMoveAv(this._oFlash, iId, iLy, iXPos, iYPos);
};

CAMFLASH.prototype.Swap = function (iId1, iId2)
{
  FlsSwapLy(this._oFlash, iId1, iId2);
};

CAMFLASH.prototype.Load = function (iDlyNo, iNo, sUrl, iXPos, iYPos, iRot, bMov, bRot, bSelc, iType, sLogo, sEmo)
{
  FlsLoadItem(this._oFlash,this._iType, iDlyNo, iNo, sUrl, iXPos, iYPos, iRot, bMov, bRot, bSelc, iType, sLogo, sEmo);
};

CAMFLASH.prototype.Unload = function (iDlyNo)
{
  var iNo = iXPos = iYPos = iRot = bMov = bRot = bSelc = iType = 0;
  var sUrl = sLogo = sEmo = "";
  FlsLoadItem(this._oFlash, this._iType, iDlyNo, iNo, sUrl, iXPos, iYPos, iRot, bMov, bRot, bSelc, iType, sLogo, sEmo);
};

CAMFLASH.prototype.UnloadAv = function (iId)
{
  FlsDelAv(this._oFlash, iId);
};

CAMFLASH.prototype.ShowAvEdit = function (iId)
{
  FlsShowAvEdit(this._oFlash, iId);
};
/////
function QQSHOWCAM()
{
  this._arrAvInf = []; //用户信息数组
  this._arrItemInf = []; //相片物品信息数组
  this._stFlash = new CAMFLASH();
  
  this._arrAvCfg = [[54, 40, 0], [56, 100, 0]]; //[index]=[对应层号, X坐标, Y坐标]
};

QQSHOWCAM.prototype.ToItemStr = function ()
{
  var sCamItems = "";
  for(var i=0;i<this._arrItemInf.length;i++)
  {
    sCamItems += this._arrItemInf[i].ToString() + ((i==this._arrItemInf.length-1)?"":"|");
  }
  return sCamItems;
};

QQSHOWCAM.prototype.FromItemStr = function (sSn)
{
  var arrTmp = sSn.toString().split('|');
  if(arrTmp[0]=="")
    return;

  for(var i=0;i<arrTmp.length;i++)
  {
    var arrTmp2 = arrTmp[i].toString().split('_');
    this._arrItemInf.push(new CAMITEMINF(arrTmp2[0], arrTmp2[1], arrTmp2[2], arrTmp2[3], arrTmp2[4], arrTmp2[5], arrTmp2[6], arrTmp2[8], arrTmp2[9], arrTmp2[10], arrTmp2[11], arrTmp2[12], unescape(arrTmp2[18])));
  }
};

QQSHOWCAM.prototype.FromStr = function (sSn)
{// iRetcode: 0-成功 other-失败
  var arrTmp1 = sSn.toString().split('&');
	if(6!=arrTmp1.length && 4!=arrTmp1.length)
		return -1;
	
	var sCamItems = arrTmp1[1].toString().split('#')[1];
	this.FromItemStr(sCamItems);
	
	if(4 == arrTmp1.length)
	{//单人照
	  var arrTmp2 = arrTmp1[2].toString().split('_');
	  this._arrAvInf[0] = new CAMAVINF();
    this._arrAvInf[0].Init(arrTmp2[0], arrTmp2[1], arrTmp2[2], arrTmp1[3].toString());
	}
	else
  {//双人照
    var arrTmp2 = arrTmp1[2].toString().split('_');
    this._arrAvInf[0] = new CAMAVINF();
	  this._arrAvInf[0].Init(arrTmp2[0], arrTmp2[1], arrTmp2[2], arrTmp1[3].toString());
	  
	  var arrTmp3 = arrTmp1[4].toString().split('_');
	  this._arrAvInf[1] = new CAMAVINF();
	  this._arrAvInf[1].Init(arrTmp3[0], arrTmp3[1], arrTmp3[2], arrTmp1[5].toString());
  }
  
};

QQSHOWCAM.prototype.ToString = function ()
{
  if(!this._arrAvInf[0] && !this._arrAvInf[1])
    return "";
    
  var sCamCtrl = "";//预留
  var sCamItems = this.ToItemStr();
  
  var sHeader = "V1";
  var sCamInf = sCamCtrl+"#"+sCamItems;
  
  if(!this._arrAvInf[0] || !this._arrAvInf[1])
  {//单人照
    if(!this._arrAvInf[0])
    {
      var sShow1 = this._arrAvInf[1]._iX+"_"+this._arrAvInf[1]._iY+"_"+this._arrAvInf[1]._iLy;
      var sSn1 = this._arrAvInf[1]._sItemsn;
    }
    else
    {
      var sShow1 = this._arrAvInf[0]._iX+"_"+this._arrAvInf[0]._iY+"_"+this._arrAvInf[0]._iLy;
      var sSn1 = this._arrAvInf[0]._sItemsn;
    }  
    return sHeader+"&"+sCamInf+"&"+sShow1+"&"+sSn1;
  }
  else
  {//双人照
    var sShow1 = this._arrAvInf[0]._iX+"_"+this._arrAvInf[0]._iY+"_"+this._arrAvInf[0]._iLy;
    var sSn1 = this._arrAvInf[0]._sItemsn;
    var sShow2 = this._arrAvInf[1]._iX+"_"+this._arrAvInf[1]._iY+"_"+this._arrAvInf[1]._iLy;
    var sSn2 = this._arrAvInf[1]._sItemsn;
    
    return sHeader+"&"+sCamInf+"&"+sShow1+"&"+sSn1+"&"+sShow2+"&"+sSn2;
  } 
};

QQSHOWCAM.prototype.GetFlashReady = function ()
{
  return this._stFlash.GetReady();
};
 
QQSHOWCAM.prototype.InitFlash = function (oFlash)
{
  this._stFlash.Init(oFlash);
};

QQSHOWCAM.prototype.GetInitAvILy = function (iIdx)
{
  if(typeof(this._arrAvInf[((iIdx==0)?1:0)])!="undefined" && typeof(this._arrAvInf[((iIdx==0)?1:0)]._iLy)!="undefined" && this._arrAvInf[((iIdx==0)?1:0)]._iLy==this._arrAvCfg[iIdx][0])
  {
    return this._arrAvCfg[((iIdx==0)?1:0)][0];
  }
  return this._arrAvCfg[iIdx][0];
};

QQSHOWCAM.prototype.InitAvInf = function (iIdx, sSn)
{
  this._arrAvInf[iIdx] = new CAMAVINF();
  this._arrAvInf[iIdx].Init(this._arrAvCfg[iIdx][1], this._arrAvCfg[iIdx][2], this.GetInitAvILy(iIdx), sSn);
};

QQSHOWCAM.prototype.InitUserShow = function ()
{
  for(var i=0; i<this._arrAvInf.length; i++)
  {
    this.LoadAvItemArray(i);
    this._stFlash.MoveAv(i, this._arrAvInf[i]._iLy, this._arrAvInf[i]._iX, this._arrAvInf[i]._iY);
  }
};

QQSHOWCAM.prototype.LoadAvItemArray = function(iIdx)
{
	for(var i=0; i<this._arrAvInf[iIdx]._arrItem.length; i++)
	{
	  if(IsAvItem(this._arrAvInf[iIdx]._arrItem[i]._iDlyNo)==1)
		  this._stFlash.LoadAvItem(iIdx, this._arrAvInf[iIdx]._iLy, this._arrAvInf[iIdx]._arrItem[i]._iDlyNo, this._arrAvInf[iIdx]._arrItem[i]._iItemNo, GetUrl(this._arrAvInf[iIdx]._arrItem[i]._iItemNo, this._arrAvInf[iIdx]._arrItem[i]._iPlyNo, this._arrAvInf[iIdx]._arrItem[i]._iType), this._arrAvInf[iIdx]._arrItem[i]._iXPos, this._arrAvInf[iIdx]._arrItem[i]._iYPos, this._arrAvInf[iIdx]._arrItem[i]._iRot, this._arrAvInf[iIdx]._arrItem[i]._bMov, this._arrAvInf[iIdx]._arrItem[i]._bRot, this._arrAvInf[iIdx]._arrItem[i]._bSelc, this._arrAvInf[iIdx]._arrItem[i]._iType, this._arrAvInf[iIdx]._arrItem[i]._sLogo, this._arrAvInf[iIdx]._sEmo);
	}
};

QQSHOWCAM.prototype.UnloadAvItem = function(iIdx)
{
  this._stFlash.UnloadAv(iIdx);
  this._arrAvInf.splice(iIdx, 1);
};

QQSHOWCAM.prototype.MoveUserAv = function (iIdx, iDir)
{//iDir: 0-left 1-right
  var iPx = 10;
  if(iDir == 0)
    this._arrAvInf[iIdx]._iX -= iPx;
  else
    this._arrAvInf[iIdx]._iX += iPx;
    
  this._stFlash.MoveAv(this._arrAvInf[iIdx]._iLy, this._arrAvInf[iIdx]._iX, this._arrAvInf[iIdx]._iY);
};

QQSHOWCAM.prototype.GetLayer = function (iIdx)
{
  return this._arrAvInf[iIdx]._iLy;
};

QQSHOWCAM.prototype.GetIndex = function (iLy)
{
  for(var iIdx in this._arrAvInf)
  {
    if(iLy == this._arrAvInf[iIdx]._iLy)
      return iIdx;
  }
  return -1;
};

QQSHOWCAM.prototype.SwapLayer = function (iIdx1, iIdx2)
{
  this._stFlash.Swap(iIdx1, iIdx2._iLy);
  this.ChangeLayer(iIdx1, iIdx2);
};

QQSHOWCAM.prototype.ChangeLayer = function (iIdx1, iIdx2)
{
  var iLy = this._arrAvInf[iIdx1]._iLy;
  this._arrAvInf[iIdx1]._iLy = this._arrAvInf[iIdx2]._iLy;
  this._arrAvInf[iIdx2]._iLy = iLy;
};

QQSHOWCAM.prototype.ReqSwapLayer = function (iIdx1, iIdx2)
{
  this.ChangeLayer(iIdx1, iIdx2);
};

QQSHOWCAM.prototype.ReqEditAv = function (iIdx, iX, iY)
{
  this._arrAvInf[iIdx]._iX = iX;
  this._arrAvInf[iIdx]._iY = iY;
};

QQSHOWCAM.prototype.ShowEdit = function (iIdx)
{
  this._stFlash.ShowAvEdit(iIdx);
};

QQSHOWCAM.prototype.InitItems = function ()
{
  for(var i=0;i<this._arrItemInf.length;i++)
  {
    this._stFlash.Load(this._arrItemInf[i]._iDlyNo, this._arrItemInf[i]._iItemNo, GetUrl(this._arrItemInf[i]._iItemNo, this._arrItemInf[i]._iPlyNo,this._arrItemInf[i]._iType), this._arrItemInf[i]._iDefX, this._arrItemInf[i]._iDefY, 0, this._arrItemInf[i]._bMov, this._arrItemInf[i]._bRot, this._arrItemInf[i]._bSelc, this._arrItemInf[i]._iType, this._arrItemInf[i]._sLogo, "");
  }
};

QQSHOWCAM.prototype.LoadItem = function (iItemNo, iPlyNo, iDlyNo, iFStl, iDefX, iDefY, bMov, bRot, bSelc, iType, sLogo)
{
  this._stFlash.Load(iDlyNo, iItemNo, GetUrl(iItemNo, iPlyNo, iType), iDefX, iDefY, 0, bMov, bRot, bSelc, iType, sLogo, "");
  this._arrItemInf.push(new CAMITEMINF(iItemNo, iPlyNo, iDefX, iDefY, bMov, bRot, bSelc, iType, iDlyNo, iDefX, iDefY, 0, sLogo));
};

QQSHOWCAM.prototype.UnLoadItem = function (iIdx)
{
	if(this._stFlash._oFlash)
	{
		this._stFlash.Unload(this._arrItemInf[iIdx]._iDlyNo);
	}
	this._arrItemInf.splice(iIdx, 1);
};

QQSHOWCAM.prototype.ItemCount = function ()
{
  return this._arrItemInf.length;
};

QQSHOWCAM.prototype.GetNewDly = function(iPlyNo)
{
  var arrFntDLy = [];
  var arrBkgDLy = [];
	for(var i=0; i<this._arrItemInf.length; i++)
	{
		var iTemp = this._arrItemInf[i]._iDlyNo;
		if((iTemp >= 70)&&(iTemp <= 79))//记住身前已分配的层号
			arrFntDLy.push(iTemp);
		else if((iTemp >= 30)&&(iTemp <= 39))//记住身后已分配的层号
			arrBkgDLy.push(iTemp);
	}
	
	var iDlyNo;
	if(99 == iPlyNo)//身前
		iDlyNo = GetMinLy(arrFntDLy, 70, 79);
	else//身后
		iDlyNo = GetMinLy(arrBkgDLy, 30, 39);
		
	return iDlyNo;
};

QQSHOWCAM.prototype.ShopLoadItem = function(iItemNo, iPlyNo, iFStl, iDefX, iDefY, bMov, bRot, bSelc, iType, sLogo)
{//iRetcode 0:没变化 1:脱掉 2:穿上 3:换上
  if("undefined" == typeof(sLogo))
    sLogo="";
	if(99 == iPlyNo || 1 == iPlyNo)//动态层换装
	{
		var iIdx = -1;
		for(var i=0; i<this._arrItemInf.length; i++)
		{//根据iItemNo遍历
			if(iItemNo == this._arrItemInf[i]._iItemNo)
			{
				iIdx = i;
				break;
			}
		}
		
		if(iIdx != -1)//已有该物品 脱
		{
			this.UnLoadItem(iIdx);
			return 1;
		}
		else//还没这个物品 穿
		{			
		  this.LoadItem(iItemNo, iPlyNo, this.GetNewDly(iPlyNo), iFStl, iDefX, iDefY, bMov, bRot, bSelc, iType, sLogo);
			return 2;
		}
	}
	else//固定层换装
	{
		var iIdx = iAvItemNo = -1;
		for(var i=0; i<this._arrItemInf.length; i++)
		{//根据层号找
			if(iPlyNo == this._arrItemInf[i]._iDlyNo)//该层已有物品
			{
				iIdx = i;
				iAvItemNo = this._arrItemInf[i]._iItemNo;
				break;
			}
		}
		
		if(iAvItemNo == iItemNo)//该层已有同样物品 脱
		{
				this.UnLoadItem(iIdx);
				return 1;
		}
		else
		{
			if(iAvItemNo != -1)//该层有另一件物品 换
			{
			  this._arrItemInf.splice(iIdx, 1);
			  this.LoadItem(iItemNo, iPlyNo, iPlyNo, iFStl, iDefX, iDefY, bMov, bRot, bSelc, iType, sLogo);
			  return 3;
			}
			else//还没有这一层 穿
			{
        this.LoadItem(iItemNo, iPlyNo, iPlyNo, iFStl, iDefX, iDefY, bMov, bRot, bSelc, iType, sLogo);
			  return 2;
			}
		}
	}
};

/////上面会用到
function FlsLoadAv(oFlash, iId, iLy, iDlyNo, iNo, sUrl, iXPos, iYPos, iRot, bMov, bRot, bSelc, iType, sLogo, sEmo)
{
  if(sLogo=="undefined")
    sLogo="";
    
  if(sEmo=="undefined")
    sEmo="";
  
	oFlash.TCallLabel("_root", "FDef");
	oFlash.SetVariable("iId", iId);
	oFlash.SetVariable("iLy", iLy);
	oFlash.SetVariable("iDlyNo", iDlyNo);
	oFlash.SetVariable("iNo",  iNo);
	oFlash.SetVariable("sUrl", sUrl);
	oFlash.SetVariable("iXPos", iXPos);
	oFlash.SetVariable("iYPos", iYPos);
	oFlash.SetVariable("iRot", iRot);
	oFlash.SetVariable("bMov", bMov);
	oFlash.SetVariable("bRot", bRot);
	oFlash.SetVariable("bSelc", bSelc);
	oFlash.SetVariable("iType", iType);
	oFlash.SetVariable("sLogo", sLogo);
	oFlash.SetVariable("sTxt", sEmo);
	oFlash.TCallLabel("_root","FLoadAv");
};

function FlsMoveAv(oFlash, iId, iLy, iXPos, iYPos)
{
	oFlash.TCallLabel("_root", "FDef");
	oFlash.SetVariable("iId", iId);
	oFlash.SetVariable("iLy", iLy);
	oFlash.SetVariable("iAvXPos", iXPos);
	oFlash.SetVariable("iAvYPos", iYPos);
	oFlash.TCallLabel("_root","FMoveAv");
};

function FlsSwapLy(oFlash, iId1, iId2)
{
	oFlash.TCallLabel("_root", "FDef");
	oFlash.SetVariable("iId", iId1);
	oFlash.SetVariable("iLy", iId2);
	oFlash.TCallLabel("_root","FSwitch");
};

function FlsDelAv(oFlash, iId)
{
	oFlash.TCallLabel("_root", "FDef");
	oFlash.SetVariable("iId", iId);
	oFlash.TCallLabel("_root","FDelAv");
};

function FlsShowAvEdit(oFlash, iId)
{
	oFlash.TCallLabel("_root", "FDef");
	oFlash.SetVariable("iId", iId);
	oFlash.TCallLabel("_root","FShowAvEdit");
};

function IsAvItem(iDly)
{
  if(iDly>=250 && iDly<=650)
    return 1;
  else
    return 0;
};
function SN(sSn, aItem, bReplace, bChangeStyle, bChangeSex)
{
	this.sSn = sSn;
	this.arrItem = aItem; 	
	this.cSex = "U";
	this.iStyle = -1; 	
	this.oQSAV = new QQSHOWAV();
	
	this.bReplace = true;
	if(bReplace) this.bReplace = bReplace;
	this.bChangeStyle = false;
	if(bChangeStyle) this.bChangeStyle = bChangeStyle;
	this.bChangeSex = false;
	if(bChangeSex) this.bChangeSex = bChangeSex; 

	this.bInit = false;
	this.bOn = false;
};
SN.prototype.isValidSex = function(sex)
{									  
	if(sex == "M" || sex == "F") return true;
	else return false;
};
SN.prototype.isValidStyle = function(style)
{
	if(style == 0 || style == 1) return true;
	else return false;
};
SN.prototype.isValidSn = function ()
{
	if(this.sSn.length >= 0)
	{			 
		var arr = this.sSn.toString().split("#");
		if(arr.length !=4) return false;
		var aUserInfo = arr[1].split("_");
		if(aUserInfo.length != 8) return false;
		return true;
	}
	return false;
};
SN.prototype.GetSexAndStyle = function()
{
	var bChange = false; 

	//从形象串中获取性别和风格
	var cSnSex = "U";
	var iSnStyle = -1;
	if(this.sSn.length > 0 && this.isValidSn(this.sSn))
	{
		var aItem = this.sSn.toString().split("#");
		var sUserInfo = aItem[1];
		var aUserInfo = sUserInfo.split("_");
		cSnSex = aUserInfo[0];
		iSnStyle = parseInt(aUserInfo[1], 10);
	}
	else
	{
		this.bChangeStyle = true;
		this.bChangeSex = true;
	}

	//从需要穿上的item数组中获取性别和风格
	if(this.bChangeStyle || this.bChangeSex)
	{
		for(var i = 0;i< this.arrItem.length;i++)
		{
			var o = this.arrItem[i];
			var iStyle = o._iItemNo<1000000?0:(o._iItemNo<2000000?1:-1);
			if(this.bChangeStyle && this.bChangeSex && this.isValidSex(o._cSex) && this.isValidStyle(iStyle))
			{
				this.cSex = o._cSex;
				this.iStyle = iStyle;
			}
			else if(this.bChangeStyle && this.isValidStyle(iStyle) && (cSnSex == o._cSex))
			{
				this.iStyle = iStyle;
			}
			else if(this.bChangeSex && this.isValidSex(o._cSex) && (iSnStyle == iStyle))
			{
				this.cSex = o._cSex;
			}
			else continue;	 
			break;
		}
		if(!this.isValidSex(this.cSex)) this.cSex = cSnSex;
		if(!this.isValidStyle(this.iStyle)) this.iStyle = iSnStyle;
	}
	else
	{
		this.cSex = cSnSex;
		this.iStyle = iSnStyle;
	}
	
	//如果item数组的性别或风格跟原来不一样，则重置形象串
	if((this.cSex != cSnSex) || (this.iStyle != iSnStyle))
	{
		bChange = true;
	}
	
	//如果既没有形象串
	if(!this.isValidSex(this.cSex)) 
	{	
		this.cSex = "F";
		bChange = true;
	}
	if(!this.isValidStyle(this.iStyle)) 
	{
		this.iStyle = 1;
		bChange = true;
	}
	if(bChange) 
	{
		this.oQSAV.FromItemSn(this.oQSAV.MakeDefStr(this.cSex, this.iStyle), true);	
		this.sSn = this.oQSAV.ToItemSn(0, 0, 0);
	} 
	else this.oQSAV.FromItemSn(this.sSn, true);
};
SN.prototype.InitSn = function()
{
	if(!this.isValidSex() || !this.isValidStyle()) this.GetSexAndStyle(); 
	this.bInit = true;
};
SN.prototype.TryOn = function()
{
	if(!this.bInit) this.InitSn();
	for(var i = 0; i < this.arrItem.length; i++)
	{
		var o = this.arrItem[i];
		var cItemSex = o._cSex;
		var iItemStyle = o._iItemNo<1000000?0:(o._iItemNo<2000000?1:-1);
		if((iItemStyle == -1 || iItemStyle == this.iStyle) && (cItemSex=="U" || cItemSex == this.cSex))
		{
			this.oQSAV.ShopProc(o._iItemNo, o._cSex, o._iPlyNo, o._iPose, o._bPoseBind, o._iDefX, o._iDefY, o._bMov, o._bRot, o._bSelc, o._iType, o._sLogo);	
		}
	}
	this.bOn = true;
};
SN.prototype.GetSn = function()
{
	if(!this.bOn) this.TryOn();
	this.sSn = this.oQSAV.ToItemSn(0, 0, 0);
	return this.sSn;
};
SN.prototype.ItemCount	=	function()
{
	if(!this.bOn) this.TryOn();
	return this.oQSAV.ItemCount();
}/*  |xGv00|2e0885293f1fe0429fbb6a73ecd44a4b */