//document.writeln("123");
//alert((autoPlayFlag)?"none":"block");


//scripted by guowei1 bellow, 2004
var isIE = navigator.appVersion.toLowerCase().indexOf("msie") >= 0;


var curBroad = MovieFile;
var curFile;



var flag = true;

function OnloadFun(){
	startdrag();
	setInterval("FixPos()",1000);

}
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;
	}
}




var mutePic = new Image();
mutePic.src = "/images/vod_bt/bnp_mute0.gif";
function Mute()
{
	//alert(MediaPlayer.Mute);
	if(document.MediaPlayer.Mute.toString().toLowerCase()=='true')
	{
		document.MediaPlayer.Mute='False';
		document.images("muteControl").src = "/images/vod_bt/bnp_mute1.gif";
		document.images("muteControl").alt = "关闭声音";
	}else{
		document.MediaPlayer.Mute='True';
		document.images("muteControl").src = mutePic.src;
		document.images("muteControl").alt = "打开声音";
	}
}

var isPlayO = autoPlayFlag?true:false;
var isStopO = autoPlayFlag?false:true;
var isPauseO = autoPlayFlag?false:true;
var playPic = new Image();
playPic.src = "/images/vod_bt/bnp_play.gif";
var stopPic = new Image();
stopPic.src = "/images/vod_bt/bnp_stop0.gif";
//var pausePic = new Image(28,77);
//pausePic.src = "http://image2.sina.com.cn/dongman/bn_new//images/vod_bt/gw_bn_mp_18.gif";


function toPlay()
{
	if(!isIE){
		alert("请使用IE浏览器欣赏视频!谢谢!")
		return false;
	}
	/*
	if(document.MediaPlayer.FileName != MovieFile && document.MediaPlayer.FileName != curPreN){
		
		ChgBN(MovieFile,curPreN);
		return false;
	}
	*/
	//document.MediaPlayer.AutoStart="True";
	if(document.MediaPlayer.PlayState!=3 && document.MediaPlayer.PlayState!=8){
		if(isPlayO){
			toPause();
		}else{
			if(isStopO||isPauseO)
			{

				/* 050829 新增 part1 begin */
				if(!(isswf==""||isswf==null)){
					GetObj("hideScreen").innerHTML = "";
				}
				/* 050829 新增 part1 end */

				//alert(isStopO||isPauseO);
				document.MediaPlayer.Play();
				document.MediaPlayer.AutoStart="True";
				document.images("playControl").src = "/images/vod_bt/bnp_pause.gif";
				document.images("stopControl").src = "/images/vod_bt/bnp_stop1.gif";
				//document.images("pauseControl").src = "http://image2.sina.com.cn/dongman/BN/http://image2.sina.com.cn/dongman/bn_new//images/vod_bt/vod009.gif";
				isPlayO = true;
				isStopO = false;
				isPauseO = false;
				//alert(isPlayO +"=="+ isStopO+"=="+ isPauseO);

			}
				if(flag){
					GetObj('hideScreen').style.display = 'none';
					GetObj('myScreen').style.display = 'block';
					flag = false;
				}
		}
	}
	if(document.getElementById("div_end_flash_ad")) document.getElementById("div_end_flash_ad").style.display='none';
}



//back to ini video
function toStop()
{
if(document.MediaPlayer.PlayState!=3 && document.MediaPlayer.PlayState!=8){
	//alert(MediaPlayer.Mute);
			
	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;
		//clearInterval(idTmr);

		if(!flag){
		  if((iniSrc!=""&&iniSrc!=null) || (!isswf)){
			GetObj('hideScreen').style.display = 'block';
			//GetObj('hideScreen').innerHTML = swfhtml;
			GetObj('myScreen').style.display = 'none';
			
				/* 050829 新增 part3 begin */
				if(!isswf){
					GetObj("hideScreen").innerHTML = swfhtml;
				}else{
					GetObj("hideScreen").innerHTML = pichtml;
				}
				/* 050829 新增 part3 end */
			
		  }
			curBroad = MovieFile;
			//curNarrow = narrowFile;
			//CheckBand();
			document.MediaPlayer.FileName = curFile;
			flag = true;
		}
		document.getElementById('pBox').style.left = '0px';
	}
}
xFlag = true;
}
			


			
function toPause()
{
//alert(MediaPlayer.Mute);
	if(document.MediaPlayer.Duration>0){
		if(isPlayO&&document.MediaPlayer.PlayState!=3)
		{
			document.MediaPlayer.Pause();
			document.images("playControl").src = playPic.src;
			//document.images("pauseControl").src = pausePic.src;
			isPlayO = false;
			isPauseO = true;
		}
	}
}
//--->


	
var fFlag= false;
//mpControl func

//drag func
var pFlag = false;



