//scripted by guowei1 bellow, 2004
var isIE = navigator.appVersion.toLowerCase().indexOf("msie") >= 0;
if(typeof autoPlayFlag=='undefined') var autoPlayFlag = true	//设定是否自动播放

var curBroad = broadFile;
var curNarrow = narrowFile;
var curFile =curNarrow;
vHeight += 24;



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);
	}
}


var objHTML1 = ("<table width=261 border=0 cellspacing=0 cellpadding=0><tr><td colspan=3><img src=http://nanjing.soufun.com/yuefen/njplayer/nanjing1.gif width=261 height=10></td></tr><tr><td width=11 valign=top><img src=http://nanjing.soufun.com/yuefen/njplayer/playtd_1_r2_c1.gif width=11 height=204></td><td align=center width=286 bgcolor=#000000><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='True'>");
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></td><td width=10 valign=top><img src=http://nanjing.soufun.com/yuefen/njplayer/playtd_1_r2_c3.gif width=10 height=204></td></tr><tr><td colspan=3><img src=http://nanjing.soufun.com/yuefen/njplayer/playtd_1_r3_c1.gif width=261 height=3></td></tr></table>");



document.writeln("<table border=0 cellpadding=0 cellspacing=0 width=261>");
document.writeln("<form name='myForm'><tr><td>");


document.writeln("	<div id='myScreen' style='border:0px solid #000;display:block'>");
document.writeln(objHTML1 + curFile + objHTML2);
document.writeln("	</div>");




document.writeln("</td></tr>");
document.writeln("<tr><td>");
document.writeln("<table width='261' border='0' cellspacing='0' cellpadding='0' background=http://wuhan.soufun.com/market/tv/images/playtd_r23.gif>");
document.writeln("  <tr>");
document.writeln("    <td width=19><img src=http://wuhan.soufun.com/market/tv/images/playtd_r21.gif width=19 height=12></td>");
 document.writeln("   <td align='left' id='pZone' onmousedown='mouseDown(0)' style='POSITION: relative;left:0;'><div id='pBox' title='移动滑块控制影片进度' style='overflow: hidden;POSITION: relative;cursor:e-resize;left:0px;top:0px;width:13px;height:12px;background-image:url(http://wuhan.soufun.com/market/tv/images/playtd_r24.gif);'></div></td>");
 document.writeln("   <td width=19><img src=http://wuhan.soufun.com/market/tv/images/playtd_r22.gif width=19 height=12></td>");
 document.writeln(" </tr>");
document.writeln("</table>");
document.writeln("</td></tr>");
document.writeln("<tr><td>");


document.writeln("<table width=261 border=0 cellspacing=0 cellpadding=0 background=http://nanjing.soufun.com/yuefen/njplayer/ptd_bg.gif height=59>");
document.writeln("  <tr align=center> ");
document.writeln("    <td>");
document.writeln("      <table width=90% border=0 cellspacing=0 cellpadding=0>");
document.writeln("        <tr> ");
document.writeln("          <td align=right><img id=playControl src="+(autoPlayFlag?"http://wuhan.soufun.com/market/tv/images/ptd_b11.gif":"http://wuhan.soufun.com/market/tv/images/ptd_b12.gif")+" width=41 height=39 alt='播放/暂停' style='cursor:pointer;' onClick='toPlay()'/></td>");
document.writeln("          <td align=right><img id=stopControl src="+(autoPlayFlag?"http://wuhan.soufun.com/market/tv/images/ptd_b21.gif":"http://wuhan.soufun.com/market/tv/images/ptd_b22.gif")+" width=25 height=25 alt='停止' style='cursor:pointer;' onClick='toStop()'/></td>");
document.writeln("         <td align=right><div style='width:0px;height:0px;position:relative;'><div id='msgBox' style='color:#f00;left:22px;top:22px;width:138px;padding:5px 5px 5px 5px;line-height:19px;border:1px solid #aaa;display:none;background-color:#fff;z-index:99;position:absolute;filter:alpha(opacity=90);'></div></div><img src='http://wuhan.soufun.com/market/tv/images/ptd_b31.gif' width=25 height=25 onMouseOver=ShowMsg('在播放中进行全屏播放&lt;br&gt;全屏后可双击屏幕还原') onMouseOut=HideMsg() onClick=FullScreen() style='cursor:pointer;'/></td>");
document.writeln("          <td align=right><img id=muteControl src=http://wuhan.soufun.com/market/tv/images/ptd_b41.gif width=21 height=21 alt='关闭声音' onClick='Mute()' style='cursor:pointer;'/></td>");
document.writeln("          <td align=center>");
document.writeln("            <table width=72 border=0 cellspacing=0 cellpadding=0 background=http://wuhan.soufun.com/market/tv/images/ptd_b5.gif>");
document.writeln("              <tr>");
document.writeln("                <td align='left' id='vZone' onmousedown='mouseDown(1)' style='POSITION: relative;left:0;'><div id='vBox' title='移动滑块控制音量' style='OVERFLOW: hidden;POSITION: relative;cursor: pointer;left:0px;top:0px;width:11px;height:19px;background-image:url(http://wuhan.soufun.com/market/tv/images/ptd_b6.gif)'></div></td>");
document.writeln("              </tr>");
document.writeln("            </table>");
document.writeln("          </td>");
document.writeln("        </tr>");
document.writeln("      </table>");
document.writeln("    </td>");
document.writeln("  </tr>");
document.writeln("</table>");

