function funcUse(id, useAction, personal, iname)
{
	if(useAction == 'wear')
	{
		if(personal == 1)
		{
			if(confirm("Вы действительно хотите одеть именную вещь?\nПосле одевания вещь нельзя будет больше передать."))
				window.top.main.mainpanel.ref_inv.location.href="ref_inv.php?wear=" + id;
		}
		else
		{
			window.top.main.mainpanel.ref_inv.location.href="ref_inv.php?wear=" + id;
		}
	}
	else if(useAction == 'unwear')
	{
		window.top.main.mainpanel.ref_inv.location.href="ref_inv.php?unwear=" + id;
	}
	else if(useAction == 'auction')
	{
		//if(parent.frames['auction_add_lot'])
			//alert(parent.frames['auction_add_lot']);
		window.parent.auction_add_lot.location.href="auction_add_lot.php?add_item=" + id;
		//parent.frames['auction_add_lot'].location.href="auction_add_lot.php?add_item=" + id;
	}
	else if(useAction == 'add_to_present')
	{
		window.parent.form.present_item_id.value = id;
		window.parent.present_item_id_str.innerHTML = iname;
	//	window.parent.getElementById("present_item_id_str").innerHTML = iname;
	}
	else if(useAction == 'open_present')
	{
		if(confirm('Вы действительно хотите открыть подарок?'))
		{
			location.href="info_user.php?name=" + iname + "&open_present=" + id;
		}
	}
	else if(useAction == 'heal')
	{
		location.href="item_heal.php?heal_wound=" + id;
	}
	else
	{}
}

function funcInfo(id)
{
	window.open('info_item.php?itemId='+id,id,'width=700,height=550,resizable=yes,scrollbars=yes');
}

function funcDrop(id)
{
	if(confirm('Вы действительно хотите выбросить эту вещь?'))
	{
		window.top.main.mainpanel.ref_inv.location.href="ref_inv.php?drop=" + id;
	}
}

function funcQuote(id)
{
	window.top.chat_menu.insertItem(id);
}

var ItemTypeStr =
{
"0": "",
"1":"Шлем",
"2":"Одежда&nbsp;(Верх)",
"3":"Одежда&nbsp;(Низ)",
"4":"Браслет",
"5":"Пояс",
"6":"Обувь",
"7":"Амулет",
"8":"Оружие",

"9":"Щит",
"9.100":"Оружие&nbsp;(Вместо&nbsp;Щита)",

"10":"Кольцо",
"11":"Перчатки",
"12":"Нижняя&nbsp;Одежда",
"13":"Оберег",
"14":"Наплечники",
"15":"Серьги",
"30":"Боевой&nbsp;Свиток",
"40":"Вещь&nbsp;на&nbsp;Продажу",

"50":"Ресурс",
"50.1":"Ископаемое",
"50.51":"Материал (Камень)",
"50.52":"Материал (Шкура)",
"50.53":"Материал (Кожа)",
"50.54":"Материал (Кость)",
"50.55":"Материал (Метал)",
"50.56":"Материал (Древесина)",
"50.57":"Материал (Маг. Металл)",
"50.59":"Материал (Драг. Металл)",
"50.60":"Материал (Ткань)",
"50.61":"Материал (Драг. Сплав)",
"50.62":"Материал (Сплав)",

"60":"Рецепт",
"70":"Подарок",
"74":"Еда",
"75":"Лекарство",
"84":"Эликсиры",
"80":"Зелье",
"81":"Свиток",
"82":"Книга",
"82.1":"Регистрационная Книга",
"83":"Свиток",
"84":"Эликсир",
"85":"Сундук",
"86":"Ключ",
"err":"<font color=ff0000>(error_type)</font>"};

function ConvertItemTypeToStr(_type, subtype)
{
   return ItemTypeStr[_type + '.' + subtype] || ItemTypeStr[_type] || ItemTypeStr['err'];
}


