/******************************************************************************
* Cookie functions.                                                           *
******************************************************************************/

function setCookie (name, value) {

  document.cookie = name + "=" + value + "; path=" + cookiePath;
}

function getCookie(name) {

  var search;

  search = name + "="
  offset = document.cookie.indexOf(search) 
  if (offset != -1) {
    offset += search.length ;
    end = document.cookie.indexOf(";", offset) ;
    if (end == -1)
      end = document.cookie.length;
    return unescape(document.cookie.substring(offset, end));
  }
  else
    return "";
}

function deleteCookie(name) {

  setCookie(name, "");
}

/******************************************************************************
* End of cookie functions.                                                    *
******************************************************************************/


/*******************************
 * 打开购物车页面
 *******************************/
function openCart() 
{
   var url="z_home_cartbag.asp"
   var cart;
   cart =window.open(url,"cart","menubar=no,toolbar=no,location=no,directories=no,status=no,width=530,height=400,left=150,top=100,scrollbars=yes");
   cart.focus();
}

function ConvStr(srcStr, desDelim, srcDelim)
{
	var tmpStr = new String(srcStr);
	var tmpArray = tmpStr.split(srcDelim);
	var tmp='';
	for(var i=0;i<tmpArray.length;i++)
	{
		if(i == 0)
			tmp += tmpArray[i];
		else
			tmp += desDelim+tmpArray[i];
	}
	
	return tmp;
}

function OpenHome(uin)
{
	if (window.screen)
	{
	var sw = screen.width;
	if(sw<835)
	{
	if(new Number(uin) == 0) //开自己的家园
	{
		var url='/home/';
		var home =window.open(url,"home","menubar=no,toolbar=no,location=no,directories=no,status=no,width=760,height=500,left=0,top=0,scrollbars=yes");
		home.focus();
		return; 
	}
	//开别人的家园
	var url='/home/?uin='+uin;
	var home =window.open(url,"","menubar=no,toolbar=no,location=no,directories=no,status=no,width=760,height=500,left=0,top=0,scrollbars=yes");
	home.focus();
	return; 
	}
	if(sw>=835)
	{
		if(new Number(uin) == 0) //开自己的家园
	{
		var url='/home/';
		var home =window.open(url,"home","menubar=no,toolbar=no,location=no,directories=no,status=no,width=1000,height=700,left=0,top=0,scrollbars=auto");
		home.focus();
		return; 
	}
	//开别人的家园
	var url='/home/?uin='+uin;
	var home =window.open(url,"","menubar=no,toolbar=no,location=no,directories=no,status=no,width=1000,height=700,left=0,top=0,scrollbars=auto");
	home.focus();
	return; 
	}
	}
}

function changeSkin(itemno)
{
	if(itemno <= 0)
		itemno = 1; //默认皮肤的itemno=1

	if(localPic==1) {
		var url=("0000"+itemno);
		url=picPath + '1/'+url.substring(url.length-4,url.length)+'.gif';
	} else {
		var url=picPath + itemno+'/01/00/';
	}	
		
	top.document.body.background=url;
	return false;
}

function loadScenario0(notSkip, notMove)
{
	ciAddMyAvata(notMove);
	ciRemoveItemAll();
}
function selScen()
{
	var scenno=document.all.scenlist.options[document.all.scenlist.selectedIndex].value;
	if(scenno == 0)
		ciRemoveItemAll();
	else
		eval('loadScenario'+scenno+'();');
}
function newScen()
{
	//ciRemoveItemAll();
	//document.all.scenlist.options[0].selected = true;
	document.URL='z_home.asp';
}
function renameScen()
{
	var scenno=document.all.scenlist.options[document.all.scenlist.selectedIndex].value;
	if(scenno == 0)
		return ;
	else
	{
		var url='z_home_save.asp?type='+MODIFY_NAME+'&scenno='+scenno;
		rename=window.open(url,'rename','menubar=no,toolbar=no,location=no,directories=no,status=no,width=530,height=400,left=150,top=100,scrollbars=yes');
		rename.focus();
	}		
}
function delScen()
{
	var scenno=document.all.scenlist.options[document.all.scenlist.selectedIndex].value;
	if(scenno == 0)
		return ;
	else
	{
		var conf=confirm('确定要删除吗？');
		if(!conf)
			return ;
		var url='z_home_save.asp?type='+MODIFY_DELETE+'&scenno='+scenno;
		deletescen=window.open(url,'deletescen','menubar=no,toolbar=no,location=no,directories=no,status=no,width=530,height=400,left=150,top=100,scrollbars=yes');
		deletescen.focus();
	}		
}

