function ciRecoverBgCore(nAttr) {
	if ( !ciChkBgShow(nAttr) )
		ciMakeNewItemElement(( nAttr == AR_ATTR_FLOR ? UCODE_FLOOR : UCODE_WALL ), 0 , nAttr, 0, "我的"+( nAttr == AR_ATTR_FLOR ? "地面" : "墙纸" ), true)
}
function ciRecoverBg(nAttr) {
	if ( nAttr < AR_ATTR_ITEM && !ciChkBgShow(AR_ATTR_SPEC) ) {
		ciRecoverBgCore(AR_ATTR_FLOR);
		ciRecoverBgCore(AR_ATTR_WALL);
	}
}
function ciAddMyAvata(notMove, bFlip, PosX, PosY, refAvata, Content, LinkBBS, nCost) {
//bFlip = false;
//PosX=20;
//PosY=20;
	var appletFrame, myUerObj, arrChar;
	if ( !isShop && !objItemListTBody )
		return;
	// if ( !ISObject(appletFrame = ret_appletFrame(self))
//  || !ISObject(myUerObj = appletFrame.User)
//  || !ISObject(arrChar = myUerObj.user_char2)
//   ) {
   arrChar= curVisual;
// }


	myUerObj = ciMakeNewItemElement(UCODE_MYAVATA, "avata", AR_ATTR_AVA, arrChar, curUserName+"的虚拟形象", true, refAvata, bFlip, PosX, PosY, Content, LinkBBS, nCost, notMove);
	objAvataDiv = myUerObj.eleObj;
	objAvataTr = myUerObj.trObj;
}
function ciIsDefItem(nUniCode) {
	return ( nUniCode == UCODE_WALL || nUniCode == UCODE_FLOOR );
}

//nUniCode--编码 nCode--item编号 nAttrib--属性 nSkillCode--组合编号
function ciMakeNewItemElement(nUniCode, nCode, nAttrib, nSkillCode, strName, bMine, refAvata, bFlip, PosX, PosY, Content, LinkBBS, nCost, notMove) {
	var ret;
	if ( IsSkinItem(nAttrib) )
		return false;
	if ( !arrItemObj[nUniCode] ) {
		ret = ciMakeItemInfoObj(nUniCode, nCode, nAttrib, nSkillCode, strName, bMine, Content, LinkBBS);
		if( nCost ) 
			ret.nCost = nCost;

		if ( !objItemListTBody );
		else if ( ret.trObj ) 
			ciUpdateItemListObj(ret.trObj, ret);
		else 
			ret.trObj = ciMakeItemListObj(ret);
		
		if ( IsBgLayer(ret.nSortLev) ) {
			ciMakeStaticRoomElement(ret.eleObj);
			PosX = PosY = 0;
		}
		else if ( ItemCanMove )
		{
			ciMakeMoveRoomElement(ret.eleObj, ( ret.nAttr == AR_ATTR_AVA ), PosX, PosY, notMove);		
			if(bFlip)
				ciRoomItemFlipHRev(nUniCode);
		}
		
		if ( typeof(refAvata) != "undefined" ) {
			ciRoomItemFlipH(ret.eleObj, bFlip)
			ciMoveRoomItem(ret.eleObj, PosX, PosY)
		}

		if ( !ciIsDefItem(nUniCode) )
			ciRecoverBg(ret.nAttr);
		refAvata = 0;
		ciSortRoomItem(nUniCode, ret.trObj, ret.nSortLev, refAvata);
		ciSumnTotalCost(1, ret);
	}

	if(!notMove)
		ciItemFocus(nUniCode);
	return ret;
}
function ciMakeItemListObj(objInfo) {
	if ( !objItemListTBody )
		return false;
	return ciUpdateItemListObj(ciMakeItemListNullObj(),objInfo);
}

function ciItemOnMouseClick(nUniCode, forother) { //button=1 左键 移动开始 2 右键 打开鼠标右键菜单
	if ( !event )
		return;
	ciItemFocus(nUniCode);
	if ( event.button == 1 )
		if(!forother)
			ciRoomItemMoveStart(nUniCode);
		else
			ciProcessItem(nUniCode);
	else 
		ciItemMenuView(nUniCode, bf_azit, forother);
}
function ciProcessItem(nUniCode) 
{
        var targObj;
        if ( !( targObj = ciGetRoomItemObj(nUniCode)) )
                return;
}

function ciItemMenuView(nUniCode, bFlag, forother) {
	var targObj;
	//if ( !event || event.button != 2 || !(targObj = ciGetRoomItemObj(nUniCode)) )
	if ( !event || event.button == 1 || !(targObj = ciGetRoomItemObj(nUniCode)) )
		return;
	if ( IsDefBg(targObj) || targObj.nAttr == AR_ATTR_AVA )
		bFlag &= ~( bf_aitem_content | bf_aitem_remove | bf_aitem_lv );
	if ( IsBgLayer(targObj.nSortLev) )
		bFlag &= ~( bf_aitem_lv | bf_aitem_flip | bf_aitem_center | bf_aitem_content );
	if ( targObj.nAttr == 24 )
		bFlag &= ~bf_aitem_content;
	if ( bFlag ) {
		open_user_menu(nUniCode, bFlag, forother);
		ciDisableEvent();
	}
}
function ciItemListClick(nUniCode, bFlag) {
	ciItemFocus(nUniCode, true);
	ciItemMenuView(nUniCode, bFlag);
}
function ciMakeItemListNullObj() {
	var objTr, objTable, objTd;
	if ( !(objTr = ciStackNullTrObj(true)) ) {
		objTr = makeTagNode("TR");
		objTr.style.cursor = "hand";
		objTd = objTr.appendChild(makeTagNode("TD"));
		objTd.width = DEF_LISTIMG_WIDTH;
		objTd.appendChild(makeTagNode("<INPUT ID=chkboxItem TYPE=checkBox>"));
		objTd.appendChild(makeImgNode(DEF_LISTIMG)).align = "absmiddle";
		objTd.align = "center";
		objTr.appendChild(makeTagNode("TD")).appendChild(makeTagNode("DIV", "itemListNameDiv")).noWrap  = true;
	}
	return objTr;
}
function ciUpdateItemListObj(objTr, objInfo) {
	var objTable, objTd, tmpValue;
	objTr.onmousedown = new Function("ciItemListClick('"+objInfo.nUniCode+"',bf_azit)");
	objTr.nUniCode = objInfo.nUniCode;
	objTd = objTr.childNodes[1].firstChild;
	objTr.title = objTd.innerText = objInfo.strName;
	objTd = objTr.childNodes[0];
	tmpValue = ( objInfo.bMine ? 1 : 0 );
	objTd.childNodes[(1-tmpValue)].style.display = "none";
	objTd.childNodes[tmpValue].style.display = "";
	objTr.style.display = "";
	if ( typeof(bChkAll) == "object" )
		objTr.firstChild.firstChild.checked = bChkAll.checked;	
	return objTr;
}