function startdrag()
{
	//alert(document.MediaPlayer.Duration||(!isNaN(document.MediaPlayer.Duration)));
	if(document.MediaPlayer.Duration||(!isNaN(document.MediaPlayer.Duration))){
		window.document.onmousemove = mouseMove;
		window.document.ondragstart = mouseEnd;
		window.document.onmouseup = mouseUp;
		/*window.document.onmousedown = mouseDown;*/
	}else{
		GetObj('myScreen').innerHTML='<img width=320 height=264 src=http://image2.sina.com.cn/dongman/BN//images/vod_bt/gw_bn_278.jpg alt="请使用IE浏览器观看视频"/>';
	}
}
var isPorV = 0;
function mouseDown(objSign){
	//alert(window.event.srcElement.id);
	isPorV = objSign;
	if(isPorV==0){
		if(document.MediaPlayer.Duration>0){
			pFlag = true;
			//GetObj('pBox').style.left = (window.event.x-9);
			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;
	//alert(curObj.tagName+":"+curObj.offsetLeft)
	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"){
			//alert(curObj.tagName+":"+curObj.offsetLeft)
			objLT += curObj.offsetLeft;
		}

	}
	return objLT;
}
function mouseMove(){
		//window.status = (window.event.clientX +"-"+ GetOLeft(document.getElementById('pZone'))+"\n"+document.getElementById('pZone').offsetLeft)
	if(isPorV==0){
		if(document.MediaPlayer.Duration>0){
			//alert(window.event.x-25);
			//if(pFlag) alert(parseInt(document.getElementById('pBox').style.left));
			//if(pFlag) document.getElementById('pBox').style.left = window.event.clientX-10;// - clickleft;
			//if(pFlag) document.getElementById('PlayState').innerText = (document.getElementById('pZone').offsetLeft+':'+document.getElementById('pBox').style.left+":"+window.event.clientX);
			if(pFlag) document.getElementById('pBox').style.left = window.event.clientX - GetOLeft(document.getElementById('pZone')) - 2 +"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","")) < -5) document.getElementById('pBox').style.left=-5 +"px";
		}

	}else if(isPorV==1){
		//window.status = (window.event.clientX +"-"+ GetOLeft(document.getElementById('vZone'))+"\n"+document.getElementById('vZone').offsetLeft);
		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","")) > 35) document.getElementById('vBox').style.left = 35 +"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);
				//alert(window.event.x +"-"+document.getElementById('pZone').style.left+"="+parseInt(document.getElementById('pBox').style.left)+"("+duration * (parseInt(document.getElementById('pBox').style.left)/139)+")");
			}
			pFlag = false;
		}
	}else if(isPorV==1){
		if (vFlag){
			//var volume = document.MediaPlayer.Volume;
			tempVol = (10 - (parseInt(document.getElementById('vBox').style.left)/3.7))*(-100);
			if(tempVol<=-1000){
				if(document.MediaPlayer.Mute.toString().toLowerCase()=='false' && document.images("muteControl").src != mutePic.src){
					document.MediaPlayer.Mute='True';
					document.images("muteControl").src = mutePic.src;
					document.images("muteControl").alt = "打开声音";
				}
			}else{
				if(document.MediaPlayer.Mute.toString().toLowerCase()=='true')
				{
					document.MediaPlayer.Mute='False';
					document.images("muteControl").src = "/images/vod_bt/bnp_mute1.gif";
					document.images("muteControl").alt = "关闭声音";
				}
			}
			document.MediaPlayer.Volume=Math.round(tempVol);//duration * (parseInt(document.getElementById('vBox').style.left)/139);
			//alert(window.event.x +"-"+document.getElementById('pZone').style.left+"="+parseInt(document.getElementById('pBox').style.left)+"("+duration * (parseInt(document.getElementById('pBox').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)-5;
		}
		else{
			var pBoxPos = Math.round(pos/duration*pZoneWidth);
		}
		if (!isNaN(pBoxPos)) document.getElementById('pBox').style.left = pBoxPos;
		//alert(Math.round(pos/duration*200));
		//alert(document.MediaPlayer.Duration)
		if((document.MediaPlayer.Duration-1)<document.MediaPlayer.CurrentPosition) toStop();
	}
	//window.status = "PlayState:" + document.MediaPlayer.PlayState + " Duration:" + document.MediaPlayer.Duration;
	if((document.MediaPlayer.PlayState==0 || document.MediaPlayer.PlayState==8) && (!xFlag)) toStop();
	//if(GetObj('hideScreen').style.display.toLowerCase()=='block') ShowState();//图片上的VIDEO播放状态
}
var xFlag = true;


function VolumeUp(vol){
	/*050206-guowei1
	tempVol = (9 - vol)*(-100);
	if(tempVol < (-500)) tempVol-=200;
	//alert(tempVol);
	document.MediaPlayer.Volume= tempVol;
	for(var i=1;i<=vol;i++){
		document.images['vol'+i].src = 'http://image2.sina.com.cn/dongman/BN//images/vod_bt/vod023_'+i+'o.gif';
	}
	for(var i=vol+1;i<=9;i++){
		document.images['vol'+i].src = 'http://image2.sina.com.cn/dongman/BN//images/vod_bt/vod023_'+i+'.gif';
	}*/
	tempVol = (10 - vol)*(-100);
	document.MediaPlayer.Volume= tempVol;
	document.getElementById('vBox').style.left = vol/10*35;
}




/*
function ChgBN(bFile,nFile){
	curBroad = bFile;

	curFile = curBroad;

}

*/





function GetObj(objName){
	if(document.getElementById){
		return eval('document.getElementById("' + objName + '")');
	}else if(document.layers){
		return eval("document.layers['" + objName +"']");
	}else{
		return eval('document.all.' + objName);
	}
}


lPicArr = new Image();
lPicArr.src = iniSrc;
