	var nextChannel;
	var nextChannelName;
	
	function openChannel(channel) {
            $.cookie("channel", channel, { expires: 90 });
            if (channel == 13406) {
                    nextChannel = 18526;
                    nextChannelName = 'Бард-кафе';
            }
            else {
                    nextChannel = 13406;
                    nextChannelName = 'Бард-саммит';
            }
            $(".player").empty()
            .css('background-image', '')
            .animate({height: '316',  backgroundColor: '#000000', 'padding-top': '0'}, 1200, function() {
                 $(".player").append( '<object id="c' + channel  + '" name="c' + channel  + '" height=288" width="384" type="application/x-shockwave-flash" data="http://yatv.ru/files/swf/container.swf?layout=1full&apps=translations&cid=' + channel  + '&autoplay=1"><param name="allowScriptAccess" value="always"></param><param name="allowFullScreen" value="true"></param><param name="movie" value="http://yatv.ru/files/swf/container.swf?layout=1full&apps=translations&cid=' + channel  + '&autoplay=1"></param></object><br><span onClick="removeAll()" class="buttonRemovePlayer">Стоп</span><span onClick="openChannel(' + nextChannel + ')" class="buttonChangePlayer">' + nextChannelName + '</span>' )
                 .css('color', '#FFFFFF');
            });
	}
	
	function removeAll() {
            $.cookie("channel", null);
            $(".player").empty()
            .animate({height: '56',  backgroundColor: '#AAFFAA', 'padding-top': '14'}, 1200, function() {
                $(".player").append( '<span onClick="openChannel(13406)" class="buttonNewPlayer">Бард-саммит</span><br><span onClick="openChannel(18526)" class="buttonNewPlayer">Бард-кафе</span>' )
                .css('color', '#000000')
                .css('background-image', 'url(img/yatv.png)');
            });
	}
	
	$(document).ready(function(){
            var channel = $.cookie("channel");
            if (channel != null ) {
                    $(".player").css('background-color', '#000000');
                    openChannel(channel);
            }
            else {
                    removeAll();
            }
	});
