// пульт / device
swfobject.embedSWF(
	"/i/swf/promoblock.swf", "promoblock", 647, 332, "6.0.0", "/i/swf/expressinstall.swf",
	{ path: '/show/?p=327' },
	{ wmode: 'transparent', menu: 'false' }
);

// табы на главной странице
$(function() {
	var scr = $('#screen');

	if(!scr.length) {
		return;
	}
	scr = scr.get(0);

	// открытая в данный момент вкладка
	scr.className = document.location.hash.substr(1);;
	if(!scr.className.length) {
		scr.className = 'best';
	}

	// переключатели вкладок
	$('h2 a', scr).click(function() {
		scr.className = this.hash.substr(1);

		$('a#yxo', scr)[0].row = 0;

		return false;
	});

	// зебра для лучших мелодий
	$('td.best-music table', scr).each(function(){
		$('tr', this).each(function(index){
			if(index % 2 != 0) {
				$(this).addClass('e');
			}
		});
	});

	$('div#music table table', scr).each(function(){
		$('tr', this).each(function(index){
			if(index % 2 == 1) {
				$(this).addClass('e');
			}
		});
	});

	// проставление первого столбца в табах
	var tabs = ['java', 'picture', 'video', 'music'];
	for(var i in tabs) {
		$('div#'+tabs[i]+' td', scr).each(function(index) {
			var count = tabs[i] == 'music' ? 2 : 5;
			if(index % count == 0) {
				$(this).addClass('first');
			}
		});
	}

	// переключалка контента в табе
	$('a#yxo', scr).click(function() {
		window.fnClosePlayer();

		var moreCount = $(this).attr('count');

		var row = this.row;

		if(row == undefined) {
			var row = Math.ceil(Math.random()*moreCount) - 1;
			this.row = row;
		}

		$('body.root #screen #'+scr.className+' div.rowx').hide();
		row++;

		if(row + 1 > moreCount) {
			row = 0;
		}

		$('body.root #screen #'+scr.className+' div.row'+row).show();

		this.row = row;

		return false;
	});

});