document.writeln("</td></tr>");
document.writeln("<tr><td>");

document.writeln("<table width=261 border=0 cellspacing=3 cellpadding=0 background=http://nanjing.soufun.com/yuefen/njplayer/playtd_r4_c1.gif>");
document.writeln("  <tr> ");
document.writeln("    <td  width=90> ");
document.writeln("      <div id='broad'><input name=band type=radio value='broad' onClick='SetBand()'/>高清视频</div>");
document.writeln("    </td><td style=font-size:14px> ");
document.writeln("      <div align='left' id='narrow'><input name=band type=radio value='narrow' checked onClick='SetBand()'/>普通视频</div></td>");
document.writeln("  </tr>");
document.writeln("</table>");


document.writeln("</td></tr>");
document.writeln("</form>");
document.writeln("</table>");

function RadioBand(){
	if(curFile == curBroad) document.myForm.band[0].checked = true;
	else document.myForm.band[1].checked = true;
	if(curBroad=="" || curBroad==null) GetObj("broad").style.display = "none";
	else GetObj("broad").style.display = "block";
	if(curNarrow=="" || curNarrow==null) GetObj("narrow").style.display = "none";
	else GetObj("narrow").style.display = "block";
}
RadioBand();


function ShowMsg(Msg){
	GetObj("msgBox").innerHTML = Msg;
	GetObj("msgBox").style.display = "block";
}


function HideMsg(){GetObj("msgBox").style.display = "none";}

function FullScreen(){
	if(document.MediaPlayer.Duration>0){
		document.MediaPlayer.DisplaySize = 3;
	}
}
function SetBand(){

  if(((document.myForm.band[0].checked)?curBroad:curNarrow)!=document.MediaPlayer.FileName){
	GetObj('myScreen').innerHTML=objHTML1+((document.myForm.band[0].checked)?curBroad:curNarrow)+objHTML2;
	ChgVideo((document.myForm.band[0].checked)?curBroad:curNarrow);
  }
}