function ciItemFocus(nUniCode, bNotScroll) {
	if ( !ItemCanMove )
		return;
	var prop;
	nFocusId = nUniCode;
	for(prop in arrItemObj) 
		ciItemFocusEffect(arrItemObj[prop].trObj, ( prop == nFocusId ));
	if ( !bNotScroll )
		ciFocusListScroll();
	ciItemOnMouseOverEffectByUCode(true, nUniCode);
	ciHideContentInput();
}
function ciItemFocusEffect(objTr, bFocus) {
	if ( objTr )
		objTr.childNodes[1].firstChild.className = ( bFocus ? "clsFocusItemList itemListNameDiv" : "itemListNameDiv" );	
}
	
function ciGetRoomItemObj(nUniCode) {
	return ( arrItemObj[nUniCode] ? arrItemObj[nUniCode] : false );
}
function ciGetRoomItemEleObj(nUniCode) {
	return ( arrItemObj[nUniCode] ? arrItemObj[nUniCode].eleObj : false );
}
function ciGetCurFocusObj() {
	return ciGetRoomItemObj(nFocusId);
}
function ciRecoverRoom() {
	ciRemoveItemAll();
	ciChangeARoomSetCode();
	ciMakeMoveRoomElement(objAvataDiv, true);
}
function IsDefBg(infoObj) {
	return ( infoObj && IsBgAttribute(infoObj.nAttr) && infoObj.nCode < 0 );
}
function ciRemoveItemByUniCode(nUniCode) {
	var infoOb, trObj, nAttr;
	if ( !(infoObj = ciGetRoomItemObj(nUniCode)) || IsDefBg(infoObj) )
		return true;
	nAttr = infoObj.nAttr;
	if ( !ciRemoveItemCore(nUniCode) )
		return true;
	else if ((trObj = infoObj.trObj) &&  nUniCode == nFocusId ) {
		var nCurFocusCode,sNode;
		if ( (sNode = ciGetSibling(trObj, true)) )
			nCurFocusCode = sNode.nUniCode;
		else if ( (sNode = ciGetSibling(trObj, false)) )
			nCurFocusCode = sNode.nUniCode;
		ciItemFocus(nCurFocusCode);	
	}
	return ciRecoverBg(nAttr);
}
function ciRemoveItem() {
	if ( ciRemoveItemByUniCode(nFocusId) )
		alert("基本元素无法删除！");
}
function ciFocusListScroll() {
	if ( !objItemList 
			|| !(targObj = ciGetRoomItemObj(nFocusId)) 
			|| !(targObj = targObj.trObj) )
		return;
	objItemList.scrollTop = Math.max(targObj.offsetTop-20, 0);
}
function ciSyncRoomItem(nUniCode) {
	var targObj, divObj, swapObj = false;
	if ( !(targObj = ciGetRoomItemObj(nUniCode)) || !(divObj = targObj.eleObj) )
		return;
	if ( (targObj = targObj.trObj)
			&& (swapObj = ciGetSibling(targObj, false)) 
			&& (swapObj = ciGetRoomItemObj(swapObj.nUniCode)) 
			&& (swapObj = swapObj.eleObj) );
	ciAddOrInsertDiv(objAzitRoomBody,divObj,swapObj);
}
function ciGetTrObj(nUniCode) {
	var targObj;
	return ( !(targObj = ciGetRoomItemObj(nUniCode)) || !(targObj = targObj.trObj) ? false : targObj );
}
function IsBgLayerTr(trObj) {
	var infoObj;
	return ( trObj && (infoObj = ciGetRoomItemObj(trObj.nUniCode)) && IsBgLayer(infoObj.nSortLev) );
}
function ciGetSwapObj(targObj, bUp, bAll) {
	var swapObj = false, tmpObj, i, cNode;
	if ( bAll && bUp );
	else if ( bAll ) 
		for(cNode = objItemListTBody.lastChild; cNode && IsBgLayerTr(cNode); cNode = ciGetSibling(cNode, false) )
			swapObj = cNode;	
	else if ( bUp ) 
		swapObj =  ciGetSibling(targObj,false);
	else {
		for(i=0, swapObj = targObj; i<2 && swapObj ;i++) 
			if ( IsBgLayerTr(swapObj = ciGetSibling(swapObj,true)) )
				break;
	}
	if ( bUp && ( !swapObj || swapObj == objAvataTr ) ) 
		//swapObj = objItemListTBody.firstChild;
		swapObj =  ( objAvataTr ? ciGetSibling(objAvataTr,true) : objItemListTBody.firstChild);
		
	return swapObj;
}
function ciItemMoveZCore(targObj, swapObj) {
	var chk1= ciGetCheckBoxObj(targObj);
	ciAddOrInsertDiv(objItemListTBody, targObj, swapObj);
	ciSetCheckObj(targObj, chk1);
	ciSyncRoomItem(targObj.nUniCode);
	ciFocusListScroll();
}
function ciItemMoveZ(bUp, bAll){
	var targObj, infoObj;
	if ( !(infoObj = ciGetRoomItemObj(nFocusId)) || IsBgLayer(infoObj.nSortLev) || !(targObj = infoObj.trObj) || targObj == objAvataTr )
		return;
	ciItemMoveZCore(targObj, ciGetSwapObj(targObj, bUp, bAll));
}
function ciItemMoveBeforeAvata(bUp) {
	var targObj, infoObj;
	if ( !(infoObj = ciGetRoomItemObj(nFocusId)) || IsBgLayer(infoObj.nSortLev) || !(targObj = infoObj.trObj) )
		return;
	ciItemMoveZCore(targObj, (bUp ? objAvataTr : ciGetSibling(objAvataTr, true)));
}
function ciSortRoomItem(nUniCode, targObj, thisLev, refAvata) {
	var swapObj = false, tmpObj, i, objNode;
	if ( objItemListTBody && targObj ) {
		if ( thisLev == AR_LAY_ITEM1 ) {
			if ( typeof(refAvata) == "undefined" )
				refAvata = 0;
			swapObj = ( refAvata == 2 || !objAvataTr ? objItemListTBody.firstChild : ciGetSibling(objAvataTr,true));
		}
		else {
			for(objNode=objItemListTBody.lastChild;objNode;objNode = ciGetSibling(objNode, false)) {
				if ( objNode == targObj || objNode.style.display != "" || !(tmpObj = ciGetRoomItemObj(objNode.nUniCode)) )
					continue;
				else if ( tmpObj.nSortLev > thisLev ) 
					break;
				swapObj = objNode;
			}
		}
		ciAddOrInsertDiv(objItemListTBody,targObj,swapObj);
	}
	ciSyncRoomItem(nUniCode);
	return targObj;
}

