if(typeof autoPlayFlag=='undefined') var autoPlayFlag = true	//设定是否自动播放

var isIE = navigator.appVersion.toLowerCase().indexOf("msie") >= 0;

var curFile;

var flag = true;

var isPlayO = autoPlayFlag?true:false;
var isStopO = autoPlayFlag?false:true;
//var isPauseO = autoPlayFlag?false:true;
var isPauseO = false;
var playPic = new Image(35,36);
playPic.src="splay.jpg";
var stopPic = new Image(27,31);
stopPic.src="sstop.jpg";

function OnloadFun(){
	startdrag();
	setInterval("FixPos()",1000);
	if(typeof setTailPosition == 'function') setTailPosition();

}
document.body.onload=OnloadFun;

function GetObj(objName){
	if(document.getElementById){
		return eval('document.getElementById("' + objName + '")');
	}else{
		return eval('document.all.' + objName);
	}
}

function FullScreen(){
	if(document.MediaPlayer.Duration>0){
		document.MediaPlayer.DisplaySize = 3;
	}
}

function toPlay()
{
	if(!isIE){
		alert("请使用IE浏览器欣赏视频!谢谢!")
		return false;
	}
	if(document.MediaPlayer.Duration>0){
		if(isPlayO){
			toPause();
		}else{
			if(isStopO||isPauseO)
			{
				document.MediaPlayer.Play();
				document.images("playControl").src="spause.jpg";
				document.images("stopControl").src="sstop.jpg";

				isPlayO = true;
				isStopO = false;
				isPauseO = false;

			}
		}
	}
}

function toPlay2()
{
	document.MediaPlayer.AutoStart="True";
	document.images("playControl").src="spause.jpg";
	document.images("stopControl").src="sstop.jpg";
	isPlayO = true;
	isStopO = false;
	isPauseO = false;
	if(document.MediaPlayer.Duration>0){
		if(isStopO||isPauseO)
		{
			document.MediaPlayer.Play();
			document.images("playControl").src="spause.jpg";
			document.images("stopControl").src="sstop.jpg";
			isPlayO = true;
			isStopO = false;
			isPauseO = false;

		}
	}
}

function toStop()
{
	if(document.MediaPlayer.Duration>0){
		if(isPlayO||isPauseO)
		{
			document.MediaPlayer.AutoStart="False";
			document.MediaPlayer.Stop();
			document.images("playControl").src = playPic.src;
			document.images("stopControl").src = stopPic.src;
			isPlayO = false;
			isStopO = true;
	
			//document.MediaPlayer.FileName = curFile;
		}
	}
}

function toPause()
{
	if(document.MediaPlayer.Duration>0){
		if(isPlayO&&document.MediaPlayer.PlayState!=3)
		{
			document.MediaPlayer.Pause();
			document.images("playControl").src = playPic.src;

			isPlayO = false;
			isPauseO = true;
		}
	}
}

var fFlag= false;

//drag func
var pFlag = false;

var pZoneWidth = 176;//进度条的长度
var vZoneWidth = 25;//声音条的长度

function startdrag()
{
	if(document.MediaPlayer.Duration||(!isNaN(document.MediaPlayer.Duration))){
		window.document.onmousemove = mouseMove;
		window.document.ondragstart = mouseEnd;
		window.document.onmouseup = mouseUp;
	}
}

var isPorV = 0;
function mouseDown(objSign){
	isPorV = objSign;
	if(isPorV==0){
		if(document.MediaPlayer.Duration>0){
			pFlag = true;
			if(window.event.srcElement.id!='pZone') GetObj('pBox').style.left = GetObj('pBox').offsetLeft;
			else GetObj('pBox').style.left = (window.event.x-9);
		}
	}else if(isPorV==1){
		vFlag = true;
		if(window.event.srcElement.id!='vZone') GetObj('vBox').style.left = GetObj('vBox').offsetLeft;
		else GetObj('vBox').style.left = (window.event.x-4);
	}
}

function GetOLeft(myObj){
	curObj = myObj;

	var objLT = curObj.offsetLeft;
	while(curObj!=curObj.offsetParent && curObj.offsetParent){
		curObj=curObj.offsetParent;
		if(curObj.tagName=="DIV" || curObj.tagName=="TABLE" || curObj.tagName=="TR" || curObj.tagName=="TD"){
			objLT += curObj.offsetLeft;
		}

	}
	return objLT;
}

function mouseMove(){

		if(isPorV==0){
			if(document.MediaPlayer.Duration>0){

				if(pFlag) document.getElementById('pBox').style.left = window.event.clientX - GetOLeft(document.getElementById('pZone')) - 9 +"px"; //window.event.x-9;
				if (parseInt(document.getElementById('pBox').style.left.replace("px","")) > pZoneWidth) document.getElementById('pBox').style.left=pZoneWidth +"px";
				if (parseInt(document.getElementById('pBox').style.left.replace("px","")) < 0) document.getElementById('pBox').style.left=0 +"px";
			}

		}else if(isPorV==1){

			if(vFlag) document.getElementById('vBox').style.left = window.event.clientX - GetOLeft(document.getElementById('vZone')) - 4 +"px"; //window.event.x-9;
				if (parseInt(document.getElementById('vBox').style.left.replace("px","")) > vZoneWidth) document.getElementById('vBox').style.left=vZoneWidth +"px";
				if (parseInt(document.getElementById('vBox').style.left.replace("px","")) < 0) document.getElementById('vBox').style.left=0 +"px";
		}
}