function ConvertStatCodeToString(code)
{
	if(code == "hp")
		return "Жизнь";
	else if(code == "mana")
		return "Мана";

	else if(code == "crit")
		return "Критический&nbsp;Удар";
	else if(code == "dodge")
		return "Уворот";
	else if(code == "block")
		return "Блок";

	else if(code == "defence_poison")
		return "Защита&nbsp;от&nbsp;Яда";

	else if(code == "luck")
		return "Удача";
	else if(code == "luck")
		return "Удача";
	else if(code == "speed")
		return "Скорость";
	else if(code == "karma")
		return "Карма";
	else if(code == "lie")
		return "Обман";
	else if(code == "speek")
		return "Красноречие";
	else if(code == "steal")
		return "Воровство";
	else if(code == "crack")
		return "Взлом";

	else if(code == "knockback")
		return "Ответный&nbsp;Удар";

	else if(code == "quality")
		return "Качество";

	else if(code == "damage_troopers")
		return "Атака&nbsp;Пехоты";
	else if(code == "damage_horses")
		return "Атака&nbsp;Всадников";
	else if(code == "damage_rangers")
		return "Атака&nbsp;Стрелков";
	else if(code == "damage_all")
		return "Атака&nbsp;Всех";

	else if(code == "damage_light")
		return "Атака&nbsp;Света";
	else if(code == "damage_dark")
		return "Атака&nbsp;Тьмы";

	else if(code == "damage_fire")
		return "Атака&nbsp;Огня";
	else if(code == "damage_water")
		return "Атака&nbsp;Воды";
	else if(code == "damage_sky")
		return "Атака&nbsp;Воздуха";
	else if(code == "damage_earth")
		return "Атака&nbsp;Земли";


	else if(code == "defence_troopers")
		return "Защита&nbsp;Пехоты";
	else if(code == "defence_horses")
		return "Защита&nbsp;Всадников";
	else if(code == "defence_rangers")
		return "Защита&nbsp;Стрелков";
	else if(code == "defence_all")
		return "Защита&nbsp;Всех";

	else if(code == "defence_light")
		return "Защита&nbsp;от&nbsp;Света";
	else if(code == "defence_dark")
		return "Защита&nbsp;от&nbsp;Тьмы";


	else if(code == "mining")
		return "Шахтерство";
	else if(code == "hunting")
		return "Охота";
	else if(code == "bomj")
		return "Попрошайка";
	else if(code == "searching")
		return "Собирательство";
	else if(code == "finding")
		return "Археология";
	else if(code == "farming")
		return "Фермерство";
	else if(code == "fishing")
		return "Рыбалка";
	else if(code == "wooding")
		return "Дровосек";
	else if(code == "training")
		return "Тренировка";
	else if(code == "building")
		return "Строительство";
	else if(code == "lumbering")
		return "Навык&nbsp;Лесоруба";


	else if(code == "conc")
		return "Концентрация";

	return code;
}

