
window.addEvent('domready', function()
{
	$$('#box7 a div').each(function(el) { el.setStyle('opacity', 0.6); });

	var mainTexts = $('mainTexts');
	if (mainTexts)
	{
		var news = mainTexts.getChildren();
		mainTexts.selected = news[0];
		news.each(function(t)
		{
			t.addEvent('mouseover', function(event2)
			{
				if (t == mainTexts.selected) return;
				mainTexts.selected.className = "mainText";
				mainTexts.selected = t;
				t.className = "mainText_w";
				var img = t.getChildren()[1];
				$('mainImg0').style.backgroundImage = "url(" + img.src + ")";
			});
		});
	}

	if (typeof (plData) != 'undefined') Ax.CreateBestPlayers();
});


var Ax = {
	xnewsTab: function(n)
	{
		for (var i = 1; i <= 3; i++)
		{
			$('tab' + i + 'Data').style.display = n == i ? 'block' : 'none';
			$('tab' + i + 'Btn').className = n == i ? 'tabActive' : 'tabInactive';
		}
	},
	delComment: function(id)
	{
		if (!confirm('Удалить?')) return;
		new Request({
			method: 'get',
			url: baseURL + 'delcomm.php?id=' + id,
			evalResponse: true
		}).send();
	},

	pltabSelect: function(n)
	{
		for (var i = 0; i < 3; i++)
		{
			$("pltab_" + i).className = "pltabContent" + (i == n ? "Sel" : "");
			$("pltab_capt_" + i).className = "pltabHead" + (i == n ? "Sel" : "");
		}
	},
	plstatShow: function(el)
	{
		var prev = el.getPrevious();
		el.getParent().getChildren().each(function(x)
		{
			var show = x.className == 'plRow' ? x != el : x == prev;
			x.style.display = show ? 'block' : 'none';
		});
	},
	CreateBestPlayers: function()
	{
		var content = new Array();
		for (var i = 0; i < plData.Values.length; i++)
		{
			content.push("<div id='pltab_" + i + "' class='pltabContent" + (i == 0 ? "Sel" : "") + "'>");
			var cont = plData.Values[i];
			for (var n = 0; n < cont.length; n += 2)
			{
				var pl = plData.Names[cont[n]];
				var img = pl[5].split(".");
				content.push("<div style='display:" + (n == 0 ? "block" : "none") + ";'>");
				content.push('<img src="' + baseURL + 'files/players/'
					+ img[0] + "_small." + img[1] + '" style="float:left; margin-right:5px;"/>');
				// id="pltab_img0"
				content.push('<div class="pltabValue">' + cont[n + 1].toFixed(1) + '</div>');
				content.push('<a href="' + baseURL + 'stat.php?id=' + cont[n] + '">'
					+ pl[1] + '<br/>' + pl[0] + '</a>');
				content.push('<div style="margin-top:13px;">Рост: ' + pl[4] + ' см<br/>Вес: ' + pl[3] + ' кг<br/>'
					+ pl[6] + '</div>');
				content.push("</div><div class='plRow' style='display:" + (n == 0 ? "none" : "block")
					+ ";' onclick='Ax.plstatShow($(this))'>");
				content.push("<div style='float:right'>" + cont[n + 1].toFixed(1) + "</div>"
					+ (n / 2 + 1) + ". " + pl[1] + " " + pl[0]);
				content.push("</div>");
			}
			content.push("</div>");
		}
		$("playersPos").set('html', content.join(''));
	},

	ttToggle: function(n)
	{
		var show2 = n==1;
		$('ttSwitch').style.display = show2 ? "block" : "none";
		$('ttInner2_1').style.display = show2 ? "block" : "none";
		$('ttInner2_0').style.display = show2 ? "none" : "block";
	}
};

function submit_enter(e, validator) {
	var code = window.event ? window.event.keyCode : (e ? e.which : null);
	if (code == 13 && (validator == null || validator())) { login_submit(); return false; }
	return true;
}
function login_validate() {
	return $('m_email').value != '' && $('m_pwd1').value != '';
}
function login_submit() {
	$('loginForm').submit();
	//document.forms[0].submit();
}

