function ge(z){return document.getElementById(z)}
function gE(z,y){return z.getElementsByTagName(y)}
function ce(z){return document.createElement(z)}
function de(z){z.parentNode.removeChild(z)}
function ct(z){return document.createTextNode(z)}
function rf(){return false}
function tb(){this.blur()}
function ac(z){var a=0,b=0;while(z){a+=z.offsetLeft;b+=z.offsetTop;z=z.offsetParent} return [a,b]}

var Browser = {
	ie:     !!(window.attachEvent && !window.opera),
	opera:  !!window.opera,
	safari: navigator.userAgent.indexOf('Safari') != -1,
	gecko:  navigator.userAgent.indexOf('Gecko') != -1 && navigator.userAgent.indexOf('KHTML') == -1
};
Browser.ie6 = Browser.ie && navigator.userAgent.indexOf('MSIE 6.0') != -1;
navigator.userAgent.match(/Gecko\/([0-9]+)/);
Browser.geckoVersion = parseInt(RegExp.$1) | 0;

/////////////////////////////////////////////////

var Get={
windowSize:function()
{
	var width = 0, height = 0;
	if(typeof window.innerWidth == 'number') //Non-IE
	{
		width = window.innerWidth;
		height = window.innerHeight;
	}
	else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
  	{
		//IE 6+ in 'standards compliant mode'
		width = document.documentElement.clientWidth;
		height = document.documentElement.clientHeight;
	}
 	else if(document.body && (document.body.clientWidth || document.body.clientHeight))
	{
		//IE 4 compatible
		width = document.body.clientWidth;
		height = document.body.clientHeight;
	}
	return [width, height];
}
,

scroll:function()
{
	var x = 0, y = 0;
	if(typeof(window.pageYOffset) == 'number')
	{
		//Netscape compliant
		x = window.pageXOffset;
		y = window.pageYOffset;
	}
	else if(document.body && (document.body.scrollLeft || document.body.scrollTop))
	{
		//DOM compliant
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop))
	{
		//IE6 standards compliant mode
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	return [x, y];
}
}



function g_createGlow(txt, cn)
{
	var s = ce('span');

	for(var i = -1; i <= 1; ++i)
	{
		for(var j = -1; j <= 1; ++j)
		{
			var d = ce('div');
			d.style.position = 'absolute';
			d.style.whiteSpace = 'nowrap';
			d.style.left = i + 'px';
			d.style.top = j + 'px';

			if(i == 0 && j == 0)
				d.style.zIndex = 4;
			else
			{
				d.style.color = 'black';
				d.style.zIndex = 2;
			}
			d.appendChild(ct(txt));
			s.appendChild(d);
		}
	}
	s.style.position = 'relative';
	s.className = 'glow' + (cn != null ? ' ' + cn : '');
	var ph = ce('span');
	ph.style.visibility = 'hidden';
	ph.appendChild(ct(txt));
	s.appendChild(ph);
	return s;
}

