	/** Group methods **/
	group = 
	{
		join : function(obj, groupId)
		{
			// TODO:: ajax method to join a group
			var joinFunction = function(){groupAjaxActions.join(obj, groupId)};
			groupUIActions.confirm("are you sure you want to join this group?", joinFunction);
		},
		
		leave : function(obj, groupId)
		{
			// TODO:: ajax method to leave a group
			var leaveFunction = function(){groupAjaxActions.leave(obj, groupId)};
			groupUIActions.confirm("are you sure you want to leave this group?", leaveFunction);
		}
	}
	
	groupAjaxActions = 
	{
		join : function(obj, groupId, userType)
		{		
			var s = "/group/"+groupId+"/join";
			new Ajax.Request(
				s,
				{
					method : 'get',
					parameters: {'public_id' : memberStringActions.getPublicId(obj.id)},
					onSuccess: function(data){

						if(data.responseText.match('success'))
						{
							groupUIActions.updateButtons(obj, groupId);
						}
						else
						{
							memberUIActions.showError(data.responseText);
						}
					}
				}
			);
		},
		
		leave : function(obj, groupId, userType)
		{
			// TODO:: leave ajax method
			var s = "/group/"+groupId+"/leave";
			new Ajax.Request(
				s,
				{
					method : 'get',
					parameters: {'public_id' : memberStringActions.getPublicId(obj.id)},
					onSuccess: function(data){

						if(data.responseText.match('success'))
						{
							groupUIActions.updateButtons(obj, groupId);
						}
						else
						{
							memberUIActions.showError(data.responseText);
						}
					}
				}
			);
		}
	}
	
	groupUIActions = 
	{
		showError : function(msg)
		{
			alert("error: " + msg);
		},
		
		updateButtons : function(obj, groupId)
		{
			var typ = $(obj).name;
			var typ_toshow = "";
			if(typ == "leave")
				typ_toshow = ".join";
			else if(typ == "join")
				typ_toshow = ".leave";
			
			Effect.Fade($(obj), {
				afterFinish : function() {
					Effect.appear($(typ_toshow));
				}
			});
		},
		
		confirm : function(msg, functionToExecute)
		{
			/* TODO:: confirm the group action requested
			$(".spdialog").html(msg);
			$(".spdialog").dialog({
				draggable : false,
				resizable : false,
				modal: true,
				title : "Service Pals",
				overlay: { 
			        opacity: 0.5, 
			        background: "#eeeeee" 
			    },
			    stack : false,
			    width : 350,
			    height: 150,
			    buttons: { 
			        "Ok": function() { 
			            functionToExecute();
			            $(this).dialog("destroy");
			        }, 
			        "Cancel": function() { 
			            $(this).dialog("destroy");
			        } 
			    },
			    open : function() {
			    	$(".spdialog").hide();
					$(".spdialog").fadeIn('slow');
			    }
			});
			*/
			if(confirm(msg))
			{
				functionToExecute();
			}
		}
	}
	
	/** Discussion methods **/
	discussion = 
	{
		post : function()
		{
			// TODO: post a forum
		},
		
		remove : function()
		{
			// TODO: remove a post
		}
	
	}
	
	discussionAjaxActions = 
	{
		post : function()
		{
			// TODO:: ajax action for the creation of a post to a discussion
		},
		
		remove : function()
		{
			// TODO:: ajax action for the deletion of a post from a discussion
		}
	}
	
	discussionUIActions = 
	{
		showError : function(msg)
		{
			// show the error
			alert("Error: " + msg);
		},
		
		confirm : function()
		{
			// TODO: confirmation of discussion action
		}
	
	}
