var stationID = 0;
//var FileLocation = "http://da5nvap6twti1.cloudfront.net/mps/q4_2008_10slides/Q42008.mps.idx";
//var FileLocation = "http://bgomps01.vizky.com:8031/banner/header.mps.idx";
//var FileLocation = VizkyGetPathOfHtmlPage() + "Airport/AirportInfoX.mps.idx"
var FileLocation = "http://BGOMPS02.vizky.com/Demo/Airport/AirportInfoX.mps.idx"
var extID = 0;
var instID = 0;
var VizkyVersion = 0;

var Width = 950
var Height = 533

//Full Window button scene
var extIDFull = 0;
var instIDFull = 0;
var fullflag = false
//Full Window button scene
function Fullscreen(ControlObject)
{
	ControlObject.SetCommandPipeline(9);
	ControlObject.ClearCommandPipeline();
	ControlObject.ToggleFullscreen();
	if (fullflag)
	{
		ControlObject.ShowDirectorTag(instIDFull,"full","max");
		fullflag = false
	}else
		{
		   ControlObject.ShowDirectorTag(instIDFull,"full","min");
		   fullflag = true
		}
		ControlObject.SetCommandPipeline(0);
}
function OnVizkyLMouseDown(ControlObject)
{
	var aUObject = ControlObject.GetInteractivityObject();
	switch(aUObject)
	{
		//Full Screen Window//
		case ("Full"):
			Fullscreen(ControlObject); 
		break;
		//Full Screen Window//
	}
}
function OnVizkyInit(ControlObject)
{
	
	ControlObject.CreateViewport(2);
	ControlObject.SetDisplayDownloading(1);
	stationID = ControlObject.GenerateStationID(window.location);
	ControlObject.SetViewportPositionAndSize(0, 0, 0, Width, Height);
	ControlObject.SetViewportStationAndChannelID(0, stationID, 0);
	ControlObject.SetViewportPositionAndSize(1, 0, 0, Width, Height);
	ControlObject.SetViewportStationAndChannelID(1, stationID, 1);
	ControlObject.CommitAllViewportStationAndChannelChanges();
	ControlObject.SetViewportPriorityLevel(1,9);
	// Check file version and current client version;
	VizkyVersion = ControlObject.GetVersion();
	var VersionArray = VizkyVersion.split(".");
	var currentVersion = ((parseInt(VersionArray[0]) << 28) | (parseInt(VersionArray[1]) << 24) | (parseInt(VersionArray[2]) << 16) | parseInt(VersionArray[3]));
	var requiredVersion = ((1 << 28) | (5 << 24) | (8 << 16) | 0);
	if(currentVersion >= requiredVersion)
	{	
		extID = Control.Import(stationID, FileLocation);
		instID = Control.Load(stationID, extID);
		extIdFull = Control.Import(stationID, "http://BGOMPS02.vizky.com/Demo/full/full.mps.idx");
		instIDFull = Control.Load(stationID, extIdFull);
		Control.TakeIn(stationID, 0, 0, instID);
		Control.TakeIn(stationID, 1, 0, instIDFull);
	}
	else
		{
			//---------------Vizky Checkversion Text-------------//			
			var pleaseInstall2 = '<div class="tv2_millionaer_content millionaer_download" style="font-family: arial; font-size: 12px; padding-right: 200px;"><h2>Please upgrade your Vizky plug-in</h2><p style="font-size: 12px;">Your Vizky version is&nbsp;'+ VizkyVersion +'&nbsp;This page require at least Vizky version'+ requiredVersion +'<br>We now add up more functions in the new version.<br /> Please update your Vizky to experience new enhancement of 3D Graphics.<br /><br /> <a target="_blank" style="color: #ff9000;" href="http://www.vizky.com/download/"><strong>Click to update your Vizky </strong></a><br />The program is developed from Vizrt, the world\'s leader in real-time 3D graphic render for broadcasting which has several major TV channels on the customer lists, including CNN and BBC.<br /></p><p style="font-size: 12px;"><a target="_blank" style="color: #ff9000;" href="http://mps2.vizky.com/node/68">Basic Troubleshooting</a><br /></p><p style="font-size: 12px;">When the program is installed, <strong>Restart the Browser</strong>.</p></div>';
			document.write(pleaseInstall2);
		}	
	// Check file version and current client version;		
}
function OnVizkyTimelineTrigger(varControlObject, varPlayableId, varDirectorName, varTagName, varParam)
{
	//Control.Log("varControlObject : "+varControlObject)
	varControlObject.Log("OnVizkyTimelineTrigger : DirectorName = " + varDirectorName + "; TagName : " + varTagName + " ; ParaName : " + varParam);
	
	/**/
	if(varTagName == "out")
	{
		//Control.WaitBySecond(1.0)
		//Control.ResetDirector(instID,"*")
		varControlObject.ResetDirector(instID,"Default");
		varControlObject.ResetDirector(instID,"Loop");
		varControlObject.ContinueDirector(instID,"Default");
		varControlObject.ContinueDirector(instID,"Loop");
	}
	
}