//////////////////////////////////////////////////////////
var Tooltip = {
	create: function(htmlTooltip)
	{
		var d = ce('div'), t = ce('table'), tb = ce('tbody'), tr1 = ce('tr'), tr2 = ce('tr'), td = ce('td'), th1 = ce('th'), th2 = ce('th'), th3 = ce('th');
		d.className = 'tooltip';
		th1.style.backgroundPosition = 'top right';
		th2.style.backgroundPosition = 'bottom left';
		th3.style.backgroundPosition = 'bottom right';
		if(htmlTooltip)
		td.innerHTML = htmlTooltip;
		td.id="text";
		tr1.appendChild(td);
		tr1.appendChild(th1);
		tb.appendChild(tr1);
		tr2.appendChild(th2);
		tr2.appendChild(th3);
		tb.appendChild(tr2);
		t.appendChild(tb);
		d.appendChild(t);
		return d;
	},

	fix: function(tooltip, noShrink, visible)
	{
		var table = gE(tooltip, 'table')[0],
		    td = gE(table, 'td')[0],
		    c = td.childNodes;
		if(c.length >= 2 && c[0].nodeName == 'TABLE' && c[1].nodeName == 'TABLE')
		{
			var m;
			if(c[1].offsetWidth > 300)
				m = Math.max(300, c[0].offsetWidth) + 20;
			else
				m = Math.max(c[0].offsetWidth, c[1].offsetWidth) + 20;
			if(m > 20)
			{
				tooltip.style.width = m + 'px';
				c[0].style.width = c[1].style.width = '100%';

				if(!noShrink && tooltip.offsetHeight > document.body.clientHeight)
					table.className = 'shrink';
			}
		}
		if(visible)
			tooltip.style.visibility = 'visible';
	},

	fixSafe: function(p1, p2, p3)
	{
		if(Browser.ie)
			setTimeout(Tooltip.fix.bind(this, p1, p2, p3), 1);
		else
			Tooltip.fix(p1, p2, p3);
	},

	append: function(el, htmlTooltip)
	{
		var el = $(el);
		var tooltip = Tooltip.create(htmlTooltip);
		el.appendChild(tooltip);

		Tooltip.fixSafe(tooltip, 1, 1);
	},

	move: function(_this, tooltip, x, y, tow, toh, clip)
	{
		var _,
		    c = ac(_this),
		    left = c[0],
		    top  = c[1],
		    minx = 0,
		    miny = 0,
		    w1   = _this.offsetWidth  + x,
		    h1   = _this.offsetHeight + y,
		    windowSize = Get.windowSize(),
		    scroll = Get.scroll(),
		    bcw = windowSize[0],
		    bch = windowSize[1],
		    bsl = scroll[0],
		    bst = scroll[1];
		tooltip.style.width = tow + 'px';
		if(clip)
		{
			_ = ge(clip);
			if(_)
			{
				c = ac(_);
				minx = c[0];
				miny = c[1];

				if(_.offsetWidth + minx <= bsl + bcw)
					bcw = _.offsetWidth  + minx - bsl;

				if(_.offsetHeight + miny <= bst + bch)
					bch = _.offsetHeight + miny - bst;
			}
		}
		if(left + w1 + tow > bcw)
			left = Math.max(left - tow - x, minx);
		else
			left += w1;

		if(left < minx)
			left = minx;
		else if(left + tow > bsl + bcw)
			left = bsl + bcw - tow;

		if(top - toh - y > Math.max(bst, miny))
			top = top - toh - y;
		else
			top += h1;

		if(top < miny)
			top = miny;
		else if(top + toh > bst + bch)
			top = Math.max(bst, bst + bch - toh);
		tooltip.style.left = left + 'px';
		tooltip.style.top  = top  + 'px';
		tooltip.style.visibility = 'visible';
	},

	show: function(_this, text, x, y,_type,spanClass)
	{
		var _;
		if(!Tooltip.tooltip)
		{
			_ = Tooltip.create();
			_.style.position = 'absolute';
			_.style.left = _.style.top = '-2323px';

			var lay = ge('layers');
			lay.appendChild(_);

			Tooltip.tooltip      = _;
			Tooltip.tooltipTable = gE(_, 'table')[0];
			Tooltip.tooltipTd    = gE(_, 'td')[0];
		}

		if(spanClass) text = '<span class="' + spanClass + '">' + text + '</span>';
		_ = Tooltip.tooltip;
		_.style.width = '500px';
		_.style.left = '-2323px';
		_.style.top  = '-2323px';
		Tooltip.tooltipTd.innerHTML = text;

switch(_type)
	{
	case "i":
		 getData(_this,"i");
	break;
	case "s":
		 getData(_this,"s");
	break;
	default:
		 getData(_this,"i");
	}

		_.style.display = '';
		Tooltip.fix(_, 0, 0);
		Tooltip.move(_this, _, x, y, Tooltip.tooltipTable.offsetWidth, Tooltip.tooltipTable.offsetHeight, 'fixTooltip');
	},

	hide: function()
	{
		if(Tooltip.tooltip)
		{
			Tooltip.tooltip.style.display = 'none';
			Tooltip.tooltip.visibility = 'hidden';
			Tooltip.tooltipTable.className = '';
		}
	}
};
/////////////////////////////////////////


