var BASE_HREF = BASE_HREF || '../';
var FILES_HREF = '/underwood/download/files/';

$(document).ready(function()
{	
	/* Featured articles sliding */
	if($.fn.cycle) $('.featured-articles').cycle({
		speed:  1000,
		timeout: 5000,
		pause: 1,
		pager:  '.paging-slide'
	});

//	$('#logo *').pngFix();

	$('.att-images a.thickbox').kfBox({
		pageSpan: 4
	});
/*
	var nowPlayingHash = $('.now-playing .author').html() + $('.now-playing .song').html();
	setInterval(function()
	{
		$.ajax(
			{
				type: "GET",
				url: "/rds.php",
				success: function (data, textStatus) 
				{ 
					var author = $('author', data).text();
					var song = $('song', data).text();					
					if(author + song != nowPlayingHash)
					{ 
						$('.now-playing').fadeOut(function(){
							$(this)
								.find('.author').empty().append(author).end()
								.find('.song').empty().append(song).end()
								.fadeIn();
							nowPlayingHash = author + song;
						});
					}
				}
			}
		);		
	}, 5 * 1000);
*/
	// Flash video player
	$.fn.flashembed && $('.flash-player').each(function()
	{
		var $a = $(this).find('a');
		if($a.size())
		{
			var $i = $(this).find('img');
			var flashvars = {
				file: ($a.attr('href').indexOf("http://") == 0 ? "" : FILES_HREF) + $a.attr('href'),
				searchbar: 'false',
				autostart: 'false'
			};
			if($i.size()) flashvars = $.extend(flashvars, { image: $i.attr('src') });
			$(this).flashembed(
	        {
				src: '/flash/player.swf',
				width: $a.attr('class') == "audio-panel" ?  220 : 410,
				height: $a.attr('class') == "audio" || $a.attr('class') == "audio-panel" ? 20 : 300,
				wmode: 'opaque',
				allowfullscreen: 'true'
	        }, flashvars);
        }
	});
	
	/* Hlasování v hitparádě */
	$('.hitparade a.btn-like, .hitparade a.btn-dislike').bind('click', function()
	{
		if($(this).hasClass('btn-disabled')) return false;
		$.ajax(
			{
				type: "GET",
				url: $(this).attr('href') + "&ajax=true"
			}
		);		
		$(this).parent().find('a.btn-like, a.btn-dislike').addClass('btn-disabled');
		return false;
	});
	
});

function PlayRadio(bitrate) {
	window.open('http://www.play.cz/listen/listen.php?sh=krokodyl&bitrate=' + bitrate + '', 'playradio', 'width=490,height=200,top='+((screen.availHeight-200)/2)+',left='+((screen.availWidth-490)/2)+',status=0,scrollbar=0');
}

function openPlayer(objhref) {
	return window.open(objhref,'radio','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=490,height=150,left=200,top=200');
}