var mutePic = new Image(29,29);
mutePic.src = "http://wuhan.soufun.com/market/tv/images/ptd_b42.gif";
function Mute()
{
	//alert(MediaPlayer.Mute);
	if(document.MediaPlayer.Mute.toString().toLowerCase()=='true')
	{
		document.MediaPlayer.Mute='False';
		document.images("muteControl").src = "http://wuhan.soufun.com/market/tv/images/ptd_b41.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(48,77);
			playPic.src = "http://wuhan.soufun.com/market/tv/images/ptd_b11.gif";
			var stopPic = new Image(24,35);
			stopPic.src = "http://wuhan.soufun.com/market/tv/images/ptd_b22.gif";
			

function toPlay()
{
	if(!isIE){
		alert("请使用IE浏览器欣赏视频!谢谢!")
		return false;
	}
	//document.MediaPlayer.AutoStart="True";
	if(document.MediaPlayer.Duration>0){
		if(isPlayO){
			toPause();
		}else{
			if(isStopO||isPauseO)
			{

				/* 050829 新增 part1 end */
				//alert(isStopO||isPauseO);
				document.MediaPlayer.Play();
				document.images("playControl").src = "http://wuhan.soufun.com/market/tv/images/ptd_b12.gif";
				document.images("stopControl").src = "http://wuhan.soufun.com/market/tv/images/ptd_b21.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;
				}
				*/
		}
	}

}

function toPlay2()
{
	document.MediaPlayer.AutoStart="True";
	if(document.MediaPlayer.Duration>0){
		if(isStopO||isPauseO)
		{
				/* 050829 新增 part2 begin */
				if(!(pics==""||pics==null)){
					GetObj("hideScreen").innerHTML = "";
				}
				/* 050829 新增 part2 end */
			//alert(isStopO||isPauseO);
			document.MediaPlayer.Play();
			document.images("playControl").src = "http://wuhan.soufun.com/market/tv/images/ptd_b12.gif";
			document.images("stopControl").src = "http://wuhan.soufun.com/market/tv/images/ptd_b21.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';
}

			/*
			//stop on current video
			function toStop()
			{
			//alert(MediaPlayer.Mute);
				if(isPlayO||isPauseO)
				{
					document.MediaPlayer.Stop();
					document.images("playControl").src = playPic.src;
					document.images("stopControl").src = stopPic.src;
					isPlayO = false;
					isStopO = true;
				}
				if((!flag)&&(document.MediaPlayer.FileName==broadFile||document.MediaPlayer.FileName==narrowFile)){
					GetObj('hideScreen').style.display = 'block';
					GetObj('myScreen').style.display = 'none';
					flag = true;
				}
			}
			*/

//back to ini video
function toStop()
{
if(document.MediaPlayer.Duration>0){
	//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((iniPic!=""&&iniPic!=null) || (pics!=""&&pics!=null)){
			GetObj('hideScreen').style.display = 'block';
			//GetObj('hideScreen').innerHTML = focusPic;
			GetObj('myScreen').style.display = 'none';
			
				
				if(!(pics==""||pics==null)){
					GetObj("hideScreen").innerHTML = focusPic;
				}
				
			
		  }
			curBroad = broadFile;
			curNarrow = narrowFile;
			CheckBand();
			document.MediaPlayer.FileName = curFile;
			flag = true;
		}
	}
}
}
			
			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;
	
	var pFlag = false;

	var pZoneWidth = 270;
	function startdrag()
	{
		if(document.MediaPlayer.Duration||(!isNaN(document.MediaPlayer.Duration))){
			window.document.onmousemove = mouseMove;
			window.document.ondragstart = mouseEnd;
			window.document.onmouseup = mouseUp;
			}else{
			GetObj('myScreen').innerHTML='<center>请使用IE浏览器观看视频</center>';
		}
	}
	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"; 
				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){
			if(vFlag) document.getElementById('vBox').style.left = window.event.clientX - GetOLeft(document.getElementById('vZone')) - 4 +"px"; 
				if (parseInt(document.getElementById('vBox').style.left.replace("px","")) > 65) document.getElementById('vBox').style.left=65 +"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)/7.2))*(-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 = "http://wuhan.soufun.com/market/tv/images/ptd_b41.gif";
						document.images("muteControl").alt = "关闭声音";
					}
				}
				document.MediaPlayer.Volume=Math.round(tempVol);}
			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;
			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 = '...';
		}

	}

	

	function VolumeUp(vol){
		tempVol = (10 - vol)*(-100);
		document.MediaPlayer.Volume= tempVol;
		document.getElementById('vBox').style.left = vol/10*72;
	}


	function checkstat()
			{
				if (document.MediaPlayer.PlayState==0||document.MediaPlayer.PlayState==8){
					toPlay2();

					broadFile = tempFile;
				}else{}
			}
	var tempHTML;
	var tempFile;
	function ChgVideo(filename){
		if(!isIE){
			alert("请使用IE浏览器欣赏视频!谢谢!")
			return false;
		}

			var tempCurB = curBroad;
			var tempCurN = curNarrow;

			toStop();
			if(autoPlayFlag) document.MediaPlayer.AutoStart="True";
			curBroad = tempCurB;
			curNarrow = tempCurN;

			tempFile = broadFile;
			document.MediaPlayer.FileName=filename;
			if(autoPlayFlag){
			document.images("playControl").src = "http://wuhan.soufun.com/market/tv/images/ptd_b12.gif";
				document.images("stopControl").src = "http://wuhan.soufun.com/market/tv/images/ptd_b21.gif";
				isPlayO = true;
				isStopO = false;
				isPauseO = false;
			}else{
				idTmr = setInterval("checkstat()",300);
			}
	}

	function ChgBN(bFile,nFile){
		curBroad = bFile;
		curNarrow = nFile;
		curFile = curBroad;
		CheckBand();

		RadioBand();

		ChgVideo((document.myForm.band[0].checked)?curBroad:curNarrow);
	}
	function SetBN(bFile,nFile){
		curBroad = bFile;
		curNarrow = nFile;
		curFile = curBroad;
	}