var Icon = {
	sizes: ['s', 'm', 'l'],
	set:function (_e,_ar)
	{
		ge(_e).appendChild(Icon.create(_ar[0],_ar[1],_ar[2],_ar[3],_ar[4],_ar[5]));
	},
	create: function(image, size, tooltip, link, num, qty)
	{
		var _;
		var icon = ce('div'), tile = ce('div'), hover = ce('div');

		icon.className = 'icon' + Icon.sizes[size];
		if(image != null){
			switch(size){
				case 0: icon_size = 'small';break;
				case 1: icon_size = 'medium';break;
				case 2: icon_size = 'large';break;
			}
			icon.style.backgroundImage = 'url(icon/' + icon_size + '/' + image + '.jpg)';
		}

		tile.className = 'tile';
		hover.className = 'hover';

		if(tooltip)
		{

			hover.id = (tooltip).length ? tooltip : null;

			if (! hover.id)
			{
				hover.onmouseover = Icon.over;
				hover.onmouseout  = Icon.out;
			}

		}

		if(typeof(link) == 'string')
		{
			var a = ce('a');
			a.href = link;
			hover.appendChild(a);
		}

		else if(size == 2)
		{
			hover.ondblclick = function() { prompt('', image) };
		}

		if(num != null && (num > 1 || num.length))
		{
			_ = g_createGlow(num, 'q1');
			_.style.right = '0';
			_.style.bottom = '0';
			_.style.position = 'absolute';
			tile.appendChild(_);
		}

		if(qty != null && qty > 0)
		{
			_ = g_createGlow('(' + qty + ')', 'q');
			_.style.left = '0';
			_.style.top = '0';
			_.style.position = 'absolute';
			tile.appendChild(_);
		}

		tile.appendChild(hover);
		icon.appendChild(tile);

		return icon;
	},

	over: function()
	{
		if(!Icon.hilite)
		{
			var _ = ce('div');
			_.className = 'hilite';
			Icon.hilite = _;
		}
	
		this.parentNode.insertBefore(Icon.hilite, this.parentNode.lastChild.nextSibling);
		Icon.hilite.style.display = '';

		if(this.id != null)
		{
			//alert (this.id);
			Tooltip.show(this, this.id, 0, 0);
		}
	},

	out: function()
	{
		if(Icon.hilite)
			Icon.hilite.style.display = 'none';
		Tooltip.hide();
	}
};

/////////////////////////////////////////
function addBookmark(){
var _title=document.title;
var _url=document.location.href;
if (window.sidebar) { window.sidebar.addPanel(_title, _url,""); } else if( document.all ) {window.external.AddFavorite( _url, _title);} else if( window.opera && window.print ) {return true;}}


/////////////////////////////////////////

var xmlHttp;

function createXMLHttpRequest() {
	if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();        
	}
}

function getData(_this,_type) {
	createXMLHttpRequest();
	var url;
switch(_type)
	{
	case "i":
		url = "gi-" + escape(_this.id) + ".html";
	break;
	case "s":
		url = "gs-" + escape(_this.id) + ".html";
	break;
	default:
		return;
	}

	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function()
{
ge("text").innerHTML="资料载入中...";

if (xmlHttp.readyState == 4) 
	{
	if (xmlHttp.status == 200) {
		ge("text").innerHTML=xmlHttp.responseText;
		Tooltip.fix(Tooltip.tooltip, 0, 0);
		Tooltip.move(_this, Tooltip.tooltip, 0, 0, ge('text').offsetWidth, ge('text').offsetHeight, 'fixTooltip');
		}
	}
	
};
	xmlHttp.send(null);
}


