function ShowVideoPlayer(pointX,pointY,ptWidth,ptHeight,hideAnyway)
{
	hideAnyway = (typeof(hideAnyway)=="undefined")? false:hideAnyway;
	var divID = document.getElementById("divOCX");
	divID.style.position = "absolute";
	divID.style.left=pointX;
	divID.style.top=pointY;
	divID.style.width = ptWidth;
	divID.style.height = ptHeight;
	if(hideAnyway)
	{
		divID.style.display ="none";
	}
	else
	{
		divID.style.display ="block";
	}
/*	
	alert("ShowVideoPlayer" + pointX + ":" +pointY);
*/
}

function DisplayVideoPlayer()
{
	var divID = document.getElementById("divOCX");
	divID.style.display ="block";
}

function HideVideoPlayer()
{
	var divID = document.getElementById("divOCX");
	divID.style.display ="none";
}

function GetCurrentChannel()
{
	return VP.CurrentChannel;
}

function SetCurrentChannel(channel)
{
	if(channel<0)
	{
		return;
	}
	VP.CurrentChannel = channel;
}

function FixAspectRatio(value)
{
	VP.EnableFixAspectRatio(value);
}

function SetFullScreenFlag(flag)
{
	VP.FullScreenEnabled = flag;
}

function SetDBClickFlag(flag)
{
	VP.DBClickEnabled = flag;
}

function SetPicInPic(enable)
{
	VP.PicInPic = enable;
	if(enable)
	{
		for(var i=0;i<16;i++)
		{
			VP.SetPipChildren(i, 1);
		}
	}
}

function GetPicInPic()
{
	return VP.PicInPic;
}

function GetNumConnected(maxChannel)
{
	var nNum = 0;
	for(var i=0;i<maxChannel;i++)
	{
		if(VP.IsConnected(i))
		{
			nNum++;
		}
	}
	return nNum;
}

function MoveVideoPlayer(pointX,pointY,ptWidth,ptHeight)
{
	var divID = document.getElementById("divOCX");
	VP.width = ptWidth;
	VP.height = ptHeight;
	divID.style.left=pointX;
	divID.style.top=pointY;
	divID.style.width = ptWidth;
	divID.style.height = ptHeight;

//	alert("MoveVideoPlayer" + pointX + ":" +pointY + ",width:"+ptWidth+",height:" +ptHeight);
}

function HideVideoScheme()
{
	var divID = document.getElementById("divOCX");
	divID.style.display ="none";
}

function SetMode(nChannel, strMode)
{
	if(VP.IsConnected(nChannel))
	{
		VP.Disconnect(nChannel);
	}
	VP.SetMode(nChannel, strMode);
}

function SetDecodeWorkMode(nChannel, nMode)
{
	return VP.SetDecodeWorkMode(nChannel,nMode);
}

function GetDecodeWorkMode(nChannel)
{
	return VP.GetDecodeWorkMode(nChannel);
}

function SetZoomStatus(nLocalChannel,nStatus)
{
	VP.SetZoomStatus(nLocalChannel,nStatus);
	return true;
}

function GetZoomStatus(nLocalChannel)
{
	return VP.GetZoomStatus(nLocalChannel);
}

function IsZoomIn(nLocalChannel)
{
	return VP.IsZoomIn(nLocalChannel);
}

function SetScreenMode(nScreenMode)
{
	VP.ScreenMode = nScreenMode;
}

function GetScreenMode()
{
	return VP.ScreenMode;
}

function SwitchSingleScreen()
{
	VP.SwitchSingleScreen();
}

function SwitchFullScreen()
{
	VP.SwitchFullScreen();
}

function Connect(localChannel,strAddress,nPort,strUser,strPassword,remoteChannel,nPriorityContinuity,nConnectMainStream,proxyAddr,proxyPort)
{
	if(VP.IsConnected(localChannel))
	{
		VP.Disconnect(localChannel);
	}
	return VP.Connect(localChannel,nPriorityContinuity,0,nConnectMainStream,strAddress,nPort,remoteChannel,strUser,strPassword,proxyAddr,proxyPort);
}

function IsConnected(localChannel)
{
	return VP.IsConnected(localChannel);
}

function IsServerChannelConnected(strAddress,nPort,remoteChannel)
{
	return VP.IsServerChannelConnected(strAddress,nPort,remoteChannel);
}

function Disconnect(localChannel)
{
	VP.Disconnect(localChannel);
}

function DisconnectAll()
{
	VP.DisconnectAll();
}

function AddMotionRect(localChannel, rectArray)
{
	var nNum = 0;
	VP.ClearMotionRectArray(localChannel);
//	return VP.AddMotionRect(localChannel, rectInfo);
	for(var i = 0; i < rectArray.length; i++)
	{
		if(VP.AddMotionRect(localChannel, rectArray[i].Areas)<0)
		{
			continue;
		}
		nNum++;
	}
	return nNum;
}

function SetCurrentMotionRect(localChannel, sentryCurrentArea)
{
	return VP.SetCurrentMotionRect(localChannel, sentryCurrentArea);
}

