
document.write("<script language=\"javascript\" src=\"dojo/dojo.js\"></script>");
if (typeof autoPlayFlag == "undefined") {
	var autoPlayFlag = true;
}	//播放器是否自动开始播放
if (typeof iniPic == "undefined") {
	var iniPic = "";
}					//播放器不停止时的显示图片
if (typeof showInfo == "undefined") {
	var showInfo = "\u6b63\u5728\u76f4\u64ad";
}
if (typeof videoFile == "undefined") {
	var videoFile = "";
}			//播放器的播放文件
if (typeof baseUrl == "undefined") {
	var baseUrl = "web/images/player/";
}					//图片的根路径
if (typeof isVideo=='undefined'){
	var isVideo=true;
}
var pWidth = 422;												//播放器的宽，不能变动
var vWidth = 418;												//视频的宽，不能变动
var vHeight = 314;												//视频的高，不能变动
var isPlayO = autoPlayFlag ? true : false;
var isStopO = autoPlayFlag ? false : true;
var isPauseO = autoPlayFlag ? false : true;
var playPic = new Image();
playPic.src = baseUrl + "/play.jpg";
var playOverPic = new Image();
playOverPic.src = baseUrl + "/play_over.jpg";
var stopPic = new Image();
stopPic.src = baseUrl + "/stop.jpg";
var stopOverPic = new Image();
stopOverPic.src = baseUrl + "/stop_over.jpg";
var pausePic = new Image();
pausePic.src = baseUrl + "/play_over.jpg";
var muteOnPic = new Image();
muteOnPic.src = baseUrl + "/voice.jpg";
var muteOffPic = new Image();
muteOffPic.src = baseUrl + "/novoice.jpg";
var muteOnOverPic = new Image();
muteOnOverPic.src = baseUrl + "/voice_over.jpg";
var muteOffOverPic = new Image();
muteOffOverPic.src = baseUrl + "/novoice_over.jpg";
var fullScreenPic = new Image();
fullScreenPic.src = baseUrl + "/screenpic.jpg";
var fullScreenOverPic = new Image();
fullScreenOverPic.src = baseUrl + "/fullscreen_over.jpg";
var voiceButton = new Image();
voiceButton.src = baseUrl + "/button_volumn.gif";
var voiceButtonOverPic = new Image();
voiceButtonOverPic.src = baseUrl + "/button_volumn_over.gif";
function GetObj(objName) {
	if (document.getElementById) {
		return eval("document.getElementById(\"" + objName + "\")");
	} else {
		return eval("document.all." + objName);
	}
}
var isIE = navigator.appVersion.toLowerCase().indexOf("msie") >= 0;