function gData(_this,_type,_site) { //最终页面用
	createXMLHttpRequest();
	var url;
switch(_type)
	{
	case "i":
		url = "gi-" + escape(_this.id) + ".html";
	break;
	case "s":
		url = "gs-" + escape(_this.id) + ".html";
	break;
	default:
		return;
	}

	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function()
	{
	ge(_site).innerHTML="资料载入中...";

	if (xmlHttp.readyState == 4) 
		{
		if (xmlHttp.status == 200) {
			ge(_site).innerHTML=xmlHttp.responseText;
			}
		}
	};
	xmlHttp.send(null);
}


function pause(numberMillis)
{
var dialogScript = 'window.setTimeout(' + ' function () { window.close(); }, ' + numberMillis + ');';
var result = window.showModalDialog('javascript:document.writeln(' + '"<script>' + dialogScript + '<' + '/script>")'); 
}



var subclass_=[["","--  无子分类  --"]];
var subclass_2=[["","--  所有武器  --"],[0,"单手斧"],[1,"双手斧"],[2,"弓"],[3,"枪"],[4,"单手锤"],[5,"双手锤"],[6,"长柄武器"],[7,"单手剑"],[8,"双手剑"],[10,"法杖"],[13,"拳套"],[15,"匕首"],[16,"投掷武器"],[19,"魔杖"],[18,"弩"],[20,"鱼杆"],[14,"其他"]];
var subclass_4=[["","--  所有装备  --"],[1,"布甲"],[2,"皮甲"],[3,"锁甲"],[4,"板甲"],[5,"小圆盾"],[6,"盾牌"],[7,"圣契"],[8,"神像"],[9,"图腾"],[10,"符印"],[0,"其它"]];
var subclass_5=[["","--  无子分类  --"]];
var subclass_6=[["","--  无子分类  --"]];
var subclass_7=[["","--  所有商品  --"],[0,"商品"],[1,"零件"],[2,"火药炸弹"],[3,"工程物品"]];
var subclass_9=[["","--  所有配方  --"],[0,"书籍"],[1,"制皮"],[2,"裁缝"],[3,"工程学"],[4,"锻造"],[5,"烹饪"],[6,"炼金术"],[7,"急救"],[8,"附魔"],[9,"钩鱼"],[10,"珠宝加工"]];
var subclass_11=[["","--  无子分类  --"]];
var subclass_12=[["","--  无子分类  --"]];
var subclass_13=[["","--  无子分类  --"]];
var subclass_15=[["","--  无子分类  --"]];
var subclass_0=[["","--  无子分类  --"]];
var subclass_1=[["","--  所有容器  --"],[0,"容器"],[1,"灵魂袋"],[2,"草药袋"],[3,"附魔材料袋"],[4,"工程学材料袋"],[5,"宝石背包"],[6,"矿石包"]];
var subclass_3=[["","--  所有宝石  --"],[0,"红色"],[1,"蓝色"],[2,"黄色"],[3,"紫色"],[4,"绿色"],[5,"橙色"],[6,"變換"],[7,"简单"],[8,"棱彩"]];

