﻿//弹出视频窗口系列函数
// javascript:playwinbox(标题,地址,高,宽)
//window.onload = getMsg;
//window.onresize = resizeDiv;
//window.onerror = function(){}
//短信提示使用(asilas添加)
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,strs;
//获得信息
function getMsg()
{
try{
	divTop = parseInt(document.getElementById("eMeng").style.top,10)
	divLeft = parseInt(document.getElementById("eMeng").style.left,10)
	divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10)
	divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10)
	docWidth = document.body.clientWidth;
	docHeight = document.body.clientHeight;
	document.getElementById("eMeng").style.top = parseInt(document.body.scrollTop,10) + docHeight + 10;// divHeight
	document.getElementById("eMeng").style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth;
	document.getElementById("eMeng").style.visibility="visible";
	objTimer = window.setInterval("moveDiv()",10);
	}
	catch(e){}
}

//检测文件名后缀
function checkfilenameext(filenamestr)
{
try{
  	var len = filenamestr.length;   
  	var xx = filenamestr.substr(filenamestr.lastIndexOf("."),len);   
    return xx.toLowerCase(xx); 
	}
	catch(e){};
} 
  

//重新设置窗口位置
function resizeDiv()
{
//ii+=1
try{
divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10);
divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10);
docWidth = document.body.clientWidth;
docHeight = document.body.clientHeight;
document.getElementById("eMeng").style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10);
document.getElementById("eMeng").style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10);
}
catch(e){}
}

//移动窗口
function moveDiv()
{
try
{
if(parseInt(document.getElementById("eMeng").style.top,10) <= (docHeight - divHeight + parseInt(document.body.scrollTop,10)))
{
window.clearInterval(objTimer)
objTimer = window.setInterval("resizeDiv()",1)
}
divTop = parseInt(document.getElementById("eMeng").style.top,10)
document.getElementById("eMeng").style.top = divTop - 20
}
catch(e){}
}

//关闭窗口
function closeDiv()
{
//document.getElementById('eMeng').style.visibility='hidden';
document.getElementById('eMeng').innerHTML   =   "";
var div=document.getElementById('eMeng');
div.parentNode.removeChild(div);
if(objTimer) window.clearInterval(objTimer);
}

