
window.addEvent('domready', function()
{

	$$('#box7 a div').each(function(el) { el.setStyle('opacity', 0.6); });

	if ($('mainImage'))
	{
		var fxOptions7 = { property: 'left', duration: 500, wait: false };
		var thumbsFx = new Fx.Tween($('thumbs_mask7'), fxOptions7);
		new noobSlide({
			box: $('box7'), size: 650, items: [0, 1, 2], handles: $$('#thumbs_handles7 span'),
			autoPlay: true, fxOptions: fxOptions7,
			onWalk: function(currentItem)
			{
				thumbsFx.start(currentItem * 76);
			}
		}).walk(0);
	}
	if ($('photogallery'))
	{
		var ch = $('photogallery').getChildren(), pb = ch[2].getChildren();
		ch[1].setStyle('opacity', 0.6);
		new noobSlide({
			box: ch[0], size: 323, items: [0, 1, 2],
			autoPlay: false, interval: 3000,
			fxOptions: { property: 'left', duration: 500, wait: false },
			addButtons: { previous: pb[0], next: pb[1] }
		}).walk(0);
	}
	if ($('scrolltable'))
	{
		var dt = new Date(), day = dt.getDate(), delta = day - bcbDt;
		if (day < bcbDt) // next month
		{
			var daysInMonth = 32 - new Date(dt.getFullYear(), dt.getMonth() - 1, 32).getDate();
			delta = daysInMonth - bcbDt + day;
		}
		var n = 5 + Math.min(delta, 5);

		new noobSlide({
			box: $('scrolltable'), size: 59, items: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
			fxOptions: { property: 'left', duration: 300, wait: false },
			addButtons: { previous: $('gameScrollLeft'), next: $('gameScrollRight') }
		}).walk(n);
	}
	if (typeof plData != 'undefined') Ax.CreateBestPlayers();
});


var Ax = {
	xnewsTab: function(n)
	{
		for (var i = 1; i <= 4; 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();
}