var zone_=[["","------ 任何地区 ------"]];
var zone_0=[["","------ 東部王國任何區域 ------"],[3487,"銀月城 "],[2918,"勇士大廳 "],[2257,"礦道地鐵 "],[1537,"鐵爐堡 "],[1519,"暴風城 "],[1497,"幽暗城 "],[3430,"永歌森林 (1-10)"],[85,"提里斯法林地 (1-10)"],[1,"丹莫洛 (1-10)"],[12,"艾爾文森林 (1-10)"],[130,"銀松森林 (10-20)"],[3433,"鬼魂之地 (10-20)"],[38,"洛克莫丹 (10-20)"],[40,"西部荒野 (10-20)"],[44,"赤脊山 (15-25)"],[10,"暮色森林 (18-30)"],[11,"濕地 (20-30)"],[267,"希爾斯布萊德丘陵 (20-30)"],[33,"荊棘谷 (30-45)"],[45,"阿拉希高地 (30-40)"],[36,"奧特蘭克山脈 (30-40)"],[3,"荒蕪之地 (35-45)"],[8,"悲傷沼澤 (35-45)"],[51,"灼熱峽谷 (43-50)"],[47,"辛特蘭 (45-50)"],[4,"詛咒之地 (45-55)"],[46,"燃燒平原 (50-58)"],[28,"西瘟疫之地 (51-58)"],[25,"黑石山 (52-60)"],[139,"東瘟疫之地 (53-60)"],[41,"逆風小徑 (55-70)"]];
var zone_1=[["","------ 卡林多任何區域 ------"],[3557,"艾克索達 "],[2917,"傳說大廳 "],[1657,"達納蘇斯 "],[1638,"雷霆崖 "],[1637,"奧格瑪 "],[493,"月光林地 "],[3524,"藍謎島 (1-10)"],[457,"迷霧之海 (1-10)"],[14,"杜洛塔 (1-10)"],[141,"泰達希爾 (1-10)"],[215,"莫高雷 (1-10)"],[17,"貧瘠之地 (10-25)"],[148,"黑海岸 (10-20)"],[3525,"血謎島 (10-20)"],[406,"石爪山脈 (15-27)"],[331,"梣谷 (18-30)"],[400,"千針石林 (25-35)"],[405,"淒涼之地 (30-40)"],[15,"塵泥沼澤 (35-45)"],[357,"菲拉斯 (40-50)"],[440,"塔納利斯 (40-50)"],[16,"艾薩拉 (48-55)"],[361,"費伍德森林 (48-55)"],[490,"安戈洛環形山 (48-55)"],[618,"冬泉谷 (53-60)"],[1377,"希利蘇斯 (55-60)"]];
var zone_530=[["","------ 外域任何區域 ------"],[3703,"撒塔斯城 "],[3483,"地獄火半島 (58-63)"],[3521,"贊格沼澤 (60-64)"],[3519,"泰洛卡森林 (62-65)"],[3518,"納葛蘭 (64-67)"],[3522,"劍刃山脈 (65-68)"],[3520,"影月谷 (67-70)"],[3523,"虛空風暴 (67-70)"]];
var zone_10=[["","------ 北裂境任何區域 ------"],[4395,"达拉然"],[3537,"北風凍原 (68-72)"],[495,"凜風峽灣 (68-72)"],[65,"龍骨荒野 (71-74)"],[394,"灰白之丘 (73-75)"],[2817,"水晶之歌森林 (74-76)"],[66,"祖爾德拉克 (74-77)"],[3711,"休拉薩盆地 (75-78)"],[67,"風暴群山 (76-80)"],[210,"寒冰皇冠 (77-80)"],[4197,"冬握湖 (77-80)"],];
var zone_571=[["","------ 北裂境任何區域 ------"],[4395,"达拉然"],[3537,"北風凍原 (68-72)"],[495,"凜風峽灣 (68-72)"],[65,"龍骨荒野 (71-74)"],[394,"灰白之丘 (73-75)"],[2817,"水晶之歌森林 (74-76)"],[66,"祖爾德拉克 (74-77)"],[3711,"休拉薩盆地 (75-78)"],[67,"風暴群山 (76-80)"],[210,"寒冰皇冠 (77-80)"],[4197,"冬握湖 (77-80)"],];
var zone_992=[["","------ 所有5人副本 ------"],[206,"俄特加德要塞 (70)"],[4120,"奧核之心 (71)"],[4196,"德拉克薩隆要塞 (74)"],[4415,"紫羅蘭堡 (75)"],[4375,"剛德拉克 (76)"],[4264,"石之大廳 (77)"],[4100,"斯坦索姆的抉擇 (80)"],[1196,"俄特加德之巔 (80)"],[4228,"奧核之眼 (80)"],[4272,"雷光大廳 (80)"],[3562,"地獄火壁壘 (60)"],[3713,"血熔爐 (61)"],[3717,"奴隸監獄 (62)"],[3716,"深幽泥沼 (63)"],[3792,"法力墓地 (64)"],[3790,"奧奇奈地穴 (65)"],[2367,"希爾斯布萊德丘陵舊址 (66)"],[3791,"塞司克大廳 (67)"],[3846,"亞克崔茲 (70)"],[3849,"麥克納爾 (70)"],[3789,"暗影迷宮 (70)"],[2366,"黑色沼澤 (70)"],[3847,"波塔尼卡 (70)"],[4095,"博學者殿堂 (70)"],[3714,"破碎大廳 (70)"],[3715,"蒸汽洞窟 (70)"],[2437,"怒焰裂谷 (13)"],[1581,"死亡礦坑 (15)"],[718,"哀嚎洞穴 (15)"],[209,"影牙城堡 (18)"],[719,"黑暗深淵 (20)"],[717,"監獄 (24)"],[133,"諾姆瑞根 (24)"],[491,"剃刀沼澤 (25)"],[722,"剃刀高地 (33)"],[796,"血色修道院 (34)"],[1337,"奧達曼 (39)"],[2100,"瑪拉頓 (43)"],[978,"祖爾法拉克 (43)"],[1417,"沉沒的神廟 (49)"],[1584,"黑石深淵 (55)"],[2057,"通靈學院 (58)"],[1583,"黑石塔 (58)"],[2017,"斯坦索姆 (58)"],[2557,"厄運之槌 (58)"]];
var zone_993=[["","------ 所有團隊副本 ------"],[4500,"永恆之眼 (80)"],[4493,"黑曜聖所 (80)"],[3456,"納克薩瑪斯 (80)"],[4603,"亞夏梵穹殿 (80)"],[3959,"黑暗神廟 (70)"],[4075,"太陽之井高地 (70)"],[2562,"卡拉贊 (70)"],[3836,"瑪瑟里頓的巢穴 (70)"],[3618,"戈魯爾之巢 (70)"],[3607,"毒蛇神殿洞穴 (70)"],[3606,"海加爾山 (70)"],[3805,"祖阿曼 (70)"],[3842,"風暴要塞 (70)"],[3428,"安其拉 (60)"],[3429,"安其拉廢墟 (60)"],[2159,"奧妮克希亞的巢穴 (60)"],[2717,"熔火之心 (60)"],[2677,"黑翼之巢 (60)"],[19,"祖爾格拉布 (60)"]];
var zone_996=[["","------ 所有戰場 ------"],[3277,"戰歌峽谷 (10-70)"],[3358,"阿拉希盆地 (20-70)"],[2597,"奧特蘭克山谷 (51-70)"],[3820,"暴風之眼 (61-70)"],[4384,"遠祖灘頭 (71-80)"]];

