function gameFail( level )
{
	$.ajax({
		type: "POST",
		url: "/a/php/common/removeSuperpowerUse.php",
		success: function(msg)
		{
		}
	});
}


function addPoints( path, item, level, playerId )
{
	$.ajax({
		type: "POST",
		url: "/a/php/common/addPoints.php",
		data: "gP=" + path + "&item=" + item + "&gL=" + level + "&pId=" + playerId,
		success: function(msg){
			$.jGrowl.defaults.pool = 5;
			if ( msg == 'Error Message: No Player Id' )
			{
				$.jGrowl("You must be logged in to earn SuperPoints on this site. Make sure you login at the top of the page!");
			}

			if ( !isNaN( parseInt(msg) ) )
			{
				if ( 0 < msg )
				{
					$.jGrowl("<img src=\"/a/img/global/promoPanels/spIcon.png\" width=\"51\" height=\"50\" alt=\"SuperPoints\" />Well done, you have been awarded " + msg + " SuperPoints!", { life: 4000 });
				}
				else
				{
					$.jGrowl("Sorry you have gained no points for this game.");
				}
			}
			
		}
	});
}

function useSuperpower( superpowerId, name, remainingUses )
{
	var usesLeft = '';
	var addS = '';
	if ( 0 < remainingUses )
	{
		if ( 1 < remainingUses )
		{
			var addS = 's';
		}
		var usesLeft = 'You have ' + remainingUses + ' use' + addS + ' remaining.';
	}

	$.blockUI({
		message: '<h2 class="lockedArea"><img src="/a/img/icons/superpowers/' + superpowerId + '.gif" width="53" height="52" alt="Superpower" />DO YOU WISH TO USE YOUR ' + name + ' SUPERPOWER AND DOUBLE YOUR POINTS? ' + usesLeft + ' <a href="#" id="yes" class="closeBlock">YES</a> <a href="#" id="no" class="closeBlock">NO</a></h2>',
		css: { border: 'none', background: 'none', cursor: 'default', top:'40%' },
		overlayCSS: { cursor: 'default' },
		centerY: true
	});

	$('.closeBlock').click(function(){
		var closeButton = $(this)
		$.unblockUI({
			onUnblock: function(){
				if ( "yes" == closeButton.attr('id') )
				{
					$.ajax({
						type: "POST",
						url: "/a/php/common/setSuperpowerUse.php",
						data: "id=" + superpowerId,
						success: function(msg)
						{
						}
					});
				}
			}
		});
		return false;
	});
}