//遮盖标识，true表示正显示图片；false表示正显示视频
var flag = !autoPlayFlag;
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=\"449\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
document.writeln("       <tr>");
document.writeln("          <td height=\"15\" colspan=\"3\" align=\"center\"><img src=\""+baseUrl+"/top_order.jpg\" width=\"449\" height=\"15\" /></td>");
document.writeln("  	 </tr>");
document.writeln("   <tr>");
document.writeln("    <td width=\"12\"><img src=\""+baseUrl+"/left.jpg\" width=\"15\" height=\"314\" /></td>");
document.writeln("     <td width=\"422\">");
document.writeln("      <div id=\"screenPic\" width=\"422\" "+(isVideo?"style=\"display: "+(autoPlayFlag ?"none" :"block")+";\"":"style=\"display: block;")+" \" onclick=\"javascript:toPlay();\">");
document.writeln("       <img src=\"" + baseUrl + "/screenpic.jpg\" width=\"418\" height=\"310\"  style=\"cursor: hand\" />");
document.writeln("      </div>");
document.writeln("      <div id=\"screenVideo\" "+(isVideo?"style=\"display: "+(autoPlayFlag ?"block" :"none")+";\"":"style=\"display: none")+";height: 314;width=418\">");
document.writeln(			objHTML1 + videoFile + objHTML2);
document.writeln("     </div>");
document.writeln("    </td>");
document.writeln("     <td width=\"15\"><img src=\"" + baseUrl + "/right.jpg\" width=\"15\" height=\"314\" /></td>");
document.writeln("      </tr>");
document.writeln("      <tr>");
document.writeln("      <td colspan=\"3\"><img src=\"" + baseUrl + "/bottom.jpg\" width=\"449\" height=\"10\" /></td>");
document.writeln("       </tr>");
document.writeln("       <tr>");
document.writeln("       <td colspan=\"3\"><table width=\"449\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
document.writeln("       </tr>");
document.writeln("        <tr>");
document.writeln("       <td width=\"48\"><img title=\"播放\" id=\"playControl\" onmouseover='playOver();' onmouseout='playOver();' src=\"" + baseUrl + "/"+(autoPlayFlag ?"play_over.jpg" :"play.jpg")+"\" width=\"48\" height=\"33\" onclick=\"toPlay();\"/></td>");
document.writeln("       <td width=\"26\"><img title=\"停止\" id=\"stopControl\" src=\"" + baseUrl + "/stop.jpg\" width=\"26\" height=\"33\" onclick=\"toStop();\" onmouseover=\"stopOver();\" onmouseout=\"stopOver();\" style=\"cursor:hand\"/></td>");
document.writeln("       <td width=\"26\"><img title=\"全屏\" id=\"fullScrControl\" src=\"" + baseUrl + "/fullscreen.jpg\" width=\"26\" height=\"33\" style=\"cursor:hand;\" onclick=\"FullScreen();\" onmouseover=\"fullScreenOver();\" onmouseout=\"fullScreenOver();\"/></td>");
document.writeln("		<td width=\"9\"><img src=\""+baseUrl+"/jinduleft.jpg\" width=\"9\" height=\"33\" /></td>");
document.writeln("      <td id=\"pZone\" onmousedown=\"mouseDown(0);\" width=\"166\" background=\""+baseUrl+"/jindu.jpg\" style='POSITION: relative;left:0px;'><div id='pBox' title='移动滑块控制影片进度'  style='OVERFLOW: hidden;POSITION: relative;cursor:e-resize;left:0px;top:10px;width:16px;height:10px;background-image:url("+baseUrl+"/button_jindu.gif);'></div></td>");
document.writeln("      <td width=\"9\"><img src=\""+baseUrl+"/jinduright.jpg\" width=\"9\" height=\"33\" /></td>");
document.writeln("       <td width=\"25\"><img id=\"muteControl\" src=\"" + baseUrl + "/voice.jpg\" width=\"25\" height=\"33\" onclick='Mute();' onmouseover='mouseOverMute();' onmouseout='mouseOutMute();' style='POSITION: relative;left:0;' /></td>");
document.writeln("       <td width=\"122\" id='vZone' background=\"" + baseUrl + "/volumn.jpg\"><div id='vBox' title='\u79fb\u52a8\u6ed1\u5757\u63a7\u5236\u97f3\u91cf' style='OVERFLOW: hidden;POSITION: relative;cursor: pointer;left:0px;width:11px;height:10px;background-image:url(" + baseUrl + "/button_volumn.gif)' onmousedown='mouseDown(1);'></div></td>");
document.writeln("       <td width=\"18\"><img src=\"" + baseUrl + "/volumnright.jpg\" width=\"18\" height=\"33\" /></td>");
document.writeln("     </tr>");
document.writeln("    </table></td>");
document.writeln("  </tr>");
document.writeln(" </table>");
if (!isIE) {
	showNoIE();
}
function showNoIE() {
	GetObj("myScreen").innerHTML = "<img width=" + vWidth + " height=" + vHeight + " src=" + baseUrl + "player/noie.gif alt=\"\u8bf7\u4f7f\u7528IE\u6d4f\u89c8\u5668\u89c2\u770b\u89c6\u9891\"/>";
}
function FullScreen() {
	if (isPlayO) {
		GetObj("MediaPlayer").DisplaySize = 3;
	}
}
function mouseOverMute() {
	if (document.images("muteControl").src == muteOnPic.src) {
		document.images("muteControl").src = muteOnOverPic.src;
	} else {
		if (document.images("muteControl").src == muteOffPic.src) {
			document.images("muteControl").src = muteOffOverPic.src;
		}
	}
}
function mouseOutMute() {
	if (document.images("muteControl").src == muteOnOverPic.src) {
		document.images("muteControl").src = muteOnPic.src;
	} else {
		if (document.images("muteControl").src == muteOffOverPic.src) {
			document.images("muteControl").src = muteOffPic.src;
		}
	}
}
function playOver() {
	if (GetObj("playControl").src == playOverPic.src) {
		GetObj("playControl").src = playPic.src;
	} else {
		if (GetObj("playControl").src == playPic.src) {
			GetObj("playControl").src = playOverPic.src;
		}
	}
	if(isPlayO){
		GetObj("playControl").src = playOverPic.src;
	}
}
function stopOver() {
	if (GetObj("stopControl").src == stopPic.src) {
		GetObj("stopControl").src = stopOverPic.src;
	} else {
		if (GetObj("stopControl").src == stopOverPic.src) {
			GetObj("stopControl").src = stopPic.src;
		}
	}
}
function fullScreenOver() {
	if (GetObj("fullScrControl").src == fullScreenOverPic.src) {
		GetObj("fullScrControl").src = fullScreenPic.src;
	} else {
		if (GetObj("fullScrControl").src == fullScreenPic.src) {
			GetObj("fullScrControl").src = fullScreenOverPic.src;
		}
	}
}
function voiceButtonOver() {
//	if (GetObj("vBox").style.background-image == voiceButton.src) {
//		GetObj("vBox").src = voiceButtonOverPic.src;
//	} else {
//		if (GetObj("voiceButton").src == voiceButtonOverPic.src) {
//			GetObj("voiceButton").src = voiceButton.src;
//		}
//	}
}
function Mute() {
	if (GetObj("MediaPlayer").Mute.toString().toLowerCase() == "true") {
		GetObj("MediaPlayer").Mute = "False";
		document.images("muteControl").src = muteOnPic.src;
		document.images("muteControl").alt = "\u5173\u95ed\u58f0\u97f3";
	} else {
		GetObj("MediaPlayer").Mute = "True";
		document.images("muteControl").src = muteOffPic.src;
		document.images("muteControl").alt = "\u6253\u5f00\u58f0\u97f3";
	}
}
function checkPlay(){
	if(GetObj("MediaPlayer").PlayState==0){
		toStop();
	}
}
var interval;
function toPlay() {
	if (!isIE) {
		alert("\u8bf7\u4f7f\u7528IE\u6d4f\u89c8\u5668\u6b23\u8d4f\u89c6\u9891!\u8c22\u8c22!");
		return false;
	}
	if (isStopO || isPauseO) {
		GetObj("MediaPlayer").Play();
		GetObj("MediaPlayer").AutoStart=true;
		interval=setInterval("checkPlay()", 1000);
		document.images("playControl").src = playOverPic.src;
		document.images("stopControl").src = stopPic.src;
		isPlayO = true;
		isStopO = false;
		isPauseO = false;
		if(isVideo){
			dojo.byId("screenPic").style.display="none";
			dojo.byId("screenVideo").style.display="block";
		}else{
			dojo.byId("screenPic").style.display="block";
			dojo.byId("screenVideo").style.display="none";
		}
	}
	if (flag) {
	if(isVideo){
		GetObj("screenPic").style.display = "none";
		}
		GetObj("screenVideo").style.display = "block";
		flag = false;
	}
}

//back to ini video
function toStop() {
		if (isPlayO || isPauseO) {
			GetObj("MediaPlayer").AutoStart = "False";
			GetObj("MediaPlayer").Stop();
			document.images("playControl").src = playPic.src;
			document.images("stopControl").src = stopOverPic.src;
			isPlayO = false;
			isStopO = true;
			isPauseO = false;
			if(isVideo){
				GetObj("screenPic").style.display = "block";
			}
			GetObj("screenVideo").style.display = "none";
			GetObj("MediaPlayer").FileName = videoFile;
			window.clearInterval(interval);
				
	}
}
function toPause() {
	if (GetObj("MediaPlayer").Duration > 0) {
		if (isPlayO && GetObj("MediaPlayer").PlayState != 3) {
			GetObj("MediaPlayer").Pause();
			document.images("playControl").src = playPic.src;
			isPlayO = false;
			isPauseO = true;
		}
	}
}
function OnloadFun() {
	startdrag();
	setInterval("FixPos()", 1000);
}
dojo.addOnLoad(OnloadFun);
var pBoxLength = GetObj("pBox").style.width.replace("px", "");//进度条上钮宽
var vBoxLength = GetObj("vBox").style.width.replace("px", "");//声音条上钮宽
var pZoneLength = GetObj("pZone").width - pBoxLength;//进度条宽
var vZoneLength = GetObj("vZone").width - vBoxLength;//声音条宽
function startdrag() {
	if (GetObj("MediaPlayer").Duration || (!isNaN(GetObj("MediaPlayer").Duration))) {
		window.document.onmousemove = mouseMove;
		window.document.ondragstart = mouseEnd;
		window.document.onmouseup = mouseUp;
	} else {
		showNoIE();
	}
}
//拖动对象标识：0进度条；1声音条
var isPorV = 1;
var pFlag = false;//true表示正在拖动进度条
var vFlag = false;//true表示正在拖动声音条
function mouseDown(objSign){
	isPorV = objSign;
	if(isPorV==0){
		if(GetObj("MediaPlayer").Duration>0 && GetObj("MediaPlayer").PlayState!=0){
			pFlag = true;
			if(window.event.srcElement.id!='pZone') {
				GetObj('pBox').style.left = GetObj('pBox').offsetLeft;
				}
			else GetObj('pBox').style.left = window.event.x;
		}
	}else if(isPorV==1){
		if(GetObj("MediaPlayer").PlayState!=0){
			vFlag = true;
			if(window.event.srcElement.id!='vZone'){
				 GetObj('vBox').style.left = GetObj('vBox').offsetLeft;
			}
			else {
				GetObj('vBox').style.left = window.event.x;
			}
		}
	}
}
function mouseOut(objSign) {
	isPorV = objSign;
	if (isPorV == 0) {
		if (GetObj("MediaPlayer").Duration > 0 && GetObj("MediaPlayer").PlayState != 0) {
			pFlag = true;
			if (window.event.srcElement.id != "pZone") {
				GetObj("pBox").style.left = GetObj("pBox").offsetLeft;
			} else {
				GetObj("pBox").style.left = window.event.x;
			}
		}
	} else {
		if (isPorV == 1) {
			if (GetObj("MediaPlayer").PlayState != 0) {
				vFlag = true;
				if (window.event.srcElement.id != "vZone") {
					GetObj("vBox").style.left = GetObj("vBox").offsetLeft;
				} else {
					GetObj("vBox").style.left = window.event.x;
				}
			}
		}
	}
}
function mouseMove() {
	if (isPorV == 0) {
		if (GetObj("MediaPlayer").Duration > 0 && GetObj("MediaPlayer").PlayState != 0) {
			if (pFlag) {
				GetObj("pBox").style.left = window.event.clientX - GetOLeft(GetObj("pZone")) + "px";
			}
			if (parseInt(GetObj("pBox").style.left.replace("px", "")) > pZoneLength) {
				GetObj("pBox").style.left = pZoneLength + "px";
			}
			if (parseInt(GetObj("pBox").style.left.replace("px", "")) < 0) {
				GetObj("pBox").style.left = 0 + "px";
			}
		}
	} else {
		if (isPorV == 1) {
			if (GetObj("MediaPlayer").PlayState != 0) {
				if (vFlag) {
					GetObj("vBox").style.left = window.event.clientX - GetOLeft(GetObj("vZone")) + "px";
				}
				if (parseInt(GetObj("vBox").style.left.replace("px", "")) > vZoneLength) {
					GetObj("vBox").style.left = vZoneLength + "px";
				}
				if (parseInt(GetObj("vBox").style.left.replace("px", "")) < 0) {
					GetObj("vBox").style.left = 0 + "px";
				}
			}
		}
	}
}
function mouseUp() {
	if (isPorV == 0) {
		if (GetObj("MediaPlayer").Duration > 0 && GetObj("MediaPlayer").PlayState != 0) {
			if (pFlag) {
				var duration = GetObj("MediaPlayer").Duration;
				GetObj("MediaPlayer").CurrentPosition = duration * (parseInt(GetObj("pBox").style.left) / pZoneLength);
			}
			pFlag = false;
		}
	} else {
		if (isPorV == 1) {
			if (GetObj("MediaPlayer").Duration > 0 && GetObj("MediaPlayer").PlayState != 0) {
				if (vFlag) {
					tempVol = (10 - (10 * parseInt(GetObj("vBox").style.left) / vZoneLength)) * (-340);
					if (tempVol <= -3400) {
						if (GetObj("MediaPlayer").Mute.toString().toLowerCase() == "false" && document.images("muteControl").src != muteOffPic.src) {
							GetObj("MediaPlayer").Mute = "True";
							document.images("muteControl").src = muteOffPic.src;
							document.images("muteControl").alt = "\u6253\u5f00\u58f0\u97f3";
						}
					} else {
						if (GetObj("MediaPlayer").Mute.toString().toLowerCase() == "true") {
							GetObj("MediaPlayer").Mute = "False";
							document.images("muteControl").src = muteOnPic.src;
							document.images("muteControl").alt = "\u5173\u95ed\u58f0\u97f3";
						}
					}
					GetObj("MediaPlayer").Volume = Math.round(tempVol);//duration * (parseInt(GetObj('vBox').style.left)/139);
				}
			}
			vFlag = false;
		}
	}
}
function mouseEnd() {
	if (GetObj("MediaPlayer").Duration > 0) {
		window.event.returnValue = false;
	}
}
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 FixPos() {
	if (GetObj("MediaPlayer").Duration > 0) {
		var duration = GetObj("MediaPlayer").Duration;
		var pos = GetObj("MediaPlayer").CurrentPosition;
		var pBoxPos = Math.round(pos / duration * pZoneLength);
		if (!isNaN(pBoxPos)) {
			GetObj("pBox").style.left = pBoxPos;
		}
		if (GetObj("MediaPlayer").PlayState == 0) {
			toStop();
		}
	}
}
/*
function ShowState(){
	var msgObj = GetObj('picMsg');
	if(msgObj == null) return false;
	switch (GetObj("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) * (-340);
//GetObj("MediaPlayer").Volume = tempVol;
	GetObj('vBox').style.left = vol/10*vZoneLength-vBoxLength;
	GetObj("vBox").style.left = vol / 10 * vZoneLength - vBoxLength;
}
if(autoPlayFlag){
	interval=setInterval("checkPlay()", 1000);
}