function getLink(type, id, name, color){
	var link = "";
	switch(type){
		case "item":
			link = "/script print(\"多玩魔獸數據庫: \\124c"+color+"\\124H"+type+":"+id+":0:0:0:0:0:0:0\\124h["+name+"]\\124h\\124r\");";
			break;
		case "spell":
			link = "/script print(\"多玩魔獸數據庫: \\124c"+color+"\\124H"+type+":"+id+"\\124h["+name+"]\\124h\\124r\");";
			break;
		case "achievement":
			link = "/script print(\"多玩魔獸數據庫: \"..GetAchievementLink("+id+"));";
			break;
		case "quest":
			link = "/script print(\"多玩魔獸數據庫: \\124c"+color+"\\124H"+type+":"+id+":0\\124h["+name+"]\\124h\\124r\");";
			break;			
	}
	window.prompt("复制/粘贴如下代码至游戏的聊天窗口：", link);
	return false;
}

var g_sources={
    1:"製造",2:"掉落",3:"PvP",4:"任務",5:"商人",6:"訓練師",7:"探索",8:"兌換",9:"天賦"
};

function $(C)
{
    if(arguments.length>1)
    {
        var D=[];
        for(var B=0,A=arguments.length;B<A;++B)
        {
            D.push($(arguments[B]))
        }
        return D
    }
    if(typeof C=="string")
    {
        C=ge(C)
    }
    return C
}
function $E(A)
{
    if(!A)
    {
        if(typeof event!="undefined")
        {
            A=event
        }
        else
        {
            return null
        }
    }
    A._button=A.which?A.which:A.button;
    A._target=A.target?A.target:A.srcElement;
    return A
}
function $A(B)
{
    var D=[];
    for(var C=0,A=B.length;C<A;++C)
    {
        D.push(B[C])
    }
    return D
}
Function.prototype.bind=function()
{
    var A=this,C=$A(arguments),B=C.shift();
return function()
{
    return A.apply(B,C.concat($A(arguments)))
}
};

