function DoFollow(userid,act)
{		
	val = parseInt(document.getElementById('follow_user_'+userid).value);
	var _do = act.length;
	switch (val)
	{
		case -1:
			break;
		default:		
			oTitle = document.getElementById('follow_manage_'+userid);
		  if (_do==0) 
		  {
		  	oTitle.innerHTML = "Following";
		  	setTimeout(function(){oTitle.innerHTML = "Remove";},3000);
		  	oTitle.title = "Click to remove following";
		  	oTitle.onclick = function(){ FollowAction(userid,"remove"); };
		  }
		  if (act=='remove') 
		  {
		  	oTitle.innerHTML = "Follow";		  	
		  	setTimeout(function(){oTitle.innerHTML = "Follow";},3000);
		  	oTitle.title = "Click to follow again";
		  	oTitle.onclick = function(){ FollowAction(userid,""); };	
		  }		  
		break;
	}
}


function FollowAction(iUserId,act)
{		
	var whichact = act.length;
	
	if (whichact==0)
	{		
		var sObjName  = '#follow_user_'+iUserId;
		$(sObjName).load(gHTTPURL+'dispatch/follow.php?tofollow='+iUserId,'',DoFollow(iUserId,''));
	}	
	if (act=='remove')
	{
		var sObjName  = '#follow_user_'+iUserId;
		$(sObjName).load(gHTTPURL+'dispatch/follow.php?tofollow='+iUserId+'&do=remove','',DoFollow(iUserId,'remove'));
	}	
}