
	function add_to_collection(id)
	{
		new Ajax.Request('index.php', {
			method: 'get',
			parameters: "action=ajax_add_to_collection&id=" + id,
			onComplete: function(transport, json) {
				alert("This movie is now in your collection.");
			}
			});
	}

	function remove_from_collection(id)
	{
		new Ajax.Request('index.php', {
			method: 'get',
			parameters: "action=ajax_remove_from_collection&id=" + id,
			onComplete: function(transport, json) {
				alert("This movie is no longer in your collection.");
			}
			});
	}
	
	function add_tag(id,tag)
	{
		if(!tag)
			return;
			
		new Ajax.Request('index.php', {
			method: 'get',
			parameters: "action=ajax_add_tag&id=" + id + "&tag=" + escape(tag),
			onComplete: function(transport, json) {
				if(json['tag'])
					$('tags').innerHTML += "<span id='tag_" + tag + "' style='padding: 2px 5px 2px 5px;'>" + tag + " <a class='fake_link' onClick='if(!confirm(\"Are you sure you want to remove this tag?\")) return; remove_tag(" + id + ",\"" + tag + "\");'>X</a></span>";
			}
			});
	}	
	
	function remove_tag(id,tag)
	{
		if(!tag)
			return;
			
		new Ajax.Request('index.php', {
			method: 'get',
			parameters: "action=ajax_remove_tag&id=" + id + "&tag=" + escape(tag),
			onComplete: function(transport, json) {
				if(json['tag'])
					$('tag_' + tag).style.display="none";
			}
			});
	}		
