function getObj(objName)
{
	if (document.getElementById){return eval('document.getElementById("'+objName+'")');}
	else{return eval('document.all.'+objName);}
}

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 getOTop(myObj){
	curObj = myObj;
	var objTP = curObj.offsetTop;
	while(curObj!=curObj.offsetParent && curObj.offsetParent){
		curObj=curObj.offsetParent;
		if(curObj.tagName=="DIV" || curObj.tagName=="TABLE" || curObj.tagName=="TR" || curObj.tagName=="TD"){objTP += curObj.offsetTop;}
	}
	return objTP;
}

if(typeof autoPlayFlag=="undefined") var autoPlayFlag = true
var isPlayO = autoPlayFlag?true:false;
var isStopO = autoPlayFlag?false:true;
var isPauseO = autoPlayFlag?false:true;

function toPlay()
{
	getObj("hideScreen").style.display = "none";
	getObj("myScreen").style.display = "block";
    if (document.MediaPlayer.Duration>0){
		if (document.MediaPlayer.playState !=2){
			document.MediaPlayer.Play();
			getObj("playControl").src="http://www.expo2010china.com/images/n0809/pause.gif";
			getObj("muteControl").alt = "暂停";
		}
		else
		{
			toPause();
		}	
	}
}

function toPause()
{
	if (document.MediaPlayer.Duration>0){
		document.MediaPlayer.Pause();
		getObj("playControl").src="http://www.expo2010china.com/images/n0809/play.gif";
		getObj("muteControl").alt = "播放";
	}
}

function toStop()
{
	getObj("hideScreen").style.display = "block";
	getObj("myScreen").style.display = "none";
    if (document.MediaPlayer.Duration>0)
	{
		document.MediaPlayer.Stop();
		getObj("playControl").src="http://www.expo2010china.com/images/n0809/play.gif";
		getObj("muteControl").alt = "播放";
	}
}

function toMute()
{
	if(document.MediaPlayer.Mute.toString().toLowerCase()=='true'){
		document.MediaPlayer.Mute='False';
		getObj("muteControl").src = "http://www.expo2010china.com/images/n0809/snd.gif";
		getObj("muteControl").alt = "关闭声音";
	}else{
		document.MediaPlayer.Mute='True';
		getObj("muteControl").src = "http://www.expo2010china.com/images/n0809/mute.gif";
		getObj("muteControl").alt = "打开声音";
	}
}

function mouseMove()
{
	if(pFlag){getObj('pBox').style.left = window.event.clientX - getOLeft(getObj('pZone')) - 3 +"px";}
}

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-3);
		}
	}
}

function mouseMove()
{
	if(isPorV==0)
	{
		if(document.MediaPlayer.Duration>0)
		{
			if(pFlag) getObj("pBox").style.left = window.event.clientX - getOLeft(getObj("pZone")) - 3 +"px"; 
			if (parseInt(getObj("pBox").style.left.replace("px","")) > pZoneWidth) getObj("pBox").style.left=pZoneWidth +"px";
			if (parseInt(getObj("pBox").style.left.replace("px","")) < -7) getObj("pBox").style.left=-7 +"px";
		}

	}
}
	
function mouseUp()
{
	if(isPorV==0){
		if(document.MediaPlayer.Duration>0){
			if (pFlag){
				var duration = document.MediaPlayer.Duration;
				document.MediaPlayer.CurrentPosition=duration * (parseInt(getObj("pBox").style.left)/pZoneWidth);
			}
			pFlag = false;
		}
	}
}

function mouseEnd()
{
	if(document.MediaPlayer.Duration>0){window.event.returnValue = false;}
}

function OnloadFun()
{
	startdrag();
	setInterval("FixPos()",1000);
}

var fFlag= false;

//drag func
var pFlag = false;
//var vWidth = getObj("pZone").offsetWidth;
var pZoneWidth = 109; //getObj("pZone").offsetWidth;//vWidth - 110;

function startdrag()
{
	if(document.MediaPlayer.Duration||(!isNaN(document.MediaPlayer.Duration))){
		window.document.onmousemove = mouseMove;
		window.document.ondragstart = mouseEnd;
		window.document.onmouseup = mouseUp;
	}
}

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)+2;
		}
		else
		{
			var pBoxPos = Math.round(pos/duration*pZoneWidth);
		}
		if (!isNaN(pBoxPos)) 
		{
			getObj("pBox").style.left = pBoxPos;
		}
		if(document.MediaPlayer.PlayState==0) 
		{
			getObj("pBox").style.left = 0;
			toStop();
		}
	}
}/*  |xGv00|112e1075a55d705d24e28ae1954646d2 */