function CMaze(parent)
{
	this.parent = parent;
	
	this.reqs = new CReqs(this);
	
	this.mazeSaved = null;
	this.mazeId = null; //only used for saving
	this.mazeData = "";
	this.photoLink = "";
	
	this.read = function()
	{
		this.parent.response("mazeRead", this.mazeData);
	}
	
	this.load = function(id)
	{
		//this.mazeId = id;
		this.mazeSaved = null;
		this.mazeId = null;
		
		if(id > 0)
		  this.reqs.get("maze.load&maze="+id, "mazeLoad", null);
    else
      this.reqs.get("maze.load", "mazeLoad", null);
	}
	
	this.save = function(target, maze)
	{
		this.mazeData = maze;
		this.reqs.post("maze.save", '{"target":"'+target+'","data":"'+maze+'"}', "mazeSave", null);
	}
	
	this.share = function()
	{
		//FB.Connect.requireSession(function(){}, function(){}, true);
		
		/*
		if(this.parent.connected == 0 || this.parent.authService == null)
		{
			//TODO: Improve message
			alert("You're not connected to any auth/sharing service.");
			return;
		}
		*/
		
		/*
		if(this.mazeId == null)
		{
			//TODO: Improve message
			alert("This maze was not saved yet. Cannot share.");
			return;
		}
		*/
		
		if(this.mazeSaved)
			this.parent.authService.share();
	}
	
	this.requestCallback = function(type, data)
	{
		switch(type)
		{
			case "mazeLoad":
				game.maze.mazeId = data.id;
				game.maze.mazeData = data.data;
				game.maze.photoLink = data.photoLink;
				
        game.fb.target.enablePending();
				
				game.response(type, data.data);
			break;
			
			case "mazeSave":
				game.maze.mazeSaved = 1;
				game.maze.mazeId = data.id;
				game.stats.savePendingScore();
				game.maze.photoLink = data.photoLink;
				//game.maze.share();
				game.response(type, data.id);
			break;
		}
	}
}

