var sThumbs = new Array();

function StartThumbChange(sId, iThumbsCount, sPath)
{	
	sThumbs[sId] = true;
	
	ChangeThumb(sId, 3, iThumbsCount, sPath);
}

function EndThumbChange(sId, sPath)
{
	sThumbs[sId] = false;
//	$('#'+sId).attr('src', sPath + '.003.jpg');
}

function ChangeThumb(sId, i, iThumbsCount, sPath)
{
	if (sThumbs[sId])
	{
		if (i < 10)
		{
			sI = '00'+i;
		}
		else if (i < 100)
		{
			sI = '0'+i;
		}
		else
		{
			sI = i;
		}
		sVal = sPath + '.' + sI + '.jpg';
		$('#'+sId).attr('src', sVal);
		i = i % iThumbsCount;
		i++;

		setTimeout("ChangeThumb('" + sId + "'," + i + ", " + iThumbsCount + ", '" + sPath + "')", 1100);
	}
}	

// ------------------- Player -------------------

function ShowPlayer(sPlayerId, sUrl, sImage, iWidth, iHeight, sAdsMainId, sAdsBottomId, sPlayerPath, iAutoPlay)
{
	var sAdsBottom = $('#'+sAdsBottomId).html();
	var sAdsMain = $('#'+sAdsMainId).html();

	if (sAdsBottom == null) sAdsBottom = '';
	if (sAdsMain == null) sAdsMain = '';

	if (sPlayerPath == null) sPlayerPath = '/player/';

	if (iAutoPlay == null) iAutoPlay = false;

	$f(sPlayerId, sPlayerPath+"flowplayer.swf", { 

		canvas: { 
	    	backgroundColor: '#000000',
//			backgroundImage: sImage,
			backgroundGradient: [0, 0, 0],
			border: '2px solid #000000'
		},

		play: {
//			label: 'Play movie'
		},

		playlist: [
	        { 
    	        url: sImage,
	            scaling: 'fit' 
	        }, 

	    	{ 
	        	url: escape(sUrl),
		        provider: 'lighttpd',
		        autoPlay: iAutoPlay,
//				autoBuffering: true,
				scaling: 'fit'
		    }
		],

		plugins: { 

		    lighttpd: {
	    	    url: sPlayerPath+'flowplayer.pseudostreaming.swf'
		    },

	    	controls: { 
	        	url: sPlayerPath+'flowplayer.controls.swf',
				backgroundColor: '#333333'
		    },

			adsBottom: {
				url: sPlayerPath+'flowplayer.content.swf',
				html: sAdsBottom,
				style: {
					p: {fontSize:21, color:'#FFFFFF', fontFamily:'Verdana', fontWeight:'bold', textAlign: 'center'},
					a: {color:'#fcff00'}
				},
				borderRadius: 0,
				bottom: 30,
				height: 40,
				opacity: 0.95,
				display: 'none',
				backgroundColor: '#333333',
				border: '1px solid #777777',
				backgroundGradient: [0, 0, 0]
			},

			adsMain: {
				url: sPlayerPath+'flowplayer.content.swf',
				html: sAdsMain,
				style: {
					p: {fontSize:25, textAlign: 'center'},
					a: {color:'#fcff00', textAlign: 'center'}
				},
				borderRadius: 0,
				top: 10,
				height: (iHeight - 100),
				bottom: 85,
				opacity: 0.95,
				closeButton: true,
				display: 'none',
				backgroundColor: '#333333',
				border: '1px solid #777777',
				backgroundGradient: [0, 0, 0]
			}
		}
	});

	function ShowAds(sId)
	{
		var plugin = $f(sPlayerId).getPlugin(sId); 
		plugin.show();
	}
	function HideAds(sId)
	{
		var plugin = $f(sPlayerId).getPlugin(sId); 
		plugin.hide();
	}
/*
	$('#'+sPlayerId).mouseover(function() {
		pl = $f(sPlayerId);
		if (pl.isLoaded())
		{
			if (pl.isPlaying() && sAdsBottom != '')
			{
				ShowAds('adsBottom');
			}
		}
	});

	$('#'+sPlayerId).mouseout(function() {
		pl = $f(sPlayerId);
		if (pl.isLoaded())
		{
			if (pl.isPlaying() && sAdsBottom != '')
			{
				HideAds('adsBottom');
			}
		}
	});
*/
	$f(sPlayerId).onLoad(function() {
		if (sAdsBottom != '') ShowAds('adsBottom');
	});

	$f(sPlayerId).onPause(function() {
		if (sAdsMain != '') ShowAds('adsMain');
		if (sAdsBottom != '') ShowAds('adsBottom');
	});

	$f(sPlayerId).onFinish(function() {
		$f(sPlayerId).stop();
		if ( (sAdsMain != '') && ($f(sPlayerId).getClip().index > 0))	ShowAds('adsMain');
		if (sAdsBottom != '') ShowAds('adsBottom');
	});

	$f(sPlayerId).onResume(function() {
		if (sAdsMain != '') HideAds('adsMain');
	});

} // function ShowPlayer()
// ------------------- Player -------------------