var game_channel_url;
var gamewrapper;

/**
 * This function allows Flash to retrieve the portal's game channel url for internal linking.
 * @return Game channel url for the current portal
 */
function retrieve_gamechannel_url()
{
	return game_channel_url;
}

/**
 * Open a novel game window
 * @param (String) gametitle Opens the specified game in a new window
 * @return false
 */
function open_novelgames_win(gametitle)
{ 
	window.name = "main";
	if ( gamewrapper )
	{
		gamewrapper.close();
		gamewrapper = null;
	}
	
	var gamewrapperURL = "flash_games/novel_games_wrapper.php?game=" + gametitle;
	gamewrapper = window.open(gamewrapperURL, "gamewrapper", "menubar=0,toolbar=0,location=0,status=0,scrollbars=0,resizable=1,directories=0,width=746,height=740"); 
	gamewrapper.self.focus();
	return false;
}

/**
 * Close a novel game window
 */
function close_game_win()
{
	if (window.name == "gamewrapper")
	{
		window.close();
	}
}

/**
 * Function for handling the refresh of an iframe element.
 * The reloading is done by removing and replacing the "src"
 * attribute. This way, the JavaScript needs to only know the
 * id of the iFrame element.
 */
function reloadIFrame(id)
{
	document.getElementById(id).setAttribute('src', document.getElementById(id).getAttribute('src'));
}

/**
 * Function to initiate the timed refresh of an iFrame.
 */
function initiateIFrameReload(id)
{
	setInterval('reloadIFrame("' + id + '")', 1000 * 60 * 2);
}

// Call the function for initiating the timed refresh of the advertisement, passing in the id associated with its iFrame.
initiateIFrameReload('flash_game_ad');