function ciItemOnMouseOverEffectCore(bOver, targObj) {
	if ( !targObj || targObj.className != "divAzitRoomElement" )
		return;
	var bWidth = ( bOver ? 1 : 0 );
	targObj.style.padding = ( 1 - bWidth )+"px";
	targObj.style.borderWidth = bWidth+"px";
}
function ciItemOnMouseOverEffect(bOver, targObj) {
	var prop;
	ciItemOnMouseOverEffectCore(false, objLastObjTarget);
	objLastObjTarget = ( bOver ? targObj : false );
	ciItemOnMouseOverEffectCore(bOver, targObj);
}
function ciItemOnMouseOverEffectByUCode(bOver, nUniCode) {
	ciItemOnMouseOverEffect(bOver, ciGetRoomItemEleObj(nUniCode));
}
function ciInitMouseActionObj() {
	this.bMove = false;
	this.startDivX = 0;
	this.startDivY = 0;
	this.startX = 0;
	this.startY = 0;
	this.targObj = false;
}
function ciRoomItemMoveStart(nUniCode) {
	var targObj;
	if ( !(targObj = ciGetRoomItemEleObj(nUniCode)) )
		return;
	mouseActionObj.bMove = true;
	objAzitRoomBody.setCapture();
	mouseActionObj.targObj = targObj;
	mouseActionObj.targObj.style.cursor = objAzitRoomBody.style.cursor = "move";
	mouseActionObj.startX = event.clientX;
	mouseActionObj.startY = event.clientY;
	mouseActionObj.startDivX = targObj.style.pixelLeft;
	mouseActionObj.startDivY = targObj.style.pixelBottom;
}
function ciRoomItemMoveEnd() {
	if ( !mouseActionObj.bMove )
		return;
	objAzitRoomBody.releaseCapture();
	objAzitRoomBody.style.cursor = "";
	mouseActionObj.targObj.style.cursor = "hand";
	mouseActionObj.bMove = false;
}
function ciGetRoomCenterPosition() {
	var ret = new Object();
	ret.l = Math.floor((parseInt(objAzitRoomBody.currentStyle.width)-77)/2);
	ret.b = Math.floor((parseInt(objAzitRoomBody.currentStyle.height)-127)/2);
	return ret;
}
function ciMakeStaticRoomElement(divObj) {
	divObj.onmouseover = divObj.onmouseout = divObj.onmousedown = NULLFUNC;
	divObj.style.bottom = divObj.style.left = divObj.style.cursor = "";
}


function ciMakeMoveRoomElement(divObj, bCenter, PosX, PosY, notMove) {
var objPos = ( bCenter ? ( ciGetRoomCenterPosition() ) : ciGetRandomPosition() );
if(typeof(PosX) != "undefined")

	objPos =  ciGetAbsolutePosition(PosX, PosY);
	if (divObj) {
		divObj.onmouseover = new Function("ciItemOnMouseOverEffect(true, this)");
		divObj.onmouseout = new Function("ciItemOnMouseOverEffect(false, this)");
		if(notMove != 1)
			divObj.onmousedown = new Function("ciItemOnMouseClick(this.nUniCode)");
		else
			divObj.onmousedown = new Function("ciItemOnMouseClick(this.nUniCode, 1)");
		ciMoveRoomItem(divObj, objPos.l, objPos.b);
		divObj.style.cursor = "hand";
	}
	return divObj
}
function ciRoomItemMoving() {
	if ( !mouseActionObj.bMove || !mouseActionObj.targObj )
		return;
	ciMoveRoomItem(mouseActionObj.targObj, 
							( mouseActionObj.startDivX + event.clientX - mouseActionObj.startX )
							,( mouseActionObj.startDivY - event.clientY + mouseActionObj.startY ));
	return false;
}
function ciRoomItemMoveCenter(nUniCode) {
	var targObj;
	if ( !(targObj = ciGetRoomItemEleObj(nUniCode)) )
		return;
	ciMoveRoomItem(targObj, 
							Math.floor((objAzitRoomBody.clientWidth - targObj.clientWidth)/2),
							Math.floor((objAzitRoomBody.clientHeight - targObj.clientHeight)/2));
}
function ciRoomFocusItemMoveCenter() {
	ciRoomItemMoveCenter(nFocusId);
}
function ciSetSelectData(optObj, text, value) {
	optObj.text = text;
	optObj.value = value;
	
}

function ciRefillListBBSInfo() {
	if ( !objContentInput || !objContentInput.objBBSSelect || !objContentInput.objModeSelect )
		return;
	var strMode = objContentInput.objModeSelect.value, i, optObj;
	if ( !(optObj = objContentInput.objBBSSelect.options) )
		return;
	objContentInput.objBBSSelect.value = "";
	optObj.length = 1;
	if ( !objBBSInfo[strMode] )
		return;
	optObj.length += objBBSInfo[strMode].length;
	for(i=0;i<objBBSInfo[strMode].length;i++)
		ciSetSelectData(optObj[i+1], objBBSInfo[strMode][i].nm, strMode+objBBSInfo[strMode][i].code);
}
function ciInitBBSInfoElement(nm, code) {
	this.nm = nm;
	this.code = code;
}
function ciAddArrayValue(arrObj, value) {
	arrObj[arrObj.length] = value;
}
function ciAddBBSInfo(bAlbum, nm, code) {
	var strMode = ( bAlbum ? "@" : "#" );
	if ( !objBBSInfo[strMode] )
		objBBSInfo[strMode] = new Array();
	ciAddArrayValue(objBBSInfo[strMode], new ciInitBBSInfoElement(nm, code));
}
function ciSaveContentInput() {
	var targObj, strText;
	if ( !objContentInput || !(targObj = ciGetRoomItemObj(objContentInput.nUniCode)) );
	else if ( (strText = subStringByByte(objContentInput.objTextArea.value, 100)) != objContentInput.objTextArea.value ) {
		objContentInput.objTextArea.value = strText;
		alert("...");
	}
	else {
		targObj.Content = objContentInput.objTextArea.value;
		targObj.LinkBBS = ( targObj.Content ? objContentInput.objBBSSelect.value : "" );
		ciHideContentInput();
	}
}
function ciHideContentInput() {
	if ( !objContentInput )
		return;
	objContentInput.nUniCode = false;
	var tbObj = objContentInput.tbObj;
	if ( objContentInput.timeId != -1 ) {
		clearInterval(objContentInput.timeId) 
		objContentInput.timeId = -1;
	}
	tbObj.style.display = "none";
	return 0;
}
function ciFixErrorCalc(value) {
	return value-(value%5);
}
function ciSetContentDivPosition() {
	var targObj, offsetObj, ret, tbObj, tailObj;
	if ( !objContentInput 
		|| !( tbObj = objContentInput.tbObj )
		|| !objContentInput.nUniCode 
		|| !(targObj = ciGetRoomItemEleObj(objContentInput.nUniCode)) )
		return 10;
	offsetObj = ciGetOffsetTop(targObj);
	ret = offsetObj.x + targObj.clientWidth;
	if ( (tailObj = tbObj.childNodes[1]) ) {
		var nTempValue, nTempValue1;
		nTempValue = parseInt(tbObj.currentStyle.width);
		nTempValue1 = ret + nTempValue;
		if (  nTempValue1 > document.body.scrollLeft + document.body.clientWidth ) {
			ret = offsetObj.x - nTempValue;
			tailObj.style.filter = "FLIPH()";
			tailObj.style.left = "";
			tailObj.style.right = "0px";
		}
		else {
			tailObj.style.filter = "";
			tailObj.style.left = "0px";
			tailObj.style.right = "";
		}
	}
	ret = Math.max(ret,5);
	if ( Math.abs(tbObj.style.pixelLeft - ret) > 5 ) 
		tbObj.style.pixelLeft = ret;
	ret = offsetObj.y -55+Math.floor(targObj.clientHeight/2);
	if ( Math.abs(tbObj.style.pixelTop - ret) > 5 )
		tbObj.style.pixelTop = ret;
		
	return ret;
}
function ciRoomFocusItemFlipH() {
	ciRoomItemFlipHRev(nFocusId);
}
function ciRoomItemFlipHRev(nUniCode) {
	var targObj;
	if ( !(targObj = ciGetRoomItemEleObj(nUniCode)) )
		return;
	ciRoomItemFlipH(targObj, ( targObj.style.filter == "" ));
}
function ciBuyItem() {
        ciRoomItemBuy(nFocusId);
}
function ciRoomItemBuy(nUniCode) {
	var targObj;
	if ( !( targObj = ciGetRoomItemObj(nUniCode)) )
		return;
	if(targObj.nCode != 'avata')
	{
		var leftval=new Number(targObj.eleObj.style.pixelLeft)+48;
		var topval=271-new Number(targObj.eleObj.style.pixelBottom);
		var widthval=267;
		var heightval=156;
		var url='z_home_item.asp?itemno='+targObj.nCode;
		var status='scrollbars=no,width='+widthval+',height='+heightval+', left='+leftval+',top='+topval;
    window.open(url, '', status);
	}
	else
	{
		var userName = targObj.strName;
		userName = userName.substr(0,userName.length-("的虚拟形象").length);
		var url='dispuser.asp?name='+userName;
    window.open(url);
	}
}

