//-------------------------------------
// Mako collection functions
//-------------------------------------

(function()
{
	/*
	* Toggle loading and disable checkbox while sending a request
	*
	* @param int - status (on or off)
	* @return void
	* @requires jQuery
	*/
	
	Mako.toggleCollectionLoading = function(status)
	{
		if(status == 1)
		{
			$("#collection_box").css({display:"none"});
			$("#collection_loading").css({display:"inline"});
			$("#collection_status").attr("disabled","disabled");
		}
		else
		{
			$("#collection_box").css({display:"inline"});
			$("#collection_loading").css({display:"none"});
			$("#collection_status").removeAttr("disabled");
		}
	};
	
	/*
	* Ajax request that toggles the collection status of the game
	*
	* @param int - game id
	* @return void
	* @reqires jQuery
	*/
	
	Mako.updateCollection = function(id)
	{
		$.ajax({
			beforeSend: function()
			{
				Mako.toggleCollectionLoading(1);
			},
			type: "POST",
			url: "/?act=members&do=updatecollection",
			data: "&id="+id,
			error: function()
			{
				alert("Error: Failed to contact the server.");
			},
			complete: function()
			{
				Mako.toggleCollectionLoading(0);
			}
		});
	};
})();