function showImage( image, id, filename )
{
	return hs.expand( image, { src: '/images/items/'+id+'/'+filename+'-full.jpg' } );
}

function showProgram( program )
{
	document.getElementById( 'program_content_header' ).innerHTML = document.getElementById( 'program_' + program + '_header' ).innerHTML;
	document.getElementById( 'program_content_text' ).innerHTML = document.getElementById( 'program_' + program + '_text' ).innerHTML;
}

function showVideo( file_id, name )
{
	if ( document.getElementById( 'video_name' ) ) document.getElementById( 'video_name' ).innerHTML = name;
	if ( document.getElementById( 'video_download' ) ) document.getElementById( 'video_download' ).innerHTML = '<a href="/content/video/' + file_id + '.avi" target="_blank">скачать в avi</a>';

	var so = new SWFObject( '/images/flash/video_player.swf', 'videoplayer', '320', '265', '8', '#FFFFFF' );
	so.addParam( 'wmode', 'transparent' );
	so.addParam( 'allowScriptAccess', 'always' );
	so.addVariable( 'callback_function', 'onFlashMessage' );
	so.addVariable( 'video_url', '/content/video/' + file_id + '.flv' );
	so.write( 'video_player' );

	setTimeout( 'autoplayVideo(' + file_id + ')', 200 );
}

function autoplayVideo( file_id )
{
	sendFlashAction( 'videoplayer', 'loadURL', '/content/video/' + file_id + '.flv' );
	sendFlashAction( 'videoplayer', 'vidPlay' );
}

function showAudio( file_id, name )
{
	if ( document.getElementById( 'audio_name' ) ) document.getElementById( 'audio_name' ).innerHTML = name;
	if ( document.getElementById( 'audio_download' ) ) document.getElementById( 'audio_download' ).innerHTML = '<a href="/content/audio/' + file_id + '.mp3" target="_blank">скачать в mp3</a>';

	var so = new SWFObject( '/images/flash/audio_player.swf', 'audioplayer', '320', '26', '8', '#FFFFFF' );
	so.addParam( 'wmode', 'transparent' );
	so.addParam( 'allowScriptAccess', 'always' );
	so.addVariable ( 'audio_url', '/content/audio/' + file_id + '.mp3' );
	so.write( 'audio_player' );

	setTimeout( 'autoplayAudio(' + file_id + ')', 200 );
}

function autoplayAudio( file_id )
{
	sendFlashAction( 'audioplayer', 'loadURL', '/content/audio/' + file_id + '.mp3' );
	sendFlashAction( 'audioplayer', 'sndPlay' );
}

// получить указатель на флаш-апплет
function _getFlash( movieName )
{
	if ( window.document[movieName] )
		return window.document[movieName];
	else if ( document.embeds && document.embeds[movieName] )
		return document.embeds[movieName]; 
	else
		return document.getElementById(movieName);
}

// функция, вызывающаяся как основная функция Flash_2_JS
function sendFlashAction( mov_name, action, field )
{
	var el;
	var fl = _getFlash( mov_name );

	if ( field ) el = document.getElementById ( field );
	fl[action] ( (el||{}).value );
}

function onFlashMessage( str ) 
{
	//alert ( str );
}