/**
 * @author zerostyle
 * @QQ:83226227
 * @namespace ZeroStyle.VVSWeb.API
 * @projectDescription _本文件描述了API接口，与创建控件对象的方法_
 * @warning _本文件采用ANSI编码，请使用ANSI编码的编辑器编辑，如果因编码问题导致的程序无法运行，本人不负责任_
 * @since 2010/6/3-2010/6/4_
 * @version 0.0.1 BETA
 */
Namespace.register("ZeroStyle.VVSWeb.API");
ZeroStyle.VVSWeb.API=
{
	DebugMode:ZeroStyle.FrameWork.RunningTime.DebugMode,
	controlId:"VVSWeb_ActiveX",
	thisCom:null,
	cabUrl:"ActiveX/JdvrOcx.cab#version=1,0,0,1",
	classId:"clsid:AC48D52E-666C-4464-B39F-B1B3D786A860",
	Events:{
		
		OnSearchGetOneRECResult:function(){throw new Error()},
		OnCustomVideoGroupChange:function(){throw new Error()}
		
	},
	Init:function()
	{
		with(this)
			{
				thisCom=ZeroStyle.Web.UI.Helper.$("VVSWeb_ActiveX");
				thisCom.style.border="0"
				thisCom.style.borderColor="red"
				thisCom.style.width="100%";
				thisCom.style.height="100%";
				if(thisCom.addEventListener!=undefined&&thisCom.addEventListener!="undefined")
				{
					thisCom.addEventListener("JSOnGetOneRECFile",Events.OnSearchGetOneRECResult,false);
					thisCom.addEventListener("JSOnCustomVideoGroupChange",Events.OnCustomVideoGroupChange,false);
				}
				else
				{
					thisCom.attachEvent("JSOnGetOneRECFile",Events.OnSearchGetOneRECResult);
					thisCom.attachEvent("JSOnCustomVideoGroupChange",Events.OnCustomVideoGroupChange);
				}
			}
	},
	AddEventListener:function()
	{
		with(this)
		{
			if(thisCom.addEventListener!=undefined&&thisCom.addEventListener!="undefined")
				{
					//alert("1")
					thisCom.addEventListener("JSOnGetOneRECFile",Events.OnSearchGetOneRECResult,false);
					thisCom.addEventListener("JSOnCustomVideoGroupChange",Events.OnCustomVideoGroupChange,false);
					
					//alert("1")
				}
				else
				{
					//alert(thisCom)
					thisCom.attachEvent("JSOnGetOneRECFile",Events.OnSearchGetOneRECResult);
					thisCom.attachEvent("JSOnCustomVideoGroupChange",Events.OnCustomVideoGroupChange);
					//alert("2")
				}
			}
	},
	/**
	 * 
	 * @param {Object} containerObj
	 */
	RenderTo:function(containerId,width,height)
	{
		try{
			with(this)
			{	
				var containerObj=ZeroStyle.Web.UI.Helper.$(containerId);
				//ZeroStyle.Web.UI.Helper.$("VVSWeb_ActiveX_Temp").JSExit();
				//ZeroStyle.Web.UI.Helper.$remove("VVSWeb_ActiveX_Temp")
				if(containerObj=="undefined")
				{
					throw new Error("container is null");
				}
				//containerObj.innerHTML="";
				if(width)
				{
					thisCom.style.width=width;
				}
				if(height)
				{
					thisCom.style.height=height;
				}
				containerObj.appendChild(thisCom);
				//alert(containerObj.innerHTML);
			}
		}
		catch(e)
		{
			alert("11"+e.message);
		}
	},
	Dispose:function()
	{
		this.controlId="";
		this.thisCom=null;
		this.Events=null;
		thisObj=null;
	},
	
	/**
	 * _连接_
	 */
	Connect:function()
	{
		try
		{
			with(this)
			{
				thisCom.JSLink();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	/**
	 * _断开_
	 */
	DisConnect:function()
	{
		try
		{
			with(this)
			{
				thisCom.JSUnLink();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	/**
	 * _连接所有通道_
	 */
	ConnectAll:function()
	{
		try
		{
			with(this)
			{
				//alert(thisCom.id);
				thisCom.JSLinkAll();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _断开所有_
	 */
	DisConnectAll:function()
	{
		try
		{
			with(this)
			{
				thisCom.JSUnLinkAll();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _开始录像_
	 */
	StartREC:function()
	{
		try
		{
			with(this)
			{
				thisCom.JSRecStart();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _停止录像_
	 */
	StopREC:function()
	{
		try
		{
			with(this)
			{
				thisCom.JSRecStop();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _所有通道开始录像_
	 */
	StartAllREC:function()
	{
		try
		{
			with(this)
			{
				thisCom.JSRecStartAll();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _所有通道停止录像_
	 */
	StopAllREC:function()
	{
		try
		{
			with(this)
			{
				thisCom.JSRecStopAll();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _抓图管理_
	 */
	PicManage:function()
	{
		try
		{
			with(this)
			{
				thisCom.JSPicMan();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	/**
	 * _日志管理_
	 */
	logManage:function()
	{
		try
		{
			with(this)
			{
				thisCom.JSLogsMan();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _录像回放_
	 */
	PlayBack:function()
	{
		try
		{
			with(this)
			{
				thisCom.JSPlayerBack();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _配置_
	 */
	Config:function()
	{
		try
		{
			with(this)
			{
				thisCom.JSConfig();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _打开声音_
	 */
	OpenSound:function()
	{
		try
		{
			with(this)
			{
				thisCom.JSOpenSound();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _关闭声音_
	 */
	CloseSound:function()
	{
		try
		{
			with(this)
			{
				thisCom.JSCloseSound();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _抓图_
	 */
	GetPicture:function()
	{
		try
		{
			with(this)
			{
				thisCom.JSPicture();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _分屏_
	 * @param {Object} divideCount _要分割的个数_
	 */
	DivideWindow:function(divideCount)
	{
		try
		{
			with(this)
			{
				thisCom.JSDivideWindow(divideCount);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _云台控制_上_
	 * @param {Object} mouseDown _是否是鼠标按下_
	 */
	CloudControl_top:function(mouseDown)
	{
		try
		{
			with(this)
			{
				thisCom.JSCloDeck(mouseDown,1);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _云台控制_下_
	 * @param {Object} mouseDown  _是否是鼠标按下_
	 */
	CloudControl_bottom:function(mouseDown)
	{
		try
		{
			with(this)
			{
				thisCom.JSCloDeck(mouseDown,2);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _云台控制_左_
	 * @param {Object} mouseDown _是否是鼠标按下_
	 */
	CloudControl_left:function(mouseDown)
	{
		try
		{
			with(this)
			{
				thisCom.JSCloDeck(mouseDown,3);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _云台控制_右_
	 * @param {Object} mouseDown _是否是鼠标按下_
	 */
	CloudControl_right:function(mouseDown)
	{
		try
		{
			with(this)
			{
				thisCom.JSCloDeck(mouseDown,4);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _云台控制_自动_
	 * @param {Object} mouseDown _是否是鼠标按下_
	 */
	CloudControl_Auto:function(mouseDown)
	{
		try
		{
			with(this)
			{
				thisCom.JSCloDeck(mouseDown,5);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _光圈变大_
	 * @param {Object} mouseDown _是否是鼠标按下_
	 */
	Aperture_l:function(mouseDown)
	{
		try
		{
			with(this)
			{
				thisCom.JSIris(mouseDown,1);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _光圈缩小_
	 * @param {Object} mouseDown _是否是鼠标按下_
	 */
	Aperture_s:function(mouseDown)
	{
		try
		{
			with(this)
			{
				thisCom.JSIris(mouseDown,2);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
		
	},
	
	/**
	 * _变焦_近__
	 * @param {Object} mouseDown
	 */
	Focus_n:function(mouseDown)
	{
		try
		{
			with(this)
			{
				thisCom.JSFocus(mouseDown,1);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _变焦_远__
	 * @param {Object} mouseDown
	 */
	Focus_f:function(mouseDown)
	{
		try
		{
			with(this)
			{
				thisCom.JSFocus(mouseDown,2);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _变倍_近__
	 * @param {Object} mouseDown
	 */
	Zoom_i:function(mouseDown)
	{
		try
		{
			with(this)
			{
				thisCom.JSZoom(mouseDown,1);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _变倍_远__
	 * @param {Object} mouseDown
	 */
	Zoom_o:function(mouseDown)
	{
		try
		{
			with(this)
			{
				thisCom.JSZoom(mouseDown,2);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	
	/**
	 * _用户登录_
	 * @param {Object} userName _用户名_
	 * @param {Object} userPasswd _密码_
	 */
	Login:function(userName,userPasswd,lang)
	{
		try
		{
			//alert(this.thisCom);
			//alert(this.thisCom.JSLogin());
			if(userName=="undefined")
			{
				throw new Error(JoveTech.VVSWeb.Language.Error.error1);
			}
			if(userPasswd=="undefined")
			{
				throw new Error(JoveTech.VVSWeb.Language.Error.error2);
			}
			var loginSucc=false;
			with(this)
			{
				//alert(userName+" "+userPasswd)
				loginSucc=thisCom.JSLogin(userName,userPasswd,lang);
			}
			//alert(loginSucc)
			return loginSucc;
			
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
		
	},
	
	/**
	 * Application _退出_
	 */
	Exit:function()
	{
		with(this)
		{
			//thisCom.JSExit();
			Dispose();
		}
	},
	
	/**
	 * _检索录像文件_
	 * @param {Object} datetimeStr _检索的时间_
	 */
	SearchRECFile:function(datetimeStr)
	{
		try
		{
			with(this)
			{
				//alert("ss");
				thisCom.JSSearchRECFile(datetimeStr);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	/**
	 * _录像回放_
	 * @param {Object} playId
	 */
	PlayBackRECFile:function(playId)
	{
		try
		{
			with(this)
			{
				thisCom.JSPlayBackRECFile(playId);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	/**
	 * _录像下载_
	 * @param {Object} playId
	 */
	DownLoadRECFile:function(playId)
	{
		try
		{
			with(this)
			{
				thisCom.JSDownLoadRECFile(playId);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	/**
	 * _根据父节点找到子节点_
	 * @param {Object} parentNodeId _父节点唯一识别ID(非控件ID)，可以为空，为空时取得根节点，否则为该节点下的子节点_
	 */
	GetCustomVideoGroups:function(parentNodeId)
	{
		try
		{
			with(this)
			{
				var result=null;
				if(!parentNodeId)
				{
					//alert("1")
					result=thisCom.JSGetCustomVideoGroups("");
				}
				else
				{
					//alert("2")
					result=thisCom.JSGetCustomVideoGroups(parentNodeId);
				}
				//alert(result)
				return result;
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	PlayCustomVideoGroupPoint:function(groupIndex,pointIndex)
	{
		try
		{
			with(this)
			{
				//alert(thisCom+" "+groupIndex+" "+pointIndex)
				thisCom.JSPlayCustomVideoGroupPoint(groupIndex,pointIndex);
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	RefreshWindow:function()
	{
		try
		{
			with(this)
			{
				//alert(thisCom+" "+groupIndex+" "+pointIndex)
				thisCom.JSRefreshWindow();
			}
		}
		catch(e)
		{
			throw new Error(JoveTech.VVSWeb.Language.Error.error4);
		}
	},
	thisObj:this
	
}


