

	var hwnd;
	var FDListString;
	var ChannelListString;
	var tmpStr_array;
	var sCameraID="";
	var sChannelID="";
	
//界面伸缩控制	
function $(element){
return element = document.getElementById(element);
}
function $D(){
var d=$('video_con');
var h=d.offsetHeight;
var maxh=240;
function dmove(){
h+=50; //设置层展开的速度
if(h>=maxh){
d.style.height='240px';
clearInterval(iIntervalId);
}else{
d.style.display='block';
d.style.height=h+'px';
}
}
iIntervalId=setInterval(dmove,2);
}
function $D2(){
var d=$('video_con');
var h=d.offsetHeight;
var maxh=240;
function dmove(){
h-=50;//设置层收缩的速度
if(h<=0){
d.style.display='none';
clearInterval(iIntervalId);
}else{
d.style.height=h+'px';
}
}
iIntervalId=setInterval(dmove,2);
}
function $use(){
var d=$('video_con');
var sb=$('stateBut');
if(d.style.display=='none'){
$D();
sb.innerHTML='隐藏&gt&gt';
}else{
$D2();
sb.innerHTML='展开&gt&gt';
}
}
		
//初始化OCx控件
function init()
{
	hwnd = document.form1.VOcx.Initial(0, 0, 264, 188, 0);
	document.form1.VOcx.SetWindowsNumber(1);
	document.form1.WebOcx.Initial(0);
  Login();	
}
//默认登陆方法
function Login()
{
    var	lResult = 1;
	  lResult = document.form1.WebOcx.Login("59.50.112.82",6666,"",'user7@nyt.hn.ge','1234');
	  if(lResult != 0)
        {
         alert("登陆失败!");
        }
    sec=false;
}

//用户登陆方法
function LoginSec()
{
    document.form1.WebOcx.Logout();
    var	lResult = 1;
		var userName = document.form1.userName.value;
		var userPassword = document.form1.userPassword.value;
		
		if(userName==null || userName==""){
		  alert("帐号不能为空，请重新填写！");
		  return false;
	   }
	  if(userPassword==null || userPassword==""){
		  alert("密码不能为空，请重新填写！");
	   	return false;
	   }
    lResult = document.form1.WebOcx.Login("59.50.112.82",6666,"",userName,userPassword);
	  if(lResult != 0)
       {
        alert("登陆失败!");
       }
    sec=true;
}

//退出平台
function Logout()
{
    document.form1.WebOcx.StopVideo(hwnd);
    document.form1.WebOcx.Logout();
    document.getElementById('divIn').style.display = "";
    document.getElementById('divOut').style.display = "none";
    document.getElementById('tree-div').innerHTML="";
    Login();
}

//控件释放
function Free()
{
     //document.form1.WebOcx.Logout();
     document.form1.WebOcx.Free();
}

//开始视频
function Start()
{
	 document.form1.WebOcx.PlayVideo(hwnd,sCameraID,sChannelID);
         
}

//结束视频
function Stop()
{
	document.form1.WebOcx.StopVideo(hwnd);
       
}

//解析字符串
function parseXml(cString) {
	// 然后开始获取 fdInfo.xml 需要的的第一个节点的属性值
	//alert(cString);
	var tree = new Ext.tree.TreePanel('tree-div', {
		animate : true,
		line : true,
		selMode : true,
		rootVisible : false,//不显示根节点
		loader : false
	});

	var rootNode = new Ext.tree.TreeNode( {
		text : '监控点列表',
		draggable : false,
		id : '0'
	});
	
  var tmpStr_array =cString.split("$");
  
	for (var i = 1;i < tmpStr_array.length; i++) 
		{
	  
	 var tmpStr_array2=tmpStr_array[i].split("|");
	 var fdId = tmpStr_array2[0];
	 var fdName = tmpStr_array2[1];
	 var Status = tmpStr_array2[3];
	 var flag = false;
		
		if(Status == 1)
		{
			
		var childNode = new Ext.tree.TreeNode( {
			id : fdId,
			text : fdName,
			icon : 'images/list-items.gif',
			disabled: flag,
			leaf : false
			//cls : 'folder'
		});
		rootNode.appendChild(childNode);
	  }	
	}

	tree.setRootNode(rootNode);
	tree.render();
	rootNode.expand();

	tree.on("click", function(node) {
		if (node != null) {
			if (node.isLeaf()) {
				var TwoID = node.attributes.id;
				sCameraID = TwoID.substring(0,18);
				sChannelID = TwoID.substring(19,20);
			    
			}
		}
	});
	
		tree.on("dblclick", function(node) {
				if (node != null) {
					if (node.isLeaf()) {
					var TwoID = node.attributes.id;
				      sCameraID = TwoID.substring(0,18);
				      sChannelID = TwoID.substring(19,20);				
                 

		  		    document.form1.WebOcx.StopVideo(hwnd);
					//PanelHandle = WndContainerOcx.GetPanelHandle();// 获得空闲窗口句柄
					re = document.form1.WebOcx.PlayVideo(hwnd,sCameraID,sChannelID);
	
	         } else {
						if(node.attributes.cls != "folder")
						{
							tempNode = node;
							IniFDID=node.attributes.id;
							var ChannelList = document.form1.WebOcx.GetChannelList(node.attributes.id);
							node.expand(true);	
			  		}
			  			
			  		else {
			  	    node.collapseChildNodes();
			      }			
		   }
    }
	}		);
		
}	

function addChild(node,ChannelListString)
	{
			var chStr_array =ChannelListString.split("$");
			var childLength =chStr_array.length;
			  if (childLength > 0) {
	     for (var j = 1;j < childLength; j++) {
			  
	    var chStr_array2=chStr_array[j].split("|");
	    var channelId = chStr_array2[1];
	    var channelName = chStr_array2[3];
							var childNode = new Ext.tree.TreeNode( {
								id : channelId,
								text : channelName,
								disabled : false,
								icon : 'images/video.gif',
								leaf : true,
								cls : 'file'
							});
							node.appendChild(childNode);
							node.expand(true);
							node.attributes.cls="folder";						
					}
				}			
}


//云台上转
function TurnUp()
{
	document.form1.WebOcx.PTZControlEx(hwnd,1,5);
 
}
//云台下转
function TurnDown()
{ 
    document.form1.WebOcx.PTZControlEx(hwnd,2,5);
}		
//云台的左转
function TurnLeft()
{       
   document.form1.WebOcx.PTZControlEx(hwnd,3,5);
}
//云台的右转
function TurnRight()
{    
    document.form1.WebOcx.PTZControlEx(hwnd,4,5);
}

//变亮
function Brighten()
{
    document.form1.WebOcx.PTZControlEx(hwnd,5,5);
}
//变暗
function Darken()
{
    document.form1.WebOcx.PTZControlEx(hwnd,6,5);
}
//停止转动
function StopTurn()
{
    document.form1.WebOcx.PTZControlEx(hwnd,0,5);
    
}
//拉远镜头
function LenFar()
{
    document.form1.WebOcx.PTZControlEx(hwnd,8,5);
}
//拉近镜头
function LenNear()
{
    document.form1.WebOcx.PTZControlEx(hwnd,7,5);
}
//改变窗口数目
function changeScreen(lWndNumber)
{	 
    document.form1.VOcx.SetWindowsNumber(lWndNumber);
   
}
//窗口全屏
function setFullScreen()
{
  document.form1.VOcx.SetFullScreen(hwnd);
}