var sectionId = 0;
function start(){
	
	if(random_bg_music == 1){
		start_again();
	}
	else{
		playing(music_bg_array[0]);
	}
}		

function start_again(){
	var my_m_path = music_bg_array[Math.floor(Math.random()*music_bg_array.length)] 
	playing2(my_m_path);
	window.setTimeout("start_again()",63000);
}

var globalContentForMusic = '';
function playing(musicPath){
	
	var temp = musicPath.split(".");
	if(temp[1]=='mp3'){
		globalContentForMusic = "<object height='0' width='0' classid='CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95'><param name='SRC' value='"+musicPath+"'></param><param name='Showcontrols' value='True'></param><param name='autostart' value='1'></param><embed style='height:0px; width:0px;' autostart='true' showcontrols='true' src='"+musicPath+"' name='MediaPlayer'></embed></object>";
	}
	else{
		globalContentForMusic = "<EMBED id=\"playerStream\" name =\"playerStream\" src= '"+musicPath+"' border=\"0\" WIDTH=\"0px\" HEIGHT=\"0px\" AUTOSTART=\"TRUE\" LOOP=\"false\" VOLUME=\"100\" TYPE=\"audio/x-pn-realaudio-plugin\" HIDDEN=\"true\" ></EMBED>";
	}
	
	$('#music_container').html( globalContentForMusic );
}

function playing2(musicPath){
	
	var temp = musicPath.split(".");
	if(temp[1]=='mp3'){
		globalContentForMusic = "<object height='0' width='0' classid='CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95'><param name='SRC' value='"+musicPath+"'></param><param name='Showcontrols' value='True'></param><param name='autostart' value='1'></param><embed style='height:0px; width:0px;' autostart='true' showcontrols='true' src='"+musicPath+"' name='MediaPlayer' SelectionEnd='60'></embed></object>";
	}
	else{
		globalContentForMusic = "<EMBED id=\"playerStream\" name =\"playerStream\" src= '"+musicPath+"' border=\"0\" WIDTH=\"0px\" HEIGHT=\"0px\" AUTOSTART=\"TRUE\" LOOP=\"false\" VOLUME=\"100\" TYPE=\"audio/x-pn-realaudio-plugin\" HIDDEN=\"true\" SelectionEnd='60'></EMBED>";
	}
	
	$('#music_container').html( globalContentForMusic );
	
}

function player_on(){
	$('#music_container').html( globalContentForMusic );
	if(audio_is_off == 1){
		start(sectionId);
	}
}

var audio_is_off = 0;
function player_off(){
	$('#music_container').html('');
	audio_is_off = 1;
}