function sprintf(B)
{
    var A;
    for(A=1,len=arguments.length;A<len;++A)
    {
        B=B.replace("$"+A,arguments[A])
    }
    return B
}
function ns(A)
{
    if(Browser.ie)
    {
        A.onfocus=tb;
        A.onmousedown=A.onselectstart=A.ondragstart=rf
    }
}
function cO(C,A)
{
    for(var B in A)
    {
        C[B]=A[B]
    }
}

function g_convertRatingToPercent(F,B,E)
{
    var D=
    {
        12:1.5,13:12,14:15,15:5,16:10,17:10,18:8,19:14,20:14,21:14,22:10,23:10,24:0,25:0,26:0,27:0,28:10,29:10,30:10,31:10,32:14,33:0,34:0,35:25,36:10,37:2.5,44:4.69512176513672
    };
    if(F<0)
    {
        F=1
    }
    else
    {
        if(F>80)
        {
            F=80
        }
    }
    if((B==14||B==12||B==15)&&F<34)
    {
        F=34
    }
    if(E<0)
    {
        E=0
    }
    var C;
    if(D[B]==null)
    {
        C=0
    }
    else
    {
        var A;
        if(F>70)
        {
            A=(82/52)*Math.pow((131/63),((F-70)/10))
        }
        else
        {
            if(F>60)
            {
                A=(82/(262-3*F))
            }
            else
            {
                if(F>10)
                {
                    A=((F-8)/52)
                }
                else
                {
                    A=2/52
                }
            }
        }
        C=E/D[B]/A
    }
    return C
}

function g_setRatingLevel(F,E,A,C)
{
	prompt_ratinglevel = "请输入需计算的人物等级 ($1 - $2):";
	tooltip_combatrating = "($1&nbsp;@&nbsp;L$2)";
    var D=prompt(sprintf(prompt_ratinglevel,1,80),E);
    if(D!=null)
    {
        D|=0;
        if(D!=E&&D>=1&&D<=80)
        {
            E=D;
            var B=g_convertRatingToPercent(E,A,C);
            B=(Math.round(B*100)/100);
            if(A!=12&&A!=37)
            {
                B+="%"
            }
            F.innerHTML=sprintf(tooltip_combatrating,B,E);
            F.onclick=g_setRatingLevel.bind(0,F,E,A,C)
        }
    }
}

function getMoney(copper){
	var copper_str = new String(copper);
	var money = "";
	var len = copper_str.length;
	
	if(copper >= 10000){
		var g = copper_str.substr(0, len-4);
		if(Number(g)>0) money += "<span class=\"moneygold\">"+g+"</span>";
	}
	if(copper >= 100){
		var _ = copper_str.substr(0, len-2);
		var s = _.substr(_.length-2);
		if(Number(s)>0) money += "<span class=\"moneysilver\">"+s+"</span>";
	}
	var c = copper_str.substr(len-2);
	if(Number(c)>0) money += "<span class=\"moneycopper\">"+c+"</span>";
	
	return money;
}