/*
弹出遮罩层效果,必须设定弹出层的宽度.
mid = 包含弹出容器与遮罩层内容的底层容器ID
sid = 弹出层ID
mw = 弹出层的宽度
如:showPopupArea('popoutArea','popoutMain','240')
*/

function showPopupArea(mid,sid,mw,strURL) {
	var tagDiv = document.getElementById(mid);
	var mainDiv = document.getElementById(sid);
	var gHeight =  document.documentElement.offsetHeight;
	if(window.ActiveXObject){
		tagDiv.style.display = "block";
		var mH = mainDiv.clientHeight;
		tagDiv.style.display = "none";
		tagDiv.style.height = document.body.offsetHeight + "px";
		mainDiv.style.top = (document.documentElement.scrollTop + 150) + "px";
		var iFm = document.createElement("iframe");
		with(iFm.style){
			width = "100%";
			filter = "Alpha(opacity=0)";
			height =  document.body.offsetHeight + "px";
		}
		tagDiv.appendChild(iFm);
		
	}else if(window.XMLHttpRequest){
		tagDiv.style.height = gHeight + "px";
		mainDiv.style.position = "fixed";
		mainDiv.style.marginTop = "125px";
	}
	tagDiv.style.display = "block";
	mainDiv.style.width = mw + "px";
	mainDiv.style.marginLeft = "-" + parseInt(mw/2)+ "px";
	if(strURL) PlayVideo(strURL);
	
}
function closeDiv(targetDiv){
	var targetDiv = document.getElementById(targetDiv);
	targetDiv.style.display = "none";
	if (document.getElementById("divVideoImg"))
	 {
	    document.getElementById("divVideoImg").innerHTML="";
	 }
	
	
	 
	 
	
	
}	

 function GetVideoType(strURL)
{
	if (strURL.lastIndexOf(".")!= -1)
	{
		return strURL.substr(strURL.toString().lastIndexOf(".")+1);
	}
}


 function  PlayFlvVideo(strURL)
{

	var FU = {movie:"/flash/flv/flvplayer.swf",width:"353px",height:"315px",majorversion:"7",build:"0",bgcolor:"#FFFFFF",
	flashvars:"file=" + strURL + "&autostart=true"};
	UFO.create(FU, "divVideoImg");
}

function PlayOrtherVideo(strURL)
{
	 if (document.getElementById("MediaPlayCol"))
	 {
	    document.getElementById("MediaPlayCol").parentNode.removeChild(document.getElementById("MediaPlayCol") );
	 }
		var obj = document.createElement("object");
		obj.setAttribute("id","MediaPlayCol");
		if(window.ActiveXObject)
		    obj.setAttribute("classid","CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95");
		else if(window.XMLHttpRequest)
		    obj.setAttribute("type","video/x-ms-wmv");
		obj.setAttribute("height","315px");
		obj.setAttribute("width","353px");
		obj.setAttribute("title","");
		obj.setAttribute("FileName",strURL);
		obj.setAttribute("enableContextMenu","false");
		obj.setAttribute("ShowStatusBar","-1");
		document.getElementById("divVideoImg").appendChild(obj);
	

}

 function PlayVideo(strURL)
{
	var type = GetVideoType(strURL) ;
	switch(type)
	{
		case "flv" :
			PlayFlvVideo(strURL);
			break;
		case "wmv" :
			PlayOrtherVideo(strURL);
			break;
		default :
			PlayOrtherVideo(strURL);
			break;
	}
	
}
	
	