function mouseUp()
{
	if(isPorV==0){
		if(document.MediaPlayer.Duration>0){
			if (pFlag){
				var duration = document.MediaPlayer.Duration;
				document.MediaPlayer.CurrentPosition=duration * (parseInt(document.getElementById('pBox').style.left)/pZoneWidth);
			}
			pFlag = false;
		}
	}else if(isPorV==1){
		if (vFlag){
			tempVol = (10 - (parseInt(GetObj('vBox').style.left)/3.7))*(-100);

			document.MediaPlayer.Volume=Math.round(tempVol);//duration * (parseInt(GetObj('vBox').style.left)/139);
		}
		vFlag = false;
	}
}

function mouseEnd()
{
	if(document.MediaPlayer.Duration>0){
		window.event.returnValue = false;
	}
}

function FixPos(){
	if(document.MediaPlayer.Duration>0){
		var duration = document.MediaPlayer.Duration;
		var pos = document.MediaPlayer.CurrentPosition;
		if (pos == 0)
		{
			var pBoxPos = Math.round(pos/duration*pZoneWidth)-0;
		}
		else{
			var pBoxPos = Math.round(pos/duration*pZoneWidth);
		}
		if (!isNaN(pBoxPos)) document.getElementById('pBox').style.left = pBoxPos;
		if(document.MediaPlayer.PlayState==0) toStop();
	}
}

function ShowState(){
	var msgObj = document.getElementById('picMsg');
	if(msgObj == null) return false;
	switch (document.MediaPlayer.PlayState){
		case 0:
			msgObj.innerText = '已就绪';
			break;
		case 1:
			msgObj.innerText = '已暂停';
			break;
		case 2:
			msgObj.innerText = '播放中';
			break;
		case 3:
			msgObj.innerText = '连接服务器';
			fFlag= true;
			break;
		case 4:
			msgObj.innerText = 'Stream is scanning forward';
			break;
		case 5:
			msgObj.innerText = 'Stream is scanning in reverse';
			break;
		case 6:
			msgObj.innerText = 'Skipping to next';
			break;
		case 7:
			msgObj.innerText = 'Skipping to previous';
			break;
		case 8:
			msgObj.innerText = '未打开任何影音文件';
			break;
		default:
			msgObj.innerText = '...';
	}

//0 mpStopped Playback is stopped. 
//1 mpPaused Playback is paused. 
//2 mpPlaying Stream is playing. 
//3 mpWaiting Waiting for stream to begin. 
//4 mpScanForward . 
//5 mpScanReverse Stream is scanning in reverse. 
//6 mpSkipForward Skipping to next. 
//7 mpSkipReverse Skipping to previous. 
//8 mpClosed Stream is not open. 

}

function VolumeUp(vol){
	tempVol = (10 - vol)*(-100);
	document.MediaPlayer.Volume= tempVol;
	MyVolume = tempVol;
	document.getElementById('vBox').style.left = vol/10*35;
}
var isMute = false;
var MyVolume = -600;
function Mute() {
	if (isMute)
	{
		document.MediaPlayer.Volume = MyVolume;
		document.getElementById("muteControl").src="sy_sp_bfq_05.jpg";
		isMute = false;
	} else {
		document.MediaPlayer.Volume = -10000;
		document.getElementById("muteControl").src="sy_sp_bfq_05a.jpg";
		isMute = true;
	}	
}
function VUp() {//sy_sp_bfq_05a_01.jpg
	var src = document.getElementById("vBanner").src;

	//alert(src + src.indexOf("sy_sp_bfq_05a_"));
	var curVal = parseInt(src.substr(src.indexOf("sy_sp_bfq_05a_")+14, 1));
	if (curVal<5)
	{		
		curVal++;
		if (curVal == 1)
		{
			document.getElementById("vBanner").src="sy_sp_bfq_05a_"+curVal+".jpg";
			document.MediaPlayer.Volume = (5 - curVal)*(-200);
			MyVolume = document.MediaPlayer.Volume;
			Mute();
			return;
		}
		document.getElementById("vBanner").src="sy_sp_bfq_05a_"+curVal+".jpg";
		document.MediaPlayer.Volume = (5 - curVal)*(-200);
		MyVolume = document.MediaPlayer.Volume;
	}
}
function VDown() {
	var src = document.getElementById("vBanner").src;
	var curVal = parseInt(src.substr(src.indexOf("sy_sp_bfq_05a_")+14, 1));
	if (curVal>0)
	{
		curVal--;
		if (curVal == 0)
		{
			document.getElementById("vBanner").src="sy_sp_bfq_05a_"+curVal+".jpg";
			MyVolume = document.MediaPlayer.Volume;
			Mute();
			return;
		}
		document.getElementById("vBanner").src="sy_sp_bfq_05a_"+curVal+".jpg";
		MyVolume = document.MediaPlayer.Volume;
		document.MediaPlayer.Volume = (5 - curVal)*(-200);
	}
}
function play(file) {
	document.MediaPlayer.FileName = file;
	toPlay2();
}
var objHTML1 = ("	<OBJECT ID='MediaPlayer' width='"+vWidth+"' height='"+vHeight+"' CLASSID='CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95' STANDBY='Loading Windows Media Player components...' TYPE='application/x-oleobject' VIEWASTEXT>");
objHTML1 += ("	<PARAM NAME='FileName' VALUE='");


