var mPath = "";
var bgImage = "";
var video_filename = "";
var music_playing = false;

function LoadVideo() {
	MusicPlayer.Cancel();
	timer=window.setTimeout("video_play()",200);
}

function video_play() {
	music_playing = true;
	MusicPlayer.Open(m_form.m_name.value);
	document.title = m_form.m_name.options[m_form.m_name.selectedIndex].text;
}

function music_end() {
	play_select();
	if(m_form.cont.checked == true)
		LoadVideo(m_form.m_name.value);
}

function play_next() {
	play_select();
	if (music_playing == true)
		LoadVideo(m_form.m_name.value);
}

function play_select() {
	var m_rand = 0;

//	for (var i=0;i<document.m_form.m_rand.length;i++) {
//		if(document.m_form.m_rand[i].checked) {
//			m_rand = document.m_form.m_rand[i].value;
//			break;
//		}
//	}

//	if(m_rand == 0){		//random play
		next_num = getRandom(0,m_form.m_name.length);
//	} else if(m_rand == 1){	//continuous play
//		if(m_form.m_name.length-1 > m_form.m_name.selectedIndex)
//			next_num = m_form.m_name.selectedIndex+1;
//		else
//			next_num = 0;
//	} else if(m_rand == 2){	//only one music play
//		next_num = m_form.m_name.selectedIndex;
//	}
	m_form.m_name.options[next_num].selected=true;
}

function getRandom(s_num,e_num) {
	num = Math.random()*(e_num-s_num)+s_num;
	return Math.floor(num);
}

function play_stop() {
	document.title='pause';
	MusicPlayer.Stop()
	music_playing = false;
}

function end_of_music() {
	document.title='end.';
	music_end();
}

function error_of_music() {
	document.title='error';
}