function ciRestrictEvent() {
	var tmp1 = event;
	var tmp2="INPUT|TEXTAREA".indexOf(event.srcElement.tagName) != -1;
	return ( tmp1 && tmp2);
	//return ( event && "INPUT|TEXTAREA".indexOf(event.srcElement.tagName) != -1 );
}
function ciInitMakeRoomSet(AzitRoomBody, ItemList, ItemListTBody, notMove) {
	if ( !AzitRoomBody )
		return;
	objAzitRoomBody = AzitRoomBody;
	objItemListTBody = ItemListTBody
	objItemList = ItemList;
	// 设定动作
	objAzitRoomBody.onmousemove = ciRoomItemMoving;
	//objAzitRoomBody.onmouseout=ciRoomItemMoveEnd;
	document.onmouseup = ciRoomItemMoveEnd;
	// 禁止鼠标右键
	document.onselectstart = ciRestrictEvent;
	document.ondrag = ciRestrictEvent;
	document.oncontextmenu = ciRestrictEvent;
	//ciAddMyAvata(notMove);
}
function ciMakeTagNode(targWin, strValue) {
	return targWin.document.body.appendChild(targWin.document.createElement(strValue));
}
function ciMakeHiddenInput(targWin, formObj, name, value) {
	var inputObj;
	if ( !(inputObj = formObj[name]) )
		inputObj = formObj.appendChild(ciMakeTagNode(targWin,"<INPUT name="+name+" type=hidden>"));
	inputObj.value = value;
	return inputObj;
}
function ciSetCheckObj(aNode, bCheck) {
	var targObj;
	if ( !(targObj = ciGetCheckObj(aNode)) )
		return;
	targObj.checked = bCheck;
}
function ciGetCheckObj(aNode) {
	return aNode.firstChild.firstChild;
}
function ciGetCheckBoxObj(aNode) {
	var obj = ciGetCheckObj(aNode);
	if ( !obj )
		obj = false;
	else if ( obj.tagName != "INPUT" || obj.style.display != "" )	
		obj = true;
	else
		obj = obj.checked;
	return obj;
}
function ciMakeFormRoomInfo(targWin, formObj, arrItemObj, bCosmetic) {
	var i, beforeAvata, bMine = 0, infoObj, eleObj, n=0;
	for(i=0, beforeAvata = true;i<arrItemObj.length;i++) {
		if ( !(infoObj = arrItemObj[i]) || !(eleObj = infoObj.eleObj) )
			continue;
		if ( infoObj.nAttr == AR_ATTR_AVA )
			beforeAvata = false;
		else if ( !IsDefBg(infoObj) ) {
			if ( beforeAvata && eleObj.nSortLev == AR_LAY_ITEM2 )
				beforeAvata = false;
			ciMakeHiddenInput(targWin, formObj, "ARoomItem"+n+"_nICode", infoObj.nCode);
			ciMakeHiddenInput(targWin, formObj, "ARoomItem"+n+"_nCode", infoObj.nCode);
			ciMakeHiddenInput(targWin, formObj, "ARoomItem"+n+"_nSkill", infoObj.nSkillCode);
			ciMakeHiddenInput(targWin, formObj, "ARoomItem"+n+"_nAttr", infoObj.nAttr);
			ciMakeHiddenInput(targWin, formObj, "ARoomItem"+n+"_nPosX", eleObj.style.pixelLeft);
			ciMakeHiddenInput(targWin, formObj, "ARoomItem"+n+"_nPosY", eleObj.style.pixelBottom);
			ciMakeHiddenInput(targWin, formObj, "ARoomItem"+n+"_bFlip", (eleObj.style.filter == "" ? 0 : 1) );
			ciMakeHiddenInput(targWin, formObj, "ARoomItem"+n+"_refAvata", ( beforeAvata ? 0 : 2 ));
			ciMakeHiddenInput(targWin, formObj, "ARoomItem"+n+"_nPrice", ( infoObj.nCost ? infoObj.nCost : 0 ));
			if ( !bCosmetic ) {
				bMine = ( infoObj.bMine ? 1 : 0 );
				ciMakeHiddenInput(targWin, formObj, "ARoomItem"+n+"_nUnicode", infoObj.nUniCode);
				ciMakeHiddenInput(targWin, formObj, "ARoomItem"+n+"_Content", infoObj.Content);
				ciMakeHiddenInput(targWin, formObj, "ARoomItem"+n+"_RefBBS", infoObj.LinkBBS);
			}
			ciMakeHiddenInput(targWin, formObj, "ARoomItem"+n+"_bMine", bMine);
			n++;
		}
	}
	ciMakeHiddenInput(targWin, formObj, "ARoomTotalItem", n);
}