function saveScen()
{
	var scenno=document.all.scenlist.options[document.all.scenlist.selectedIndex].value;
	if(scenno == 0)
		ciSaveSetRoomAll(0);
	else
	{
		var conf=confirm('确定要修改吗？');
			if(!conf)
				return ;
		ciSaveSetRoomAll(scenno);
	}		
}

function setDefault()
{
	var scenno=document.all.scenlist.options[document.all.scenlist.selectedIndex].value;
	if(scenno == 0)
	{
		alert("请先保存再设置优先显示！");
		return ;
	}
	else
	{
		var conf=confirm('确定要优先显示该方案吗？');
		if(!conf)
			return ;
		var url='z_home_save.asp?type='+MODIFY_DEFAULT+'&scenno='+scenno;
		defaultscen=window.open(url,'defaultscen','menubar=no,toolbar=no,location=no,directories=no,status=no,width=530,height=400,left=150,top=100,scrollbars=yes');
		defaultscen.focus();
	}		
}

function setOpen()
{
	var scenno=document.all.scenlist.options[document.all.scenlist.selectedIndex].value;
	if(scenno == 0)
	{
		alert("请先保存再设置开放/非开放！");
		return ;
	}
	else
	{
		if(curOpen == 0)
			var conf='确定要设置为开放吗？';
		else
			var conf='确定要设置为关闭吗？';
		var confret = confirm(conf);
		if(!confret)
			return ;
		if(curOpen == 0)
			var open = HOPEN;
		else
			var open = HCLOSE;
			
		var url='z_home_save.asp?type='+MODIFY_OPEN+'&scenno='+scenno+'&open='+open;
		openscen=window.open(url,'openscen','menubar=no,toolbar=no,location=no,directories=no,status=no,width=530,height=400,left=150,top=100,scrollbars=yes');
		openscen.focus();
	}		
}
function photoScen()
{
var scenno=document.all.scenlist.options[document.all.scenlist.selectedIndex].value;
if(scenno == 0)
{
  alert("请先保存再设置拍照！");
  return ;
}
else
{
  var url='z_home_save.asp?type='+MODIFY_PHOTO+'&scenno='+scenno;
  photoscen=window.open(url,'photoscen','menubar=no,toolbar=no,location=no,directories=no,status=no,width=530,height=400,left=150,top=100,scrollbars=yes');
  photoscen.focus();
}  
}


function stealScen(stolenItemList)
{
	if ( stolenItemList !="" && stolenItemList.indexOf("|") && stolenItemList.indexOf("_")) {
		var url='z_home_save.asp?type='+MODIFY_ADDNEW+'&scenno=0&itemlist='+stolenItemList;
		var stealscen = window.open(url,'cart','menubar=no,toolbar=no,location=no,directories=no,status=no,width=530,height=400,left=150,top=100,scrollbars=yes');
		stealscen.focus();
	}
}
function putScen()
{
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 == "" && aNode.nUniCode
            && (infoObj = ciGetRoomItemObj(aNode.nUniCode))
            && infoObj.eleObj
            && ( !isShop
      || ( infoObj.eleObj.style.display == ""
      && infoObj.eleObj.firstChild
      && infoObj.eleObj.firstChild.style.display == "" ) ) )
    {
   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+'|'
    }
  }
var url='z_home_save.asp?type='+MODIFY_PUT+'&scenno=0&itemlist='+itemList;
var putscen = window.open(url,'putscen','menubar=no,toolbar=no,location=no,directories=no,status=no,width=530,height=400,left=150,top=100,scrollbars=yes');
putscen.focus();
}


