var stopped = false, paused = false;
var check_id = 0;

function moviePlay() {
	var f = getFlashMovieObject("filmik");
	if( f == null ) return;
	moviePhotoDisplay( "none" );

	if( stopped ) stopped = false;

	try {	f.Play(); } catch( e ) { }
	if( check_id == 0 ) check_id = setInterval( movieCheckForStop, 300 );
}

function moviePause() {
	var f = getFlashMovieObject("filmik");
	if( f == null ) return;
	paused = true;
	try { f.StopPlay(); } catch(e) { }
}

function movieStop() {
	if( stopped ) return;
	var f = getFlashMovieObject("filmik");
	if( f == null ) return;
	try { f.StopPlay(); } catch(e) { }
	try { f.GotoFrame( "0" ); } catch(e) { }
	stopped = true;
	if( check_id > 0 ) {
		clearInterval(check_id);
		check_id = 0;
	}

	moviePhotoDisplay("block");
}

function movieCheckForStop() {
	var f = getFlashMovieObject("filmik");
	if( f == null ) return;

	if( !f.IsPlaying() && !paused )	movieStop();
}

function started() {
	movieStop();
}

function moviePhotoDisplay(d) {
	var ph = document.getElementById( "moviePhoto" );
	var df = document.getElementById( "divFilmik" );
	if( ph ) ph.style.display = d;
	if( df ) df.style.display = d == "none" ? "block" : "none";
}