function ciSaveRoom(scenno)
{
	var aNode, arrItemObj = new Array(), n, infoObj;
	var itemList='';
	if ( typeof(objItemListTBody) != "object" ) return;
  for(aNode = objItemListTBody.lastChild, n=0; aNode; aNode = ciGetSibling(aNode, false) )
  {
    if ( aNode.style.display == "" && ciGetCheckBoxObj(aNode) && aNode.nUniCode
            && (infoObj = ciGetRoomItemObj(aNode.nUniCode))
            && infoObj.eleObj
            && ( !isShop
                    || ( infoObj.eleObj.style.display == ""
                                    && infoObj.eleObj.firstChild
                                    && infoObj.eleObj.firstChild.style.display == "" ) ) )
    {
//alert('unicode='+ aNode.nUniCode+', attr='+ infoObj.nAttr+',itemno='+infoObj.nCode+
//             ',name='+infoObj.strName+',flip='+(infoObj.eleObj.style.filter=="FLIPH()")+
//            ',x='+infoObj.eleObj.style.pixelLeft+',y='+infoObj.eleObj.style.pixelBottom);
			arrItemObj[n++] = infoObj;
			var itemno=infoObj.nCode;
			var unicode=aNode.nUniCode;
			if(infoObj.eleObj.style.filter=="FLIPH()")
				var flip = 1; 
			else
				var flip = 0; 
			var x=infoObj.eleObj.style.pixelLeft;
			var y=infoObj.eleObj.style.pixelBottom;
			
			if(itemno != 0 && itemno != 'avata') 
				itemList = itemList+itemno+'_'+unicode+'_'+flip+'_'+x+'_'+y+'|'
			else if(itemno == 'avata') 
				itemList = itemList+0+'_'+unicode+'_'+flip+'_'+x+'_'+y+'|'
    }
  }
//alert(itemList);
	if(scenno)
	{	
		var url='z_home_save.asp?type='+MODIFY_ITEM+'&scenno='+scenno+'&itemlist='+itemList;
		//window.location = url;
		var savescen = window.open(url,'cart','menubar=no,toolbar=no,location=no,directories=no,status=no,width=530,height=400,left=150,top=100,scrollbars=yes');
	}
	else
	{
		var url='z_home_save.asp?type='+MODIFY_ADDNEW+'&scenno=0&itemlist='+itemList;
		var savescen = window.open(url,'cart','menubar=no,toolbar=no,location=no,directories=no,status=no,width=530,height=400,left=150,top=100,scrollbars=yes');
		//var savescen = window.open(url,'cart','scrollbars=yes,width=513,height=368');
		savescen.focus();
	}
}

function ciChangeARoomSetCode(bPreserv) {
	if ( typeof(SelectRoomSet) == "object" ) 
		ciChangeARoomSet(SelectRoomSet.value, bPreserv);
}

function ciRemoveItemAll(bMine) {
	var prop;
	for ( prop in arrItemObj )
		if ( !IsDefBg(arrItemObj[prop]) && ( !bMine || arrItemObj[prop].bMine ) && arrItemObj[prop].nAttr ) 
			ciRemoveItemCore(prop);
	ciRoomItemMoveCenter(-1);
	ciRecoverBg(0);
}
function ciAzitShopOpenWin(url, w, h) {
	return window.open(url,"","width="+w+",height="+h+",top="+((screen.height-h)/2)+",left="+((screen.width-w)/2)+",resizable=no,scrollbars=no");
}
function ciMakeFormObj() {
	var targWin = ciAzitShopOpenWin("about:blank", 400, 300), formObj;
	targWin.document.open();
	targWin.document.charset = "euc-kr";
	targWin.document.writeln("<HTML><HEAD></HEAD><BODY></BODY><HTML>");
	return targWin;
}
function ciChangeARoomSet(setCode, bPreserv, notMove) {
	var targObj, arrItem;
	if ( typeof(SelectRoomSet) == "object" ) 
		SelectRoomSet.disabled = true;
	if ( !bPreserv )
		ciRemoveItemAll(true);
	if ( (targObj = arrRoomSet[setCode]) ) {
		arrItem = targObj.arrItem;
		for(i=0;i<arrItem.length;i++) 
			if ( targObj.bMine )
				ciMakeNewItemElement(arrItem[i].nUniCode, arrItem[i].nCode, arrItem[i].nAttrib, arrItem[i].nSkillCode, arrItem[i].strName, true, arrItem[i].refAvata, arrItem[i].bFlip, arrItem[i].PosX, arrItem[i].PosY, arrItem[i].Content, arrItem[i].LinkBBS);
			else
				ciAddRoomItem(arrItem[i].nCode, arrItem[i].nAttrib, arrItem[i].strName, arrItem[i].nSkillCode, arrItem[i].nCost, arrItem[i].nWhereCode, arrItem[i].refAvata, arrItem[i].bFlip, arrItem[i].PosX, arrItem[i].PosY, arrItem[i].Content, arrItem[i].LinkBBS);
	}
	if ( typeof(SelectRoomSet) == "object" ) 
		SelectRoomSet.disabled = false;
}
function ciSetNewRoomSet() {
	if ( typeof(SelectRoomSet) == "object" ) {
		SelectRoomSet.value = 0;
		if ( SelectRoomSet.onchange )
			SelectRoomSet.onchange(0);
	}
}

/*
function ciAddARoomSetRefItem(nSetCode, nUniCode, nCode, nAttrib, nSkillCode, strName, posX, posY, bFlip, refAvata, Content, LinkBBS) {
	ciAddARoomSetRefItemCore(nSetCode, nUniCode, nCode, nAttrib, nSkillCode, strName, posX, posY, bFlip, refAvata, 0, Content, LinkBBS, 0);
}
function ciAddARoomSetRefItemCore(nSetCode, nUniCode, nCode, nAttrib, nSkillCode, strName, posX, posY, bFlip, refAvata, nPrice, Content, LinkBBS, nWhereCode) {
	var tartObj, idx;
	if ( !(tartObj = arrRoomSet[nSetCode]) )
		return;
	idx = tartObj.arrItem.length;
	tartObj.arrItem[idx] = new ciMakRoomSetRefItem(nUniCode, nCode, nAttrib, nSkillCode, strName, posX, posY, bFlip, refAvata, 0, Content, LinkBBS, nWhereCode);
}

function ciInitRoomSetObj(setCode, name, bMine) {
	this.setCode = setCode;
	this.name = name;
	this.bMine = bMine;
	this.arrItem = new Array();
}
function ciMakRoomSetRefItem(nUniCode, nCode, nAttrib, nSkillCode, strName, posX, posY, bFlip, refAvata, nCost, Content, LinkBBS, nWhereCode) {
	this.nUniCode = nUniCode;
	this.nCode = nCode;
	this.nAttrib = nAttrib;
	this.nSkillCode = nSkillCode;
	this.strName = strName;
	this.PosX = posX;
	this.PosY = posY;
	this.bFlip = bFlip;
	this.refAvata = refAvata;
	this.nCost = nCost;
	this.Content = Content;
	this.LinkBBS = LinkBBS;
	this.nWhereCode = nWhereCode;
}
function ciAddRoomSet(code, name, bMine, bCheck) {
	if ( !arrRoomSet[code] )
		arrRoomSet[code] = new ciInitRoomSetObj(code, name, bMine);
	if ( bMine && typeof(SelectRoomSet) == "object" && SelectRoomSet.options ) {
		var nIdx = SelectRoomSet.options.length++;
		SelectRoomSet.options[nIdx].value = code;
		SelectRoomSet.options[nIdx].text = name;
		if ( !SelectRoomSet.onchange )
			SelectRoomSet.onchange=new Function("ciChangeARoomSet(this.value)");
		if ( bCheck ) 
			SelectRoomSet.value = code;
	}
}
*/

