function loginCheck()
{
	if(!loggedIn())
	{
		if(confirm('You need to be logged in to do that.\n\nLogin now?'))
			window.location = '/login';
		return false;
	}
	
	return true;
}
function subscribe(button,id)
{
//alert("Subscribe " + id);
	if(!loginCheck())
		return false;
	
	button.value="Please Wait";
	button.disabled=true;
	var url = "/user/subscribe/" + id;
	async(url,
		function()
		{
			button.disabled=false;
			button.value='Unsubscribe';
			button.onclick=function(){return unsubscribe(button,id);}
		}
	);
//alert("RETURN FALSE");
	return false;
}

function unsubscribe(button,id)
{
//alert("Unsubscribe " + id);
	if(!loginCheck())
		return false;
	
	button.value="Please Wait";
	button.disabled=true;
	var url = "/user/unsubscribe/" + id;
	async(url,
		function()
		{
			button.disabled=false;
			button.value='Subscribe';
			button.onclick=function(){return subscribe(button,id);}
		}
	);
//alert("RETURN FALSE");
	return false;
}

function tagEpisode(button,id)
{
//alert("Tag " + id);
	if(!loginCheck())
		return false;
	
	button.value="Please Wait";
	button.disabled=true;
	var url = "/user/addFeedItem/" + id;
	async(url,
		function()
		{
			button.disabled=false;
			button.value='Untag';
			button.onclick=function(){return unTagEpisode(button,id);}
		}
	);
//alert("RETURN FALSE");
	return false;
}

function unTagEpisode(button,id)
{
//alert("Untag " + id);
	if(!loginCheck())
		return false;
	
	button.value="Please Wait";
	button.disabled=true;
	var url = "/user/removeFeedItem/" + id;
	async(url,
		function()
		{
			button.disabled=false;
			button.value='Tag';
			button.onclick=function(){return tagEpisode(button,id);}
		}
	);
//alert("RETURN FALSE");
	return false;
}

function fullDescription(id,action)
{
	var d = document.getElementById(action + '_' + id);
	var url = '/feed' + '/' + action + '/' + id;
	var req = async(url,
		function()
		{
			d.innerHTML = req.responseText;
		}
	);
	return false;
}

function fullFeedDescription(id,more)
{
	return fullDescription(id,'feedDescription');
}

function fullItemDescription(id,more)
{
	return fullDescription(id,'feedItemDescription');
}