<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	</head>
	<body>
		<div class="top"></div>
		<div class="center"
			style="width: 800px; height: 580px; margin: 0 auto;">
			<h3 id="movePopuWin">
				<a href="javascript:;" title="关闭" class="message_close"
					id="closePopuWin"></a>
				<span>视频</span>
			</h3>
			<div class="popuWinMessage_main" style="padding: 0px;">
				<div
					style="height: 30px; line-height: 30px; background: #f1f1f1; padding: 0px 10px; padding-left: 214px;">
					<div style="overflow: hidden; float: left; margin-right: 20px;">
						<input style="float:left;margin-top:9px;margin-right:5px;" value="0"
							onchange="tdChange(0,this)" type="checkbox">
						<span>窗口一</span>
					</div>

					<div style="overflow: hidden; float: left; margin-right: 20px;">
						<input style="float: left; margin-top: 9px; margin-right: 5px;" value="1"
							onchange="tdChange(1,this)" type="checkbox">
						<span>窗口二</span>
					</div>


					<div style="overflow: hidden; float: left; margin-right: 20px;">
						<input style="float: left; margin-top: 9px; margin-right: 5px;" value="2"
							onchange="tdChange(2,this)" type="checkbox">
						<span>窗口三</span>
					</div>

					<div style="overflow: hidden; float: left; margin-right: 20px;">
						<input style="float: left; margin-top: 9px; margin-right: 5px;" value="3"
							onchange="tdChange(3,this)" type="checkbox">
						<span>窗口四</span>
					</div>
				</div>
				<!--视频-->
				<div
					style="position: absolute; width: 800px; top: 65px; bottom: 0px;">
					<OBJECT classid="clsid:DAB63197-3FF9-4236-924C-F8641094DDFD"
						codebase="cmsv6.cab#version=6,0,0,3" width="95%" height="95%"
						id="gViewer" name="gViewer">
					</OBJECT>
				</div>
				<!--视频 end-->
			</div>
		</div>
		<input type="hidden" id="terCode"
			value="<%=request.getParameter("terCode")%>" />
		<div class="bot"></div>
		<script type="text/javascript">
	var view;
	var ssA;
	var ip ;
	var port;
	var terminal_num;
	function MyRecSearchEvent(strFile, nStartTime, nEndTime, nFileLen,
			nFileType, nSvrID, nLocation, nChannel) {
		alert(strFile);
	}
	function onClose() {
		stopVideo();
	}
	//获取车辆信息
	function init(){
		var terCode = $("#terCode").val();
		$.ajax( {
			type : "POST",
			dataType : "json",
			url : "json/reportsAction_getVehicleVideoInfo.action",
			data : {"terCode":terCode},
			success : function(json){
				if(json && json.flag){
					var td = 0;
					if(json.yyNum != null && json.yyNum!=''){
						var str = json.yyNum.split(" ");
						for ( var i = 0; i < str.length; i++){
							if(str[i].indexOf("s")>-1){
								ip = str[i].replace("s","");
							}
							if(str[i].indexOf("c")>-1){
								port = str[i].replace("c","");
							}
						}
					}
					if(json.dtNum != null && json.dtNum!=''){
						var str2 = json.dtNum.split(" ");
						for ( var i = 0; i < str2.length; i++){
							if(str2[i].indexOf("m")>-1){
								terminal_num = str2[i].replace("m","");
							}
							if(str2[i].indexOf("n")>-1){
								td = Number(str2[i].replace("n",""))-1;
							}
						}
					}
					if(ip==null || port==null || terminal_num==null){
						alert("视频信息不全");
						return;
					}
					$("input:checkbox[value="+td+"]").attr('checked','true');
					videoInit(td,terminal_num);
				}
			},
			error : function() {
				$("#carOwnerMsg").html("获取数据异常");
			}
		});
	}
	function tdChange(vl,e){
		if(ip==null || port==null || terminal_num==null){
			alert("视频信息不全");
			return;
		}
		if(e.checked){
			videoInit(vl,terminal_num);
		}else{
			stopVideo(vl);
		}
	}
	function videoInit(num,terminal_id){
		view = gViewer;
		view.Layout = 2;
		view.ServerIP = ip;
		view.ServerPort = port;
		stopVideoA(num,terminal_id);
	}

	function test(type) {
		init(type);
	}

	function fullScreen() {
		view.FullScreen();
	}

	document.onkeydown = function(ev) {
		var oEvent = ev || event;//获取事件对象(IE和其他浏览器不一样，这里要处理一下浏览器的兼容性event是IE；ev是chrome等)
		//Esc键的keyCode是27
		if (oEvent.keyCode == 27) {
			view.ExitFullScreen();
		}
	}

	function getPaneType(type) {
		view.PaneType = type;
	}

	function capSetSave() {
		view.CapturePicture(0);
	}

	function startVideo(dvid,type) {
		view.StartVideo(dvid,type,type);
	}

	function stopVideo(num) {
		view.StopVideo(num);
	}

	function stopVideoA(type, dvid){
		startVideo(dvid,type);
	}
	var voiceFlag = true;
	function openVoice() {
		if (voiceFlag == false) {
			voiceFlag = true;
			view.CloseAllSound();
		} else {
			voiceFlag = false;
			view.OpenSound(view.NActiveWndIndex);
		}
	}

	$(function() {
		init();
		//stopVideoA(0,'013512340102');
		//stopVideoA(1,'013500000003');
		//stopVideoA(2,'013500000004');
		//stopVideoA(3,'013587351004');
	});
</script>
	</body>
</html>