function GetCurrentRect(localChannel)
{
	return VP.GetCurrentRect(localChannel);
}

function DeleteMotionRect(localChannel)
{
	var nCurrent = parseInt(VP.RemoveMotionRect(localChannel));
	return nCurrent;
}

function NextMotionRect(localChannel)
{
	var nIndex = VP.NextMotionRect(localChannel);
	return nIndex;
}

function ClearMotionRect(localChannel)
{
	VP.ClearMotionRectArray(localChannel);
}

function SetCurrentBrightness(localChannel, value)
{
	return VP.SetCurrentBrightness(localChannel, value);
}

function GetCurrentBrightness(localChannel)
{
	return VP.GetCurrentBrightness(localChannel);
}

function GetCurrentContrast(localChannel)
{
	return VP.GetCurrentContrast(localChannel);
}

function SetCurrentContrast(localChannel, value)
{
	return VP.SetCurrentContrast(localChannel, value);
}

function GetCurrentSaturation(localChannel)
{
	return VP.GetCurrentSaturation(localChannel);
}

function SetCurrentSaturation(localChannel, value)
{
	return VP.SetCurrentSaturation(localChannel, value);
}

function GetCurrentHue(localChannel)
{
	return VP.GetCurrentHue(localChannel);
}

function SetCurrentHue(localChannel, value)
{
	return VP.SetCurrentHue(localChannel, value);
}

function GetAudioVolume()
{
	return VP.GetAudioVolume();
}

function SetAudioVolume(value)
{
	VP.SetAudioVolume(value);
}

function SetMuteStatus(status)
{
	VP.AudioEnabled = status;
}

function GetCurrentVideoParams(localChannel)
{
	if(!VP.GetCurrentVideoParam(localChannel))
	{
		return null;	}
	return {brightness:	GetCurrentBrightness(localChannel),
			contrast:	GetCurrentContrast(localChannel),
			saturation:	GetCurrentSaturation(localChannel),
			hue:		GetCurrentHue(localChannel)} 
}

function GetDefaultVideoParams(localChannel)
{
	if(!VP.GetDefaultVideoParam(localChannel))
	{
		return null;
	}
	return {brightness:	VP.GetDefaultBrightness(localChannel),
			contrast:	VP.GetDefaultContrast(localChannel),
			saturation:	VP.GetDefaultSaturation(localChannel),
			hue:		VP.GetDefaultHue(localChannel)};
}

function Snapshot()
{
	VP.Snapshot(VP.CurrentChannel, 1, "");
}

function AddDownloadFile(strAddress,nPort,strUser,strPassword,remoteFile,locationPath,proxyAddr,proxyPort)
{
	return VP.AddDownloadFile(strAddress, nPort, strUser, strPassword, remoteFile, locationPath, proxyAddr, proxyPort);
}

function ShowDownWindow(bShow)
{
	return VP.ShowDownWindow(bShow);
}

function Playback()
{
	VP.PlayBack();
}

function IsRecording(channel)
{
	return VP.IsRecording(channel);
}

function StartRecord(channel)
{
	return VP.StartRecord(channel);
}

function StopRecord(channel)
{
	return VP.StopRecord(channel);
}

function AddPlaybackCallback()
{
	try
	{
		VP.attachEvent("EndStream",onEndStream);
		VP.attachEvent("ChannelSwitched",onChannelSwitched);
		VP.PicInPic = 0;
	}
	catch(error)
	{
		if(error instanceof TypeError)
		{
			return false;
		}
	}

	return true;
}

function onEndStream(localChannel, isError)
{
	thisMovie("AppLoader").onEndStream(localChannel, isError);
}

function PlayByTime(nLocalChannel,strAddress,nMessagePort,strUser,strPassword,nRemoteChannel,strBeginDate,strEndDate,proxyAddr,proxyPost)
{
	return VP.PlayBackByTime(nLocalChannel,strAddress,nMessagePort,strUser,strPassword,nRemoteChannel,strBeginDate,strEndDate,proxyAddr,proxyPost);
}

function ConnectFile(localChannel,strAddress,nPort,strUser,strPassword,remoteChannel, strFileName, position, proxyaddr, proxyport)
{
	return VP.ConnectFile(	localChannel,
							strAddress, 
							nPort, 
							remoteChannel, 
							strFileName, 
							position, 
							strUser, 
							strPassword, 
							proxyaddr, 
							proxyport);
}

function GetRateLevel(localChannel)
{
	return VP.GetRateLevel(localChannel);
}

function SetRateLevel(localChannel,nLevel)
{
	return VP.SetRateLevel(localChannel,nLevel);
}

function RateDown(localChannel)
{
	return VP.RateDown(localChannel);
}

function RateUp(localChannel)
{
	return VP.RateUp(localChannel);
}

function GetPosition(localChannel)
{
	return VP.GetRSPosition(localChannel);
}

function Pause(localChannel)
{
	return VP.Pause(localChannel);
}

function Resume(localChannel)
{
	return VP.Resume(localChannel);
}

function GetLocalChannelConnInfo(nLocalChannel)
{
	return VP.GetLocalChannelConnInfo(nLocalChannel);
}
