var installqmp = null
var openWindows = [];
var os = null;
var browser = null;

function startMoveInstall(){
	$('containerStart').style.display = "none";
	$('container1').style.display = "block";
}

function DisplaySteps()
{
	os = MN.QMPInstall.OS();
	browser = MN.QMPInstall.Browser();
	upgrade = MN.QMPInstall.UpgradeRequired();
	$('installContainer').style.display = "block";
	if(upgrade && !(browser == "mozilla" && os != "mac")){
		$('containerStart').style.display = "none";
		$('containerUpgrade').style.display = "block";
	}
	else{
		if(os == "mac")
		{	
			MN.CSS.RemoveClass($('player'), 'playernormal');
			MN.CSS.AddClass($('player'), 'playermoved');
			if(MN.QMPInstall.BrowserIsGood()){
				if(browser == "safari")
				{
					MN.CSS.RemoveClass($('messageMac'), 'hidden');
					MN.CSS.AddClass($('install1'), 'safari1');
				}
				else if(browser == "mozilla")
				{
					MN.CSS.RemoveClass($('messageMac'), 'hidden');
					MN.CSS.AddClass($('install1'), 'macff1');
				}
			}
			else{
				MN.CSS.RemoveClass($('noMessageMac'), 'hidden');
				MN.CSS.AddClass($('buttons1'), 'hidden');
			}
		}
		else
		{
			if(MN.QMPInstall.BrowserIsGood()){
				if(browser == "ie")
				{
					MN.CSS.RemoveClass($('messageIE'), 'hidden');
					MN.CSS.AddClass($('install1'), 'ie1');
				}
				else if(browser == "mozilla")
				{
					MN.CSS.RemoveClass($('messageFFox'), 'hidden');
					MN.CSS.AddClass($('install1'), 'ff1');
				}
			}
			else{
				MN.CSS.RemoveClass($('noMessagePC'), 'hidden');
				MN.CSS.AddClass($('buttons1'), 'hidden');
			}
		}
	}
}
function PopFeedback()
{
	var popup = Popup('http://qmedia.xlontech.net/100513/global/support/feedback.html', 575, 600);
	if(popup != null)
	{
		openWindows.push(popup);
	}
}

function Popup(url, width, height, top, left)
{
	if(!height) var height = 518;
	if(!width) var width = 785;
	if(!top) var top = 0;
	if(!left) var left = 0;

	var popup = null;

	var popupString = "height=%s,width=%s,toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,top=%s,left=%s".format(height, width, top, left);
	
	if(url != null)
	{
		popup = window.open(url, '_blank', popupString);
	}
	
	// Check to see if the window actually came up
	if(popup == null || typeof(popup) == "undefined")
	{
		// we should display some message here!!!!!
		alert('popup blocked');
		return null
	}
	return popup;
}


function CanSeeVideo(b)
{
	if(b) // The user said that they CAN see the video
	{
		$('container2').style.display = 'none';
		if(installqmp)
			installqmp.Stop()
		$('player').style.display = 'none';
		location.reload(true);
	}
	else // The user said that they CAN NOT see the video
	{
		// Probably do something else for the Mac (Maybe send them to the feedback page)
		if(MN.QMPInstall.OS() == "mac")
		{
			PopFeedback();
		}
		else
		{
			Popup('http://qmedia.xlontech.net/100513/global/support/faq.html#av', 650, 768); // redirect to the Audio/Video troubleshooting part of the FAQ
		}
	}
}

function ShowInstallComplete()
{
	if(upgrade && !(browser == "mozilla" && os != "mac")){
		$('containerUpgrade').style.display = "none";
	}
	$('container2').style.display = 'block';
}

function OnInstallPlayerLoaded(player)
{
	if(!player)
	{
		return;
	}
	MN.CSS.RemoveClass($('player'), 'playermoved');
	MN.CSS.AddClass($('player'), 'playernormal');
	
	$('container1').style.display = 'none';

	$('player').style.width = '355px';
	$('player').style.height = '234px';
	installqmp = player;
	installqmp.Play('http://qmplive03.xlontech.net/kp/highdef/The_Magic_of_Flight_720/output.qmx');
	setTimeout(ShowInstallComplete, 1500);
}

function StartInstall()
{
	MN.QMPInstall.StartInstall();
}

function InstallInit()
{
	DisplaySteps();
	MN.QMPInstall.MSG_BADOS = '';
	MN.QMPInstall.MSG_BADBROWSER = '';
	MN.QMPInstall.MSG_NEEDREINSTALL = '';
	//MN.QMPInstall.MSG_NEEDUPGRADE = '';
	//MN.QMPInstall.MSG_UPGRADING = '';
	MN.QMPInstall.MSG_UPGRADE_WIN_MOZILLA = '';
	MN.QMPInstall.MSG_UPGRADE_BASE_WIN_MOZILLA = '';
	MN.QMPInstall.MSG_UPGRADEFAILED = '';
	MN.QMPInstall.MSG_CANINSTALL = '';
	MN.QMPInstall.MSG_INSTALL_win_mozilla = '';
	MN.QMPInstall.MSG_INSTALL_win_ie = '';
	MN.QMPInstall.MSG_INSTALL_java = '';
	MN.QMPInstall.MSG_INSTALLING = '<div id="moveplay_progressouter"><div id="moveplay_progressinner"></div></div><span id="moveplay_installprogressmsg">Loading...</span>';
	MN.QMPInstall.MSG_BASE_INSTALLING_PREFIX = '<div id="moveplay_progressouter"><div id="moveplay_progressinner"></div></div><span id="moveplay_installprogressmsg">Loading...</span>';
	MN.QMPInstall.MSG_BASE_INSTALLING_POSTFIX = '<div id="moveplay_progressouter"><div id="moveplay_progressinner"></div></div><span id="moveplay_installprogressmsg">Loading...</span>';
	MN.QMPInstall.MSG_NOINSTALLMETHOD = '';
	MN.QMPInstall.MSG_NEEDRESTART = '';
}

function beginInstall(){
	InstallInit();
	MN.QVT.CreatePlayer("player", OnInstallPlayerLoaded, 352, 198);
	window.focus();
}