UCODE_MYAVATA = -1;
UCODE_WALL = -2;
UCODE_FLOOR = -3;

DEF_LISTIMG = "images/img_home/arrow.gif";
DEF_LISTIMG_WIDTH = 30;
ItemCanMove = true;

saveFormObj = false;
strCookieMyAvata = false;
objContentInput = objItemList = objAzitRoomBody = objItemListTBody = false
arrRoomSet = new Object();
objAvataDiv = objAvataTr = false;
mouseActionObj = new ciInitMouseActionObj();
objBBSInfo = new Object();
nItemCnt = 0;
isShop = false;
objLastObjTarget = false;

MODIFY_ADDNEW = 0;
MODIFY_ITEM = 1;
MODIFY_NAME = 2;
MODIFY_OPEN = 3;
MODIFY_DEFAULT = 4;
MODIFY_DELETE = 5;
MODIFY_PHOTO = 6;
MODIFY_PUT = 7;
HCLOSE = 0;	
HOPEN = 1;	

function IsBgLayer(sortLev) {
	return ( sortLev < AR_LAY_EVNT1 );
}
function IsSkinItem(nAttrib) {
	return ( nAttrib > AR_ATTR_AVA && nAttrib < AR_ATTR_FLOR );
}
function IsString(varA) {	
	return ( typeof(varA) == "string" )
}
function ciRemoveComma(strA) {
	if ( IsString(strA) )
		strA = strA.replace(/[,]/g,"");
	if ( isNaN(strA = Number(strA)) )
		strA = 0;
	return strA;
}	
function ciGetSibling(targObj, bNext) {
	var ret = targObj, strAttr = ( bNext ? "nextSibling" : "previousSibling" );
	if ( ret )
		while((ret = ret[strAttr]) && ret.style.display != "" );
	return ret;
}
function ciItemDelete(bBg, targObj) {
	if ( !targObj || typeof(targObj) != "object" )
		return;
	else {
		targObj.title = targObj.style.cursor = targObj.style.filter = "";
		targObj.style.display = 'none';
		
		if ( targObj.firstChild && targObj.firstChild.tagName == "IMG" ) {
			targObj.firstChild.style.display = 'none';
			ciDeleteDisplayOpt(targObj.firstChild);
		}
	}
}
function ciStackPopObj(objStack, bPop, element) {
	if ( objStack ) {
		var nIdx = objStack.length;
		if ( bPop && !element && nIdx > 0 ) {
			element = objStack[--nIdx];
			objStack.length = nIdx;
		}
		else if ( !bPop && element ) 
			objStack[nIdx] = element;
	}
	return element;
}
function ciStackNullTrObj(bPop, trObj) {
	return ciStackPopObj(arrNullTr, bPop, trObj);
}
function ciStackNullEleObj(bPop, trObj) {
	return ciStackPopObj(arrNullEle, bPop, trObj);
}
function ciRemoveItemCore(nUniCode) {
	var targObj, nCurFocusCode = -1, bHide, sNode;
	if ( !(targObj = ciGetRoomItemObj(nUniCode)) || !targObj.nAttr )
		return false;
	delete arrItemObj[nUniCode];
	ciSumnTotalCost(-1, targObj);
	if ( !(bBg = IsBgAttribute(targObj.nAttr)) ) {
		ciStackNullTrObj(false, targObj.trObj);	
		ciStackNullEleObj(false, targObj.eleObj);	
	}
	ciItemDelete(bBg, targObj.eleObj);
	ciItemDelete(bBg, targObj.trObj);	
	return true;
}
function ciChkBgShow(nAttr) {
	return ( arrFixItemObj[nAttr] && arrFixItemObj[nAttr].eleObj.style.display == "" );
}
function ciRmoveItemBySortLev(nAttr, nReservUniCode) {
	var nUniCode, nReservLev = AR_LAY_BGIMG-1, ret = false;
	switch(nAttr) {
	case AR_ATTR_FLOR:
		nReservLev++;
	case AR_ATTR_WALL:
		nReservLev++;
	case AR_ATTR_SPEC:
		break;
	}
	for(nUniCode in arrItemObj) {
		if ( nReservUniCode == nUniCode || !arrItemObj[nUniCode] || !IsBgLayer(arrItemObj[nUniCode].nSortLev) || arrItemObj[nUniCode].nSortLev == nReservLev )
			continue;
		ciRemoveItemCore(nUniCode);
	}
	return ret;
}
function ciMakeItemInfoObjNull() {
	this.nUniCode = 0;
	this.nCode = 0;
	this.nAttr = 0;
	this.nSkillCode = 0;
	this.strName = 0;
	this.eleObj = false;
	this.bMine = false;
	this.Content = "";
	this.LinkBBS = "";
}
function ciUndefined2NullStr(strA) {
	return ( strA ? strA : "" );
}
function ciUpdateItemInfoObj(infoObj, nUniCode, nCode, nAttr, nSkillCode, strName, bMine, Content, LinkBBS) {
	if ( infoObj ) {
		infoObj.nUniCode = nUniCode;
		infoObj.nCode = nCode;
		infoObj.nAttr = nAttr;
		infoObj.nSkillCode = Number(nSkillCode);
		if ( isNaN(infoObj.nSkillCode) )
			infoObj.nSkillCode = 0;
		infoObj.strName = strName;
		infoObj.bMine = bMine;
		infoObj.Content = ciUndefined2NullStr(Content);
		infoObj.LinkBBS = ciUndefined2NullStr(LinkBBS);
	}
	return infoObj;
}
function ciMakeItemInfoObjCore(nUniCode, nCode, nAttr, nSkillCode, strName, bMine, Content, LinkBBS) {
	return ciUpdateItemInfoObj(( arrItemObj[nUniCode] ? arrItemObj[nUniCode] : new ciMakeItemInfoObjNull()) , nUniCode, nCode, nAttr, nSkillCode, strName, bMine, Content, LinkBBS);
}
function IsBgAttribute(nAttr)  {
	return ( nAttr > AR_ATTR_AVA && nAttr < AR_ATTR_ITEM );
}
function IsRoomItem(nAttr) {
	return ( nAttr >= AR_ATTR_ITEM && nAttr < AR_ATTR_SKIN );
}
function ciGetOffsetTop(cObj) {
	var ret;
	if ( !cObj || cObj == document.documentElement ) {
		ret = new Object();
		ret.x = 0;
		ret.y = 0;
	}
	else {
		ret = ciGetOffsetTop(cObj.offsetParent);
		ret.x += cObj.offsetLeft;
		ret.y += cObj.offsetTop;
	}
	return ret;
}

