var bg_sound = {};
bg_sound.init = false;

function _init_bgsound(){
	if (_init_bgsound.first) return;
	_init_bgsound.first = true;
	
	var swfVersionStr = "10.0.0";
	var xiSwfUrlStr = "/player/playerProductInstall.swf";
	var flashvars = {};
	
	var params = {};
	params.quality = "low";
	params.bgcolor = "#ffffff";
	params.allowscriptaccess = "sameDomain";
	params.allowfullscreen = "false";
	
	var attributes = {};
	attributes.id = "VGaudio";
	attributes.name = "VGaudio";
	
	$('body').append($('<div id="adasdasdasdasdasdasd"></div>'));
	
	swfobject.embedSWF(
	"/player/VGaudio.swf", "adasdasdasdasdasdasd", "0", "0", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes, 
	function(e){
		bg_sound.obj = e.ref;
		var init = setInterval(function(){
			if (!bg_sound.obj && !bg_sound.obj.action_play)
				return;
			
			bg_sound.init = true;
			clearInterval(init);
		}, 300);
	});
	
	return bg_sound;
}

function _play_bg_sound(file){
	bg_sound.file = file;
	
	_play_bg_sound.wait = setInterval(function(){
		if (!bg_sound.init)
			return;
		
		clearInterval(_play_bg_sound.wait);
		bg_sound.obj.action_play(bg_sound.file);
	}, 100);
}

function _stop_bg_sound(){
	_stop_bg_sound.wait = setInterval(function(){
		if (!bg_sound.init)
			return;
		
		clearInterval(_stop_bg_sound.wait);
		bg_sound.obj.action_stop();
	}, 100);
}
