var syt;
function syn(s){//同步英文
	clearTimeout(syt);
	syn3(s);
	s++;
	if(s<sentencetime.length) syt= setTimeout("syn2(" + s + ")",(sentencetime[s]-sentencetime[s-1])*1000);
}
function syn2(s){
	clearTimeout(syt);
	syn3(s);
	s++;
	if(s<sentencetime.length) syt= setTimeout("syn(" + s + ")",(sentencetime[s]-sentencetime[s-1])*1000);
}
function syn3(s,e){
	for(i=0;i<sentencetime.length;i++){
		document.getElementById('en_' + (i+1)).style.color = '';
	}
	if(!e) document.getElementById('en_' + (s+1)).style.color = 'red';
}
var url = "wdxtl.wma";
var starttime = "50";
var endtime = "";
var state;
//初始化 
function wmpinit() 
{
	//window.document.wmp.settings.mute = true;
	//window.document.wmp.settings.autoStart = false;
	//window.document.wmp.settings.playCount = 1;
	//if(window.document.wmp.controls.currentPosition != 0) document.getElementById("warning").innerHTML = '<font color=red>warning:你的浏览器可能不支持单句发声，只能整篇朗读，请用ie打开本页面使用更多功能^_^</font>';
	load();
}
//加载
function  load(){
	//var loadtime0 = setTimeout('window.document.wmp.settings.mute = true;','10')
	document.getElementById("playerinfo").innerHTML = "loading...";
	var loadtime = setTimeout('loaded()','2000');
}
function  loaded(){
	document.getElementById("playerinfo").innerHTML = "<font color='#E9E8FF'>已载入声音文件，如果播放不正常,一般是由于网速慢造成的，请等待加载完毕后再播放</font>"; 
}
//播放
var st;
var ids;
function play(starttime,endtime,id) 
{
	if(starttime) starttime = starttime*1;
	if(endtime) endtime = endtime*1;
	if(id) id = id*1;
	window.document.wmp.controls.stop();
	window.document.wmp.settings.volume = 100;
	if(starttime) window.document.wmp.controls.currentPosition = starttime;
	if(!id || window.document.wmp.controls.currentPosition==0 || window.document.wmp.controls.currentPosition) syn(0);//id不存在或者当前进度为0 
	if(id && window.document.wmp.controls.currentPosition!=0) {
		clearTimeout(syt);
		syn3(id-1);
		ids = id;
	}
	clearInterval(state);
	clearTimeout(st); 
	window.document.wmp.controls.play();
	state = setInterval("updatetime()",1000); 
	document.getElementById("playerinfo").innerHTML = "<img src='" + TPL_URL + "/images/spinner.gif' class='wav' border='0'/><img src='" + TPL_URL + "/images/spinner.gif' class='wav' border='0'/>播放中...";
	if(endtime) st = setTimeout("stop()",(endtime-window.document.wmp.controls.currentPosition)*1000);
	if(starttime && !endtime){
		endtime = window.document.wmp.currentMedia.duration;
		st = setTimeout("stop()",(endtime-window.document.wmp.controls.currentPosition)*1000);
		syn(id-1);
	}
}
//停止 
function stop() 
{
	syn3(ids-1,'stop');
	window.document.wmp.controls.stop();
	clearTimeout(syt);
	clearInterval(state);
	clearTimeout(st); 
	document.getElementById("playerinfo").innerHTML = "已停止";
	st = setTimeout("document.getElementById('playerinfo').innerHTML = ' '",1000);
}
function updatetime() 
{ 
	document.getElementById("playerinfo").innerHTML = window.document.wmp.controls.currentPositionString + " | " + window.document.wmp.currentMedia.durationString + ' | <a href="JavaScript:stop()">停止</a>'; 
}