var itemSortMenus =
{
"root": [["filter=all", "Все"],
        ["filter=items", "Вещи", "items"],
        ["filter=resources", "Ресурсы", "resources"],
        ["filter=presents", "Подарки", null],
        ["filter=scrolls", "Свитки", "scrolls"],
        ["filter=potions", "Зелья", "potions"],
        ["filter=quests", "Квесты", null],
        ["filter=food", "Еда", null],
        ["filter=other", "Прочее", "other"]],

potions: [["fts=75.1", "Лекарства"],
	  ["fts=84", "Эликсиры"]],

"items": [["fts=1", "Шлем"],
          ["fts=2", "Одежда&nbsp;(Верх)"],
          ["fts=3", "Одежда&nbsp;(Низ)"],

          ["fts=4", "Браслет"],
          ["fts=5", "Пояс"],

          ["fts=6", "Обувь"],
          ["fts=7", "Амулет"],
          ["fts=8", "Оружие"],
          ["fts=9.100", "Оружие&nbsp;(Вместо&nbsp;Щита)"],
          ["fts=9", "Щит"],
          ["fts=10", "Кольцо"],
          ["fts=11", "Перчатки"],
          ["fts=12", "Нижняя&nbsp;Одежда"],
          ["fts=13", "Оберег"],
          ["fts=14", "Наплечники"],
          ["fts=15", "Серьги"]],

resources: [["fts=50.51|50.52|50.53|50.54|50.55|50.56|50.57|50.59|50.60|50.61|50.62|50.63", "Материал", "mt"],
            ["fts=50.1", "Ископаемое"],
            ["fts=50.2", "Руда"],
            ["fts=50.3", "Туша"],
            ["fts=50.4", "Ингридиент"],
            ["fts=50.5", "Ингридиент (Концентрат)"],
            ["fts=50.6", "Ингридиент (Продукт)"],
            ["fts=50.7", "Драг. Камень"],
            ["fts=50.8", "Магический Камень"],
            ["fts=50.10", "Осколок Метеорита"]],

mt: [["fts=50.51", "Камень"],
     ["fts=50.52", "Шкура"],
     ["fts=50.53", "Кожа"],
     ["fts=50.54", "Кость"],
     ["fts=50.55", "Металл"],
     ["fts=50.56", "Древесина"],
     ["fts=50.57", "Маг. Металл"],
     ["fts=50.59", "Драг. Металл"],
     ["fts=50.60", "Ткань"],
     ["fts=50.61", "Драг. Сплав"],
     ["fts=50.62", "Сплав"],
     ["fts=50.63", "Волшебная Древесина"]],

scrolls: [["fts=30", "Боевой&nbsp;Свиток"],
          ["fts=83|81", "Свиток"],
          ["fts=60", "Рецепт"]],

other: [["fts=71", "Руна"],
        ["fts=40", "Вещь&nbsp;на&nbsp;Продажу"],
        ["fts=72", "Реликвия"],
        ["fts=73", "Фишка"],
        ["fts=85", "Сундук"],
        ["fts=85", "Ключ"],
        ["fts=82", "Книга"],
        ["fts=82.1", "Регистрационная Книга"]]
};

function showTsMenuItem()
{
   this.className += " hhover";
}
function hideTsMenuItem()
{
   this.className = this.className.replace(" hhover", "");
}

function createTsMenu(bs, _data, _pref, _class, _pos)
{
   var _callee = arguments.callee;
   var pref   = _pref  || "";
   _class  = _class || "";
   _pos    = _pos || null;
   var cpos = _pos || 0;

   var divc  = _pos ? _callee.__blank.cloneNode(true) : document.createElement('div');

   var menub = _pos ? CPath(divc, '0.1.0.0') : divc;

   divc.className = "tsMenuDivc" + _class + ( _pos ? "  " + "tsMenuDivc" + _class + _pos : "");

   for (var i = 0; i < _data.length; i++)
   {
      var div  = document.createElement('div');
      var a    = document.createElement('a');

      div.className = "tsMenuDiv" + _class + ( _pos ? "  " + "tsMenuDiv" + _class + _pos : "");

      a.href      = bs + '?' + _data[i][0];
      a.innerHTML = _data[i][1] + pref;

      a.className = "tsMenuA";

      div.appendChild(a);

      div.onmouseenter = showTsMenuItem;
      div.onmouseleave = hideTsMenuItem;

      if (_data[i][2])
      {
         var subdiv = createTsMenu(bs, itemSortMenus[_data[i][2]], null, "aa", cpos + 1);

         a.className += " tsMenuA-hchild";

         div.appendChild(subdiv);
      }

      menub.appendChild(div);
   }

   return divc;

}
documentReady(function()
{
   var div = document.createElement("div");
   div.innerHTML = "<div class=\"rec-base-tdtx\"><div class=\"rec-base-tdtx-tl\"><div class=\"rec-base-tdtx-tr\"><div class=\"rec-base-tdtx-tc\"></div></div></div><div class=\"rec-base-tdtx-cl\"><div class=\"rec-base-tdtx-cr\"><div class=\"rec-base-tdtx-cc\"></div></div></div><div class=\"rec-base-tdtx-bl\"><div class=\"rec-base-tdtx-br\"><div class=\"rec-base-tdtx-bc\"></div></div></div></div>";

   window.createTsMenu.__blank = div;
});