// These functions create the score display.

var popcap_score_mode = '';

function MakeScoreDisplay()
{
	if (popcap_score_report)
	{	
		var score_tag = '';
		
		if (popcap_enableZone)
			score_tag = '<textarea id="zone_score_display" rows="10" cols="60">ScoreBroadcast:</textarea>';
		else
		{
			score_tag += '<div id="popcap_score_mode">Mode:</div>';
			score_tag += '<div id="popcap_score_level">Level:</div>';
			score_tag += '<div id="popcap_score_display">Score:</div>';
		}
		
		document.write(score_tag);
	}
}

function PopcapScoreSetMode(val)
{
	thisObject('popcap_score_mode').innerHTML = 'Mode: ' + val;
}

function PopcapScoreSetScore(val)
{
	thisObject('popcap_score_display').innerHTML = 'Score: ' + val;
}

function PopcapScoreSetLevel(val)
{
	thisObject('popcap_score_level').innerHTML = 'Level: ' + val;
}

function Popcap_DisplayScore(method,param)
{
	if (method=='pc_gamestart')
	{
		popcap_score_mode = param;
		
		if (popcap_score_mode == '')
			popcap_score_mode = 'Default';

		PopcapScoreSetMode(popcap_score_mode);
		PopcapScoreSetLevel('1');
		PopcapScoreSetScore('0');
	}
	else if (method=='pc_scorebroadcast')
	{
		PopcapScoreSetScore(param);
	}
	else if (method=='pc_gameover')
	{
		PopcapScoreSetMode(popcap_score_mode + ' (gameover)');
	}	
	else if (method=='pc_gamebreak')
	{
		PopcapDebug('ScoreGameBreak: ' + method + ' ' + param);
		
		var params = param.split(',');
		var level = parseInt(params[0]);
		
		if (params.length<2 || params[1]!='gameover')
			level++;

		PopcapScoreSetLevel(level);		
	}	
}

function Zone_DisplayScore(val)
{
	if (val.search(/ScoreSubmit/) != -1)	
		thisObject('zone_score_display').value = 'ScoreSubmit: ' + val.replace(/ScoreSubmit/,'');
	else
		thisObject('zone_score_display').value = 'ScoreBroadcast: ' + val;
}

MakeScoreDisplay();
