function ShowVideoPlayer(pointX,pointY,ptWidth,ptHeight,hideAnyway)
{
	hideAnyway = (typeof(hideAnyway)=="undefined")? false:hideAnyway;

	var divID = document.getElementById("divOCX");
	VP.width = ptWidth;
	VP.height = ptHeight;
	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";
	}
}

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 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 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;
}

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 SetScreenMode(nScreenMode)
{
	VP.ScreenMode = nScreenMode;
}

function GetScreenMode()
{
	return VP.ScreenMode;
}

function SwitchSingleScreen()
{
	VP.SwitchSingleScreen();
}

function SwitchFullScreen()
{
	VP.SwitchFullScreen();
}

function Connect(localChannel,remoteChannel,nPriorityContinuity,nConnectSubStream,proxyAddr,proxyPort)
{
	if(VP.IsConnected(localChannel))
	{
		VP.Disconnect(localChannel);
	}
	return VP.Connect(localChannel,nPriorityContinuity,0,!nConnectSubStream,g_Address,g_Port,remoteChannel,g_Username,g_Password,proxyAddr,proxyPort);
}

function IsConnected(localChannel)
{
	return VP.IsConnected(localChannel);
}

function IsServerChannelConnected(remoteChannel)
{
	return VP.IsServerChannelConnected(g_Address,g_Port,remoteChannel);
}

function Disconnect(localChannel)
{
	VP.Disconnect(localChannel);
}

function DisconnectAll()
{
	VP.DisconnectAll();
}

function AddMotionRect(localChannel, rectArray, sentryCurrentArea)
{
	VP.ClearMotionRectArray(localChannel);
	for(var i = 0; i < rectArray.length; i++)
	{
		VP.AddMotionRect(localChannel, rectArray[i].Areas);
	}
}

function SetCurrentMotionRect(localChannel, sentryCurrentArea)
{
	VP.SetCurrentMotionRect(localChannel, sentryCurrentArea);
}

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(remoteFile, locationPath)
{
	return VP.AddDownloadFile(g_Address, g_Port, g_Username, g_Password, remoteFile, locationPath);
}

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 ConnectFile(localChannel, remoteChannel, strFileName, position)
{
	return VP.ConnectFile(localChannel,  g_Address, g_Port, remoteChannel, strFileName, position, g_Username, g_Password);
}

function GetRate(localChannel)
{
	return VP.GetRate(localChannel);
}

function RateDown(localChannel)
{
	VP.RateDown(localChannel);
}

function RateUp(localChannel)
{
	VP.RateUp(localChannel);
}

function GetPosition(localChannel)
{
	return VP.GetRSPosition(localChannel);
}

function Pause(localChannel)
{
	VP.Pause(localChannel);
}

function Resume(localChannel)
{
	VP.Resume(localChannel);
}

function GetLocalChannelConnInfo(nLocalChannel)
{
	return VP.GetLocalChannelConnInfo(nLocalChannel);
}