var uuid;
var monid;
var baseContainer=null;
var defaultblockCount = 3;
var blockCache=[];
var loginparam = null;
var detailtab = null;
var serverConnection = top.serverConnection ;
var nodeLimit = 20,nodeMore = "加载更多..";

$(function(){
	var planVideoJson = getConfigPlanVideoInfo();
//	for(var i=0;i<planVideoJson.length;i++){
//		console.log(i,planVideoJson[0].vdId,planVideoJson[0].channelId,planVideoJson[0].vdName)
//	}
	baseContainer = $("#video-container");
	initBodyEvent();
	BlockUtil.changeLayout(defaultblockCount);
	setTimeout(function(){
		playVideo(0,{sbbh:planVideoJson[0].vdId,tdbh:planVideoJson[0].channelId,tdmc:planVideoJson[0].vdName});
//		playVideo(0,{sbbh:"201805031342536402",tdbh:1,tdmc:"隧道口1"});
	},2000);
	setTimeout(function(){
		playVideo(1,{sbbh:planVideoJson[1].vdId,tdbh:planVideoJson[1].channelId,tdmc:planVideoJson[1].vdName});
//		playVideo(1,{sbbh:"201805031338485611",tdbh:1,tdmc:"隧道口2"});
	},4000);
	setTimeout(function(){
		playVideo(2,{sbbh:planVideoJson[2].vdId,tdbh:planVideoJson[2].channelId,tdmc:planVideoJson[2].vdName});
//		playVideo(2,{sbbh:"201805171555338411",tdbh:1,tdmc:"隧道口3"});
	},6000);
});

function initBodyEvent(){
	(window !== top.WebRtcServer.reqPage) && top.WebRtcServer.setReqPage(window);
	$(window).on("focus",function(){
		(window !== top.WebRtcServer.reqPage) && top.WebRtcServer.setReqPage(window);
	});
}

function playVideo(index,videoObj){
	var block = BlockUtil.getBlockByIndex(index || 0);
	if(block && videoObj && videoObj.sbbh && videoObj.tdbh ){
		block.setFdId(videoObj.sbbh).setChannelId(videoObj.tdbh).setHideTitle(videoObj.tdmc || "").startMonitor();
	}else{
		$.showMsg("参数异常！");
	}
}

function unloadWindow(){
	for(var i = 0;i < BlockCacher.blockCache.length;i++){
		if(BlockCacher.blockCache[i].fdId && BlockCacher.blockCache[i].channelId != null){
			BlockUtil.stopMonitor(i);
		}
	}
}
//获取配置文件信息
//获取配置文件信息
function getConfigPlanVideoInfo(){
	var obj = [];
	$.ajax({
		 type:'post',
		 dataType : 'json',
		 async:false,
		 url : 'trafficaccidentinfoAction!getConfigPlanVideoInfo.do',
//		 data:params,
		 success:function(data){
//			console.log(data);
			obj = data;
		 }
	});
	return obj;
}