function ciGetItemImgUrl(nCode, nAttr, bDp) {
	//如果是地面，默认code=3
        if(nAttr == AR_ATTR_FLOR && nCode == 0)
                nCode = 3;
	//如果是墙，默认code=2
        if(nAttr == AR_ATTR_WALL && nCode == 0)
                nCode = 2;

	if(localPic==1) {
		var tmpSrc = ("0000"+nCode);
		tmpSrc = picPath + "1/"+tmpSrc.substring(tmpSrc.length-4,tmpSrc.length)+".gif";
	} else {
		var tmpSrc = picPath + nCode+"/01/00/";
	}
//alert(tmpSrc)
	return tmpSrc;
}

function ciSetARoomItemClsName(eleObj, clsName) {
	if ( !clsName )
		clsName = "divAzitRoomElement"
	eleObj.className = clsName;
	return eleObj;
}

function ciDeleteDisplayOpt(imgObj) {
	if ( imgObj )
		imgObj.onload = imgObj.onerror = NULLFUNC;
}


//给该图片赋属性值
function ciItemImgSrcSet(imgObj, src) {
	if ( !imgObj )
		return;
	imgObj.onload = imgObj.onerror = ciItemDisplay;
	imgObj.src = src;
	imgObj.galleryImg = "no";
}

//当显示图片
function ciItemDisplay() {
	var imgObj = event.srcElement;
	imgObj.onload = imgObj.onerror = NULLFUNC;
	imgObj.style.display = "";
}

//得到家具图片放入房间
function ciGetItemImgDiv(eleObj, nUniCode, nCode, nAttr, clsName) {
	if ( !eleObj && !(eleObj = ciStackNullEleObj(true)) )
		eleObj = ciMakNullARoomItem();
	eleObj.nUniCode = nUniCode;
	ciItemImgSrcSet(eleObj.firstChild, ciGetItemImgUrl(nCode, nAttr));
	ciSetARoomItemClsName(eleObj,clsName);
	eleObj.style.display = "";
	return eleObj;
}
function ciMakNullARoomItem(cNode) {
	if ( !cNode ) 
		cNode = makeTagNode("IMG");
	var objDiv = makeTagNode("DIV");
	objDiv.appendChild(cNode);
	return objDiv;
}
function ciMakeAvataDiv(nUniCode, arrCharInfo) {
	var ret = ciSetARoomItemClsName(ciMakNullARoomItem(makeNodeAllChar(arrCharInfo)));	
	ret.nUniCode = nUniCode;
	return ret;
}
function ciMakeItemImgDiv(nUniCode, nCode, nAttr, clsName) {
	return ciMakeRoomItemElement(nUniCode, makeImgNode(ciGetItemImgUrl(nCode, nAttr)), clsName);
}
function ciMakeItemInfoObj(nUniCode, nCode, nAttr, nSkillCode, strName, bMine, Content, LinkBBS) {
	nAttr = ciRemoveComma(nAttr);
	var ret = ciMakeItemInfoObjCore(nUniCode, nCode, nAttr, nSkillCode, strName, bMine, Content, LinkBBS);

	if ( IsBgAttribute(nAttr) ) { //是背景
		if ( arrFixItemObj[nAttr] ) {
			ret.eleObj = arrFixItemObj[nAttr].eleObj;
			arrFixItemObj[nAttr].eleObj = false;
			ret.trObj = arrFixItemObj[nAttr].trObj;
			arrFixItemObj[nAttr].trObj = false;
		}
		arrFixItemObj[nAttr] = ret;
	}
	var n = 0;
	switch(nAttr) {
	case AR_ATTR_AVA:
		if ( !ret.eleObj )
			ret.eleObj = ciMakeAvataDiv(nUniCode, nSkillCode);
		//ret.nSkillCode = 0;
		ret.nSortLev = AR_LAY_AVATA;
		ret.eleObj.title = strName;
		break;
	case AR_ATTR_SPEC:
		n++;
	case AR_ATTR_WALL:
		n++;
	case AR_ATTR_FLOR:
		ciRmoveItemBySortLev(ret.nAttr, nUniCode);
		ret.eleObj = ciGetItemImgDiv(ret.eleObj, nUniCode, nCode, nAttr, "divAzitRoomBgElement");
		ret.nSortLev = AR_LAY_BGIMG + n;
		break;
	default:
		if ( !IsRoomItem(nAttr) )
			return;
		ret.eleObj = ciGetItemImgDiv(ret.eleObj, nUniCode, nCode, nAttr, false);
		ret.nSortLev = AR_LAY_ITEM1;
		ret.eleObj.title = strName;
		break;
	}
	//ret.eleObj.title = strName;
	ret.eleObj.nSortLev = ret.nSortLev;
	return (arrItemObj[nUniCode] = ret);
}
function ciMoveRoomItem(divObj, l, b) {
	if ( !divObj )
		return;
	divObj.style.pixelLeft = l;
	divObj.style.pixelBottom = b;
}
function ciAddOrInsertDiv(pDiv, cDiv, sDiv) {
	if ( ISObject(cDiv) ) {
		if ( !sDiv && pDiv.lastChild != cDiv ) 
			pDiv.appendChild(cDiv);
		else if ( sDiv && cDiv != sDiv && cDiv.nextSibling != sDiv ) 
			pDiv.insertBefore(cDiv, sDiv);
	}
	return cDiv;
}
function ciRoomItemFlipH(targObj, bFlip) {
	if ( targObj )
		targObj.style.filter = ( bFlip ? "FLIPH()" : "" );
}
function ciDisableEvent() {
	if ( typeof(event) == "object" && event ) {
		event.cancelBubble = true;
		event.returnValue = 0;
	}
	return false;
}
function ciGetRandomPosition() {
	var ret = new Object();
	ret.l = 460*Math.random();
	ret.b = 280*Math.random();
	return ret;	
}
function ciGetAbsolutePosition(PosX, PosY) {
	var ret = new Object();
	ret.l = PosX;
	ret.b = PosY;
	return ret;	
}
function ciIsChild(pObj, sObj) {
	var ret = false;
	while(  !(ret = ( sObj == pObj ))
		&& sObj
		&& (sObj = sObj.parentNode) 
		&& (sObj != document.documentElement) );
	return ret;
}
function ciStricmp(strA, strB) {
	strA = strA.toUpperCase();
	strB = strB.toUpperCase();
	if ( strA == strB )
		return 0;
	else if ( strA < strB )
		return -1;
	else 
		return 1;
}
function ciDupeObj(orgObj) {
	var ret = new Object(), prop;
	for(prop in orgObj)
		ret[prop] = orgObj[prop];
	return ret;
}
function ciGetToInt(strValue) {
	var ret = 0;
	if ( !isNaN(strValue) )
		ret = Number(strValue);
	return ret;
}
function ciGetDivLevel(targObj) {
	return ciGetToInt(targObj.nSortLev);
}
function ciRoomBodyPosition() {
	//var ret = ciGetOffsetTop(divAzitRoomBody);
	var ret = new Object();
	ret.x = 59;
	ret.y = 65;
	offsetObj = ret;
}
arrNullTr = new Array();
arrNullEle = new Array();
nFocusId = -1;
arrItemObj = new Object();
arrFixItemObj = new Object();
NULLFUNC = new Function("return")
	

