
function id(name)
{
	return document.getElementById(name);
}
function switchSound()
{
    
	var audio = id('audio');
	var  playmusic = $("#playmusic");
	if(audio.paused){
		audio.play();
		playmusic.addClass("on");
	}else{
		audio.pause();
		playmusic.removeClass("on");
	}
	
}

function playbksound()
{

	var audio = id('audio');
	
	if(audio){
	    
		audio.play();
	}
	
}


function in_weixin()
{
	var ua = navigator.userAgent.toLowerCase();

	if(ua.match(/MicroMessenger/i) == "micromessenger") {return true;}
	
	return false;
}


(function(){
	
	var onBridgeReady = function () {	

		playbksound();			
		
	};
	
	if(document.addEventListener){
		document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
	} else if(document.attachEvent){
		document.attachEvent('WeixinJSBridgeReady' , onBridgeReady);
		document.attachEvent('onWeixinJSBridgeReady' , onBridgeReady);
	}
	
	if(!in_weixin())
	{
		setTimeout(function(){
			playbksound();
			
		}, 500);		
	}
})();