//建立窗口
function playwinbox(t,movurl,h,w)
{
  if(document.getElementById('eMeng'))
  { 
  	document.getElementById('eMeng').innerHTML   =   "";
	var div=document.getElementById('eMeng');
    var mditype;
	div.parentNode.removeChild(div);
	if(objTimer) window.clearInterval(objTimer);
  }
    if (t.length<1)t="计算机网络安全精品课程";
    var strs =''
    +'<DIV id=eMeng style="BORDER-RIGHT: #455690 1px solid; BORDER-TOP: #a6b4cf 1px solid; Z-INDEX:99999; LEFT: 0px; VISIBILITY: hidden; BORDER-LEFT: #a6b4cf 1px solid; '
    +'WIDTH: 400px; BORDER-BOTTOM: #455690 1px solid; POSITION: absolute; TOP: 0px; HEIGHT: 300px; BACKGROUND-COLOR: #c9d3f3">'
	+'<TABLE style="BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid" cellSpacing=0 cellPadding=0 width="100%" bgColor=#AFDCF3 border=0>'
	+'<TBODY><TR bgColor=#6699cc><TD style="font-size: 12px; color: #0f2c8c" width=30 height=24></TD>'
	+'<TD style="font-weight: normal; font-size: 12px;  color: #ffffff; padding-left: 4px; padding-top: 4px" vAlign=center width="100%">'+t+'</TD>'
	+'<TD style=" padding-right: 2px; padding-top: 2px" vAlign=center align=right width=19><span title=关闭 style="CURSOR: hand;color:white;font-size:14px;font-weight:bold;margin-right:4px;"'
	+' onclick=closeDiv() >×</span></TD></TR>'
	+'<TR><TD style=" padding-right: 1px; padding-bottom: 1px" colSpan=3 height=90 align="center">'
	+'<DIV id=playbox style="BORDER-RIGHT: #b9c9ef 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: #728eb8 1px solid; PADDING-LEFT: 1px; FONT-SIZE: 12px; PADDING-BOTTOM: 1px;'
	+' BORDER-LEFT: #728eb8 1px solid; WIDTH: 100%; COLOR: #1f336b; PADDING-TOP: 1px; BORDER-BOTTOM: #b9c9ef 1px solid; HEIGHT: 100%">'
    mditype=checkfilenameext(movurl); //判断媒体类型	
	switch(mditype)
	{
		case ".wmv" :case ".asf":case ".avi":case ".mpg":case ".mpeg": case ".mpe":case ".asx":case ".dat":
		{
			strs=strs+'<object type="video/x-ms-wmv" data="'+movurl+'" width="'+w+'" height="'+h+'" id="VideoPlayback"> '
			+'<param name="src" value="'+movurl+'"/> '
			+'<param name="autostart" value="true" /> '
			+'<param name="controller" value="true" />'
			+'</object>';
			break;
		}
		case ".rm" :case ".rmvb":case ".ra":
		{

			strs=strs+'<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" '
			+'  width='+w+' height='+h+' onerror="ronerror()">'
			+'  <param name=src value='+movurl+'>'
			+'  <param name="AUTOSTART" value="-1">'
			+'  <param name=console value=clip1>'
			+'  <param name="CONTROLS" value="Imagewindow">'
			+'  </object>'
			+'<object classid=clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa height=32 width=100%>'
			+'<param name=src value='+movurl+'> '
			+'<param name=controls value=controlpanel><param name=console value=clip1></object>'
			
		break;
		}
		case ".flv" :
		{
			strs=strs+'<object type="application/x-shockwave-flash" data="/_styles/greybox/vcastr.swf"'
			+'width="'+w+'" height="'+h+'" id="vcastr"> '
			+'<param name="movie" value="/_styles/greybox/vcastr.swf"/> '
	        +'<param name="allowFullScreen" value="true" />'
	        +'<param name="FlashVars" value="xml='
	        +'<vcastr><channel><item>'
	        +'<source>'+movurl+'</source>'
	        +'<duration></duration>'
	        +'<title>'+t+'</title>'
	        +'</item></channel><config>'
	        +'<isAutoPlay>true</isAutoPlay>'
	        +'<isShowAbout>false</isShowAbout>'
	        +'</config><plugIns></plugIns></vcastr>"/>'
	        +'</object>'
		break;
		}
		case ".swf":
		{
//		strs=strs+'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
//			+'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" '
//			+'width="'+ w +'" height="'+ h +'">'
//			+'<param name="movie" value="/_styles/greybox/vcastr.swf">'
//			+'<param name="quality" value="high">'
//			+'<param name="menu" value="false">'
//			+'<param name="allowFullScreen" value="true" />'
//			+'<param name="FlashVars" value="vcastr_file=http://jx.gxjmzy.com/jxx_wlaq/piclib/wlfx.swf&vcastr_title='+t+'">'
//			+'<embed src="/_styles/greybox/vcastr.swf" allowFullScreen="true" '
//			+'FlashVars="vcastr_file=http://jx.gxjmzy.com/jxx_wlaq/piclib/wlfx.swf&vcastr_title='+t+'" menu="false" quality="high" '
//			+'width="'+ w +'" height="'+ h +'" type="application/x-shockwave-flash" '
//			+'pluginspage="http://www.macromedia.com/go/getflashplayer" />'
//			+'</object>'
		h=h-25;
			strs=strs+'<object type="application/x-shockwave-flash" data="'+movurl+'" width="'+w+'" height="'+h+'" id="VideoPlayback"> '
			+'<param name="movie" value="'+movurl+'"/> '
            +'<param name="allowScriptAccess" value="always"/>'
            +'<param name="allowFullScreen" value="true"/>'
            +'<param name="flashVars" value="autostart=true"/>'
			+'<param name="quality" value="best"  />'
			+'<param name="bgcolor" value="#000000" />'
			+'<param name="loop" value="false"   />'
			+'<param name="salign" value="TL"  />'
			+'<param name="scale" value="showall"  />'
			+'<param name="FlashVars" value="playerMode=embedded" />'
			+'</object>';
			break;
		}
		default :strs=strs+'不支持类型'+mditype;
	}
	strs=strs+'</DIV></TD></TR></TBODY></TABLE>';

//	checkfilenameext(movurl);
	
	document.body.insertAdjacentHTML("beforeEnd",strs);
//初始化参数
	divTop = parseInt(document.getElementById("eMeng").style.top,10)
	divLeft = parseInt(document.getElementById("eMeng").style.left,10)
	divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10)
	divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10)
	docWidth = document.body.clientWidth;
	docHeight = document.body.clientHeight;
	document.getElementById("eMeng").style.top = parseInt(document.body.scrollTop,10) + docHeight + 10;// divHeight
	document.getElementById("eMeng").style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth;
	document.getElementById("eMeng").style.visibility="visible";
	objTimer = window.setInterval("moveDiv()",10);

}