//层设定
AR_LAY_MSBTM = 0; // 最下端
AR_LAY_BGIMG	= 5; // 背景
AR_LAY_EVNT1 = 10; // event 1
AR_LAY_ITEM1 = 15; // 小东东1（出现在avatar后）
AR_LAY_AVATA = 20; // avatar
AR_LAY_ITEM2 = 25; // 小东东2（出现在avatar前）
AR_LAY_EVNT2 = 30; // event2
AR_LAY_TALKB = 35; // 对话气球泡泡
AR_LAY_EVNT3 = 40; // event3
AR_LAY_MSTOP = 45; // 最上端

// 属性attr
AR_ATTR_AVA	 = 0; // avatar
AR_ATTR_FLOR = 11; // 地板
AR_ATTR_WALL = 12; // 墙
AR_ATTR_SPEC = 13; // 特殊背景
AR_ATTR_MOVE = 15; // 可移动的（能移动的）最小大小
AR_ATTR_ITEM = 16; // 一般item
AR_ATTR_GAME = 99; // 游戏
AR_ATTR_SKIN = 101;

AR_SKILL_GAME = 0x01;


function ciCheckAllBox(bCheck) {
	var arrInput = (chkboxItem.length ? chkboxItem : new Array(chkboxItem)), i;
	for(i=0;i<arrInput.length;i++)
		arrInput[i].checked = bCheck;
}
function ciGetCheckBoxObjChecked(aNode) {
	var obj = ciGetCheckObj(aNode);
	if ( !obj || obj.tagName != "INPUT" || obj.style.display != "" )	
		obj = false;
	else
		obj = obj.checked;
	return obj;
}
function ciGetCntItemCheck() {
	var ret = 0;
	if ( objItemListTBody ) 
		for(aNode = objItemListTBody.lastChild; aNode; aNode = ciGetSibling(aNode, false) ) 
			if ( aNode.style.display == "" && ciGetCheckBoxObjChecked(aNode) )
				ret++;
	return ret;
}
function ciSaveSetRoomAll(scenno) {
	ciCheckAllBox(true);	
	ciSaveSetRoomPart(scenno);
}
function ciSaveSetRoomPart(scenno) {
	var targWin;
	//if ( nItemCnt > 0 && ciGetCntItemCheck() > 0 ) 
	if ( ciGetCntItemCheck() > 0 ) 
	{
		ciSaveRoom(scenno);
	}
	else 
		alert("请先装扮好再保存！");
}
function ciGetSerialCode() {
	while(ciGetRoomItemObj(nItemSerialCode) && --nItemSerialCode );
	return nItemSerialCode;
}
function ciSumnTotalCost(sign , objItemInfo) {
	if ( objItemInfo.bMine || isNaN(objItemInfo.nCost) )
		return;
	nItemCnt += sign;
	nTotalCost += sign * objItemInfo.nCost;
var nTotalQBCost = nTotalCost;
	if ( typeof(spanCashView) == "object" )
		spanCashView.innerText = nTotalQBCost;
	if ( typeof(spanCntView) == "object" )
		spanCntView.innerText = nItemCnt;
}
function ciMakeArray(strA, strSep) {
	if ( typeof(strA) != "string" )
		strA = strA.toString();
	return ( strA.indexOf(strSep) != -1 ? strA.split(strSep) : new Array(strA) );
}
function ciAddRoomItem(nCode, nSkillCode, strName, nCost, nAttrib, bFlip, PosX, PosY, refAvata, Content, LinkBBS, notMove) {
	if ( isNaN(nCode = Number(nCode)) 
			|| isNaN(nAttrib = Number(nAttrib))  
			|| !strName
			|| isNaN(nSkillCode = Number(nSkillCode))  
			|| isNaN(nCost = Number(nCost))  )
		return;
	ciMakeNewItemElement(ciGetSerialCode(), nCode, nAttrib, nSkillCode, strName, false, refAvata, bFlip, PosX, PosY, Content, LinkBBS, ciRemoveComma(nCost), notMove);
}
function ciAddRoomItemShop(nCode, nSkillCode, strName, nCost, nAttrib, bFlip, PosX, PosY, notMove) 
{
	if ( typeof(nAttrib) == "number" && nAttrib == AR_ATTR_SKIN )  //皮肤item
	{
		//这里打开的是皮肤的预览
		skinprv =window.open(ciGetItemImgUrl(nCode, nAttrib),"skinprv","menubar=no,toolbar=no,location=no,directories=no,status=no,width=1000,height=700,left=5,top=5,scrollbars=no");
		skinprv.focus();
		return ;
	}

	else if ( typeof(nAttrib) == "number" && nAttrib < 10 ) 
		return;
	else {
		//alert('nAttrib [' + nAttrib + ']');
		var strSep = "|", i;
		var arrCode, arrSkillCode, arrName, arrCost, arrAttrib;
		arrCode = ciMakeArray(nCode, strSep);
		arrSkillCode = ciMakeArray(nSkillCode, strSep);
		arrName = ciMakeArray(strName, strSep);
		arrCost = ciMakeArray(nCost, strSep);
		arrAttrib = ciMakeArray(nAttrib, strSep);
		if ( arrCode.length == arrSkillCode.length 
				&& arrCode.length == arrName.length 
				&& arrCode.length == arrCost.length 
				&& arrCode.length == arrAttrib.length )
		{
			var refAvata, Content, LinkBBS;
			for(i=0;i<arrCode.length;i++) 
				ciAddRoomItem(arrCode[i], arrSkillCode[i], arrName[i], arrCost[i], arrAttrib[i], bFlip, PosX, PosY, refAvata, Content, LinkBBS, notMove);
		}
		else
			alert("..");
	}
}
nItemSerialCode = -10;
nTotalCost = 0;