var objHTML2 = ("'>");
objHTML2 += ("	<PARAM NAME='AutoStart' VALUE='"+(autoPlayFlag?"True":"False")+"'>");
objHTML2 += ("	<PARAM NAME='ShowStatusBar' VALUE='True'>");
objHTML2 += ("	<PARAM NAME='ShowControls' VALUE='False'>");
objHTML2 += ("	<PARAM NAME='ShowTracker' VALUE='False'>");
objHTML2 += ("	<PARAM NAME='EnableTracker' VALUE='False'>");
objHTML2 += ("	<PARAM NAME='ShowPositionControls' VALUE='False'>");
objHTML2 += ("	<PARAM NAME='EnablePositionControls' VALUE='False'>");
objHTML2 += ("	<param name='enableContextMenu' value='false'>");

objHTML2 += ("	</OBJECT>");

document.writeln("    <table width='326' border='0' align='center' cellpadding='0' cellspacing='0'>");
document.writeln("      <tr>");
document.writeln("        <td width='6' rowspan='4'><img src='sleft.jpg' width='12' height='294' /></td>");
document.writeln("        <td width='296' height='141'>");
document.writeln("			<center><div id='myScreen' style='border:0px solid #000;display:block;'>");
document.writeln(objHTML1 + curFile + objHTML2);

document.writeln("			</div></center>");

document.writeln("			</td>")
document.writeln("        <td width='6' rowspan='4'><img src='sright.jpg' width='12' height='294' /></td>");
document.writeln("      </tr>");
document.writeln("      <tr>");
document.writeln("        <td valign='top'><img src='sy_sp_bk_03.jpg' width='320' height='4' /></td>");
document.writeln("      </tr>");

document.writeln("      <tr>");
document.writeln("        <td height='53'  valign='top' background='bottom.jpg'><table border='0' align='left'  width='320' cellpadding='0' cellspacing='0'>");
document.writeln("          <tr>");
document.writeln("            <td id='pZone' width='200' onmousedown='mouseDown(0)' style='POSITION: relative;left:0;' height='6' colspan='2' background='tiao.jpg'><div id='pBox' style='OVERFLOW: hidden;POSITION: relative;cursor:e-resize;left:0px;top:0px;width:9px;height:10px;background-image:url(yuan.jpg);'></div></td>");
document.writeln("          </tr>");



document.writeln("      <tr>");
document.writeln("        <td valign='top' height='6'></td>");
document.writeln("      </tr>");



document.writeln("          <tr>");
document.writeln("              <td width=\"214\" height=\"17\" ><img id=playControl src=\""+(autoPlayFlag?"spause.jpg":"splay.jpg")+"\" width=\"42\" height=\"17\" style='cursor:pointer;' onClick='toPlay()'/><img id=stopControl src=\""+(autoPlayFlag?"sstop.jpg":"sstop.jpg")+"\" width=\"42\" height=\"17\" hspace=\"10\" style='cursor:pointer;' onClick='toStop()' /></td>");
document.writeln("            <td ><table width='100%' border='0' cellspacing='0' cellpadding='0'>" );
document.writeln("                <tr>");
document.writeln("                  <td colspan='3'><img id=full src=\"full.jpg\" width=\"27\" height=\"17\" onClick='FullScreen();' style='cursor:pointer;' /></td>");
document.writeln("                  <td colspan='3' width='8'></td>");
document.writeln("                  <td colspan='3'><img id=muteControl src=\"sy_sp_bfq_05.jpg\" width=\"27\" height=\"17\" onClick='Mute();' style='cursor:pointer;' /></td>");
document.writeln("                  <td colspan='3' width='25'>&nbsp</td>");
document.writeln("                  <td colspan='3'><img onClick='VDown();' src='sy_sp_bfq_06a.gif' width='16' height='17' /></td>");
document.writeln("                  <td colspan='3' width='4'></td>");
document.writeln("                  <td colspan='3' width='80'><img id=vBanner src='sy_sp_bfq_05a_5.jpg' width='70' height='16' /></td>");
document.writeln("                  <td colspan='3' width='4'></td>");
document.writeln("                  <td colspan='3'><img onClick='VUp();' src='sy_sp_bfq_06b.gif' width='16' height='17' /></td>");
document.writeln("                </tr>");
document.writeln("            </table></td>");
document.writeln("          </tr>");
document.writeln("        </table></td>");
document.writeln("      </tr>");
document.writeln("    </table>");

//$ {代码显示}
