
<!--
// Javascript Play All Trivia common functions.

var selectedGameID = 0;
var playAllTriviaDownloadURL = "http://downloads.zoitec.com/playalltriviainstall.exe";

function patGo()
{
	PAT_playTriviaGame(selectedGameID);
}

function setGame(gameID)
{
	selectedGameID=gameID;
	setInfo();
}

function setInfo()
{
	document.getElementById("BlurbText").innerHTML="Loading...";
	document.getElementById("GameName").innerHTML="";
	PlayTrivia.Index.getGameInfo(selectedGameID, infoReturn);
}

function infoReturn(res)
{
	var ginfo=res.value.split("*",2);
	document.getElementById("BlurbText").innerHTML=ginfo[1];
	document.getElementById("GameName").innerHTML=ginfo[0];
}

function webReturn(res)
{
	if(res.value!= null || res.value != "")
		window.location=res.value;
}

function patClickWebsiteButton()
{
	if(selectedGameID==0)
	{
		alert("select a game from the tree above");
	}
	else
	{
		PlayTrivia.Index.goToWebsite(selectedGameID, webReturn);
	}
}

function patClickPlayButton()
{
	if(selectedGameID==0)
	{
		alert("select a game from the tree above");
	}
	else
	{
		patClickPlayGame(selectedGameID);
	}
}

function patClickPlayGame(gameID)
{

	if ("PROD" == "PROD")
	{
		urchinTracker('/PATClickPlayGame');
	}
	if (isClientInstalled())
	{
		PAT_playTriviaGame(String(gameID));
	}
	else
	{
		// Register first.
		selectedGameID = String(gameID);
		try
		{
			scroll(0, 0);
		}
		catch (e)
		{
		}
		document.getElementById("DownloadFrame").src = playAllTriviaDownloadURL;
	}
}

function startPlay2(gameID)
{
	if ("PROD" == "PROD")
	{
		urchinTracker('/PATClickPlayGame');
	}
	if (isClientInstalled())
	{
		PAT_playTriviaGame(gameID);
	}
	else
	{
		// Register first.
		selectedGameID = gameID;
		try
		{
			scroll(0, 0);
		}
		catch (e)
		{
		}
		document.getElementById("DownloadFrame").src = playAllTriviaDownloadURL;
	}
}

function challenge(fromEmailAddress, toEmailAddress, downloadURL)
{
	var consoleClient = null;
	try
	{
		consoleClient = new ActiveXObject("tg_service.WebInterface1");
	}
	catch (ex)
	{
	}
	if (null == consoleClient)
	{
		if (confirm("You must have the game installed and be a registered user to get your credits for referring a friend. Click ok to install the game at this time."))
		{
			document.URL = downloadURL;
		}
		return;
	}
	var clientID = "35";
	var loginStatus = null;
	try
	{
		loginStatus = consoleClient.UserInfo("LOGGEDIN");
	}
	catch (ex)
	{
	}
	if ((null != loginStatus) && ("true" != loginStatus))
	{
		consoleClient.ShowWin(4, 0, 0, "");
		try
		{
			loginStatus = consoleClient.UserInfo("LOGGEDIN");
		}
		catch (ex)
		{
			alert("You must log in receive credit for referring a friend.");
			return;
		}
	}
	if(loginStatus!='true')
		return;
	var userID = consoleClient.UserInfo("USERID");
	var username = consoleClient.UserInfo("USERNAME");
	var urlString="http://console.tournamentgames.com/consolev9/consolemain.aspx?TARGET_SPMAIN_FRAME=../../accounts/tellafriend.aspx?userid=" + userID + "^username=" + username + "^to_email_address=" + toEmailAddress + "^from_email_address=" + fromEmailAddress + "&tguserid=" + userID + "&tgusername=" + username;
	consoleClient.ShowWin(3, 0, 0, urlString);
}

function isClientInstalled()
{
	try
	{
		var c = new ActiveXObject("tg_service.WebInterface1");
		c = null;
		return true;
	}
	catch (e)
	{
		return false;
	}
}
//-->
